Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
df159c9
Set local scope branch for sentry-native submodule
tustanivsky May 26, 2025
b9d7d94
Update changelog
tustanivsky May 26, 2025
0690dd4
Bump submodule
tustanivsky May 26, 2025
6434596
Bump submodule again
tustanivsky May 26, 2025
d914c5a
Add local scope implementation for desktop
tustanivsky May 27, 2025
40b0774
Fix lint errors
tustanivsky May 27, 2025
f2bb0ed
Fix
tustanivsky May 27, 2025
7a0f5dc
Include order
tustanivsky May 27, 2025
df4cbe2
Revert scope data caching on Unreal's side
tustanivsky May 27, 2025
507be99
Merge branch 'main' into feat/local-scope-desktop
tustanivsky May 28, 2025
74b0419
Fix lint errors
tustanivsky May 28, 2025
1fd94a6
Remove env and dist setters from scope class
tustanivsky May 28, 2025
79fc0bc
Merge branch 'feat/local-scope-desktop' of github.com:getsentry/sentr…
tustanivsky May 28, 2025
5eee756
Update changelog
tustanivsky May 28, 2025
556c3b4
Remove ConfigureScope function
tustanivsky May 29, 2025
7f9c65e
Update changelog
tustanivsky May 29, 2025
b418ebd
Remove redundant array size checks
tustanivsky May 29, 2025
e79bd84
Free memory after capturing event with local scope
tustanivsky May 30, 2025
15fc482
Bump submodule
tustanivsky Jun 4, 2025
269a4e2
Merge branch 'main' into feat/local-scope-desktop
tustanivsky Jun 4, 2025
946a510
Remove sentry_scope_free calls as this API was deleted in native
tustanivsky Jun 4, 2025
ddf3a09
Fix blueprint errors
tustanivsky Jun 4, 2025
68e25f6
Merge branch 'main' into feat/local-scope-desktop
tustanivsky Jun 6, 2025
d676b55
Update CHANGELOG.md
tustanivsky Jun 6, 2025
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## Unreleased

### Breaking Changes

- `Environment` and `Dist` get/set functions were removed from the `Scope` class and now these properties have to be set in plugin settings instead.
- `ConfigureScope` function was removed from `SentrySubsystem` class.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably ok without deprecating first because it hasn't reached 1.0.0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, given the scope of the changes in this PR it seems like an appropriate time to remove these APIs ahead of the major version bump.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summarizing the reason with a few words and perhaps linking to https://develop.sentry.dev/sdk/miscellaneous/hub_and_scope_refactoring/ could make the breaking change easier to accept for those who'll be affected 😉


### Features

