Skip to content

Commit

Permalink
chore(native): Add react-native postfix to native SDKs (#2814)
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich committed Apr 11, 2023
1 parent 458e78a commit 850e1e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 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 @@ -51,6 +52,7 @@
import io.sentry.android.core.AndroidLogger;
import io.sentry.android.core.AnrIntegration;
import io.sentry.android.core.AppStartState;
import io.sentry.android.core.BuildConfig;
import io.sentry.android.core.BuildInfoProvider;
import io.sentry.android.core.CurrentActivityHolder;
import io.sentry.android.core.NdkIntegration;
Expand Down Expand Up @@ -102,6 +104,17 @@ Activity getCurrentActivity() {

public void initNativeSdk(final ReadableMap rnOptions, Promise promise) {
SentryAndroid.init(this.getReactApplicationContext(), options -> {
@NonNull final String sdkName = "sentry.java.android.react-native";
@Nullable SdkVersion sdkVersion = options.getSdkVersion();
if (sdkVersion == null) {
sdkVersion = new SdkVersion(sdkName, BuildConfig.VERSION_NAME);
} else {
sdkVersion.setName(sdkName);
}

options.setSentryClientName(sdkVersion.getName() + "/" + sdkVersion.getVersion());
options.setSdkVersion(sdkVersion);

if (rnOptions.hasKey("debug") && rnOptions.getBoolean("debug")) {
options.setDebug(true);
}
Expand Down
4 changes: 4 additions & 0 deletions ios/RNSentry.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ + (BOOL)requiresMainQueueSetup {
return;
}

NSString *sdkName = @"sentry.cocoa.react-native";
NSString *sdkVersion = [PrivateSentrySDKOnly getSdkVersionString];
[PrivateSentrySDKOnly setSdkName: sdkName andVersionString: sdkVersion];

[SentrySDK startWithOptions:sentryOptions];

#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
Expand Down

0 comments on commit 850e1e5

Please sign in to comment.