Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repositories {
}

dependencies {
api 'com.segment.analytics.android:analytics:4.9.1-beta'
api 'com.segment.analytics.android:analytics:4.9.3'

api 'com.facebook.react:react-native:+'
api "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : defaultKotlinVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class RNAnalyticsModule(context: ReactApplicationContext): ReactContextBaseJavaM
val json = options.getString("json")
val writeKey = options.getString("writeKey")

if (writeKey == null) {
return promise.reject("E_SEGMENT_RECONFIGURED", "writeKey cannot be null")
}

if(singletonJsonConfig != null) {
if(json == singletonJsonConfig) {
return promise.resolve(null)
Expand Down Expand Up @@ -183,6 +187,13 @@ class RNAnalyticsModule(context: ReactApplicationContext): ReactContextBaseJavaM
})
}

if(options.hasKey("defaultProjectSettings")) {
builder.defaultProjectSettings(Utils.toValueMap(options.getMap("defaultProjectSettings")))
}

// RN does not need this flag enabled
builder.experimentalUseNewLifecycleMethods(false)

try {
Analytics.setSingletonInstance(
RNAnalytics.buildWithIntegrations(builder)
Expand All @@ -196,14 +207,6 @@ class RNAnalyticsModule(context: ReactApplicationContext): ReactContextBaseJavaM
return promise.reject("E_SEGMENT_ERROR", e)
}

if(options.getBoolean("trackAppLifecycleEvents")) {
this.trackApplicationLifecycleEvents(writeKey)
}

if(options.hasKey("defaultProjectSettings")) {
builder.defaultProjectSettings(Utils.toValueMap(options.getMap("defaultProjectSettings")))
}

RNAnalytics.setupCallbacks(analytics)

singletonJsonConfig = json
Expand Down