diff --git a/CHANGELOG.md b/CHANGELOG.md index 03ed32085..44b5edd19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,15 @@ ## 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)) - Custom tags are now correctly included in Android NDK crash events ([#1160](https://github.com/getsentry/sentry-unreal/pull/1160)) +- Fix compatibility issues with Cocoa SDK 9.0.0 ([#1149](https://github.com/getsentry/sentry-unreal/pull/1149)) ### Dependencies diff --git a/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp index 144cb2b5e..55d935b86 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. Returning default `false` value.")); + 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/AppleSentryLog.cpp b/plugin-dev/Source/Sentry/Private/Apple/AppleSentryLog.cpp index a68d7c6fc..bcb2f1069 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/AppleSentryLog.cpp +++ b/plugin-dev/Source/Sentry/Private/Apple/AppleSentryLog.cpp @@ -15,7 +15,7 @@ FAppleSentryLog::FAppleSentryLog() LogApple.traceId = [[SENTRY_APPLE_CLASS(SentryId) alloc] init]; LogApple.body = @""; LogApple.attributes = @{}; - LogApple.level = SentryStructuredLogLevelDebug; + LogApple.level = SentryLogLevelDebug; } FAppleSentryLog::FAppleSentryLog(SentryLog* log) @@ -56,10 +56,10 @@ FString FAppleSentryLog::GetBody() const void FAppleSentryLog::SetLevel(ESentryLevel level) { - LogApple.level = FAppleSentryConverters::SentryStructuredLogLevelToNative(level); + LogApple.level = FAppleSentryConverters::SentryLogLevelToNative(level); } ESentryLevel FAppleSentryLog::GetLevel() const { - return FAppleSentryConverters::SentryStructuredLogLevelToUnreal(LogApple.level); + return FAppleSentryConverters::SentryLogLevelToUnreal(LogApple.level); } \ 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 1cabebd1f..5d3d6ec54 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp @@ -64,7 +64,7 @@ void FAppleSentrySubsystem::InitWithSettings(const USentrySettings* settings, US options.maxBreadcrumbs = settings->MaxBreadcrumbs; options.sendDefaultPii = settings->SendDefaultPii; options.maxAttachmentSize = settings->MaxAttachmentSize; - options.experimental.enableLogs = settings->EnableStructuredLogging; + options.enableLogs = settings->EnableStructuredLogging; #if SENTRY_UIKIT_AVAILABLE options.attachScreenshot = settings->AttachScreenshot; #endif @@ -86,10 +86,6 @@ void FAppleSentrySubsystem::InitWithSettings(const USentrySettings* settings, US { [options addInAppInclude:it->GetNSString()]; } - for (auto it = settings->InAppExclude.CreateConstIterator(); it; ++it) - { - [options addInAppExclude:it->GetNSString()]; - } options.enableAppHangTracking = settings->EnableAppNotRespondingTracking; if (settings->EnableTracing && settings->SamplingType == ESentryTracesSamplingType::UniformSampleRate) { @@ -415,6 +411,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]; @@ -499,7 +501,7 @@ void FAppleSentrySubsystem::UploadAttachmentForEvent(TSharedPtr event SentryId* id = StaticCastSharedPtr(eventId)->GetNativeObject(); - SentryEnvelopeHeader* envelopeHeader = [[SENTRY_APPLE_CLASS(SentryEnvelopeHeader) alloc] initWithId:id sdkInfo:nil traceContext:nil]; + SentryEnvelopeHeader* envelopeHeader = [[SENTRY_APPLE_CLASS(SentryEnvelopeHeader) alloc] initWithId:id traceContext:nil]; SentryEnvelope* envelope = [[SENTRY_APPLE_CLASS(SentryEnvelope) alloc] initWithHeader:envelopeHeader singleItem:envelopeItem]; diff --git a/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h b/plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h index 502d6a915..37d4115ee 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,7 @@ 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: bool isScreenshotAttachmentEnabled = false; diff --git a/plugin-dev/Source/Sentry/Private/Apple/Infrastructure/AppleSentryConverters.cpp b/plugin-dev/Source/Sentry/Private/Apple/Infrastructure/AppleSentryConverters.cpp index b8a32d527..17f2f42ed 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/Infrastructure/AppleSentryConverters.cpp +++ b/plugin-dev/Source/Sentry/Private/Apple/Infrastructure/AppleSentryConverters.cpp @@ -35,26 +35,26 @@ SentryLevel FAppleSentryConverters::SentryLevelToNative(ESentryLevel level) return nativeLevel; } -SentryStructuredLogLevel FAppleSentryConverters::SentryStructuredLogLevelToNative(ESentryLevel level) +SentryLogLevel FAppleSentryConverters::SentryLogLevelToNative(ESentryLevel level) { - SentryStructuredLogLevel nativeLevel = SentryStructuredLogLevelDebug; + SentryLogLevel nativeLevel = SentryLogLevelDebug; switch (level) { case ESentryLevel::Debug: - nativeLevel = SentryStructuredLogLevelDebug; + nativeLevel = SentryLogLevelDebug; break; case ESentryLevel::Info: - nativeLevel = SentryStructuredLogLevelInfo; + nativeLevel = SentryLogLevelInfo; break; case ESentryLevel::Warning: - nativeLevel = SentryStructuredLogLevelWarn; + nativeLevel = SentryLogLevelWarn; break; case ESentryLevel::Error: - nativeLevel = SentryStructuredLogLevelError; + nativeLevel = SentryLogLevelError; break; case ESentryLevel::Fatal: - nativeLevel = SentryStructuredLogLevelFatal; + nativeLevel = SentryLogLevelFatal; break; default: UE_LOG(LogSentrySdk, Warning, TEXT("Unknown Sentry level value used. Debug will be returned.")); @@ -183,26 +183,26 @@ ESentryLevel FAppleSentryConverters::SentryLevelToUnreal(SentryLevel level) return unrealLevel; } -ESentryLevel FAppleSentryConverters::SentryStructuredLogLevelToUnreal(SentryStructuredLogLevel level) +ESentryLevel FAppleSentryConverters::SentryLogLevelToUnreal(SentryLogLevel level) { ESentryLevel unrealLevel = ESentryLevel::Debug; switch (level) { - case SentryStructuredLogLevelTrace: - case SentryStructuredLogLevelDebug: + case SentryLogLevelTrace: + case SentryLogLevelDebug: unrealLevel = ESentryLevel::Debug; break; - case SentryStructuredLogLevelInfo: + case SentryLogLevelInfo: unrealLevel = ESentryLevel::Info; break; - case SentryStructuredLogLevelWarn: + case SentryLogLevelWarn: unrealLevel = ESentryLevel::Warning; break; - case SentryStructuredLogLevelError: + case SentryLogLevelError: unrealLevel = ESentryLevel::Error; break; - case SentryStructuredLogLevelFatal: + case SentryLogLevelFatal: unrealLevel = ESentryLevel::Fatal; break; default: diff --git a/plugin-dev/Source/Sentry/Private/Apple/Infrastructure/AppleSentryConverters.h b/plugin-dev/Source/Sentry/Private/Apple/Infrastructure/AppleSentryConverters.h index 655dee14e..fdfccb030 100644 --- a/plugin-dev/Source/Sentry/Private/Apple/Infrastructure/AppleSentryConverters.h +++ b/plugin-dev/Source/Sentry/Private/Apple/Infrastructure/AppleSentryConverters.h @@ -16,7 +16,7 @@ class FAppleSentryConverters public: /** Conversions to native Mac/iOS types */ static SentryLevel SentryLevelToNative(ESentryLevel level); - static SentryStructuredLogLevel SentryStructuredLogLevelToNative(ESentryLevel level); + static SentryLogLevel SentryLogLevelToNative(ESentryLevel level); static NSDictionary* StringMapToNative(const TMap& map); static NSArray* StringArrayToNative(const TArray& array); static NSData* ByteDataToNative(const TArray& array); @@ -27,7 +27,7 @@ class FAppleSentryConverters /** Conversions from native Mac/iOS types */ static ESentryLevel SentryLevelToUnreal(SentryLevel level); - static ESentryLevel SentryStructuredLogLevelToUnreal(SentryStructuredLogLevel level); + static ESentryLevel SentryLogLevelToUnreal(SentryLogLevel level); static TMap StringMapToUnreal(NSDictionary* dict); static TArray StringArrayToUnreal(NSArray* array); static TArray ByteDataToUnreal(NSData* data); diff --git a/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp index 4efc57485..0d8a3ca79 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_is_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..147443e13 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 = 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; diff --git a/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp index 88a0b0169..697eb8358 100644 --- a/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp @@ -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); diff --git a/plugin-dev/Source/Sentry/Public/SentrySettings.h b/plugin-dev/Source/Sentry/Public/SentrySettings.h index e03328725..38675e077 100644 --- a/plugin-dev/Source/Sentry/Public/SentrySettings.h +++ b/plugin-dev/Source/Sentry/Public/SentrySettings.h @@ -339,7 +339,7 @@ class SENTRY_API USentrySettings : public UObject TArray InAppInclude; UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "General|Mobile", - Meta = (DisplayName = "In-app excludes (for Android/Apple only)", Tooltip = "A list of string prefixes of module names that don't belong to the app.")) + Meta = (DisplayName = "In-app excludes (for Android only)", Tooltip = "A list of string prefixes of module names that don't belong to the app.")) TArray InAppExclude; UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "General|Mobile", 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. *