@posthog/react-native-plugin 2.2.3 → 2.3.0

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.
@@ -14,9 +14,21 @@ export interface PostHogReactNativePluginErrorTrackingConfig {
14
14
  nativeAutocapture?: boolean;
15
15
  exceptionSteps?: PostHogReactNativePluginExceptionStepsConfig;
16
16
  }
17
+ export interface PostHogReactNativePluginPushConfig {
18
+ capturePushNotificationSubscriptions?: boolean;
19
+ capturePushNotificationOpened?: boolean;
20
+ /**
21
+ * A provider callback can't cross the bridge, so this only tells native whether to
22
+ * install the bridging provider at all — installing one the host didn't ask for
23
+ * would change how the native SDK handles a 401 on the subscription call.
24
+ * Pair with {@link setPushIdentityProvider} before calling setup().
25
+ */
26
+ pushIdentityProviderEnabled?: boolean;
27
+ }
17
28
  export interface PostHogReactNativePluginConfig {
18
29
  sessionReplay?: PostHogReactNativePluginSessionReplayConfig;
19
30
  errorTracking?: PostHogReactNativePluginErrorTrackingConfig;
31
+ push?: PostHogReactNativePluginPushConfig;
20
32
  }
21
33
  export declare function setup(sessionId: string, sdkOptions: PostHogReactNativePluginMap, pluginConfig?: PostHogReactNativePluginConfig): Promise<void>;
22
34
  export declare function start(sessionId: string, sdkOptions: PostHogReactNativePluginMap, sdkReplayConfig: PostHogReactNativePluginMap, decideReplayConfig: PostHogReactNativePluginMap): Promise<void>;
@@ -24,9 +36,38 @@ export declare function startSession(sessionId: string): Promise<void>;
24
36
  export declare function endSession(): Promise<void>;
25
37
  export declare function isEnabled(): Promise<boolean>;
26
38
  export declare function identify(distinctId: string, anonymousId: string): Promise<void>;
39
+ /**
40
+ * Resets the native SDK's identity on logout. Unlike {@link identify}, this calls the native
41
+ * SDK's own `reset()`, which unregisters the logged-out user's push subscription and
42
+ * re-registers it under the new anonymous id.
43
+ */
44
+ export declare function reset(distinctId: string, anonymousId: string): Promise<void>;
27
45
  export declare function startRecording(resumeCurrent: boolean): Promise<void>;
28
46
  export declare function stopRecording(): Promise<void>;
29
47
  export declare function addExceptionStep(message: string, properties?: PostHogReactNativePluginMap): Promise<void>;
