Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(native): Add react-native postfix to native SDKs #2814

Merged
merged 7 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
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))
krystofwoldrich marked this conversation as resolved.
Show resolved Hide resolved

## 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")) {
krystofwoldrich marked this conversation as resolved.
Show resolved Hide resolved
@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);
krystofwoldrich marked this conversation as resolved.
Show resolved Hide resolved
}
}
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