From d7c4cf3452e345911a2f481d8af2fa478c642ee6 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Thu, 26 Jun 2025 09:19:02 +0300 Subject: [PATCH 01/13] Add attachment desktop-specific class --- .../GenericPlatformSentryAttachment.cpp | 37 +++++++++++++++++++ .../GenericPlatformSentryAttachment.h | 31 ++++++++++++++++ .../Private/HAL/PlatformSentryAttachment.h | 2 + 3 files changed, 70 insertions(+) create mode 100644 plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp create mode 100644 plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp new file mode 100644 index 000000000..9465ea0ee --- /dev/null +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp @@ -0,0 +1,37 @@ +// Copyright (c) 2025 Sentry. All Rights Reserved. + +#include "GenericPlatformSentryAttachment.h" + +#if USE_SENTRY_NATIVE + +FGenericPlatformSentryAttachment::FGenericPlatformSentryAttachment(const TArray& data, const FString& filename, const FString& contentType) + : Data(data), Filename(filename), ContentType(contentType) +{ +} + +FGenericPlatformSentryAttachment::FGenericPlatformSentryAttachment(const FString& path, const FString& filename, const FString& contentType) + : Path(path), Filename(filename), ContentType(contentType) +{ +} + +TArray FGenericPlatformSentryAttachment::GetData() const +{ + return Data; +} + +FString FGenericPlatformSentryAttachment::GetPath() const +{ + return Path; +} + +FString FGenericPlatformSentryAttachment::GetFilename() const +{ + return Filename; +} + +FString FGenericPlatformSentryAttachment::GetContentType() const +{ + return ContentType; +} + +#endif diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h new file mode 100644 index 000000000..20e7335fd --- /dev/null +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h @@ -0,0 +1,31 @@ +// Copyright (c) 2025 Sentry. All Rights Reserved. + +#pragma once + +#include "Convenience/GenericPlatformSentryInclude.h" + +#include "Interface/SentryAttachmentInterface.h" + +#if USE_SENTRY_NATIVE + +class FGenericPlatformSentryAttachment : public ISentryAttachment +{ +public: + FGenericPlatformSentryAttachment(const TArray& data, const FString& filename, const FString& contentType); + FGenericPlatformSentryAttachment(const FString& path, const FString& filename, const FString& contentType); + + virtual TArray GetData() const override; + virtual FString GetPath() const override; + virtual FString GetFilename() const override; + virtual FString GetContentType() const override; + +private: + TArray Data; + FString Path; + FString Filename; + FString ContentType; +}; + +typedef FGenericPlatformSentryAttachment FPlatformSentryAttachment; + +#endif diff --git a/plugin-dev/Source/Sentry/Private/HAL/PlatformSentryAttachment.h b/plugin-dev/Source/Sentry/Private/HAL/PlatformSentryAttachment.h index f4a8e4520..38b2fc4db 100644 --- a/plugin-dev/Source/Sentry/Private/HAL/PlatformSentryAttachment.h +++ b/plugin-dev/Source/Sentry/Private/HAL/PlatformSentryAttachment.h @@ -6,6 +6,8 @@ #include "Android/AndroidSentryAttachment.h" #elif PLATFORM_APPLE #include "Apple/AppleSentryAttachment.h" +#elif USE_SENTRY_NATIVE +#include "GenericPlatform/GenericPlatformSentryAttachment.h" #else #include "Null/NullSentryAttachment.h" #endif From 0158151e79841fb01b7dc91435e6c7fed130080f Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Thu, 26 Jun 2025 10:58:38 +0300 Subject: [PATCH 02/13] Add attachments support for desktop scope --- .../GenericPlatformSentryAttachment.cpp | 15 +++++++ .../GenericPlatformSentryAttachment.h | 6 +++ .../GenericPlatformSentryScope.cpp | 44 ++++++++++++++++++- .../GenericPlatformSentryScope.h | 7 +++ 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp index 9465ea0ee..9e2a832fd 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp @@ -14,6 +14,21 @@ FGenericPlatformSentryAttachment::FGenericPlatformSentryAttachment(const FString { } +FGenericPlatformSentryAttachment::~FGenericPlatformSentryAttachment() +{ + // Put custom destructor logic here if needed +} + +void FGenericPlatformSentryAttachment::SetNativeObject(sentry_attachment_t* attachment) +{ + Attachment = attachment; +} + +sentry_attachment_t* FGenericPlatformSentryAttachment::GetNativeObject() +{ + return Attachment; +} + TArray FGenericPlatformSentryAttachment::GetData() const { return Data; diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h index 20e7335fd..84303fbb0 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h @@ -13,6 +13,10 @@ class FGenericPlatformSentryAttachment : public ISentryAttachment public: FGenericPlatformSentryAttachment(const TArray& data, const FString& filename, const FString& contentType); FGenericPlatformSentryAttachment(const FString& path, const FString& filename, const FString& contentType); + virtual ~FGenericPlatformSentryAttachment() override; + + void SetNativeObject(sentry_attachment_t* attachment); + sentry_attachment_t* GetNativeObject(); virtual TArray GetData() const override; virtual FString GetPath() const override; @@ -24,6 +28,8 @@ class FGenericPlatformSentryAttachment : public ISentryAttachment FString Path; FString Filename; FString ContentType; + + sentry_attachment_t* Attachment; }; typedef FGenericPlatformSentryAttachment FPlatformSentryAttachment; diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp index 97f703290..fd3797db6 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2025 Sentry. All Rights Reserved. #include "GenericPlatformSentryScope.h" +#include "GenericPlatformSentryAttachment.h" #include "GenericPlatformSentryBreadcrumb.h" #include "GenericPlatformSentryEvent.h" @@ -39,12 +40,12 @@ void FGenericPlatformSentryScope::ClearBreadcrumbs() void FGenericPlatformSentryScope::AddAttachment(TSharedPtr attachment) { - // Not available for generic platform + Attachments.Add(StaticCastSharedPtr(attachment)); } void FGenericPlatformSentryScope::ClearAttachments() { - // Not available for generic platform + Attachments.Empty(); } void FGenericPlatformSentryScope::SetTag(const FString& key, const FString& value) @@ -195,6 +196,18 @@ void FGenericPlatformSentryScope::Apply(sentry_scope_t* scope) sentry_scope_add_breadcrumb(scope, nativeBreadcrumb); } + for (auto& Attachment : Attachments) + { + if (!Attachment->GetPath().IsEmpty()) + { + AddFileAttachment(Attachment, scope); + } + else + { + AddByteAttachment(Attachment, scope); + } + } + if (Fingerprint.Num() > 0) { sentry_scope_set_fingerprints(scope, FGenericPlatformSentryConverters::StringArrayToNative(Fingerprint)); @@ -218,4 +231,31 @@ void FGenericPlatformSentryScope::Apply(sentry_scope_t* scope) sentry_scope_set_level(scope, FGenericPlatformSentryConverters::SentryLevelToNative(Level)); } +void FGenericPlatformSentryScope::AddFileAttachment(TSharedPtr attachment, sentry_scope_t* scope) +{ + sentry_attachment_t* nativeAttachment = + sentry_scope_attach_file(scope, TCHAR_TO_UTF8(*attachment->GetPath())); + + if (!attachment->GetFilename().IsEmpty()) + sentry_attachment_set_filename(nativeAttachment, TCHAR_TO_UTF8(*attachment->GetFilename())); + + if (!attachment->GetContentType().IsEmpty()) + sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*attachment->GetContentType())); + + attachment->SetNativeObject(nativeAttachment); +} + +void FGenericPlatformSentryScope::AddByteAttachment(TSharedPtr attachment, sentry_scope_t* scope) +{ + const TArray& byteBuf = attachment->GetData(); + + sentry_attachment_t* nativeAttachment = + sentry_scope_attach_bytes(scope, reinterpret_cast(byteBuf.GetData()), byteBuf.Num(), TCHAR_TO_UTF8(*attachment->GetFilename())); + + if (!attachment->GetContentType().IsEmpty()) + sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*attachment->GetContentType())); + + attachment->SetNativeObject(nativeAttachment); +} + #endif diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.h b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.h index b9413b81e..e9bec2c68 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.h +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.h @@ -9,6 +9,7 @@ #if USE_SENTRY_NATIVE +class FGenericPlatformSentryAttachment; class FGenericPlatformSentryBreadcrumb; class FGenericPlatformSentryEvent; @@ -46,6 +47,10 @@ class FGenericPlatformSentryScope : public ISentryScope void Apply(sentry_scope_t* scope); +protected: + virtual void AddFileAttachment(TSharedPtr attachment, sentry_scope_t* scope); + virtual void AddByteAttachment(TSharedPtr attachment, sentry_scope_t* scope); + private: FString Dist; FString Environment; @@ -59,6 +64,8 @@ class FGenericPlatformSentryScope : public ISentryScope TRingBuffer> Breadcrumbs; + TArray> Attachments; + ESentryLevel Level; }; From a18bbdf5e4d5a3bebf6c231d802b31d1c108209e Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Thu, 26 Jun 2025 11:44:51 +0300 Subject: [PATCH 03/13] Adopt wide char version of the attachment API for Microsoft platforms (Win, Xbox) --- .../GenericPlatformSentryScope.h | 2 ++ .../Sentry/Private/HAL/PlatformSentryScope.h | 2 ++ .../Microsoft/MicrosoftSentryScope.cpp | 32 +++++++++++++++++++ .../Private/Microsoft/MicrosoftSentryScope.h | 21 ++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp create mode 100644 plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.h diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.h b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.h index e9bec2c68..18d4bf529 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.h +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.h @@ -69,6 +69,8 @@ class FGenericPlatformSentryScope : public ISentryScope ESentryLevel Level; }; +#if !PLATFORM_MICROSOFT typedef FGenericPlatformSentryScope FPlatformSentryScope; +#endif #endif \ No newline at end of file diff --git a/plugin-dev/Source/Sentry/Private/HAL/PlatformSentryScope.h b/plugin-dev/Source/Sentry/Private/HAL/PlatformSentryScope.h index c1aedf176..0d096dad4 100644 --- a/plugin-dev/Source/Sentry/Private/HAL/PlatformSentryScope.h +++ b/plugin-dev/Source/Sentry/Private/HAL/PlatformSentryScope.h @@ -6,6 +6,8 @@ #include "Android/AndroidSentryScope.h" #elif PLATFORM_APPLE #include "Apple/AppleSentryScope.h" +#elif PLATFORM_MICROSOFT +#include "Microsoft/MicrosoftSentryScope.h" #elif USE_SENTRY_NATIVE #include "GenericPlatform/GenericPlatformSentryScope.h" #else diff --git a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp new file mode 100644 index 000000000..2a8a88721 --- /dev/null +++ b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp @@ -0,0 +1,32 @@ +// Copyright (c) 2025 Sentry. All Rights Reserved. + +#include "MicrosoftSentryScope.h" + +#include "GenericPlatform/GenericPlatformSentryAttachment.h" + +void FMicrosoftSentryScope::AddFileAttachment(TSharedPtr attachment, sentry_scope_t* scope) +{ + sentry_attachment_t* nativeAttachment = + sentry_scope_attach_filew(scope, *attachment->GetPath()); + + if (!attachment->GetFilename().IsEmpty()) + sentry_attachment_set_filenamew(nativeAttachment, *attachment->GetFilename()); + + if (!attachment->GetContentType().IsEmpty()) + sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*attachment->GetContentType())); + + attachment->SetNativeObject(nativeAttachment); +} + +void FMicrosoftSentryScope::AddByteAttachment(TSharedPtr attachment, sentry_scope_t* scope) +{ + const TArray& byteBuf = attachment->GetData(); + + sentry_attachment_t* nativeAttachment = + sentry_scope_attach_bytesw(scope, reinterpret_cast(byteBuf.GetData()), byteBuf.Num(), *attachment->GetFilename()); + + if (!attachment->GetContentType().IsEmpty()) + sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*attachment->GetContentType())); + + attachment->SetNativeObject(nativeAttachment); +} \ No newline at end of file diff --git a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.h b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.h new file mode 100644 index 000000000..4e39f1d81 --- /dev/null +++ b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.h @@ -0,0 +1,21 @@ +// Copyright (c) 2025 Sentry. All Rights Reserved. + +#pragma once + +#if USE_SENTRY_NATIVE + +#include "GenericPlatform/GenericPlatformSentryScope.h" + +class FMicrosoftSentryScope : public FGenericPlatformSentryScope +{ +public: + virtual ~FMicrosoftSentryScope() override = default; + +protected: + virtual void AddFileAttachment(TSharedPtr attachment, sentry_scope_t* scope) override; + virtual void AddByteAttachment(TSharedPtr attachment, sentry_scope_t* scope) override; +}; + +typedef FMicrosoftSentryScope FPlatformSentryScope; + +#endif From bd0896786a5d287cc65dbc5fb8c07fd7a72b9944 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Thu, 26 Jun 2025 15:58:18 +0300 Subject: [PATCH 04/13] Add functions to add/remove attachments in global scope --- .../Android/AndroidSentrySubsystem.cpp | 17 ++++++ .../Private/Android/AndroidSentrySubsystem.h | 2 + .../Android/Java/SentryBridgeJava.java | 9 ++++ .../Private/Apple/AppleSentrySubsystem.cpp | 19 +++++++ .../Private/Apple/AppleSentrySubsystem.h | 2 + .../GenericPlatformSentryScope.cpp | 2 +- .../GenericPlatformSentrySubsystem.cpp | 53 +++++++++++++++++++ .../GenericPlatformSentrySubsystem.h | 6 +++ .../Interface/SentrySubsystemInterface.h | 3 ++ .../Microsoft/MicrosoftSentrySubsystem.cpp | 33 ++++++++++++ .../Microsoft/MicrosoftSentrySubsystem.h | 3 ++ .../Source/Sentry/Private/SentrySubsystem.cpp | 25 +++++++++ .../Source/Sentry/Public/SentrySubsystem.h | 16 ++++++ 13 files changed, 189 insertions(+), 1 deletion(-) diff --git a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp index 16534478a..af3a15b0a 100644 --- a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp @@ -2,6 +2,7 @@ #include "AndroidSentrySubsystem.h" +#include "AndroidSentryAttachment.h" #include "AndroidSentryBreadcrumb.h" #include "AndroidSentryEvent.h" #include "AndroidSentryId.h" @@ -127,6 +128,22 @@ void FAndroidSentrySubsystem::ClearBreadcrumbs() FSentryJavaObjectWrapper::CallStaticMethod(SentryJavaClasses::Sentry, "clearBreadcrumbs", "()V"); } +void FAndroidSentrySubsystem::AddAttachment(TSharedPtr attachment) +{ + TSharedPtr attachmentAndroid = StaticCastSharedPtr(attachment); + + FSentryJavaObjectWrapper::CallStaticMethod(SentryJavaClasses::SentryBridgeJava, "addAttachment", "(Lio/sentry/Attachment;)V", + attachmentAndroid->GetJObject()); +} + +void FAndroidSentrySubsystem::RemoveAttachment(TSharedPtr attachment) +{ + TSharedPtr attachmentAndroid = StaticCastSharedPtr(attachment); + + FSentryJavaObjectWrapper::CallStaticMethod(SentryJavaClasses::SentryBridgeJava, "removeAttachment", "(Lio/sentry/Attachment;)V", + attachmentAndroid->GetJObject()); +} + TSharedPtr FAndroidSentrySubsystem::CaptureMessage(const FString& message, ESentryLevel level) { auto id = FSentryJavaObjectWrapper::CallStaticObjectMethod(SentryJavaClasses::Sentry, "captureMessage", "(Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId;", diff --git a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h index 6981c0e5e..0edc6f9be 100644 --- a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h @@ -14,6 +14,8 @@ class FAndroidSentrySubsystem : public ISentrySubsystem virtual void AddBreadcrumb(TSharedPtr breadcrumb) override; virtual void AddBreadcrumbWithParams(const FString& Message, const FString& Category, const FString& Type, const TMap& Data, ESentryLevel Level) override; virtual void ClearBreadcrumbs() override; + virtual void AddAttachment(TSharedPtr attachment) override; + virtual void RemoveAttachment(TSharedPtr attachment) override; virtual TSharedPtr CaptureMessage(const FString& message, ESentryLevel level) override; virtual TSharedPtr CaptureMessageWithScope(const FString& message, ESentryLevel level, const FSentryScopeDelegate& onConfigureScope) override; virtual TSharedPtr CaptureEvent(TSharedPtr event) override; diff --git a/plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java b/plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java index 3e1cf4eb9..cdfe4dc88 100644 --- a/plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java +++ b/plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java @@ -14,6 +14,7 @@ import java.util.HashMap; import java.util.Map; +import io.sentry.Attachment; import io.sentry.Breadcrumb; import io.sentry.Hint; import io.sentry.IScopes; @@ -225,4 +226,12 @@ public static Object getScopeContext(final IScope scope, final String key) { public static void setScopeExtra(final IScope scope, final String key, final Object values) { scope.setExtra(key, values.toString()); } + + public static void addAttachment(final Attachment attachment) { + Sentry.getGlobalScope().addAttachment(attachment); + } + + public static void removeAttachment(final Attachment attachment) { + Sentry.getGlobalScope().getAttachments().remove(attachment); + } } \ No newline at end of file diff --git a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp index e2316e307..ee164dea7 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp @@ -2,6 +2,7 @@ #include "AppleSentrySubsystem.h" +#include "AppleSentryAttachment.h" #include "AppleSentryBreadcrumb.h" #include "AppleSentryEvent.h" #include "AppleSentryId.h" @@ -202,6 +203,24 @@ void FAppleSentrySubsystem::ClearBreadcrumbs() }]; } +void FAppleSentrySubsystem::AddAttachment(TSharedPtr attachment) +{ + TSharedPtr attachmentApple = StaticCastSharedPtr(attachment); + + [SentrySDK configureScope:^(SentryScope* scope) { + [scope addAttachment:attachmentApple->GetNativeObject()]; + }]; +} + +void FAppleSentrySubsystem::RemoveAttachment(TSharedPtr attachment) +{ + TSharedPtr attachmentApple = StaticCastSharedPtr(attachment); + + [SentrySDK configureScope:^(SentryScope* scope) { + [scope.attachmentArray removeObject:attachmentApple->GetNativeObject()]; + }]; +} + TSharedPtr FAppleSentrySubsystem::CaptureMessage(const FString& message, ESentryLevel level) { FSentryScopeDelegate onConfigureScope; diff --git a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h index dd231b6c4..1e07299f0 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h @@ -14,6 +14,8 @@ class FAppleSentrySubsystem : public ISentrySubsystem virtual void AddBreadcrumb(TSharedPtr breadcrumb) override; virtual void AddBreadcrumbWithParams(const FString& Message, const FString& Category, const FString& Type, const TMap& Data, ESentryLevel Level) override; virtual void ClearBreadcrumbs() override; + virtual void AddAttachment(TSharedPtr attachment) override; + virtual void RemoveAttachment(TSharedPtr attachment) override; virtual TSharedPtr CaptureMessage(const FString& message, ESentryLevel level) override; virtual TSharedPtr CaptureMessageWithScope(const FString& message, ESentryLevel level, const FSentryScopeDelegate& onConfigureScope) override; virtual TSharedPtr CaptureEvent(TSharedPtr event) override; diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp index fd3797db6..3457aec9b 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp @@ -250,7 +250,7 @@ void FGenericPlatformSentryScope::AddByteAttachment(TSharedPtr& byteBuf = attachment->GetData(); sentry_attachment_t* nativeAttachment = - sentry_scope_attach_bytes(scope, reinterpret_cast(byteBuf.GetData()), byteBuf.Num(), TCHAR_TO_UTF8(*attachment->GetFilename())); + sentry_scope_attach_bytes(scope, reinterpret_cast(byteBuf.GetData()), byteBuf.Num(), TCHAR_TO_UTF8(*attachment->GetFilename())); if (!attachment->GetContentType().IsEmpty()) sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*attachment->GetContentType())); diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp index 7979e2085..78cfef2f4 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2025 Sentry. All Rights Reserved. #include "GenericPlatformSentrySubsystem.h" +#include "GenericPlatformSentryAttachment.h" #include "GenericPlatformSentryBreadcrumb.h" #include "GenericPlatformSentryEvent.h" #include "GenericPlatformSentryId.h" @@ -205,6 +206,37 @@ void FGenericPlatformSentrySubsystem::InitCrashReporter(const FString& release, crashReporter->SetEnvironment(environment); } +void FGenericPlatformSentrySubsystem::AddFileAttachment(TSharedPtr attachment) +{ + TSharedPtr platformAttachment = StaticCastSharedPtr(attachment); + + sentry_attachment_t* nativeAttachment = + sentry_attach_file(TCHAR_TO_UTF8(*platformAttachment->GetPath())); + + if (!platformAttachment->GetFilename().IsEmpty()) + sentry_attachment_set_filename(nativeAttachment, TCHAR_TO_UTF8(*platformAttachment->GetFilename())); + + if (!platformAttachment->GetContentType().IsEmpty()) + sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*platformAttachment->GetContentType())); + + platformAttachment->SetNativeObject(nativeAttachment); +} + +void FGenericPlatformSentrySubsystem::AddByteAttachment(TSharedPtr attachment) +{ + TSharedPtr platformAttachment = StaticCastSharedPtr(attachment); + + const TArray& byteBuf = platformAttachment->GetData(); + + sentry_attachment_t* nativeAttachment = + sentry_attach_bytes(reinterpret_cast(byteBuf.GetData()), byteBuf.Num(), TCHAR_TO_UTF8(*platformAttachment->GetFilename())); + + if (!platformAttachment->GetContentType().IsEmpty()) + sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*platformAttachment->GetContentType())); + + platformAttachment->SetNativeObject(nativeAttachment); +} + FGenericPlatformSentrySubsystem::FGenericPlatformSentrySubsystem() : beforeSend(nullptr) , beforeBreadcrumb(nullptr) @@ -381,6 +413,27 @@ void FGenericPlatformSentrySubsystem::ClearBreadcrumbs() // Not implemented in sentry-native } +void FGenericPlatformSentrySubsystem::AddAttachment(TSharedPtr attachment) +{ + if (!attachment->GetPath().IsEmpty()) + { + AddFileAttachment(attachment); + } + else + { + AddByteAttachment(attachment); + } +} + +void FGenericPlatformSentrySubsystem::RemoveAttachment(TSharedPtr attachment) +{ + TSharedPtr platformAttachment = StaticCastSharedPtr(attachment); + + sentry_attachment_t* nativeAttachment = platformAttachment->GetNativeObject(); + + sentry_remove_attachment(nativeAttachment); +} + TSharedPtr FGenericPlatformSentrySubsystem::CaptureMessage(const FString& message, ESentryLevel level) { sentry_value_t nativeEvent = sentry_value_new_message_event(FGenericPlatformSentryConverters::SentryLevelToNative(level), nullptr, TCHAR_TO_UTF8(*message)); diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h index a20f78b43..e00fdeadf 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h @@ -8,6 +8,7 @@ #include "HAL/CriticalSection.h" +class FGenericPlatformSentryAttachment; class FGenericPlatformSentryScope; class FGenericPlatformSentryCrashReporter; @@ -25,6 +26,8 @@ class FGenericPlatformSentrySubsystem : public ISentrySubsystem virtual void AddBreadcrumb(TSharedPtr breadcrumb) override; virtual void AddBreadcrumbWithParams(const FString& Message, const FString& Category, const FString& Type, const TMap& Data, ESentryLevel Level) override; virtual void ClearBreadcrumbs() override; + virtual void AddAttachment(TSharedPtr attachment) override; + virtual void RemoveAttachment(TSharedPtr attachment) override; virtual TSharedPtr CaptureMessage(const FString& message, ESentryLevel level) override; virtual TSharedPtr CaptureMessageWithScope(const FString& message, ESentryLevel level, const FSentryScopeDelegate& onConfigureScope) override; virtual TSharedPtr CaptureEvent(TSharedPtr event) override; @@ -71,6 +74,9 @@ class FGenericPlatformSentrySubsystem : public ISentrySubsystem void InitCrashReporter(const FString& release, const FString& environment); + virtual void AddFileAttachment(TSharedPtr attachment); + virtual void AddByteAttachment(TSharedPtr attachment); + private: /** * Static wrappers that are passed to the Sentry library. diff --git a/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h b/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h index b31d10e89..91906d092 100644 --- a/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h +++ b/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h @@ -7,6 +7,7 @@ #include "SentryDataTypes.h" #include "SentryVariant.h" +class ISentryAttachment; class ISentryBreadcrumb; class ISentryEvent; class ISentryUserFeedback; @@ -35,6 +36,8 @@ class ISentrySubsystem virtual void AddBreadcrumb(TSharedPtr breadcrumb) = 0; virtual void AddBreadcrumbWithParams(const FString& Message, const FString& Category, const FString& Type, const TMap& Data, ESentryLevel Level) = 0; virtual void ClearBreadcrumbs() = 0; + virtual void AddAttachment(TSharedPtr attachment) = 0; + virtual void RemoveAttachment(TSharedPtr attachment) = 0; virtual TSharedPtr CaptureMessage(const FString& message, ESentryLevel level) = 0; virtual TSharedPtr CaptureMessageWithScope(const FString& message, ESentryLevel level, const FSentryScopeDelegate& onConfigureScope) = 0; virtual TSharedPtr CaptureEvent(TSharedPtr event) = 0; diff --git a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp index e940cafb0..41dbedf16 100644 --- a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp @@ -10,6 +10,8 @@ #include "SentryModule.h" #include "SentrySettings.h" +#include "GenericPlatform/GenericPlatformSentryAttachment.h" + #include "GenericPlatform/GenericPlatformOutputDevices.h" #include "Misc/EngineVersionComparison.h" @@ -67,4 +69,35 @@ void FMicrosoftSentrySubsystem::ConfigureScreenshotAttachment(sentry_options_t* sentry_options_add_attachmentw(Options, *GetScreenshotPath()); } +void FMicrosoftSentrySubsystem::AddFileAttachment(TSharedPtr attachment) +{ + TSharedPtr platformAttachment = StaticCastSharedPtr(attachment); + + sentry_attachment_t* nativeAttachment = + sentry_attach_filew(*platformAttachment->GetPath()); + + if (!platformAttachment->GetFilename().IsEmpty()) + sentry_attachment_set_filenamew(nativeAttachment, *platformAttachment->GetFilename()); + + if (!platformAttachment->GetContentType().IsEmpty()) + sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*platformAttachment->GetContentType())); + + platformAttachment->SetNativeObject(nativeAttachment); +} + +void FMicrosoftSentrySubsystem::AddByteAttachment(TSharedPtr attachment) +{ + TSharedPtr platformAttachment = StaticCastSharedPtr(attachment); + + const TArray& byteBuf = platformAttachment->GetData(); + + sentry_attachment_t* nativeAttachment = + sentry_attach_bytesw(reinterpret_cast(byteBuf.GetData()), byteBuf.Num(), *platformAttachment->GetFilename()); + + if (!platformAttachment->GetContentType().IsEmpty()) + sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*platformAttachment->GetContentType())); + + platformAttachment->SetNativeObject(nativeAttachment); +} + #endif // USE_SENTRY_NATIVE diff --git a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.h b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.h index 071b52da0..45bce50bb 100644 --- a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.h @@ -18,6 +18,9 @@ class FMicrosoftSentrySubsystem : public FGenericPlatformSentrySubsystem virtual void ConfigureDatabasePath(sentry_options_t* Options) override; virtual void ConfigureLogFileAttachment(sentry_options_t* Options) override; virtual void ConfigureScreenshotAttachment(sentry_options_t* Options) override; + + virtual void AddFileAttachment(TSharedPtr attachment) override; + virtual void AddByteAttachment(TSharedPtr attachment) override; }; #endif // USE_SENTRY_NATIVE diff --git a/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp index 451564740..1dd7c14b0 100644 --- a/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp @@ -18,6 +18,7 @@ #include "SentryUserFeedback.h" #include "CoreGlobals.h" +#include "SentryAttachment.h" #include "Engine/World.h" #include "GenericPlatform/GenericPlatformDriver.h" #include "GenericPlatform/GenericPlatformMisc.h" @@ -246,6 +247,30 @@ void USentrySubsystem::ClearBreadcrumbs() SubsystemNativeImpl->ClearBreadcrumbs(); } +void USentrySubsystem::AddAttachment(USentryAttachment* Attachment) +{ + check(SubsystemNativeImpl); + + if (!SubsystemNativeImpl || !SubsystemNativeImpl->IsEnabled()) + { + return; + } + + SubsystemNativeImpl->AddAttachment(Attachment->GetNativeObject()); +} + +void USentrySubsystem::RemoveAttachment(USentryAttachment* Attachment) +{ + check(SubsystemNativeImpl); + + if (!SubsystemNativeImpl || !SubsystemNativeImpl->IsEnabled()) + { + return; + } + + SubsystemNativeImpl->RemoveAttachment(Attachment->GetNativeObject()); +} + FString USentrySubsystem::CaptureMessage(const FString& Message, ESentryLevel Level) { check(SubsystemNativeImpl); diff --git a/plugin-dev/Source/Sentry/Public/SentrySubsystem.h b/plugin-dev/Source/Sentry/Public/SentrySubsystem.h index 8e8a23c7f..b71cedb54 100644 --- a/plugin-dev/Source/Sentry/Public/SentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Public/SentrySubsystem.h @@ -104,6 +104,22 @@ class SENTRY_API USentrySubsystem : public UEngineSubsystem UFUNCTION(BlueprintCallable, Category = "Sentry") void ClearBreadcrumbs(); + /** + * Adds an attachment to the current Scope. + * + * @param Attachment The attachment that will be added to every event. + */ + UFUNCTION(BlueprintCallable, Category = "Sentry") + void AddAttachment(USentryAttachment* Attachment); + + /** + * Removes an attachment from the current Scope. + * + * @param Attachment The attachment that will be removed. + */ + UFUNCTION(BlueprintCallable, Category = "Sentry") + void RemoveAttachment(USentryAttachment* Attachment); + /** * Captures the message. * From 781288a159218bf43b6b04eb510c5fd82927e11a Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Thu, 26 Jun 2025 16:25:24 +0300 Subject: [PATCH 05/13] Fix build error --- .../Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp index ee164dea7..4c52ee589 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp @@ -214,11 +214,7 @@ void FAppleSentrySubsystem::AddAttachment(TSharedPtr attachme void FAppleSentrySubsystem::RemoveAttachment(TSharedPtr attachment) { - TSharedPtr attachmentApple = StaticCastSharedPtr(attachment); - - [SentrySDK configureScope:^(SentryScope* scope) { - [scope.attachmentArray removeObject:attachmentApple->GetNativeObject()]; - }]; + // CUrrently, Cocoa SDK doesn't have API allowing to remove individual attachments } TSharedPtr FAppleSentrySubsystem::CaptureMessage(const FString& message, ESentryLevel level) From 76477e0d1756b20f71a31e1b78752573d2e64d58 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Thu, 26 Jun 2025 16:25:57 +0300 Subject: [PATCH 06/13] Fix lint errors --- .../GenericPlatform/GenericPlatformSentrySubsystem.cpp | 2 +- .../Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp | 4 ++-- .../Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp | 2 +- plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp index 78cfef2f4..01d55e6dc 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp @@ -211,7 +211,7 @@ void FGenericPlatformSentrySubsystem::AddFileAttachment(TSharedPtr platformAttachment = StaticCastSharedPtr(attachment); sentry_attachment_t* nativeAttachment = - sentry_attach_file(TCHAR_TO_UTF8(*platformAttachment->GetPath())); + sentry_attach_file(TCHAR_TO_UTF8(*platformAttachment->GetPath())); if (!platformAttachment->GetFilename().IsEmpty()) sentry_attachment_set_filename(nativeAttachment, TCHAR_TO_UTF8(*platformAttachment->GetFilename())); diff --git a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp index 2a8a88721..27967eb59 100644 --- a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp +++ b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp @@ -7,7 +7,7 @@ void FMicrosoftSentryScope::AddFileAttachment(TSharedPtr attachment, sentry_scope_t* scope) { sentry_attachment_t* nativeAttachment = - sentry_scope_attach_filew(scope, *attachment->GetPath()); + sentry_scope_attach_filew(scope, *attachment->GetPath()); if (!attachment->GetFilename().IsEmpty()) sentry_attachment_set_filenamew(nativeAttachment, *attachment->GetFilename()); @@ -23,7 +23,7 @@ void FMicrosoftSentryScope::AddByteAttachment(TSharedPtr& byteBuf = attachment->GetData(); sentry_attachment_t* nativeAttachment = - sentry_scope_attach_bytesw(scope, reinterpret_cast(byteBuf.GetData()), byteBuf.Num(), *attachment->GetFilename()); + sentry_scope_attach_bytesw(scope, reinterpret_cast(byteBuf.GetData()), byteBuf.Num(), *attachment->GetFilename()); if (!attachment->GetContentType().IsEmpty()) sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*attachment->GetContentType())); diff --git a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp index 41dbedf16..7eb392fe3 100644 --- a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp @@ -74,7 +74,7 @@ void FMicrosoftSentrySubsystem::AddFileAttachment(TSharedPtr TSharedPtr platformAttachment = StaticCastSharedPtr(attachment); sentry_attachment_t* nativeAttachment = - sentry_attach_filew(*platformAttachment->GetPath()); + sentry_attach_filew(*platformAttachment->GetPath()); if (!platformAttachment->GetFilename().IsEmpty()) sentry_attachment_set_filenamew(nativeAttachment, *platformAttachment->GetFilename()); diff --git a/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp index 1dd7c14b0..e82cdcaef 100644 --- a/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp @@ -18,7 +18,6 @@ #include "SentryUserFeedback.h" #include "CoreGlobals.h" -#include "SentryAttachment.h" #include "Engine/World.h" #include "GenericPlatform/GenericPlatformDriver.h" #include "GenericPlatform/GenericPlatformMisc.h" @@ -26,6 +25,7 @@ #include "Misc/AssertionMacros.h" #include "Misc/CoreDelegates.h" #include "Misc/EngineVersion.h" +#include "SentryAttachment.h" #include "Interface/SentrySubsystemInterface.h" From 8c609ce157f354f2f2b5b9354dc38ab25b79f76a Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Thu, 26 Jun 2025 16:27:42 +0300 Subject: [PATCH 07/13] Fix comments --- .../Source/Sentry/Private/Android/Java/SentryBridgeJava.java | 2 +- plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java b/plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java index cdfe4dc88..776d5222a 100644 --- a/plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java +++ b/plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java @@ -232,6 +232,6 @@ public static void addAttachment(final Attachment attachment) { } public static void removeAttachment(final Attachment attachment) { - Sentry.getGlobalScope().getAttachments().remove(attachment); + // Currently, Android SDK doesn't have API allowing to remove individual attachments } } \ No newline at end of file diff --git a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp index 4c52ee589..5218f8ae4 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp @@ -214,7 +214,7 @@ void FAppleSentrySubsystem::AddAttachment(TSharedPtr attachme void FAppleSentrySubsystem::RemoveAttachment(TSharedPtr attachment) { - // CUrrently, Cocoa SDK doesn't have API allowing to remove individual attachments + // Currently, Cocoa SDK doesn't have API allowing to remove individual attachments } TSharedPtr FAppleSentrySubsystem::CaptureMessage(const FString& message, ESentryLevel level) From 98cbc93699069321b8f441bae3a881beda499443 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Thu, 26 Jun 2025 16:42:10 +0300 Subject: [PATCH 08/13] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index efc56ac3a..e55a99a3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ ### Features - Adopt generic variant type in public APIs ([#971](https://github.com/getsentry/sentry-unreal/pull/971)) +- Add runtime attachments support for Windows/Linux ([#982](https://github.com/getsentry/sentry-unreal/pull/982)) ### Dependencies From d7c4506198ed6026dcd9ef7f5e2e079f7e2d9e47 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Thu, 26 Jun 2025 16:43:59 +0300 Subject: [PATCH 09/13] Update snapshot --- scripts/packaging/package-github.snapshot | 4 ++++ scripts/packaging/package-marketplace.snapshot | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/scripts/packaging/package-github.snapshot b/scripts/packaging/package-github.snapshot index 51ce8678c..698e2638a 100644 --- a/scripts/packaging/package-github.snapshot +++ b/scripts/packaging/package-github.snapshot @@ -80,6 +80,8 @@ Source/Sentry/Private/GenericPlatform/CrashReporter/GenericPlatformSentryCrashCo Source/Sentry/Private/GenericPlatform/CrashReporter/GenericPlatformSentryCrashContext.h Source/Sentry/Private/GenericPlatform/CrashReporter/GenericPlatformSentryCrashReporter.cpp Source/Sentry/Private/GenericPlatform/CrashReporter/GenericPlatformSentryCrashReporter.h +Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp +Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h Source/Sentry/Private/GenericPlatform/GenericPlatformSentryBreadcrumb.cpp Source/Sentry/Private/GenericPlatform/GenericPlatformSentryBreadcrumb.h Source/Sentry/Private/GenericPlatform/GenericPlatformSentryEvent.cpp @@ -138,6 +140,8 @@ Source/Sentry/Private/Linux/LinuxSentryUser.h Source/Sentry/Private/Mac/MacSentrySubsystem.cpp Source/Sentry/Private/Mac/MacSentrySubsystem.h Source/Sentry/Private/Mac/MacSentryUser.h +Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp +Source/Sentry/Private/Microsoft/MicrosoftSentryScope.h Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.h Source/Sentry/Private/Null/NullSentryAttachment.h diff --git a/scripts/packaging/package-marketplace.snapshot b/scripts/packaging/package-marketplace.snapshot index 1f6f70199..ca7664995 100644 --- a/scripts/packaging/package-marketplace.snapshot +++ b/scripts/packaging/package-marketplace.snapshot @@ -79,6 +79,8 @@ Source/Sentry/Private/GenericPlatform/CrashReporter/GenericPlatformSentryCrashCo Source/Sentry/Private/GenericPlatform/CrashReporter/GenericPlatformSentryCrashContext.h Source/Sentry/Private/GenericPlatform/CrashReporter/GenericPlatformSentryCrashReporter.cpp Source/Sentry/Private/GenericPlatform/CrashReporter/GenericPlatformSentryCrashReporter.h +Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp +Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h Source/Sentry/Private/GenericPlatform/GenericPlatformSentryBreadcrumb.cpp Source/Sentry/Private/GenericPlatform/GenericPlatformSentryBreadcrumb.h Source/Sentry/Private/GenericPlatform/GenericPlatformSentryEvent.cpp @@ -137,6 +139,8 @@ Source/Sentry/Private/Linux/LinuxSentryUser.h Source/Sentry/Private/Mac/MacSentrySubsystem.cpp Source/Sentry/Private/Mac/MacSentrySubsystem.h Source/Sentry/Private/Mac/MacSentryUser.h +Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp +Source/Sentry/Private/Microsoft/MicrosoftSentryScope.h Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.h Source/Sentry/Private/Null/NullSentryAttachment.h From a28ebc5f451e814d0a589271d0384d9670d361c6 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Fri, 27 Jun 2025 10:03:38 +0300 Subject: [PATCH 10/13] Resert attachment native object reference after it was removed --- .../GenericPlatform/GenericPlatformSentryAttachment.cpp | 4 ++-- .../GenericPlatform/GenericPlatformSentrySubsystem.cpp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp index 9e2a832fd..f506739fb 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp @@ -5,12 +5,12 @@ #if USE_SENTRY_NATIVE FGenericPlatformSentryAttachment::FGenericPlatformSentryAttachment(const TArray& data, const FString& filename, const FString& contentType) - : Data(data), Filename(filename), ContentType(contentType) + : Data(data), Filename(filename), ContentType(contentType), Attachment(nullptr) { } FGenericPlatformSentryAttachment::FGenericPlatformSentryAttachment(const FString& path, const FString& filename, const FString& contentType) - : Path(path), Filename(filename), ContentType(contentType) + : Path(path), Filename(filename), ContentType(contentType), Attachment(nullptr) { } diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp index 01d55e6dc..7e5d9a0b0 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp @@ -431,7 +431,12 @@ void FGenericPlatformSentrySubsystem::RemoveAttachment(TSharedPtrGetNativeObject(); + if (!nativeAttachment) + return; + sentry_remove_attachment(nativeAttachment); + + platformAttachment->SetNativeObject(nullptr); } TSharedPtr FGenericPlatformSentrySubsystem::CaptureMessage(const FString& message, ESentryLevel level) From 591c735f1eed0e18ebcdbb432d6158a596bb870b Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Fri, 27 Jun 2025 10:27:45 +0300 Subject: [PATCH 11/13] Remove reference --- .../Private/GenericPlatform/GenericPlatformSentryScope.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp index 3457aec9b..9152bd7fb 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp @@ -247,7 +247,7 @@ void FGenericPlatformSentryScope::AddFileAttachment(TSharedPtr attachment, sentry_scope_t* scope) { - const TArray& byteBuf = attachment->GetData(); + TArray byteBuf = attachment->GetData(); sentry_attachment_t* nativeAttachment = sentry_scope_attach_bytes(scope, reinterpret_cast(byteBuf.GetData()), byteBuf.Num(), TCHAR_TO_UTF8(*attachment->GetFilename())); From 099d054af36a8ade2a8160183e7c1d07175f31e3 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Fri, 27 Jun 2025 10:47:11 +0300 Subject: [PATCH 12/13] Return attachment byte data by ref during adding --- .../GenericPlatform/GenericPlatformSentryAttachment.cpp | 5 +++++ .../GenericPlatform/GenericPlatformSentryAttachment.h | 2 ++ .../Private/GenericPlatform/GenericPlatformSentryScope.cpp | 2 +- .../GenericPlatform/GenericPlatformSentrySubsystem.cpp | 2 +- .../Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp | 2 +- .../Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp | 2 +- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp index f506739fb..8a8244a22 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp @@ -49,4 +49,9 @@ FString FGenericPlatformSentryAttachment::GetContentType() const return ContentType; } +const TArray& FGenericPlatformSentryAttachment::GetDataByRef() const +{ + return Data; +} + #endif diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h index 84303fbb0..24dd67d04 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h @@ -23,6 +23,8 @@ class FGenericPlatformSentryAttachment : public ISentryAttachment virtual FString GetFilename() const override; virtual FString GetContentType() const override; + const TArray& GetDataByRef() const; + private: TArray Data; FString Path; diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp index 9152bd7fb..62562f09a 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryScope.cpp @@ -247,7 +247,7 @@ void FGenericPlatformSentryScope::AddFileAttachment(TSharedPtr attachment, sentry_scope_t* scope) { - TArray byteBuf = attachment->GetData(); + const TArray& byteBuf = attachment->GetDataByRef(); sentry_attachment_t* nativeAttachment = sentry_scope_attach_bytes(scope, reinterpret_cast(byteBuf.GetData()), byteBuf.Num(), TCHAR_TO_UTF8(*attachment->GetFilename())); diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp index 7e5d9a0b0..d28d85cb1 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp @@ -226,7 +226,7 @@ void FGenericPlatformSentrySubsystem::AddByteAttachment(TSharedPtr platformAttachment = StaticCastSharedPtr(attachment); - const TArray& byteBuf = platformAttachment->GetData(); + const TArray& byteBuf = platformAttachment->GetDataByRef(); sentry_attachment_t* nativeAttachment = sentry_attach_bytes(reinterpret_cast(byteBuf.GetData()), byteBuf.Num(), TCHAR_TO_UTF8(*platformAttachment->GetFilename())); diff --git a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp index 27967eb59..cf5e111c8 100644 --- a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp +++ b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentryScope.cpp @@ -20,7 +20,7 @@ void FMicrosoftSentryScope::AddFileAttachment(TSharedPtr attachment, sentry_scope_t* scope) { - const TArray& byteBuf = attachment->GetData(); + const TArray& byteBuf = attachment->GetDataByRef(); sentry_attachment_t* nativeAttachment = sentry_scope_attach_bytesw(scope, reinterpret_cast(byteBuf.GetData()), byteBuf.Num(), *attachment->GetFilename()); diff --git a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp index 7eb392fe3..ff86c60bf 100644 --- a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp @@ -89,7 +89,7 @@ void FMicrosoftSentrySubsystem::AddByteAttachment(TSharedPtr { TSharedPtr platformAttachment = StaticCastSharedPtr(attachment); - const TArray& byteBuf = platformAttachment->GetData(); + const TArray& byteBuf = platformAttachment->GetDataByRef(); sentry_attachment_t* nativeAttachment = sentry_attach_bytesw(reinterpret_cast(byteBuf.GetData()), byteBuf.Num(), *platformAttachment->GetFilename()); From 19da3b2fe436afcdf5305a3790825677b137deea Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Wed, 2 Jul 2025 16:48:27 +0300 Subject: [PATCH 13/13] Add function allowing to clear all attachments from the global scope `ClearAttachments` replaces `RemoveAttachment` which is currently not availbale on mobile. For desktop, user-defined attachments are cached on the Unreal side while this functionality isn't available in sentry-native. --- .../Private/Android/AndroidSentrySubsystem.cpp | 5 +++++ .../Private/Android/AndroidSentrySubsystem.h | 1 + .../Private/Android/Java/SentryBridgeJava.java | 5 +++++ .../Sentry/Private/Apple/AppleSentrySubsystem.cpp | 7 +++++++ .../Sentry/Private/Apple/AppleSentrySubsystem.h | 1 + .../GenericPlatformSentrySubsystem.cpp | 14 ++++++++++++++ .../GenericPlatformSentrySubsystem.h | 3 +++ .../Private/Interface/SentrySubsystemInterface.h | 1 + .../Private/Microsoft/MicrosoftSentrySubsystem.cpp | 4 ++++ .../Source/Sentry/Private/SentrySubsystem.cpp | 4 ++-- plugin-dev/Source/Sentry/Public/SentrySubsystem.h | 8 ++------ 11 files changed, 45 insertions(+), 8 deletions(-) diff --git a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp index af3a15b0a..d38d85641 100644 --- a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp @@ -144,6 +144,11 @@ void FAndroidSentrySubsystem::RemoveAttachment(TSharedPtr att attachmentAndroid->GetJObject()); } +void FAndroidSentrySubsystem::ClearAttachments() +{ + FSentryJavaObjectWrapper::CallStaticMethod(SentryJavaClasses::SentryBridgeJava, "clearAttachments", "()V"); +} + TSharedPtr FAndroidSentrySubsystem::CaptureMessage(const FString& message, ESentryLevel level) { auto id = FSentryJavaObjectWrapper::CallStaticObjectMethod(SentryJavaClasses::Sentry, "captureMessage", "(Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId;", diff --git a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h index 0edc6f9be..7286fc147 100644 --- a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h @@ -16,6 +16,7 @@ class FAndroidSentrySubsystem : public ISentrySubsystem virtual void ClearBreadcrumbs() override; virtual void AddAttachment(TSharedPtr attachment) override; virtual void RemoveAttachment(TSharedPtr attachment) override; + virtual void ClearAttachments() override; virtual TSharedPtr CaptureMessage(const FString& message, ESentryLevel level) override; virtual TSharedPtr CaptureMessageWithScope(const FString& message, ESentryLevel level, const FSentryScopeDelegate& onConfigureScope) override; virtual TSharedPtr CaptureEvent(TSharedPtr event) override; diff --git a/plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java b/plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java index 776d5222a..3ef17eedb 100644 --- a/plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java +++ b/plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java @@ -234,4 +234,9 @@ public static void addAttachment(final Attachment attachment) { public static void removeAttachment(final Attachment attachment) { // Currently, Android SDK doesn't have API allowing to remove individual attachments } + + public static void clearAttachments() { + Sentry.getGlobalScope().clearAttachments(); + } + } \ No newline at end of file diff --git a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp index 5218f8ae4..93658a014 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp @@ -217,6 +217,13 @@ void FAppleSentrySubsystem::RemoveAttachment(TSharedPtr attac // Currently, Cocoa SDK doesn't have API allowing to remove individual attachments } +void FAppleSentrySubsystem::ClearAttachments() +{ + [SentrySDK configureScope:^(SentryScope* scope) { + [scope clearAttachments]; + }]; +} + TSharedPtr FAppleSentrySubsystem::CaptureMessage(const FString& message, ESentryLevel level) { FSentryScopeDelegate onConfigureScope; diff --git a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h index 1e07299f0..b4a9b6aff 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h @@ -16,6 +16,7 @@ class FAppleSentrySubsystem : public ISentrySubsystem virtual void ClearBreadcrumbs() override; virtual void AddAttachment(TSharedPtr attachment) override; virtual void RemoveAttachment(TSharedPtr attachment) override; + virtual void ClearAttachments() override; virtual TSharedPtr CaptureMessage(const FString& message, ESentryLevel level) override; virtual TSharedPtr CaptureMessageWithScope(const FString& message, ESentryLevel level, const FSentryScopeDelegate& onConfigureScope) override; virtual TSharedPtr CaptureEvent(TSharedPtr event) override; diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp index d28d85cb1..269a4e469 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp @@ -220,6 +220,8 @@ void FGenericPlatformSentrySubsystem::AddFileAttachment(TSharedPtrGetContentType())); platformAttachment->SetNativeObject(nativeAttachment); + + attachments.Add(platformAttachment); } void FGenericPlatformSentrySubsystem::AddByteAttachment(TSharedPtr attachment) @@ -235,6 +237,8 @@ void FGenericPlatformSentrySubsystem::AddByteAttachment(TSharedPtrGetContentType())); platformAttachment->SetNativeObject(nativeAttachment); + + attachments.Add(platformAttachment); } FGenericPlatformSentrySubsystem::FGenericPlatformSentrySubsystem() @@ -439,6 +443,16 @@ void FGenericPlatformSentrySubsystem::RemoveAttachment(TSharedPtrSetNativeObject(nullptr); } +void FGenericPlatformSentrySubsystem::ClearAttachments() +{ + for (auto& attachment : attachments) + { + RemoveAttachment(attachment); + } + + attachments.Empty(); +} + TSharedPtr FGenericPlatformSentrySubsystem::CaptureMessage(const FString& message, ESentryLevel level) { sentry_value_t nativeEvent = sentry_value_new_message_event(FGenericPlatformSentryConverters::SentryLevelToNative(level), nullptr, TCHAR_TO_UTF8(*message)); diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h index e00fdeadf..a9efab927 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h @@ -28,6 +28,7 @@ class FGenericPlatformSentrySubsystem : public ISentrySubsystem virtual void ClearBreadcrumbs() override; virtual void AddAttachment(TSharedPtr attachment) override; virtual void RemoveAttachment(TSharedPtr attachment) override; + virtual void ClearAttachments() override; virtual TSharedPtr CaptureMessage(const FString& message, ESentryLevel level) override; virtual TSharedPtr CaptureMessageWithScope(const FString& message, ESentryLevel level, const FSentryScopeDelegate& onConfigureScope) override; virtual TSharedPtr CaptureEvent(TSharedPtr event) override; @@ -77,6 +78,8 @@ class FGenericPlatformSentrySubsystem : public ISentrySubsystem virtual void AddFileAttachment(TSharedPtr attachment); virtual void AddByteAttachment(TSharedPtr attachment); + TArray> attachments; + private: /** * Static wrappers that are passed to the Sentry library. diff --git a/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h b/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h index 91906d092..58f503fcb 100644 --- a/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h +++ b/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h @@ -38,6 +38,7 @@ class ISentrySubsystem virtual void ClearBreadcrumbs() = 0; virtual void AddAttachment(TSharedPtr attachment) = 0; virtual void RemoveAttachment(TSharedPtr attachment) = 0; + virtual void ClearAttachments() = 0; virtual TSharedPtr CaptureMessage(const FString& message, ESentryLevel level) = 0; virtual TSharedPtr CaptureMessageWithScope(const FString& message, ESentryLevel level, const FSentryScopeDelegate& onConfigureScope) = 0; virtual TSharedPtr CaptureEvent(TSharedPtr event) = 0; diff --git a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp index ff86c60bf..8cad4879f 100644 --- a/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.cpp @@ -83,6 +83,8 @@ void FMicrosoftSentrySubsystem::AddFileAttachment(TSharedPtr sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*platformAttachment->GetContentType())); platformAttachment->SetNativeObject(nativeAttachment); + + attachments.Add(platformAttachment); } void FMicrosoftSentrySubsystem::AddByteAttachment(TSharedPtr attachment) @@ -98,6 +100,8 @@ void FMicrosoftSentrySubsystem::AddByteAttachment(TSharedPtr sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*platformAttachment->GetContentType())); platformAttachment->SetNativeObject(nativeAttachment); + + attachments.Add(platformAttachment); } #endif // USE_SENTRY_NATIVE diff --git a/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp index e82cdcaef..193df3014 100644 --- a/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp @@ -259,7 +259,7 @@ void USentrySubsystem::AddAttachment(USentryAttachment* Attachment) SubsystemNativeImpl->AddAttachment(Attachment->GetNativeObject()); } -void USentrySubsystem::RemoveAttachment(USentryAttachment* Attachment) +void USentrySubsystem::ClearAttachments() { check(SubsystemNativeImpl); @@ -268,7 +268,7 @@ void USentrySubsystem::RemoveAttachment(USentryAttachment* Attachment) return; } - SubsystemNativeImpl->RemoveAttachment(Attachment->GetNativeObject()); + SubsystemNativeImpl->ClearAttachments(); } FString USentrySubsystem::CaptureMessage(const FString& Message, ESentryLevel Level) diff --git a/plugin-dev/Source/Sentry/Public/SentrySubsystem.h b/plugin-dev/Source/Sentry/Public/SentrySubsystem.h index b71cedb54..7ae42df24 100644 --- a/plugin-dev/Source/Sentry/Public/SentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Public/SentrySubsystem.h @@ -112,13 +112,9 @@ class SENTRY_API USentrySubsystem : public UEngineSubsystem UFUNCTION(BlueprintCallable, Category = "Sentry") void AddAttachment(USentryAttachment* Attachment); - /** - * Removes an attachment from the current Scope. - * - * @param Attachment The attachment that will be removed. - */ + /** Clears all previously added attachments from the current scope. */ UFUNCTION(BlueprintCallable, Category = "Sentry") - void RemoveAttachment(USentryAttachment* Attachment); + void ClearAttachments(); /** * Captures the message.