48
+ export declare function registerPushNotificationToken(deviceToken: string, appId: string | null): Promise<void>;
49
+ export declare function unregisterPushNotificationToken(): Promise<void>;
50
+ /**
51
+ * Propagates a runtime consent change to the native SDK, which otherwise only reads the JS
52
+ * opt-out flag at setup() and could auto-register a refreshed push token after optOut().
53
+ */
54
+ export declare function setOptOut(optOut: boolean): Promise<void>;
55
+ export declare function capturePushNotificationOpened(properties: PostHogReactNativePluginMap): Promise<void>;
56
+ /**
57
+ * Mints a signed identity-verification token for a push subscription request.
58
+ * Return null to send the request without an identity token.
59
+ */
60
+ export type PostHogPushIdentityProvider = (distinctId: string, appId: string) => Promise<string | null>;
61
+ /**
62
+ * Installs the JS side of the push identity-provider bridge. The native SDK asks for a
63
+ * token via a `PostHogPushIdentityRequest` event; the reply is routed back with
64
+ * `providePushIdentityToken`, keyed by the request id so late replies are ignored.
65
+ *
66
+ * Install before setup() with `push.pushIdentityProviderEnabled` set, so the native
67
+ * config gets its bridging provider at SDK initialization. Any provider failure
68
+ * degrades to a null token — an unauthenticated request — never a stalled mint.
69
+ */
70
+ export declare function setPushIdentityProvider(provider: PostHogPushIdentityProvider): void;
30
71
  export interface PostHogReactNativePluginModule {
31
72
  setup: (sessionId: string, sdkOptions: PostHogReactNativePluginMap, pluginConfig?: PostHogReactNativePluginConfig) => Promise<void>;
32
73
  /**
@@ -37,9 +78,15 @@ export interface PostHogReactNativePluginModule {
37
78
  endSession: () => Promise<void>;
38
79
  isEnabled: () => Promise<boolean>;
39
80
  identify: (distinctId: string, anonymousId: string) => Promise<void>;
81
+ reset: (distinctId: string, anonymousId: string) => Promise<void>;
40
82
  startRecording: (resumeCurrent: boolean) => Promise<void>;
41
83
  stopRecording: () => Promise<void>;
42
84
  addExceptionStep: (message: string, properties?: PostHogReactNativePluginMap) => Promise<void>;
85
+ registerPushNotificationToken: (deviceToken: string, appId: string | null) => Promise<void>;
86
+ unregisterPushNotificationToken: () => Promise<void>;
87
+ setOptOut: (optOut: boolean) => Promise<void>;
88
+ capturePushNotificationOpened: (properties: PostHogReactNativePluginMap) => Promise<void>;
89
+ setPushIdentityProvider: (provider: PostHogPushIdentityProvider) => void;
43
90
  }
44
91
  declare const PostHogReactNativePlugin: PostHogReactNativePluginModule;
45
92
  export default PostHogReactNativePlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAmBA,MAAM,MAAM,2BAA2B,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAA;AAEhE,MAAM,WAAW,2CAA2C;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,eAAe,CAAC,EAAE,2BAA2B,CAAA;IAC7C,kBAAkB,CAAC,EAAE,2BAA2B,CAAA;CACjD;AAED,MAAM,WAAW,4CAA4C;IAC3D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,2CAA2C;IAC1D,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,cAAc,CAAC,EAAE,4CAA4C,CAAA;CAC9D;AAED,MAAM,WAAW,8BAA8B;IAC7C,aAAa,CAAC,EAAE,2CAA2C,CAAA;IAC3D,aAAa,CAAC,EAAE,2CAA2C,CAAA;CAC5D;AAED,wBAAgB,KAAK,CACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,2BAA2B,EACvC,YAAY,GAAE,8BAAmC,GAChD,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAgB,KAAK,CACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,2BAA2B,EACvC,eAAe,EAAE,2BAA2B,EAC5C,kBAAkB,EAAE,2BAA2B,GAC9C,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAgB,YAAY,CAAC,SAAS,EAA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,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3F,+BAA+B,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAEpD,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAE7C,6BAA6B,EAAE,CAAC,UAAU,EAAE,2BAA2B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAEzF,uBAAuB,EAAE,CAAC,QAAQ,EAAE,2BAA2B,KAAK,IAAI,CAAA;CACzE;AAED,QAAA,MAAM,wBAAwB,EAAE,8BAgB/B,CAAA;AAED,eAAe,wBAAwB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/react-native-plugin",
3
- "version": "2.2.3",
3
+ "version": "2.3.0",
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",
@@ -69,7 +69,6 @@
69
69
  "react-native": "*"
70
70
  },
71
71
  "jest": {
72
- "preset": "react-native",
73
72
  "modulePathIgnorePatterns": [
74
73
  "<rootDir>/lib/"
75
74
  ],
@@ -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.64.7'
9
+ posthog_ios_version = '3.69.2'
10
10
 
11
11
  Pod::Spec.new do |s|
12
12
  s.name = "posthog-react-native-plugin"
package/src/index.tsx CHANGED
@@ -1,4 +1,5 @@
1
- import { NativeModules, Platform } from 'react-native'
1
+ import { NativeEventEmitter, NativeModules, Platform } from 'react-native'
2
+ import type { EmitterSubscription } from 'react-native'
2
3
 
3
4
  const LINKING_ERROR =
4
5
  `The package '@posthog/react-native-plugin' doesn't seem to be linked. Make sure: \n\n` +
@@ -35,9 +36,22 @@ export interface PostHogReactNativePluginErrorTrackingConfig {
35
36
  exceptionSteps?: PostHogReactNativePluginExceptionStepsConfig
36
37
  }
37
38
 
39
+ export interface PostHogReactNativePluginPushConfig {
40
+ capturePushNotificationSubscriptions?: boolean
41
+ capturePushNotificationOpened?: boolean
42
+ /**
43
+ * A provider callback can't cross the bridge, so this only tells native whether to
44
+ * install the bridging provider at all — installing one the host didn't ask for
45
+ * would change how the native SDK handles a 401 on the subscription call.
46
+ * Pair with {@link setPushIdentityProvider} before calling setup().
47
+ */
48
+ pushIdentityProviderEnabled?: boolean
49
+ }
50
+
38
51
  export interface PostHogReactNativePluginConfig {
39
52
  sessionReplay?: PostHogReactNativePluginSessionReplayConfig
40
53
  errorTracking?: PostHogReactNativePluginErrorTrackingConfig
54
+ push?: PostHogReactNativePluginPushConfig
41
55
  }