- Add native local scope for Windows/Linux ([#928](https://github.com/getsentry/sentry-unreal/pull/928))

### Dependencies

- Bump Java SDK (Android) from v8.13.1 to v8.13.2 ([#932](https://github.com/getsentry/sentry-unreal/pull/932))
Expand Down
20 changes: 0 additions & 20 deletions plugin-dev/Source/Sentry/Private/Android/AndroidSentryScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,26 +99,6 @@ TMap<FString, FString> FAndroidSentryScope::GetTags() const
return FAndroidSentryConverters::StringMapToUnreal(*tags);
}

void FAndroidSentryScope::SetDist(const FString& dist)
{
SetTagValue("dist", dist);
}

FString FAndroidSentryScope::GetDist() const
{
return GetTagValue("dist");
}

void FAndroidSentryScope::SetEnvironment(const FString& environment)
{
SetTagValue("environment", environment);
}

FString FAndroidSentryScope::GetEnvironment() const
{
return GetTagValue("environment");
}

void FAndroidSentryScope::SetFingerprint(const TArray<FString>& fingerprint)
{
CallMethod<void>(SetFingerprintMethod, FAndroidSentryConverters::StringArrayToNative(fingerprint)->GetJObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ class FAndroidSentryScope : public ISentryScope, public FSentryJavaObjectWrapper
virtual void RemoveTag(const FString& key) override;
virtual void SetTags(const TMap<FString, FString>& tags) override;
virtual TMap<FString, FString> GetTags() const override;
virtual void SetDist(const FString& dist) override;
virtual FString GetDist() const override;
virtual void SetEnvironment(const FString& environment) override;
virtual FString GetEnvironment() const override;
virtual void SetFingerprint(const TArray<FString>& fingerprint) override;
virtual TArray<FString> GetFingerprint() const override;
virtual void SetLevel(ESentryLevel level) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void FAndroidSentrySubsystem::InitWithSettings(const USentrySettings* settings,
SettingsJson->SetStringField(TEXT("dsn"), settings->Dsn);
SettingsJson->SetStringField(TEXT("release"), settings->OverrideReleaseName ? settings->Release : settings->GetFormattedReleaseName());
SettingsJson->SetStringField(TEXT("environment"), settings->Environment);
SettingsJson->SetStringField(TEXT("dist"), settings->Dist);
SettingsJson->SetBoolField(TEXT("autoSessionTracking"), settings->EnableAutoSessionTracking);
SettingsJson->SetNumberField(TEXT("sessionTimeout"), settings->SessionTimeout);
SettingsJson->SetBoolField(TEXT("enableStackTrace"), settings->AttachStacktrace);
Expand Down Expand Up @@ -195,13 +196,6 @@ void FAndroidSentrySubsystem::RemoveUser()
FSentryJavaObjectWrapper::CallStaticMethod<void>(SentryJavaClasses::Sentry, "setUser", "(Lio/sentry/protocol/User;)V", nullptr);
}

void FAndroidSentrySubsystem::ConfigureScope(const FSentryScopeDelegate& onConfigureScope)
{
int64 scopeCallbackId = AndroidSentryScopeCallback::SaveDelegate(onConfigureScope);

FSentryJavaObjectWrapper::CallStaticMethod<void>(SentryJavaClasses::SentryBridgeJava, "configureScope", "(J)V", scopeCallbackId);
}

void FAndroidSentrySubsystem::SetContext(const FString& key, const TMap<FString, FString>& values)
{
FSentryJavaObjectWrapper::CallStaticMethod<void>(SentryJavaClasses::SentryBridgeJava, "setContext", "(Ljava/lang/String;Ljava/util/HashMap;)V",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class FAndroidSentrySubsystem : public ISentrySubsystem
virtual void CaptureUserFeedback(TSharedPtr<ISentryUserFeedback> userFeedback) override;
virtual void SetUser(TSharedPtr<ISentryUser> user) override;
virtual void RemoveUser() override;
virtual void ConfigureScope(const FSentryScopeDelegate& onConfigureScope) override;
virtual void SetContext(const FString& key, const TMap<FString, FString>& values) override;
virtual void SetTag(const FString& key, const FString& value) override;
virtual void RemoveTag(const FString& key) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void configure(SentryAndroidOptions options) {
options.setDsn(settingJson.getString("dsn"));
options.setRelease(settingJson.getString("release"));
options.setEnvironment(settingJson.getString("environment"));
options.setDist(settingJson.getString("dist"));
options.setEnableAutoSessionTracking(settingJson.getBoolean("autoSessionTracking"));
options.setSessionTrackingIntervalMillis(settingJson.getLong("sessionTimeout"));
options.setAttachStacktrace(settingJson.getBoolean("enableStackTrace"));
Expand Down Expand Up @@ -146,15 +147,6 @@ public static SentryId captureException(final String type, final String value) {
return eventId;
}

public static void configureScope(final long callback) {
Sentry.configureScope(new ScopeCallback() {
@Override
public void run(@NonNull IScope scope) {
onConfigureScope(callback, scope);
}
});
}

public static void setContext(final String key, final HashMap<String, String> values) {
Sentry.configureScope(new ScopeCallback() {
@Override
Expand Down
22 changes: 0 additions & 22 deletions plugin-dev/Source/Sentry/Private/Apple/AppleSentryScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,6 @@ TMap<FString, FString> FAppleSentryScope::GetTags() const
return FAppleSentryConverters::StringMapToUnreal(scopeDict[@"tags"]);
}

void FAppleSentryScope::SetDist(const FString& dist)
{
[ScopeApple setDist:dist.GetNSString()];
}

FString FAppleSentryScope::GetDist() const
{
NSDictionary* scopeDict = [ScopeApple serialize];
return FString(scopeDict[@"dist"]);
}

void FAppleSentryScope::SetEnvironment(const FString& environment)
{
[ScopeApple setEnvironment:environment.GetNSString()];
}

FString FAppleSentryScope::GetEnvironment() const
{
NSDictionary* scopeDict = [ScopeApple serialize];
return FString(scopeDict[@"environment"]);
}

void FAppleSentryScope::SetFingerprint(const TArray<FString>& fingerprint)
{
[ScopeApple setFingerprint:FAppleSentryConverters::StringArrayToNative(fingerprint)];
Expand Down
4 changes: 0 additions & 4 deletions plugin-dev/Source/Sentry/Private/Apple/AppleSentryScope.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ class FAppleSentryScope : public ISentryScope
virtual void RemoveTag(const FString& key) override;
virtual void SetTags(const TMap<FString, FString>& tags) override;
virtual TMap<FString, FString> GetTags() const override;
virtual void SetDist(const FString& dist) override;
virtual FString GetDist() const override;
virtual void SetEnvironment(const FString& environment) override;
virtual FString GetEnvironment() const override;
virtual void SetFingerprint(const TArray<FString>& fingerprint) override;
virtual TArray<FString> GetFingerprint() const override;
virtual void SetLevel(ESentryLevel level) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void FAppleSentrySubsystem::InitWithSettings(const USentrySettings* settings, US
}
#endif
options.environment = settings->Environment.GetNSString();
options.dist = settings->Dist.GetNSString();
options.enableAutoSessionTracking = settings->EnableAutoSessionTracking;
options.sessionTrackingIntervalMillis = settings->SessionTimeout;
options.releaseName = settings->OverrideReleaseName ? settings->Release.GetNSString() : settings->GetFormattedReleaseName().GetNSString();
Expand Down Expand Up @@ -288,13 +289,6 @@ void FAppleSentrySubsystem::RemoveUser()
[SentrySDK setUser:nil];
}

void FAppleSentrySubsystem::ConfigureScope(const FSentryScopeDelegate& onConfigureScope)
{
[SentrySDK configureScope:^(SentryScope* scope) {
onConfigureScope.ExecuteIfBound(MakeShareable(new FAppleSentryScope(scope)));
}];
}

void FAppleSentrySubsystem::SetContext(const FString& key, const TMap<FString, FString>& values)
{
[SentrySDK configureScope:^(SentryScope* scope) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class FAppleSentrySubsystem : public ISentrySubsystem
virtual void CaptureUserFeedback(TSharedPtr<ISentryUserFeedback> userFeedback) override;
virtual void SetUser(TSharedPtr<ISentryUser> user) override;
virtual void RemoveUser() override;
virtual void ConfigureScope(const FSentryScopeDelegate& onConfigureScope) override;
virtual void SetContext(const FString& key, const TMap<FString, FString>& values) override;
virtual void SetTag(const FString& key, const FString& value) override;
virtual void RemoveTag(const FString& key) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,12 @@ FGenericPlatformSentryScope::FGenericPlatformSentryScope()
{
}

FGenericPlatformSentryScope::FGenericPlatformSentryScope(const FGenericPlatformSentryScope& Scope)
{
Dist = Scope.Dist;
Environment = Scope.Environment;
Fingerprint = Scope.Fingerprint;
Tags = Scope.Tags;
Extra = Scope.Extra;
Contexts = Scope.Contexts;
Breadcrumbs = TRingBuffer<TSharedPtr<FGenericPlatformSentryBreadcrumb>>(Scope.Breadcrumbs);
Level = Scope.Level;
}

FGenericPlatformSentryScope::~FGenericPlatformSentryScope()
{
}

void FGenericPlatformSentryScope::AddBreadcrumb(TSharedPtr<ISentryBreadcrumb> breadcrumb)
{
FScopeLock Lock(&CriticalSection);

if (Breadcrumbs.Num() >= FSentryModule::Get().GetSettings()->MaxBreadcrumbs)
{
Breadcrumbs.PopFront();
Expand All @@ -48,8 +34,6 @@ void FGenericPlatformSentryScope::AddBreadcrumb(TSharedPtr<ISentryBreadcrumb> br

void FGenericPlatformSentryScope::ClearBreadcrumbs()
{
FScopeLock Lock(&CriticalSection);

Breadcrumbs.Empty();
}

Expand Down Expand Up @@ -91,26 +75,6 @@ TMap<FString, FString> FGenericPlatformSentryScope::GetTags() const
return Tags;
}

void FGenericPlatformSentryScope::SetDist(const FString& dist)
{
Dist = dist;
}

FString FGenericPlatformSentryScope::GetDist() const
{
return Dist;
}

void FGenericPlatformSentryScope::SetEnvironment(const FString& environment)
{
Environment = environment;
}

FString FGenericPlatformSentryScope::GetEnvironment() const
{
return Environment;
}

void FGenericPlatformSentryScope::SetFingerprint(const TArray<FString>& fingerprint)
{
Fingerprint = fingerprint;
Expand All @@ -128,7 +92,6 @@ void FGenericPlatformSentryScope::SetLevel(ESentryLevel level)

ESentryLevel FGenericPlatformSentryScope::GetLevel() const
{

return Level;
}

Expand Down Expand Up @@ -188,114 +151,36 @@ void FGenericPlatformSentryScope::Clear()
Level = ESentryLevel::Debug;
}

void FGenericPlatformSentryScope::Apply(TSharedPtr<FGenericPlatformSentryEvent> event)
void FGenericPlatformSentryScope::Apply(sentry_scope_t* scope)
{
sentry_value_t nativeEvent = event->GetNativeObject();

sentry_value_t eventLevel = sentry_value_get_by_key(nativeEvent, "level");

FString scopeLevelStr = FGenericPlatformSentryConverters::SentryLevelToString(Level).ToLower();
if (!scopeLevelStr.IsEmpty() && sentry_value_is_null(eventLevel))
for (const auto& Breadcrumb : Breadcrumbs)
{
sentry_value_set_by_key(nativeEvent, "level", sentry_value_new_string(TCHAR_TO_ANSI(*scopeLevelStr)));
}

if (!Dist.IsEmpty())
{
sentry_value_set_by_key(nativeEvent, "dist", sentry_value_new_string(TCHAR_TO_ANSI(*Dist)));
}

if (!Environment.IsEmpty())
{
sentry_value_set_by_key(nativeEvent, "environment", sentry_value_new_string(TCHAR_TO_ANSI(*Environment)));
sentry_value_t nativeBreadcrumb = Breadcrumb->GetNativeObject();
sentry_scope_add_breadcrumb(scope, nativeBreadcrumb);
}

if (Fingerprint.Num() > 0)
{
sentry_value_set_by_key(nativeEvent, "fingerprint", FGenericPlatformSentryConverters::StringArrayToNative(Fingerprint));
sentry_scope_set_fingerprints(scope, FGenericPlatformSentryConverters::StringArrayToNative(Fingerprint));
}

if (Tags.Num() > 0)
for (const auto& TagItem : Tags)
{
sentry_value_t tagsExtra = sentry_value_get_by_key(nativeEvent, "tags");
if (sentry_value_is_null(tagsExtra))
{
sentry_value_set_by_key(nativeEvent, "tags", FGenericPlatformSentryConverters::StringMapToNative(Tags));
}
else
{
for (const auto& TagItem : Tags)
{
sentry_value_set_by_key(tagsExtra, TCHAR_TO_ANSI(*TagItem.Key), sentry_value_new_string(TCHAR_TO_ANSI(*TagItem.Value)));
}
}
sentry_scope_set_tag(scope, TCHAR_TO_UTF8(*TagItem.Key), TCHAR_TO_UTF8(*TagItem.Value));
}

if (Extra.Num() > 0)
for (const auto& ExtraItem : Extra)
{
sentry_value_t eventExtra = sentry_value_get_by_key(nativeEvent, "extra");
if (sentry_value_is_null(eventExtra))
{
sentry_value_set_by_key(nativeEvent, "extra", FGenericPlatformSentryConverters::StringMapToNative(Extra));
}
else
{
for (const auto& ExtraItem : Extra)
{
sentry_value_set_by_key(eventExtra, TCHAR_TO_ANSI(*ExtraItem.Key), sentry_value_new_string(TCHAR_TO_ANSI(*ExtraItem.Value)));
}
}
sentry_scope_set_extra(scope, TCHAR_TO_UTF8(*ExtraItem.Key), sentry_value_new_string(TCHAR_TO_UTF8(*ExtraItem.Value)));
}

if (Contexts.Num() > 0)
for (const auto& ContextsItem : Contexts)
{
sentry_value_t eventContexts = sentry_value_get_by_key(nativeEvent, "contexts");
if (sentry_value_is_null(eventContexts))
{
eventContexts = sentry_value_new_object();

for (const auto& ContextsItem : Contexts)
{
sentry_value_set_by_key(eventContexts, TCHAR_TO_ANSI(*ContextsItem.Key), FGenericPlatformSentryConverters::StringMapToNative(ContextsItem.Value));
}

sentry_value_set_by_key(nativeEvent, "contexts", eventContexts);
}
else
{
for (const auto& ContextsItem : Contexts)
{
sentry_value_set_by_key(eventContexts, TCHAR_TO_ANSI(*ContextsItem.Key), FGenericPlatformSentryConverters::StringMapToNative(ContextsItem.Value));
}
}
sentry_scope_set_context(scope, TCHAR_TO_UTF8(*ContextsItem.Key), FGenericPlatformSentryConverters::StringMapToNative(ContextsItem.Value));
}

if (!Breadcrumbs.IsEmpty())
{
sentry_value_t eventBreadcrumbs = sentry_value_get_by_key(nativeEvent, "breadcrumbs");
if (sentry_value_is_null(eventBreadcrumbs))
{
eventBreadcrumbs = sentry_value_new_list();

for (const auto& Breadcrumb : Breadcrumbs)
{
sentry_value_t nativeBreadcrumb = Breadcrumb->GetNativeObject();
sentry_value_incref(nativeBreadcrumb);
sentry_value_append(eventBreadcrumbs, nativeBreadcrumb);
}

sentry_value_set_by_key(nativeEvent, "breadcrumbs", eventBreadcrumbs);
}
else
{
for (const auto& Breadcrumb : Breadcrumbs)
{
sentry_value_t nativeBreadcrumb = Breadcrumb->GetNativeObject();
sentry_value_incref(nativeBreadcrumb);
sentry_value_append(eventBreadcrumbs, nativeBreadcrumb);
}
}
}
sentry_scope_set_level(scope, FGenericPlatformSentryConverters::SentryLevelToNative(Level));
}

#endif
Loading
Loading