Skip to content

Commit 5a2ed9b

Browse files
authored
fix(android): bump deps and fix config issues (#298)
1 parent 0e6682a commit 5a2ed9b

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

packages/core/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ repositories {
3939
}
4040

4141
dependencies {
42-
api 'com.segment.analytics.android:analytics:4.9.1-beta'
42+
api 'com.segment.analytics.android:analytics:4.9.3'
4343

4444
api 'com.facebook.react:react-native:+'
4545
api "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : defaultKotlinVersion}"

packages/core/android/src/main/java/com/segment/analytics/reactnative/core/RNAnalyticsModule.kt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ class RNAnalyticsModule(context: ReactApplicationContext): ReactContextBaseJavaM
106106
val json = options.getString("json")
107107
val writeKey = options.getString("writeKey")
108108

109+
if (writeKey == null) {
110+
return promise.reject("E_SEGMENT_RECONFIGURED", "writeKey cannot be null")
111+
}
112+
109113
if(singletonJsonConfig != null) {
110114
if(json == singletonJsonConfig) {
111115
return promise.resolve(null)
@@ -183,6 +187,13 @@ class RNAnalyticsModule(context: ReactApplicationContext): ReactContextBaseJavaM
183187
})
184188
}
185189

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+
186197
try {
187198
Analytics.setSingletonInstance(
188199
RNAnalytics.buildWithIntegrations(builder)
@@ -196,14 +207,6 @@ class RNAnalyticsModule(context: ReactApplicationContext): ReactContextBaseJavaM
196207
return promise.reject("E_SEGMENT_ERROR", e)
197208
}
198209

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-
207210
RNAnalytics.setupCallbacks(analytics)
208211

209212
singletonJsonConfig = json

0 commit comments

Comments
 (0)