@posthog/react-native-plugin 2.9.2 → 2.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/android/src/main/java/com/posthogreactnativeplugin/PosthogReactNativePluginModule.kt
CHANGED
|
@@ -221,7 +221,7 @@ class PosthogReactNativePluginModule(
|
|
|
221
221
|
|
|
222
222
|
setIdentify(config.cachePreferences, distinctId, anonymousId)
|
|
223
223
|
|
|
224
|
-
captureColdStartPushOpenIfNeeded(config)
|
|
224
|
+
captureColdStartPushOpenIfNeeded(config, jsOptedOut = theOptOut)
|
|
225
225
|
} catch (e: Throwable) {
|
|
226
226
|
logError(method, e)
|
|
227
227
|
} finally {
|
|
@@ -488,7 +488,15 @@ class PosthogReactNativePluginModule(
|
|
|
488
488
|
// cold-start tray tap it exists for is the one creation it can never observe here. Read
|
|
489
489
|
// the launch intent directly, then strip the marker so the integration (or a re-run)
|
|
490
490
|
// can't capture the same tap again from this intent object.
|
|
491
|
-
|
|
491
|
+
//
|
|
492
|
+
// jsOptedOut is the consent JS passed into this setup(). The native SDK lets the opt-out it
|
|
493
|
+
// persisted itself win over that value, so after an earlier launch opted in, config.optOut no
|
|
494
|
+
// longer says what JS said and native would capture. A tap JS considers denied is consumed
|
|
495
|
+
// here without being captured, so a later opt-in cannot resurrect it either.
|
|
496
|
+
private fun captureColdStartPushOpenIfNeeded(
|
|
497
|
+
config: PostHogAndroidConfig,
|
|
498
|
+
jsOptedOut: Boolean,
|
|
499
|
+
) {
|
|
492
500
|
if (!config.capturePushNotificationOpened) {
|
|
493
501
|
return
|
|
494
502
|
}
|
|
@@ -500,6 +508,10 @@ class PosthogReactNativePluginModule(
|
|
|
500
508
|
}
|
|
501
509
|
try {
|
|
502
510
|
intent.getStringExtra(GOOGLE_MESSAGE_ID) ?: return
|
|
511
|
+
if (jsOptedOut) {
|
|
512
|
+
intent.removeExtra(GOOGLE_MESSAGE_ID)
|
|
513
|
+
return
|
|
514
|
+
}
|
|
503
515
|
// Unmarshalling extras throws BadParcelableException on a Parcelable class this
|
|
504
516
|
// classloader lacks; read before stripping the marker so a failed read leaves the
|
|
505
517
|
// intent as the native integration expects it.
|