Skip to content

Commit 0ac162c

Browse files
Merge 3368a42 into 8d3001a
2 parents 8d3001a + 3368a42 commit 0ac162c

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Breaking changes
6+
7+
- Events captured by Native SDKs are reporting as RN SDK ([#2814](https://github.com/getsentry/sentry-react-native/pull/2814))
8+
39
## 5.0.0-beta.2
410

511
### Features

android/src/main/java/io/sentry/react/RNSentryModuleImpl.java

+12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.util.SparseIntArray;
1111

1212
import androidx.annotation.Nullable;
13+
import androidx.annotation.NonNull;
1314
import androidx.core.app.FrameMetricsAggregator;
1415

1516
import com.facebook.react.bridge.Arguments;
@@ -102,6 +103,17 @@ Activity getCurrentActivity() {
102103

103104
public void initNativeSdk(final ReadableMap rnOptions, Promise promise) {
104105
SentryAndroid.init(this.getReactApplicationContext(), options -> {
106+
if (rnOptions.hasKey("_metadata")) {
107+
@Nullable final ReadableMap metadata = rnOptions.getMap("_metadata");
108+
@Nullable final ReadableMap sdkMap = metadata != null ? metadata.getMap("sdk") : null;
109+
@Nullable final String sdkMapName = sdkMap != null ? sdkMap.getString("name") : null;
110+
@Nullable final String sdkMapVersion = sdkMap != null ? sdkMap.getString("version") : null;
111+
if (sdkMapName != null && sdkMapVersion != null) {
112+
@NonNull final SdkVersion sdkVersion = new SdkVersion(sdkMapName, sdkMapVersion);
113+
options.setSentryClientName(sdkMapName + "/" + sdkMapVersion);
114+
options.setSdkVersion(sdkVersion);
115+
}
116+
}
105117
if (rnOptions.hasKey("debug") && rnOptions.getBoolean("debug")) {
106118
options.setDebug(true);
107119
}

ios/RNSentry.mm

+9
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ + (BOOL)requiresMainQueueSetup {
5656
return;
5757
}
5858

59+
if ([options[@"_metadata"] isKindOfClass: [NSDictionary class]]
60+
&& [options[@"_metadata"][@"sdk"] isKindOfClass: [NSDictionary class]]
61+
&& [options[@"_metadata"][@"sdk"][@"name"] isKindOfClass:[NSString class]]
62+
&& [options[@"_metadata"][@"sdk"][@"version"] isKindOfClass:[NSString class]]) {
63+
[PrivateSentrySDKOnly
64+
setSdkName:options[@"_metadata"][@"sdk"][@"name"]
65+
andVersionString: options[@"_metadata"][@"sdk"][@"version"]];
66+
}
67+
5968
[SentrySDK startWithOptions:sentryOptions];
6069

6170
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST

sample-new-architecture/src/App.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Sentry.init({
5959
// This will capture ALL TRACES and likely use up all your quota
6060
tracesSampleRate: 1.0,
6161
attachStacktrace: true,
62+
attachScreenshot: true,
6263
// Sets the `release` and `dist` on Sentry events. Make sure this matches EXACTLY with the values on your sourcemaps
6364
// otherwise they will not work.
6465
// release: '[email protected]+1',

0 commit comments

Comments
 (0)