Skip to content

Commit cac1345

Browse files
tustanivskynwhite-riotgetsentry-bot
authored
Fix compatibility issues with Cocoa SDK 9.0.0 (#1149)
* Remove InAppExclude option as it's no longer supported by Cocoa SDK * Logs no longer experimental * Rename logs enum * Update changelog * Expose user consent API (#1139) * Expose user consent API * Format code * Add PR * Fix method name * Add `IsUserConsentRequired` implementation stubs for Android and Apple * Format code * Fix typo * Log message --------- Co-authored-by: Sentry Github Bot <[email protected]> Co-authored-by: Ivan Tustanivskyi <[email protected]> * Fix envelope header init --------- Co-authored-by: nwhite-riot <[email protected]> Co-authored-by: Sentry Github Bot <[email protected]>
1 parent a5cbb54 commit cac1345

14 files changed

+71
-27
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
## Unreleased
44

5+
### Features
6+
7+
- Add runtime API to query user consent requirement ([#1139](https://github.com/getsentry/sentry-unreal/pull/1139))
8+
59
### Fixes
610

711
- No more warnings in UE 5.7 caused by deprecated API usage ([#1152](https://github.com/getsentry/sentry-unreal/pull/1152))
812
- Custom tags are now correctly included in Android NDK crash events ([#1160](https://github.com/getsentry/sentry-unreal/pull/1160))
13+
- Fix compatibility issues with Cocoa SDK 9.0.0 ([#1149](https://github.com/getsentry/sentry-unreal/pull/1149))
914

1015
### Dependencies
1116

plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,12 @@ EUserConsent FAndroidSentrySubsystem::GetUserConsent() const
376376
return EUserConsent::Unknown;
377377
}
378378

379+
bool FAndroidSentrySubsystem::IsUserConsentRequired() const
380+
{
381+
UE_LOG(LogSentrySdk, Log, TEXT("IsUserConsentRequired is not supported on Android. Returning default `false` value."));
382+
return false;
383+
}
384+
379385
TSharedPtr<ISentryTransaction> FAndroidSentrySubsystem::StartTransaction(const FString& name, const FString& operation, bool bindToScope)
380386
{
381387
TSharedPtr<FAndroidSentryTransactionOptions> transactionOptionsAndroid = MakeShareable(new FAndroidSentryTransactionOptions());

plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class FAndroidSentrySubsystem : public ISentrySubsystem
3838
virtual void GiveUserConsent() override;
3939
virtual void RevokeUserConsent() override;
4040
virtual EUserConsent GetUserConsent() const override;
41+
virtual bool IsUserConsentRequired() const override;
4142
virtual TSharedPtr<ISentryTransaction> StartTransaction(const FString& name, const FString& operation, bool bindToScope) override;
4243
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContext(TSharedPtr<ISentryTransactionContext> context, bool bindToScope) override;
4344
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContextAndTimestamp(TSharedPtr<ISentryTransactionContext> context, int64 timestamp, bool bindToScope) override;

plugin-dev/Source/Sentry/Private/Apple/AppleSentryLog.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ FAppleSentryLog::FAppleSentryLog()
1515
LogApple.traceId = [[SENTRY_APPLE_CLASS(SentryId) alloc] init];
1616
LogApple.body = @"";
1717
LogApple.attributes = @{};
18-
LogApple.level = SentryStructuredLogLevelDebug;
18+
LogApple.level = SentryLogLevelDebug;
1919
}
2020

2121
FAppleSentryLog::FAppleSentryLog(SentryLog* log)
@@ -56,10 +56,10 @@ FString FAppleSentryLog::GetBody() const
5656

5757
void FAppleSentryLog::SetLevel(ESentryLevel level)
5858
{
59-
LogApple.level = FAppleSentryConverters::SentryStructuredLogLevelToNative(level);
59+
LogApple.level = FAppleSentryConverters::SentryLogLevelToNative(level);
6060
}
6161

6262
ESentryLevel FAppleSentryLog::GetLevel() const
6363
{
64-
return FAppleSentryConverters::SentryStructuredLogLevelToUnreal(LogApple.level);
64+
return FAppleSentryConverters::SentryLogLevelToUnreal(LogApple.level);
6565
}

plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void FAppleSentrySubsystem::InitWithSettings(const USentrySettings* settings, US
6464
options.maxBreadcrumbs = settings->MaxBreadcrumbs;
6565
options.sendDefaultPii = settings->SendDefaultPii;
6666
options.maxAttachmentSize = settings->MaxAttachmentSize;
67-
options.experimental.enableLogs = settings->EnableStructuredLogging;
67+
options.enableLogs = settings->EnableStructuredLogging;
6868
#if SENTRY_UIKIT_AVAILABLE
6969
options.attachScreenshot = settings->AttachScreenshot;
7070
#endif
@@ -86,10 +86,6 @@ void FAppleSentrySubsystem::InitWithSettings(const USentrySettings* settings, US
8686
{
8787
[options addInAppInclude:it->GetNSString()];
8888
}
89-
for (auto it = settings->InAppExclude.CreateConstIterator(); it; ++it)
90-
{
91-
[options addInAppExclude:it->GetNSString()];
92-
}
9389
options.enableAppHangTracking = settings->EnableAppNotRespondingTracking;
9490
if (settings->EnableTracing && settings->SamplingType == ESentryTracesSamplingType::UniformSampleRate)
9591
{
@@ -415,6 +411,12 @@ EUserConsent FAppleSentrySubsystem::GetUserConsent() const
415411
return EUserConsent::Unknown;
416412
}
417413

414+
bool FAppleSentrySubsystem::IsUserConsentRequired() const
415+
{
416+
UE_LOG(LogSentrySdk, Log, TEXT("IsUserConsentRequired is not supported on Mac/iOS. Returning default `false` value."));
417+
return false;
418+
}
419+
418420
TSharedPtr<ISentryTransaction> FAppleSentrySubsystem::StartTransaction(const FString& name, const FString& operation, bool bindToScope)
419421
{
420422
id<SentrySpan> transaction = [SENTRY_APPLE_CLASS(SentrySDK) startTransactionWithName:name.GetNSString() operation:operation.GetNSString() bindToScope:bindToScope];
@@ -499,7 +501,7 @@ void FAppleSentrySubsystem::UploadAttachmentForEvent(TSharedPtr<ISentryId> event
499501

500502
SentryId* id = StaticCastSharedPtr<FAppleSentryId>(eventId)->GetNativeObject();
501503

502-
SentryEnvelopeHeader* envelopeHeader = [[SENTRY_APPLE_CLASS(SentryEnvelopeHeader) alloc] initWithId:id sdkInfo:nil traceContext:nil];
504+
SentryEnvelopeHeader* envelopeHeader = [[SENTRY_APPLE_CLASS(SentryEnvelopeHeader) alloc] initWithId:id traceContext:nil];
503505

504506
SentryEnvelope* envelope = [[SENTRY_APPLE_CLASS(SentryEnvelope) alloc] initWithHeader:envelopeHeader singleItem:envelopeItem];
505507

plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class FAppleSentrySubsystem : public ISentrySubsystem
3535
virtual void GiveUserConsent() override;
3636
virtual void RevokeUserConsent() override;
3737
virtual EUserConsent GetUserConsent() const override;
38+
virtual bool IsUserConsentRequired() const override;
3839
virtual TSharedPtr<ISentryTransaction> StartTransaction(const FString& name, const FString& operation, bool bindToScope) override;
3940
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContext(TSharedPtr<ISentryTransactionContext> context, bool bindToScope) override;
4041
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContextAndTimestamp(TSharedPtr<ISentryTransactionContext> context, int64 timestamp, bool bindToScope) override;
@@ -54,7 +55,7 @@ class FAppleSentrySubsystem : public ISentrySubsystem
5455
virtual FString GetScreenshotPath() const;
5556
virtual FString GetLatestScreenshot() const;
5657
virtual FString GetGameLogPath() const { return FString(); };
57-
virtual FString GetLatestGameLog() const { return FString(); };
58+
virtual FString GetLatestGameLog() const { return FString(); }
5859

5960
protected:
6061
bool isScreenshotAttachmentEnabled = false;

plugin-dev/Source/Sentry/Private/Apple/Infrastructure/AppleSentryConverters.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,26 @@ SentryLevel FAppleSentryConverters::SentryLevelToNative(ESentryLevel level)
3535
return nativeLevel;
3636
}
3737

38-
SentryStructuredLogLevel FAppleSentryConverters::SentryStructuredLogLevelToNative(ESentryLevel level)
38+
SentryLogLevel FAppleSentryConverters::SentryLogLevelToNative(ESentryLevel level)
3939
{
40-
SentryStructuredLogLevel nativeLevel = SentryStructuredLogLevelDebug;
40+
SentryLogLevel nativeLevel = SentryLogLevelDebug;
4141

4242
switch (level)
4343
{
4444
case ESentryLevel::Debug:
45-
nativeLevel = SentryStructuredLogLevelDebug;
45+
nativeLevel = SentryLogLevelDebug;
4646
break;
4747
case ESentryLevel::Info:
48-
nativeLevel = SentryStructuredLogLevelInfo;
48+
nativeLevel = SentryLogLevelInfo;
4949
break;
5050
case ESentryLevel::Warning:
51-
nativeLevel = SentryStructuredLogLevelWarn;
51+
nativeLevel = SentryLogLevelWarn;
5252
break;
5353
case ESentryLevel::Error:
54-
nativeLevel = SentryStructuredLogLevelError;
54+
nativeLevel = SentryLogLevelError;
5555
break;
5656
case ESentryLevel::Fatal:
57-
nativeLevel = SentryStructuredLogLevelFatal;
57+
nativeLevel = SentryLogLevelFatal;
5858
break;
5959
default:
6060
UE_LOG(LogSentrySdk, Warning, TEXT("Unknown Sentry level value used. Debug will be returned."));
@@ -183,26 +183,26 @@ ESentryLevel FAppleSentryConverters::SentryLevelToUnreal(SentryLevel level)
183183
return unrealLevel;
184184
}
185185

186-
ESentryLevel FAppleSentryConverters::SentryStructuredLogLevelToUnreal(SentryStructuredLogLevel level)
186+
ESentryLevel FAppleSentryConverters::SentryLogLevelToUnreal(SentryLogLevel level)
187187
{
188188
ESentryLevel unrealLevel = ESentryLevel::Debug;
189189

190190
switch (level)
191191
{
192-
case SentryStructuredLogLevelTrace:
193-
case SentryStructuredLogLevelDebug:
192+
case SentryLogLevelTrace:
193+
case SentryLogLevelDebug:
194194
unrealLevel = ESentryLevel::Debug;
195195
break;
196-
case SentryStructuredLogLevelInfo:
196+
case SentryLogLevelInfo:
197197
unrealLevel = ESentryLevel::Info;
198198
break;
199-
case SentryStructuredLogLevelWarn:
199+
case SentryLogLevelWarn:
200200
unrealLevel = ESentryLevel::Warning;
201201
break;
202-
case SentryStructuredLogLevelError:
202+
case SentryLogLevelError:
203203
unrealLevel = ESentryLevel::Error;
204204
break;
205-
case SentryStructuredLogLevelFatal:
205+
case SentryLogLevelFatal:
206206
unrealLevel = ESentryLevel::Fatal;
207207
break;
208208
default:

plugin-dev/Source/Sentry/Private/Apple/Infrastructure/AppleSentryConverters.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class FAppleSentryConverters
1616
public:
1717
/** Conversions to native Mac/iOS types */
1818
static SentryLevel SentryLevelToNative(ESentryLevel level);
19-
static SentryStructuredLogLevel SentryStructuredLogLevelToNative(ESentryLevel level);
19+
static SentryLogLevel SentryLogLevelToNative(ESentryLevel level);
2020
static NSDictionary* StringMapToNative(const TMap<FString, FString>& map);
2121
static NSArray* StringArrayToNative(const TArray<FString>& array);
2222
static NSData* ByteDataToNative(const TArray<uint8>& array);
@@ -27,7 +27,7 @@ class FAppleSentryConverters
2727

2828
/** Conversions from native Mac/iOS types */
2929
static ESentryLevel SentryLevelToUnreal(SentryLevel level);
30-
static ESentryLevel SentryStructuredLogLevelToUnreal(SentryStructuredLogLevel level);
30+
static ESentryLevel SentryLogLevelToUnreal(SentryLogLevel level);
3131
static TMap<FString, FString> StringMapToUnreal(NSDictionary* dict);
3232
static TArray<FString> StringArrayToUnreal(NSArray* array);
3333
static TArray<uint8> ByteDataToUnreal(NSData* data);

plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,11 @@ EUserConsent FGenericPlatformSentrySubsystem::GetUserConsent() const
749749
}
750750
}
751751

752+
bool FGenericPlatformSentrySubsystem::IsUserConsentRequired() const
753+
{
754+
return sentry_user_consent_is_required() == 1;
755+
}
756+
752757
TSharedPtr<ISentryTransaction> FGenericPlatformSentrySubsystem::StartTransaction(const FString& name, const FString& operation, bool bindToScope)
753758
{
754759
TSharedPtr<ISentryTransactionContext> transactionContext = MakeShareable(new FGenericPlatformSentryTransactionContext(name, operation));

plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class FGenericPlatformSentrySubsystem : public ISentrySubsystem
4747
virtual void GiveUserConsent() override;
4848
virtual void RevokeUserConsent() override;
4949
virtual EUserConsent GetUserConsent() const override;
50+
virtual bool IsUserConsentRequired() const override;
5051
virtual TSharedPtr<ISentryTransaction> StartTransaction(const FString& name, const FString& operation, bool bindToScope) override;
5152
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContext(TSharedPtr<ISentryTransactionContext> context, bool bindToScope) override;
5253
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContextAndTimestamp(TSharedPtr<ISentryTransactionContext> context, int64 timestamp, bool bindToScope) override;

0 commit comments

Comments
 (0)