@posthog/react-native-plugin 2.9.3 → 2.9.4
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/build.gradle
CHANGED
|
@@ -91,7 +91,7 @@ dependencies {
|
|
|
91
91
|
//noinspection GradleDynamicVersion
|
|
92
92
|
implementation "com.facebook.react:react-native:+"
|
|
93
93
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
94
|
-
implementation "com.posthog:posthog-android:3.
|
|
94
|
+
implementation "com.posthog:posthog-android:3.66.0"
|
|
95
95
|
|
|
96
96
|
testImplementation "junit:junit:4.13.2"
|
|
97
97
|
}
|
package/android/src/main/java/com/posthogreactnativeplugin/PosthogReactNativePluginModule.kt
CHANGED
|
@@ -139,6 +139,9 @@ class PosthogReactNativePluginModule(
|
|
|
139
139
|
PostHogAndroidConfig(apiKey, host).apply {
|
|
140
140
|
debug = debugValue
|
|
141
141
|
optOut = theOptOut
|
|
142
|
+
// JS owns consent: posthog-js core keeps its own store, so the value above is the
|
|
143
|
+
// answer, not a default the SDK may override from its own persisted copy.
|
|
144
|
+
persistOptOut = false
|
|
142
145
|
preloadFeatureFlags = thePreloadFeatureFlags
|
|
143
146
|
captureDeepLinks = false
|
|
144
147
|
captureApplicationLifecycleEvents = false
|
|
@@ -221,7 +224,7 @@ class PosthogReactNativePluginModule(
|
|
|
221
224
|
|
|
222
225
|
setIdentify(config.cachePreferences, distinctId, anonymousId)
|
|
223
226
|
|
|
224
|
-
captureColdStartPushOpenIfNeeded(config
|
|
227
|
+
captureColdStartPushOpenIfNeeded(config)
|
|
225
228
|
} catch (e: Throwable) {
|
|
226
229
|
logError(method, e)
|
|
227
230
|
} finally {
|
|
@@ -488,15 +491,7 @@ class PosthogReactNativePluginModule(
|
|
|
488
491
|
// cold-start tray tap it exists for is the one creation it can never observe here. Read
|
|
489
492
|
// the launch intent directly, then strip the marker so the integration (or a re-run)
|
|
490
493
|
// can't capture the same tap again from this intent object.
|
|
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
|
-
) {
|
|
494
|
+
private fun captureColdStartPushOpenIfNeeded(config: PostHogAndroidConfig) {
|
|
500
495
|
if (!config.capturePushNotificationOpened) {
|
|
501
496
|
return
|
|
502
497
|
}
|
|
@@ -508,10 +503,6 @@ class PosthogReactNativePluginModule(
|
|
|
508
503
|
}
|
|
509
504
|
try {
|
|
510
505
|
intent.getStringExtra(GOOGLE_MESSAGE_ID) ?: return
|
|
511
|
-
if (jsOptedOut) {
|
|
512
|
-
intent.removeExtra(GOOGLE_MESSAGE_ID)
|
|
513
|
-
return
|
|
514
|
-
}
|
|
515
506
|
// Unmarshalling extras throws BadParcelableException on a Parcelable class this
|
|
516
507
|
// classloader lacks; read before stripping the marker so a failed read leaves the
|
|
517
508
|
// intent as the native integration expects it.
|
package/ios/Package.swift
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import PostHog
|
|
1
|
+
@_spi(PostHogInternal) import PostHog
|
|
2
2
|
import React
|
|
3
3
|
|
|
4
4
|
/// Meant for internally logging PostHog related things
|
|
@@ -64,11 +64,9 @@ private func isReactNativeFatalJsError(_ event: PostHogEvent) -> Bool {
|
|
|
64
64
|
private final class SetupWindow {
|
|
65
65
|
private let lock = NSLock()
|
|
66
66
|
private var distinctId: String?
|
|
67
|
-
private var jsOptedOut: Bool
|
|
68
67
|
|
|
69
|
-
init(distinctId: String
|
|
68
|
+
init(distinctId: String) {
|
|
70
69
|
self.distinctId = distinctId.isEmpty ? nil : distinctId
|
|
71
|
-
self.jsOptedOut = jsOptedOut
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
var pendingDistinctId: String? {
|
|
@@ -77,17 +75,10 @@ private final class SetupWindow {
|
|
|
77
75
|
return distinctId
|
|
78
76
|
}
|
|
79
77
|
|
|
80
|
-
var dropsPushOpens: Bool {
|
|
81
|
-
lock.lock()
|
|
82
|
-
defer { lock.unlock() }
|
|
83
|
-
return jsOptedOut
|
|
84
|
-
}
|
|
85
|
-
|
|
86
78
|
func settled() {
|
|
87
79
|
lock.lock()
|
|
88
80
|
defer { lock.unlock() }
|
|
89
81
|
distinctId = nil
|
|
90
|
-
jsOptedOut = false
|
|
91
82
|
}
|
|
92
83
|
}
|
|
93
84
|
|
|
@@ -247,7 +238,7 @@ public class PosthogReactNativePlugin: RCTEventEmitter {
|
|
|
247
238
|
let distinctId = sdkOptions["distinctId"] as? String ?? ""
|
|
248
239
|
let anonymousId = sdkOptions["anonymousId"] as? String ?? ""
|
|
249
240
|
let jsOptedOut = sdkOptions["optOut"] as? Bool ?? false
|
|
250
|
-
let setupWindow = SetupWindow(distinctId: distinctId
|
|
241
|
+
let setupWindow = SetupWindow(distinctId: distinctId)
|
|
251
242
|
// Every exit below is past the point where native storage carries the ids, or past a
|
|
252
243
|
// failure that left the SDK disabled, so no path can leave the window armed.
|
|
253
244
|
defer { setupWindow.settled() }
|
|
@@ -260,13 +251,8 @@ public class PosthogReactNativePlugin: RCTEventEmitter {
|
|
|
260
251
|
}
|
|
261
252
|
// Only the replayed tap. `setup()` also replays the previous launch's crash report,
|
|
262
253
|
// and that `$exception` carries the distinct id recorded at crash time, which stands.
|
|
263
|
-
if event.event == "$push_notification_opened" {
|
|
264
|
-
|
|
265
|
-
return nil
|
|
266
|
-
}
|
|
267
|
-
if let distinctId = setupWindow.pendingDistinctId {
|
|
268
|
-
event.distinctId = distinctId
|
|
269
|
-
}
|
|
254
|
+
if event.event == "$push_notification_opened", let distinctId = setupWindow.pendingDistinctId {
|
|
255
|
+
event.distinctId = distinctId
|
|
270
256
|
}
|
|
271
257
|
return event
|
|
272
258
|
}
|
|
@@ -326,6 +312,9 @@ public class PosthogReactNativePlugin: RCTEventEmitter {
|
|
|
326
312
|
config.flushAt = flushAt
|
|
327
313
|
|
|
328
314
|
config.optOut = jsOptedOut
|
|
315
|
+
// JS owns consent: posthog-js core keeps its own store, so the value above is the answer,
|
|
316
|
+
// not a default the SDK may override from its own disk copy.
|
|
317
|
+
config.persistOptOut = false
|
|
329
318
|
// JS owns flags; it tells us when the native preload would be a duplicate. posthog-ios
|
|
330
319
|
// has no remoteConfig switch to mirror — it deprecated the option and always loads.
|
|
331
320
|
config.preloadFeatureFlags = sdkOptions["preloadFeatureFlags"] as? Bool ?? true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/react-native-plugin",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.4",
|
|
4
4
|
"description": "PostHog React Native plugin for iOS and Android integrations",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -95,6 +95,7 @@
|
|
|
95
95
|
]
|
|
96
96
|
},
|
|
97
97
|
"scripts": {
|
|
98
|
+
"check-types": "pnpm typecheck",
|
|
98
99
|
"clean": "del-cli android/build lib",
|
|
99
100
|
"lint": "oxlint --report-unused-disable-directives-severity error .",
|
|
100
101
|
"lint:fix": "oxlint --report-unused-disable-directives-severity error . --fix",
|
|
@@ -6,7 +6,7 @@ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1
|
|
|
6
6
|
# Single source of truth for the posthog-ios native dependency version.
|
|
7
7
|
# Used by both the SPM and CocoaPods resolution paths below; bump this
|
|
8
8
|
# line when picking up a new posthog-ios release.
|
|
9
|
-
posthog_ios_version = '3.
|
|
9
|
+
posthog_ios_version = '3.76.0'
|
|
10
10
|
|
|
11
11
|
Pod::Spec.new do |s|
|
|
12
12
|
s.name = "posthog-react-native-plugin"
|