Skip to content

Commit 850e1e5

Browse files
chore(native): Add react-native postfix to native SDKs (#2814)
1 parent 458e78a commit 850e1e5

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

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

+13
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;
@@ -51,6 +52,7 @@
5152
import io.sentry.android.core.AndroidLogger;
5253
import io.sentry.android.core.AnrIntegration;
5354
import io.sentry.android.core.AppStartState;
55+
import io.sentry.android.core.BuildConfig;
5456
import io.sentry.android.core.BuildInfoProvider;
5557
import io.sentry.android.core.CurrentActivityHolder;
5658
import io.sentry.android.core.NdkIntegration;
@@ -102,6 +104,17 @@ Activity getCurrentActivity() {
102104

103105
public void initNativeSdk(final ReadableMap rnOptions, Promise promise) {
104106
SentryAndroid.init(this.getReactApplicationContext(), options -> {
107+
@NonNull final String sdkName = "sentry.java.android.react-native";
108+
@Nullable SdkVersion sdkVersion = options.getSdkVersion();
109+
if (sdkVersion == null) {
110+
sdkVersion = new SdkVersion(sdkName, BuildConfig.VERSION_NAME);
111+
} else {
112+
sdkVersion.setName(sdkName);
113+
}
114+
115+
options.setSentryClientName(sdkVersion.getName() + "/" + sdkVersion.getVersion());
116+
options.setSdkVersion(sdkVersion);
117+
105118
if (rnOptions.hasKey("debug") && rnOptions.getBoolean("debug")) {
106119
options.setDebug(true);
107120
}

ios/RNSentry.mm

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

59+
NSString *sdkName = @"sentry.cocoa.react-native";
60+
NSString *sdkVersion = [PrivateSentrySDKOnly getSdkVersionString];
61+
[PrivateSentrySDKOnly setSdkName: sdkName andVersionString: sdkVersion];
62+
5963
[SentrySDK startWithOptions:sentryOptions];
6064

6165
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST

0 commit comments

Comments
 (0)