From 615e889fae0f9544071780526e5dec223992c788 Mon Sep 17 00:00:00 2001 From: Nathan White Date: Tue, 4 Nov 2025 10:37:22 -0800 Subject: [PATCH 1/8] Expose user consent API --- CHANGELOG.md | 4 ++++ .../GenericPlatformSentrySubsystem.cpp | 5 +++++ .../GenericPlatform/GenericPlatformSentrySubsystem.h | 1 + .../Private/Interface/SentrySubsystemInterface.h | 1 + plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp | 12 ++++++++++++ plugin-dev/Source/Sentry/Public/SentrySubsystem.h | 10 ++++++++++ 6 files changed, 33 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f59bdc14..0eec764b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Features + +- Add runtime API to query user consent requirement () + ### Dependencies - Bump Native SDK from v0.12.0 to v0.12.1 ([#1136](https://github.com/getsentry/sentry-unreal/pull/1136)) diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp index 4efc57485..c266cb8ab 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp @@ -749,6 +749,11 @@ EUserConsent FGenericPlatformSentrySubsystem::GetUserConsent() const } } +bool FGenericPlatformSentrySubsystem::IsUserConsentRequired() const +{ + return sentry_user_consent_required() == 1; +} + TSharedPtr FGenericPlatformSentrySubsystem::StartTransaction(const FString& name, const FString& operation, bool bindToScope) { TSharedPtr transactionContext = MakeShareable(new FGenericPlatformSentryTransactionContext(name, operation)); diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h index 892f02002..72a65c6d7 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h @@ -47,6 +47,7 @@ class FGenericPlatformSentrySubsystem : public ISentrySubsystem virtual void GiveUserConsent() override; virtual void RevokeUserConsent() override; virtual EUserConsent GetUserConsent() const override; + virtual bool IsUserConsentRequired() const override; virtual TSharedPtr StartTransaction(const FString& name, const FString& operation, bool bindToScope) override; virtual TSharedPtr StartTransactionWithContext(TSharedPtr context, bool bindToScope) override; virtual TSharedPtr StartTransactionWithContextAndTimestamp(TSharedPtr context, int64 timestamp, bool bindToScope) override; diff --git a/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h b/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h index f08d1577d..543e261a7 100644 --- a/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h +++ b/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h @@ -60,6 +60,7 @@ class ISentrySubsystem virtual void GiveUserConsent() = 0; virtual void RevokeUserConsent() = 0; virtual EUserConsent GetUserConsent() const = 0; + virtual bool IsUserConsentRequired() const { return false; } virtual TSharedPtr StartTransaction(const FString& name, const FString& operation, bool bindToScope) = 0; virtual TSharedPtr StartTransactionWithContext(TSharedPtr context, bool bindToScope) = 0; virtual TSharedPtr StartTransactionWithContextAndTimestamp(TSharedPtr context, int64 timestamp, bool bindToScope) = 0; diff --git a/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp index eb463572e..07cb47202 100644 --- a/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp @@ -623,6 +623,18 @@ EUserConsent USentrySubsystem::GetUserConsent() const return SubsystemNativeImpl->GetUserConsent(); } +bool USentrySubsystem::IsUserConsentRequired() const +{ + check(SubsystemNativeImpl); + + if (!SubsystemNativeImpl || !SubsystemNativeImpl->IsEnabled()) + { + return false; + } + + return SubsystemNativeImpl->IsUserConsentRequired(); +} + USentryTransaction* USentrySubsystem::StartTransaction(const FString& Name, const FString& Operation, bool BindToScope) { check(SubsystemNativeImpl); diff --git a/plugin-dev/Source/Sentry/Public/SentrySubsystem.h b/plugin-dev/Source/Sentry/Public/SentrySubsystem.h index 9333c0793..ba4cbe973 100644 --- a/plugin-dev/Source/Sentry/Public/SentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Public/SentrySubsystem.h @@ -319,6 +319,16 @@ class SENTRY_API USentrySubsystem : public UEngineSubsystem UFUNCTION(BlueprintCallable, Category = "Sentry") EUserConsent GetUserConsent() const; + /** + * Returns if user consent is required for crash upload. + * + * @return True if user consent is required; otherwise false. + * + * @note This method is currently only relevant on Windows and Linux; other platforms will default to `false`. + */ + UFUNCTION(BlueprintCallable, Category = "Sentry") + bool IsUserConsentRequired() const; + /** * Starts a new transaction. * From 7247e91a0bc343cadde90dcdda7f32cad1d619e6 Mon Sep 17 00:00:00 2001 From: Sentry Github Bot Date: Tue, 4 Nov 2025 18:37:43 +0000 Subject: [PATCH 2/8] Format code --- plugin-dev/Source/Sentry/Public/SentrySubsystem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin-dev/Source/Sentry/Public/SentrySubsystem.h b/plugin-dev/Source/Sentry/Public/SentrySubsystem.h index ba4cbe973..3c4776f49 100644 --- a/plugin-dev/Source/Sentry/Public/SentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Public/SentrySubsystem.h @@ -321,9 +321,9 @@ class SENTRY_API USentrySubsystem : public UEngineSubsystem /** * Returns if user consent is required for crash upload. - * + * * @return True if user consent is required; otherwise false. - * + * * @note This method is currently only relevant on Windows and Linux; other platforms will default to `false`. */ UFUNCTION(BlueprintCallable, Category = "Sentry") From 8466734672841b08f782cc2a25bf0319d55f310e Mon Sep 17 00:00:00 2001 From: Nathan White Date: Tue, 4 Nov 2025 10:38:28 -0800 Subject: [PATCH 3/8] Add PR --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eec764b0..95f5c3035 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Features -- Add runtime API to query user consent requirement () +- Add runtime API to query user consent requirement ([#1139](https://github.com/getsentry/sentry-unreal/pull/1139)) ### Dependencies From 0144aabb088625615ba35f7d183c4fea82097856 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Mon, 17 Nov 2025 15:24:58 +0200 Subject: [PATCH 4/8] Fix method name --- .../Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp index c266cb8ab..0d8a3ca79 100644 --- a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp @@ -751,7 +751,7 @@ EUserConsent FGenericPlatformSentrySubsystem::GetUserConsent() const bool FGenericPlatformSentrySubsystem::IsUserConsentRequired() const { - return sentry_user_consent_required() == 1; + return sentry_user_consent_is_required() == 1; } TSharedPtr FGenericPlatformSentrySubsystem::StartTransaction(const FString& name, const FString& operation, bool bindToScope) From 7347f0c469df6d361185615bbcf86993ee512f7a Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Mon, 17 Nov 2025 15:35:02 +0200 Subject: [PATCH 5/8] Add `IsUserConsentRequired` implementation stubs for Android and Apple --- .../Sentry/Private/Android/AndroidSentrySubsystem.cpp | 6 ++++++ .../Source/Sentry/Private/Android/AndroidSentrySubsystem.h | 1 + .../Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp | 6 ++++++ .../Source/Sentry/Private/Apple/AppleSentrySubsystem.h | 5 ++++- .../Sentry/Private/Interface/SentrySubsystemInterface.h | 2 +- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp index 144cb2b5e..8445e3408 100644 --- a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp @@ -376,6 +376,12 @@ EUserConsent FAndroidSentrySubsystem::GetUserConsent() const return EUserConsent::Unknown; } +bool FAndroidSentrySubsystem::IsUserConsentRequired() const +{ + UE_LOG(LogSentrySdk, Log, TEXT("IsUserConsentRequired is not supported on Android.")); + return false; +} + TSharedPtr FAndroidSentrySubsystem::StartTransaction(const FString& name, const FString& operation, bool bindToScope) { TSharedPtr transactionOptionsAndroid = MakeShareable(new FAndroidSentryTransactionOptions()); diff --git a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h index 39d70f755..ca9c3f037 100644 --- a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h @@ -38,6 +38,7 @@ class FAndroidSentrySubsystem : public ISentrySubsystem virtual void GiveUserConsent() override; virtual void RevokeUserConsent() override; virtual EUserConsent GetUserConsent() const override; + virtual bool IsUserConsentRequired() const override; virtual TSharedPtr StartTransaction(const FString& name, const FString& operation, bool bindToScope) override; virtual TSharedPtr StartTransactionWithContext(TSharedPtr context, bool bindToScope) override; virtual TSharedPtr StartTransactionWithContextAndTimestamp(TSharedPtr context, int64 timestamp, bool bindToScope) override; diff --git a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp index 1cabebd1f..9cab5a5be 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp @@ -415,6 +415,12 @@ EUserConsent FAppleSentrySubsystem::GetUserConsent() const return EUserConsent::Unknown; } +bool FAppleSentrySubsystem::IsUserConsentRequired() const +{ + UE_LOG(LogSentrySdk, Log, TEXT("IsUserConsentRequired is not supported on Mac/iOS. Returning default `false` value.")); + return false; +} + TSharedPtr FAppleSentrySubsystem::StartTransaction(const FString& name, const FString& operation, bool bindToScope) { id transaction = [SENTRY_APPLE_CLASS(SentrySDK) startTransactionWithName:name.GetNSString() operation:operation.GetNSString() bindToScope:bindToScope]; diff --git a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h index 502d6a915..f44f4e95c 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h @@ -35,6 +35,7 @@ class FAppleSentrySubsystem : public ISentrySubsystem virtual void GiveUserConsent() override; virtual void RevokeUserConsent() override; virtual EUserConsent GetUserConsent() const override; + virtual bool IsUserConsentRequired() const override; virtual TSharedPtr StartTransaction(const FString& name, const FString& operation, bool bindToScope) override; virtual TSharedPtr StartTransactionWithContext(TSharedPtr context, bool bindToScope) override; virtual TSharedPtr StartTransactionWithContextAndTimestamp(TSharedPtr context, int64 timestamp, bool bindToScope) override; @@ -54,7 +55,9 @@ class FAppleSentrySubsystem : public ISentrySubsystem virtual FString GetScreenshotPath() const; virtual FString GetLatestScreenshot() const; virtual FString GetGameLogPath() const { return FString(); }; - virtual FString GetLatestGameLog() const { return FString(); }; + virtual FString GetLatestGameLog() const { return FString(); } + +protected:; protected: bool isScreenshotAttachmentEnabled = false; diff --git a/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h b/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h index 543e261a7..147443e13 100644 --- a/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h +++ b/plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h @@ -60,7 +60,7 @@ class ISentrySubsystem virtual void GiveUserConsent() = 0; virtual void RevokeUserConsent() = 0; virtual EUserConsent GetUserConsent() const = 0; - virtual bool IsUserConsentRequired() const { return false; } + virtual bool IsUserConsentRequired() const = 0; virtual TSharedPtr StartTransaction(const FString& name, const FString& operation, bool bindToScope) = 0; virtual TSharedPtr StartTransactionWithContext(TSharedPtr context, bool bindToScope) = 0; virtual TSharedPtr StartTransactionWithContextAndTimestamp(TSharedPtr context, int64 timestamp, bool bindToScope) = 0; From e08c5c6cde602ce44226e60a42d876f3bb7fee39 Mon Sep 17 00:00:00 2001 From: Sentry Github Bot Date: Mon, 17 Nov 2025 13:35:21 +0000 Subject: [PATCH 6/8] Format code --- plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h index f44f4e95c..d162685f8 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h @@ -57,7 +57,8 @@ class FAppleSentrySubsystem : public ISentrySubsystem virtual FString GetGameLogPath() const { return FString(); }; virtual FString GetLatestGameLog() const { return FString(); } -protected:; +protected: + ; protected: bool isScreenshotAttachmentEnabled = false; From 15261fd967d28f15345c45a41ffe0ff6d5e3ad69 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Mon, 17 Nov 2025 15:40:07 +0200 Subject: [PATCH 7/8] Fix typo --- plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h index d162685f8..37d4115ee 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h @@ -57,9 +57,6 @@ class FAppleSentrySubsystem : public ISentrySubsystem virtual FString GetGameLogPath() const { return FString(); }; virtual FString GetLatestGameLog() const { return FString(); } -protected: - ; - protected: bool isScreenshotAttachmentEnabled = false; bool isGameLogAttachmentEnabled = false; From 09729b5aba904f97c8c66c74c54d309e92bb39a5 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Mon, 17 Nov 2025 15:44:11 +0200 Subject: [PATCH 8/8] Log message --- .../Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp index 8445e3408..55d935b86 100644 --- a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp @@ -378,7 +378,7 @@ EUserConsent FAndroidSentrySubsystem::GetUserConsent() const bool FAndroidSentrySubsystem::IsUserConsentRequired() const { - UE_LOG(LogSentrySdk, Log, TEXT("IsUserConsentRequired is not supported on Android.")); + UE_LOG(LogSentrySdk, Log, TEXT("IsUserConsentRequired is not supported on Android. Returning default `false` value.")); return false; }