Skip to content

Commit

Permalink
Merge 3368a42 into 8d3001a
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich authored Feb 8, 2023
2 parents 8d3001a + 3368a42 commit 0ac162c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Breaking changes

- Events captured by Native SDKs are reporting as RN SDK ([#2814](https://github.com/getsentry/sentry-react-native/pull/2814))

## 5.0.0-beta.2

### Features
Expand Down
12 changes: 12 additions & 0 deletions android/src/main/java/io/sentry/react/RNSentryModuleImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.util.SparseIntArray;

import androidx.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.core.app.FrameMetricsAggregator;

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

public void initNativeSdk(final ReadableMap rnOptions, Promise promise) {
SentryAndroid.init(this.getReactApplicationContext(), options -> {
if (rnOptions.hasKey("_metadata")) {
@Nullable final ReadableMap metadata = rnOptions.getMap("_metadata");
@Nullable final ReadableMap sdkMap = metadata != null ? metadata.getMap("sdk") : null;
@Nullable final String sdkMapName = sdkMap != null ? sdkMap.getString("name") : null;
@Nullable final String sdkMapVersion = sdkMap != null ? sdkMap.getString("version") : null;
if (sdkMapName != null && sdkMapVersion != null) {
@NonNull final SdkVersion sdkVersion = new SdkVersion(sdkMapName, sdkMapVersion);
options.setSentryClientName(sdkMapName + "/" + sdkMapVersion);
options.setSdkVersion(sdkVersion);
}
}
if (rnOptions.hasKey("debug") && rnOptions.getBoolean("debug")) {
options.setDebug(true);
}
Expand Down
9 changes: 9 additions & 0 deletions ios/RNSentry.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ + (BOOL)requiresMainQueueSetup {
return;
}

if ([options[@"_metadata"] isKindOfClass: [NSDictionary class]]
&& [options[@"_metadata"][@"sdk"] isKindOfClass: [NSDictionary class]]
&& [options[@"_metadata"][@"sdk"][@"name"] isKindOfClass:[NSString class]]
&& [options[@"_metadata"][@"sdk"][@"version"] isKindOfClass:[NSString class]]) {
[PrivateSentrySDKOnly
setSdkName:options[@"_metadata"][@"sdk"][@"name"]
andVersionString: options[@"_metadata"][@"sdk"][@"version"]];
}

[SentrySDK startWithOptions:sentryOptions];

#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
Expand Down
1 change: 1 addition & 0 deletions sample-new-architecture/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Sentry.init({
// This will capture ALL TRACES and likely use up all your quota
tracesSampleRate: 1.0,
attachStacktrace: true,
attachScreenshot: true,
// Sets the `release` and `dist` on Sentry events. Make sure this matches EXACTLY with the values on your sourcemaps
// otherwise they will not work.
// release: 'myapp@1.2.3+1',
Expand Down

0 comments on commit 0ac162c

Please sign in to comment.