42
56
 
43
57
  export function setup(
@@ -73,6 +87,15 @@ export function identify(distinctId: string, anonymousId: string): Promise<void>
73
87
  return PosthogReactNativePlugin.identify(distinctId, anonymousId)
74
88
  }
75
89
 
90
+ /**
91
+ * Resets the native SDK's identity on logout. Unlike {@link identify}, this calls the native
92
+ * SDK's own `reset()`, which unregisters the logged-out user's push subscription and
93
+ * re-registers it under the new anonymous id.
94
+ */
95
+ export function reset(distinctId: string, anonymousId: string): Promise<void> {
96
+ return PosthogReactNativePlugin.reset(distinctId, anonymousId)
97
+ }
98
+
76
99
  export function startRecording(resumeCurrent: boolean): Promise<void> {
77
100
  return PosthogReactNativePlugin.startRecording(resumeCurrent)
78
101
  }
@@ -85,6 +108,71 @@ export function addExceptionStep(message: string, properties?: PostHogReactNativ
85
108
  return PosthogReactNativePlugin.addExceptionStep(message, properties ?? {})
86
109
  }
87
110
 
111
+ export function registerPushNotificationToken(deviceToken: string, appId: string | null): Promise<void> {
112
+ return PosthogReactNativePlugin.registerPushNotificationToken(deviceToken, appId)
113
+ }
114
+
115
+ export function unregisterPushNotificationToken(): Promise<void> {
116
+ return PosthogReactNativePlugin.unregisterPushNotificationToken()
117
+ }
118
+
119
+ /**
120
+ * Propagates a runtime consent change to the native SDK, which otherwise only reads the JS
121
+ * opt-out flag at setup() and could auto-register a refreshed push token after optOut().
122
+ */
123
+ export function setOptOut(optOut: boolean): Promise<void> {
124
+ return PosthogReactNativePlugin.setOptOut(optOut)
125
+ }
126
+
127
+ export function capturePushNotificationOpened(properties: PostHogReactNativePluginMap): Promise<void> {
128
+ return PosthogReactNativePlugin.capturePushNotificationOpened(properties)
129
+ }
130
+
131
+ /**
132
+ * Mints a signed identity-verification token for a push subscription request.
133
+ * Return null to send the request without an identity token.
134
+ */
135
+ export type PostHogPushIdentityProvider = (distinctId: string, appId: string) => Promise<string | null>
136
+
137
+ const PUSH_IDENTITY_EVENT = 'PostHogPushIdentityRequest'
138
+
139
+ let pushIdentitySubscription: EmitterSubscription | undefined
140
+
141
+ /**
142
+ * Installs the JS side of the push identity-provider bridge. The native SDK asks for a
143
+ * token via a `PostHogPushIdentityRequest` event; the reply is routed back with
144
+ * `providePushIdentityToken`, keyed by the request id so late replies are ignored.
145
+ *
146
+ * Install before setup() with `push.pushIdentityProviderEnabled` set, so the native
147
+ * config gets its bridging provider at SDK initialization. Any provider failure
148
+ * degrades to a null token — an unauthenticated request — never a stalled mint.
149
+ */
150
+ export function setPushIdentityProvider(provider: PostHogPushIdentityProvider): void {
151
+ pushIdentitySubscription?.remove()
152
+ // Via the proxy, not raw NativeModules: an unlinked module would build an emitter over
153
+ // undefined and throw a generic RN error inside the SDK's init try, taking replay down with it.
154
+ const emitter = new NativeEventEmitter(PosthogReactNativePlugin)
155
+ pushIdentitySubscription = emitter.addListener(
156
+ PUSH_IDENTITY_EVENT,
157
+ async (request: { requestId: string; distinctId: string; appId: string }) => {
158
+ let token: string | null = null
159
+ try {
160
+ const minted = await provider(request.distinctId, request.appId)
161
+ token = typeof minted === 'string' ? minted : null
162
+ } catch (e) {
163
+ // eslint-disable-next-line no-console
164
+ console.warn(`[PostHog] pushIdentityProvider threw: ${e}. Push subscription will be sent unauthenticated.`)
165
+ }
166
+ try {
167
+ await PosthogReactNativePlugin.providePushIdentityToken(request.requestId, token)
168
+ } catch (e) {
169
+ // eslint-disable-next-line no-console
170
+ console.warn(`[PostHog] Failed to deliver push identity token to native: ${e}`)
171
+ }
172
+ }
173
+ )
174
+ }
175
+
88
176
  export interface PostHogReactNativePluginModule {
89
177
  setup: (
90
178
  sessionId: string,
@@ -110,11 +198,23 @@ export interface PostHogReactNativePluginModule {
110
198
 
111
199
  identify: (distinctId: string, anonymousId: string) => Promise<void>
112
200
 
201
+ reset: (distinctId: string, anonymousId: string) => Promise<void>
202
+
113
203
  startRecording: (resumeCurrent: boolean) => Promise<void>
114
204
 
115
205
  stopRecording: () => Promise<void>
116
206
 
117
207
  addExceptionStep: (message: string, properties?: PostHogReactNativePluginMap) => Promise<void>
208
+
209
+ registerPushNotificationToken: (deviceToken: string, appId: string | null) => Promise<void>
210
+
211
+ unregisterPushNotificationToken: () => Promise<void>
212
+
213
+ setOptOut: (optOut: boolean) => Promise<void>
214
+
215
+ capturePushNotificationOpened: (properties: PostHogReactNativePluginMap) => Promise<void>
216
+
217
+ setPushIdentityProvider: (provider: PostHogPushIdentityProvider) => void
118
218
  }
119
219
 
120
220
  const PostHogReactNativePlugin: PostHogReactNativePluginModule = {
@@ -124,9 +224,15 @@ const PostHogReactNativePlugin: PostHogReactNativePluginModule = {
124
224
  endSession,
125
225
  isEnabled,
126
226
  identify,
227
+ reset,
127
228
  startRecording,
128
229
  stopRecording,
129
230
  addExceptionStep,
231
+ registerPushNotificationToken,
232
+ unregisterPushNotificationToken,
233
+ setOptOut,
234
+ capturePushNotificationOpened,
235
+ setPushIdentityProvider,
130
236
  }
131
237
 
132
238
  export default PostHogReactNativePlugin