Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Analytics-android dependency #298

Merged
merged 1 commit into from
Apr 16, 2021
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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain this change?
After removing this line the private method defined in line 65 isn't called anywhere, sounds like a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup this was a bug. @nfcampos thanks for pointing it out :), It really helped us solve a crucial bug 🙌

}

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

RNAnalytics.setupCallbacks(analytics)

singletonJsonConfig = json
Expand Down