Skip to content

Commit efd668c

Browse files
authored
Add native local scope for Windows/Linux (#928)
* Set local scope branch for sentry-native submodule * Update changelog * Bump submodule * Bump submodule again * Add local scope implementation for desktop * Fix lint errors * Fix * Include order * Revert scope data caching on Unreal's side * Fix lint errors * Remove env and dist setters from scope class * Update changelog * Remove ConfigureScope function * Update changelog * Remove redundant array size checks * Free memory after capturing event with local scope * Bump submodule * Remove sentry_scope_free calls as this API was deleted in native * Fix blueprint errors * Update CHANGELOG.md
1 parent f1b662e commit efd668c

28 files changed

+148
-408
lines changed

CHANGELOG.md

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

33
## Unreleased
44

5+
### Breaking Changes
6+
7+
- `Environment` and `Dist` get/set functions were removed from the `Scope` class and now these properties have to be set in plugin settings instead. This unifies their usage across all platforms supported by the Unreal SDK.
8+
- `ConfigureScope` function was removed from `SentrySubsystem` class following the [Hub & Scope refactoring guidelines](https://develop.sentry.dev/sdk/miscellaneous/hub_and_scope_refactoring/) which recommend deprecating this API.
9+
10+
### Features
11+
12+
- Add native local scope for Windows/Linux ([#928](https://github.com/getsentry/sentry-unreal/pull/928))
13+
514
### Dependencies
615

716
- Bump Java SDK (Android) from v8.13.1 to v8.13.2 ([#932](https://github.com/getsentry/sentry-unreal/pull/932))

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,26 +99,6 @@ TMap<FString, FString> FAndroidSentryScope::GetTags() const
9999
return FAndroidSentryConverters::StringMapToUnreal(*tags);
100100
}
101101

102-
void FAndroidSentryScope::SetDist(const FString& dist)
103-
{
104-
SetTagValue("dist", dist);
105-
}
106-
107-
FString FAndroidSentryScope::GetDist() const
108-
{
109-
return GetTagValue("dist");
110-
}
111-
112-
void FAndroidSentryScope::SetEnvironment(const FString& environment)
113-
{
114-
SetTagValue("environment", environment);
115-
}
116-
117-
FString FAndroidSentryScope::GetEnvironment() const
118-
{
119-
return GetTagValue("environment");
120-
}
121-
122102
void FAndroidSentryScope::SetFingerprint(const TArray<FString>& fingerprint)
123103
{
124104
CallMethod<void>(SetFingerprintMethod, FAndroidSentryConverters::StringArrayToNative(fingerprint)->GetJObject());

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ class FAndroidSentryScope : public ISentryScope, public FSentryJavaObjectWrapper
2323
virtual void RemoveTag(const FString& key) override;
2424
virtual void SetTags(const TMap<FString, FString>& tags) override;
2525
virtual TMap<FString, FString> GetTags() const override;
26-
virtual void SetDist(const FString& dist) override;
27-
virtual FString GetDist() const override;
28-
virtual void SetEnvironment(const FString& environment) override;
29-
virtual FString GetEnvironment() const override;
3026
virtual void SetFingerprint(const TArray<FString>& fingerprint) override;
3127
virtual TArray<FString> GetFingerprint() const override;
3228
virtual void SetLevel(ESentryLevel level) override;

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ void FAndroidSentrySubsystem::InitWithSettings(const USentrySettings* settings,
3333
SettingsJson->SetStringField(TEXT("dsn"), settings->Dsn);
3434
SettingsJson->SetStringField(TEXT("release"), settings->OverrideReleaseName ? settings->Release : settings->GetFormattedReleaseName());
3535
SettingsJson->SetStringField(TEXT("environment"), settings->Environment);
36+
SettingsJson->SetStringField(TEXT("dist"), settings->Dist);
3637
SettingsJson->SetBoolField(TEXT("autoSessionTracking"), settings->EnableAutoSessionTracking);
3738
SettingsJson->SetNumberField(TEXT("sessionTimeout"), settings->SessionTimeout);
3839
SettingsJson->SetBoolField(TEXT("enableStackTrace"), settings->AttachStacktrace);
@@ -195,13 +196,6 @@ void FAndroidSentrySubsystem::RemoveUser()
195196
FSentryJavaObjectWrapper::CallStaticMethod<void>(SentryJavaClasses::Sentry, "setUser", "(Lio/sentry/protocol/User;)V", nullptr);
196197
}
197198

198-
void FAndroidSentrySubsystem::ConfigureScope(const FSentryScopeDelegate& onConfigureScope)
199-
{
200-
int64 scopeCallbackId = AndroidSentryScopeCallback::SaveDelegate(onConfigureScope);
201-
202-
FSentryJavaObjectWrapper::CallStaticMethod<void>(SentryJavaClasses::SentryBridgeJava, "configureScope", "(J)V", scopeCallbackId);
203-
}
204-
205199
void FAndroidSentrySubsystem::SetContext(const FString& key, const TMap<FString, FString>& values)
206200
{
207201
FSentryJavaObjectWrapper::CallStaticMethod<void>(SentryJavaClasses::SentryBridgeJava, "setContext", "(Ljava/lang/String;Ljava/util/HashMap;)V",

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class FAndroidSentrySubsystem : public ISentrySubsystem
2222
virtual void CaptureUserFeedback(TSharedPtr<ISentryUserFeedback> userFeedback) override;
2323
virtual void SetUser(TSharedPtr<ISentryUser> user) override;
2424
virtual void RemoveUser() override;
25-
virtual void ConfigureScope(const FSentryScopeDelegate& onConfigureScope) override;
2625
virtual void SetContext(const FString& key, const TMap<FString, FString>& values) override;
2726
virtual void SetTag(const FString& key, const FString& value) override;
2827
virtual void RemoveTag(const FString& key) override;

plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public void configure(SentryAndroidOptions options) {
4646
options.setDsn(settingJson.getString("dsn"));
4747
options.setRelease(settingJson.getString("release"));
4848
options.setEnvironment(settingJson.getString("environment"));
49+
options.setDist(settingJson.getString("dist"));
4950
options.setEnableAutoSessionTracking(settingJson.getBoolean("autoSessionTracking"));
5051
options.setSessionTrackingIntervalMillis(settingJson.getLong("sessionTimeout"));
5152
options.setAttachStacktrace(settingJson.getBoolean("enableStackTrace"));
@@ -146,15 +147,6 @@ public static SentryId captureException(final String type, final String value) {
146147
return eventId;
147148
}
148149

149-
public static void configureScope(final long callback) {
150-
Sentry.configureScope(new ScopeCallback() {
151-
@Override
152-
public void run(@NonNull IScope scope) {
153-
onConfigureScope(callback, scope);
154-
}
155-
});
156-
}
157-
158150
public static void setContext(final String key, final HashMap<String, String> values) {
159151
Sentry.configureScope(new ScopeCallback() {
160152
@Override

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,28 +81,6 @@ TMap<FString, FString> FAppleSentryScope::GetTags() const
8181
return FAppleSentryConverters::StringMapToUnreal(scopeDict[@"tags"]);
8282
}
8383

84-
void FAppleSentryScope::SetDist(const FString& dist)
85-
{
86-
[ScopeApple setDist:dist.GetNSString()];
87-
}
88-
89-
FString FAppleSentryScope::GetDist() const
90-
{
91-
NSDictionary* scopeDict = [ScopeApple serialize];
92-
return FString(scopeDict[@"dist"]);
93-
}
94-
95-
void FAppleSentryScope::SetEnvironment(const FString& environment)
96-
{
97-
[ScopeApple setEnvironment:environment.GetNSString()];
98-
}
99-
100-
FString FAppleSentryScope::GetEnvironment() const
101-
{
102-
NSDictionary* scopeDict = [ScopeApple serialize];
103-
return FString(scopeDict[@"environment"]);
104-
}
105-
10684
void FAppleSentryScope::SetFingerprint(const TArray<FString>& fingerprint)
10785
{
10886
[ScopeApple setFingerprint:FAppleSentryConverters::StringArrayToNative(fingerprint)];

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ class FAppleSentryScope : public ISentryScope
2424
virtual void RemoveTag(const FString& key) override;
2525
virtual void SetTags(const TMap<FString, FString>& tags) override;
2626
virtual TMap<FString, FString> GetTags() const override;
27-
virtual void SetDist(const FString& dist) override;
28-
virtual FString GetDist() const override;
29-
virtual void SetEnvironment(const FString& environment) override;
30-
virtual FString GetEnvironment() const override;
3127
virtual void SetFingerprint(const TArray<FString>& fingerprint) override;
3228
virtual TArray<FString> GetFingerprint() const override;
3329
virtual void SetLevel(ESentryLevel level) override;

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void FAppleSentrySubsystem::InitWithSettings(const USentrySettings* settings, US
5656
}
5757
#endif
5858
options.environment = settings->Environment.GetNSString();
59+
options.dist = settings->Dist.GetNSString();
5960
options.enableAutoSessionTracking = settings->EnableAutoSessionTracking;
6061
options.sessionTrackingIntervalMillis = settings->SessionTimeout;
6162
options.releaseName = settings->OverrideReleaseName ? settings->Release.GetNSString() : settings->GetFormattedReleaseName().GetNSString();
@@ -288,13 +289,6 @@ void FAppleSentrySubsystem::RemoveUser()
288289
[SentrySDK setUser:nil];
289290
}
290291

291-
void FAppleSentrySubsystem::ConfigureScope(const FSentryScopeDelegate& onConfigureScope)
292-
{
293-
[SentrySDK configureScope:^(SentryScope* scope) {
294-
onConfigureScope.ExecuteIfBound(MakeShareable(new FAppleSentryScope(scope)));
295-
}];
296-
}
297-
298292
void FAppleSentrySubsystem::SetContext(const FString& key, const TMap<FString, FString>& values)
299293
{
300294
[SentrySDK configureScope:^(SentryScope* scope) {

0 commit comments

Comments
 (0)