Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Features

- Add runtime API to query user consent requirement ([#1139](https://github.com/getsentry/sentry-unreal/pull/1139))

### Fixes

- No more warnings in UE 5.7 caused by deprecated API usage ([#1152](https://github.com/getsentry/sentry-unreal/pull/1152))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ISentryTransaction> FAndroidSentrySubsystem::StartTransaction(const FString& name, const FString& operation, bool bindToScope)
{
TSharedPtr<FAndroidSentryTransactionOptions> transactionOptionsAndroid = MakeShareable(new FAndroidSentryTransactionOptions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ISentryTransaction> StartTransaction(const FString& name, const FString& operation, bool bindToScope) override;
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContext(TSharedPtr<ISentryTransactionContext> context, bool bindToScope) override;
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContextAndTimestamp(TSharedPtr<ISentryTransactionContext> context, int64 timestamp, bool bindToScope) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ISentryTransaction> FAppleSentrySubsystem::StartTransaction(const FString& name, const FString& operation, bool bindToScope)
{
id<SentrySpan> transaction = [SENTRY_APPLE_CLASS(SentrySDK) startTransactionWithName:name.GetNSString() operation:operation.GetNSString() bindToScope:bindToScope];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ISentryTransaction> StartTransaction(const FString& name, const FString& operation, bool bindToScope) override;
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContext(TSharedPtr<ISentryTransactionContext> context, bool bindToScope) override;
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContextAndTimestamp(TSharedPtr<ISentryTransactionContext> context, int64 timestamp, bool bindToScope) override;
Expand All @@ -54,7 +55,10 @@ 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,11 @@ EUserConsent FGenericPlatformSentrySubsystem::GetUserConsent() const
}
}

bool FGenericPlatformSentrySubsystem::IsUserConsentRequired() const
{
return sentry_user_consent_is_required() == 1;
}

TSharedPtr<ISentryTransaction> FGenericPlatformSentrySubsystem::StartTransaction(const FString& name, const FString& operation, bool bindToScope)
{
TSharedPtr<ISentryTransactionContext> transactionContext = MakeShareable(new FGenericPlatformSentryTransactionContext(name, operation));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ISentryTransaction> StartTransaction(const FString& name, const FString& operation, bool bindToScope) override;
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContext(TSharedPtr<ISentryTransactionContext> context, bool bindToScope) override;
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContextAndTimestamp(TSharedPtr<ISentryTransactionContext> context, int64 timestamp, bool bindToScope) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class ISentrySubsystem
virtual void GiveUserConsent() = 0;
virtual void RevokeUserConsent() = 0;
virtual EUserConsent GetUserConsent() const = 0;
virtual bool IsUserConsentRequired() const = 0;
virtual TSharedPtr<ISentryTransaction> StartTransaction(const FString& name, const FString& operation, bool bindToScope) = 0;
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContext(TSharedPtr<ISentryTransactionContext> context, bool bindToScope) = 0;
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContextAndTimestamp(TSharedPtr<ISentryTransactionContext> context, int64 timestamp, bool bindToScope) = 0;
Expand Down
12 changes: 12 additions & 0 deletions plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,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);
Expand Down
10 changes: 10 additions & 0 deletions plugin-dev/Source/Sentry/Public/SentrySubsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down