@@ -38,11 +38,11 @@ private RNSentryStart() {
38
38
static void startWithConfiguration (
39
39
@ NotNull final Context context ,
40
40
@ NotNull Sentry .OptionsConfiguration <SentryAndroidOptions > configuration ) {
41
+ Sentry .OptionsConfiguration <SentryAndroidOptions > defaults =
42
+ options -> updateWithReactDefaults (options , null );
41
43
RNSentryCompositeOptionsConfiguration compositeConfiguration =
42
44
new RNSentryCompositeOptionsConfiguration (
43
- RNSentryStart ::updateWithReactDefaults ,
44
- configuration ,
45
- RNSentryStart ::updateWithReactFinals );
45
+ defaults , configuration , RNSentryStart ::updateWithReactFinals );
46
46
SentryAndroid .init (context , compositeConfiguration );
47
47
}
48
48
@@ -51,14 +51,13 @@ static void startWithOptions(
51
51
@ NotNull final ReadableMap rnOptions ,
52
52
@ NotNull Sentry .OptionsConfiguration <SentryAndroidOptions > configuration ,
53
53
@ NotNull ILogger logger ) {
54
+ Sentry .OptionsConfiguration <SentryAndroidOptions > defaults =
55
+ options -> updateWithReactDefaults (options , null );
54
56
Sentry .OptionsConfiguration <SentryAndroidOptions > rnConfigurationOptions =
55
- options -> getSentryAndroidOptions (options , rnOptions , null , logger );
57
+ options -> getSentryAndroidOptions (options , rnOptions , logger );
56
58
RNSentryCompositeOptionsConfiguration compositeConfiguration =
57
59
new RNSentryCompositeOptionsConfiguration (
58
- RNSentryStart ::updateWithReactDefaults ,
59
- rnConfigurationOptions ,
60
- configuration ,
61
- RNSentryStart ::updateWithReactFinals );
60
+ defaults , rnConfigurationOptions , configuration , RNSentryStart ::updateWithReactFinals );
62
61
SentryAndroid .init (context , compositeConfiguration );
63
62
}
64
63
@@ -67,21 +66,20 @@ static void startWithOptions(
67
66
@ NotNull final ReadableMap rnOptions ,
68
67
@ Nullable Activity currentActivity ,
69
68
@ NotNull ILogger logger ) {
69
+ Sentry .OptionsConfiguration <SentryAndroidOptions > defaults =
70
+ options -> updateWithReactDefaults (options , currentActivity );
70
71
Sentry .OptionsConfiguration <SentryAndroidOptions > rnConfigurationOptions =
71
- options -> getSentryAndroidOptions (options , rnOptions , currentActivity , logger );
72
+ options -> getSentryAndroidOptions (options , rnOptions , logger );
72
73
RNSentryCompositeOptionsConfiguration compositeConfiguration =
73
74
new RNSentryCompositeOptionsConfiguration (
74
- RNSentryStart ::updateWithReactDefaults ,
75
- rnConfigurationOptions ,
76
- RNSentryStart ::updateWithReactFinals );
75
+ defaults , rnConfigurationOptions , RNSentryStart ::updateWithReactFinals );
77
76
SentryAndroid .init (context , compositeConfiguration );
78
77
}
79
78
80
79
static void getSentryAndroidOptions (
81
80
@ NotNull SentryAndroidOptions options ,
82
81
@ NotNull ReadableMap rnOptions ,
83
- @ Nullable Activity currentActivity ,
84
- ILogger logger ) {
82
+ @ NotNull ILogger logger ) {
85
83
if (rnOptions .hasKey ("debug" ) && rnOptions .getBoolean ("debug" )) {
86
84
options .setDebug (true );
87
85
}
@@ -193,24 +191,23 @@ static void getSentryAndroidOptions(
193
191
}
194
192
logger .log (
195
193
SentryLevel .INFO , String .format ("Native Integrations '%s'" , options .getIntegrations ()));
196
-
197
- setCurrentActivity (currentActivity );
198
194
}
199
195
200
196
/**
201
197
* This function updates the options with RNSentry defaults. These default can be overwritten by
202
198
* users during manual native initialization.
203
199
*/
204
- static void updateWithReactDefaults (@ NotNull SentryAndroidOptions options ) {
200
+ static void updateWithReactDefaults (
201
+ @ NotNull SentryAndroidOptions options , @ Nullable Activity currentActivity ) {
205
202
@ Nullable SdkVersion sdkVersion = options .getSdkVersion ();
206
203
if (sdkVersion == null ) {
207
204
sdkVersion = new SdkVersion (RNSentryVersion .ANDROID_SDK_NAME , BuildConfig .VERSION_NAME );
208
205
} else {
209
206
sdkVersion .setName (RNSentryVersion .ANDROID_SDK_NAME );
210
207
}
211
208
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 );
214
211
215
212
options .setSentryClientName (sdkVersion .getName () + "/" + sdkVersion .getVersion ());
216
213
options .setNativeSdkName (RNSentryVersion .NATIVE_SDK_NAME );
@@ -224,6 +221,8 @@ static void updateWithReactDefaults(@NotNull SentryAndroidOptions options) {
224
221
// React native internally throws a JavascriptException.
225
222
// we want to ignore it on the native side to avoid sending it twice.
226
223
options .addIgnoredExceptionForType (JavascriptException .class );
224
+
225
+ setCurrentActivity (currentActivity );
227
226
}
228
227
229
228
/**
0 commit comments