diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f59bdc14..95f5c3035 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Features + +- Add runtime API to query user consent requirement ([#1139](https://github.com/getsentry/sentry-unreal/pull/1139)) + ### 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..3c4776f49 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. *