@@ -106,6 +106,10 @@ class RNAnalyticsModule(context: ReactApplicationContext): ReactContextBaseJavaM
106
106
val json = options.getString(" json" )
107
107
val writeKey = options.getString(" writeKey" )
108
108
109
+ if (writeKey == null ) {
110
+ return promise.reject(" E_SEGMENT_RECONFIGURED" , " writeKey cannot be null" )
111
+ }
112
+
109
113
if (singletonJsonConfig != null ) {
110
114
if (json == singletonJsonConfig) {
111
115
return promise.resolve(null )
@@ -183,6 +187,13 @@ class RNAnalyticsModule(context: ReactApplicationContext): ReactContextBaseJavaM
183
187
})
184
188
}
185
189
190
+ if (options.hasKey(" defaultProjectSettings" )) {
191
+ builder.defaultProjectSettings(Utils .toValueMap(options.getMap(" defaultProjectSettings" )))
192
+ }
193
+
194
+ // RN does not need this flag enabled
195
+ builder.experimentalUseNewLifecycleMethods(false )
196
+
186
197
try {
187
198
Analytics .setSingletonInstance(
188
199
RNAnalytics .buildWithIntegrations(builder)
@@ -196,14 +207,6 @@ class RNAnalyticsModule(context: ReactApplicationContext): ReactContextBaseJavaM
196
207
return promise.reject(" E_SEGMENT_ERROR" , e)
197
208
}
198
209
199
- if (options.getBoolean(" trackAppLifecycleEvents" )) {
200
- this .trackApplicationLifecycleEvents(writeKey)
201
- }
202
-
203
- if (options.hasKey(" defaultProjectSettings" )) {
204
- builder.defaultProjectSettings(Utils .toValueMap(options.getMap(" defaultProjectSettings" )))
205
- }
206
-
207
210
RNAnalytics .setupCallbacks(analytics)
208
211
209
212
singletonJsonConfig = json
0 commit comments