@@ -38,11 +38,11 @@ private RNSentryStart() {
3838 static void startWithConfiguration (
3939 @ NotNull final Context context ,
4040 @ NotNull Sentry .OptionsConfiguration <SentryAndroidOptions > configuration ) {
41+ Sentry .OptionsConfiguration <SentryAndroidOptions > defaults =
42+ options -> updateWithReactDefaults (options , null );
4143 RNSentryCompositeOptionsConfiguration compositeConfiguration =
4244 new RNSentryCompositeOptionsConfiguration (
43- RNSentryStart ::updateWithReactDefaults ,
44- configuration ,
45- RNSentryStart ::updateWithReactFinals );
45+ defaults , configuration , RNSentryStart ::updateWithReactFinals );
4646 SentryAndroid .init (context , compositeConfiguration );
4747 }
4848
@@ -51,14 +51,13 @@ static void startWithOptions(
5151 @ NotNull final ReadableMap rnOptions ,
5252 @ NotNull Sentry .OptionsConfiguration <SentryAndroidOptions > configuration ,
5353 @ NotNull ILogger logger ) {
54+ Sentry .OptionsConfiguration <SentryAndroidOptions > defaults =
55+ options -> updateWithReactDefaults (options , null );
5456 Sentry .OptionsConfiguration <SentryAndroidOptions > rnConfigurationOptions =
55- options -> getSentryAndroidOptions (options , rnOptions , null , logger );
57+ options -> getSentryAndroidOptions (options , rnOptions , logger );
5658 RNSentryCompositeOptionsConfiguration compositeConfiguration =
5759 new RNSentryCompositeOptionsConfiguration (
58- RNSentryStart ::updateWithReactDefaults ,
59- rnConfigurationOptions ,
60- configuration ,
61- RNSentryStart ::updateWithReactFinals );
60+ defaults , rnConfigurationOptions , configuration , RNSentryStart ::updateWithReactFinals );
6261 SentryAndroid .init (context , compositeConfiguration );
6362 }
6463
@@ -67,21 +66,20 @@ static void startWithOptions(
6766 @ NotNull final ReadableMap rnOptions ,
6867 @ Nullable Activity currentActivity ,
6968 @ NotNull ILogger logger ) {
69+ Sentry .OptionsConfiguration <SentryAndroidOptions > defaults =
70+ options -> updateWithReactDefaults (options , currentActivity );
7071 Sentry .OptionsConfiguration <SentryAndroidOptions > rnConfigurationOptions =
71- options -> getSentryAndroidOptions (options , rnOptions , currentActivity , logger );
72+ options -> getSentryAndroidOptions (options , rnOptions , logger );
7273 RNSentryCompositeOptionsConfiguration compositeConfiguration =
7374 new RNSentryCompositeOptionsConfiguration (
74- RNSentryStart ::updateWithReactDefaults ,
75- rnConfigurationOptions ,
76- RNSentryStart ::updateWithReactFinals );
75+ defaults , rnConfigurationOptions , RNSentryStart ::updateWithReactFinals );
7776 SentryAndroid .init (context , compositeConfiguration );
7877 }
7978
8079 static void getSentryAndroidOptions (
8180 @ NotNull SentryAndroidOptions options ,
8281 @ NotNull ReadableMap rnOptions ,
83- @ Nullable Activity currentActivity ,
84- ILogger logger ) {
82+ @ NotNull ILogger logger ) {
8583 if (rnOptions .hasKey ("debug" ) && rnOptions .getBoolean ("debug" )) {
8684 options .setDebug (true );
8785 }
@@ -193,24 +191,23 @@ static void getSentryAndroidOptions(
193191 }
194192 logger .log (
195193 SentryLevel .INFO , String .format ("Native Integrations '%s'" , options .getIntegrations ()));
196-
197- setCurrentActivity (currentActivity );
198194 }
199195
200196 /**
201197 * This function updates the options with RNSentry defaults. These default can be overwritten by
202198 * users during manual native initialization.
203199 */
204- static void updateWithReactDefaults (@ NotNull SentryAndroidOptions options ) {
200+ static void updateWithReactDefaults (
201+ @ NotNull SentryAndroidOptions options , @ Nullable Activity currentActivity ) {
205202 @ Nullable SdkVersion sdkVersion = options .getSdkVersion ();
206203 if (sdkVersion == null ) {
207204 sdkVersion = new SdkVersion (RNSentryVersion .ANDROID_SDK_NAME , BuildConfig .VERSION_NAME );
208205 } else {
209206 sdkVersion .setName (RNSentryVersion .ANDROID_SDK_NAME );
210207 }
211208 sdkVersion .addPackage (
212- RNSentryVersion .REACT_NATIVE_SDK_PACKAGE_NAME ,
213- RNSentryVersion .REACT_NATIVE_SDK_PACKAGE_VERSION );
209+ RNSentryVersion .REACT_NATIVE_SDK_PACKAGE_NAME ,
210+ RNSentryVersion .REACT_NATIVE_SDK_PACKAGE_VERSION );
214211
215212 options .setSentryClientName (sdkVersion .getName () + "/" + sdkVersion .getVersion ());
216213 options .setNativeSdkName (RNSentryVersion .NATIVE_SDK_NAME );
@@ -224,6 +221,8 @@ static void updateWithReactDefaults(@NotNull SentryAndroidOptions options) {
224221 // React native internally throws a JavascriptException.
225222 // we want to ignore it on the native side to avoid sending it twice.
226223 options .addIgnoredExceptionForType (JavascriptException .class );
224+
225+ setCurrentActivity (currentActivity );
227226 }
228227
229228 /**
0 commit comments