@posthog/react-native-plugin 2.5.1 → 2.6.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.
package/LICENSE CHANGED
@@ -217,6 +217,70 @@ limitations under the License.
217
217
  limitations under the License.
218
218
 
219
219
 
220
+ ---
221
+
222
+ The @posthog/core package in packages/core is licensed under the MIT License below.
223
+ Third-party code remains subject to its respective notices in this file.
224
+ This owning notice is preserved from posthog-js-lite, from which @posthog/core was migrated:
225
+ https://github.com/PostHog/posthog-js-lite/blob/5fb7bee96f739b243dfea5589e2027f16629e8cd/LICENSE
226
+
227
+ MIT License
228
+
229
+ Copyright (c) 2022 PostHog (part of Hiberly Inc)
230
+
231
+ Permission is hereby granted, free of charge, to any person obtaining a copy
232
+ of this software and associated documentation files (the "Software"), to deal
233
+ in the Software without restriction, including without limitation the rights
234
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
235
+ copies of the Software, and to permit persons to whom the Software is
236
+ furnished to do so, subject to the following conditions:
237
+
238
+ The above copyright notice and this permission notice shall be included in all
239
+ copies or substantial portions of the Software.
240
+
241
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
242
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
243
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
244
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
245
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
246
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
247
+ SOFTWARE.
248
+
249
+ ---
250
+
251
+ packages/core/src/error-tracking/parsers/index.ts and its compiled distributions contain code
252
+ derived from TraceKit. This license only applies to the relevant code.
253
+
254
+ MIT License
255
+
256
+ Copyright (c) 2013 Onur Can Cakmak onur.cakmak@gmail.com and all TraceKit contributors.
257
+
258
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
259
+ software and associated documentation files(the 'Software'), to deal in the Software
260
+ without restriction, including without limitation the rights to use, copy, modify,
261
+ merge, publish, distribute, sublicense, and / or sell copies of the Software, and to
262
+ permit persons to whom the Software is furnished to do so, subject to the following
263
+ conditions:
264
+
265
+ The above copyright notice and this permission notice shall be included in all copies
266
+ or substantial portions of the Software.
267
+
268
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
269
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
270
+ PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
271
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
272
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
273
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
274
+
275
+ ---
276
+
277
+ packages/core/src/vendor/uuidv7.ts and its compiled distributions contain code from uuidv7:
278
+ https://github.com/LiosK/uuidv7/blob/f30b7a7faff73afbce0b27a46c638310f96912ba/src/index.ts
279
+
280
+ Copyright 2021-2023 LiosK
281
+
282
+ This code is licensed under the Apache License, Version 2.0, reproduced above.
283
+
220
284
  ---
221
285
 
222
286
  Some files in this codebase contain code from getsentry/sentry-javascript.
@@ -8,7 +8,13 @@ def isNewArchitectureEnabled() {
8
8
  }
9
9
 
10
10
  apply plugin: "com.android.library"
11
- apply plugin: "kotlin-android"
11
+ // AGP 9 ships built-in Kotlin support and registers the `kotlin` extension
12
+ // itself. Applying the Kotlin plugin on top of it fails configuration with
13
+ // "Cannot add extension with name 'kotlin'". Only apply it when nothing has
14
+ // registered that extension yet.
15
+ if (project.extensions.findByName('kotlin') == null) {
16
+ apply plugin: "kotlin-android"
17
+ }
12
18
 
13
19
  if (isNewArchitectureEnabled()) {
14
20
  apply plugin: "com.facebook.react"
@@ -85,7 +91,7 @@ dependencies {
85
91
  //noinspection GradleDynamicVersion
86
92
  implementation "com.facebook.react:react-native:+"
87
93
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
88
- implementation "com.posthog:posthog-android:3.61.0"
94
+ implementation "com.posthog:posthog-android:3.62.0"
89
95
 
90
96
  testImplementation "junit:junit:4.13.2"
91
97
  }
@@ -1,7 +1,9 @@
1
1
  package com.posthogreactnativeplugin
2
2
 
3
+ import android.app.Activity
3
4
  import android.content.Intent
4
5
  import android.util.Log
6
+ import com.facebook.react.bridge.ActivityEventListener
5
7
  import com.facebook.react.bridge.Arguments
6
8
  import com.facebook.react.bridge.Promise
7
9
  import com.facebook.react.bridge.ReactApplicationContext
@@ -23,9 +25,30 @@ import java.util.UUID
23
25
 
24
26
  class PosthogReactNativePluginModule(
25
27
  reactContext: ReactApplicationContext,
26
- ) : ReactContextBaseJavaModule(reactContext) {
28
+ ) : ReactContextBaseJavaModule(reactContext),
29
+ ActivityEventListener {
27
30
  override fun getName(): String = NAME
28
31
 
32
+ override fun initialize() {
33
+ super.initialize()
34
+ // ReactActivity forwards onNewIntent to its listeners, so unlike a plain Android host the
35
+ // app needs no code of its own for warm-start taps.
36
+ reactApplicationContext.addActivityEventListener(this)
37
+ }
38
+
39
+ override fun onActivityResult(
40
+ activity: Activity,
41
+ requestCode: Int,
42
+ resultCode: Int,
43
+ data: Intent?,
44
+ ) = Unit
45
+
46
+ // A tap delivered while the process is alive never reaches onActivityCreated, so the native
47
+ // integration cannot see it. Deduplicated by message id against the cold-start path.
48
+ override fun onNewIntent(intent: Intent) {
49
+ PostHogAndroid.capturePushNotificationOpened(intent)
50
+ }
51
+
29
52
  @ReactMethod
30
53
  fun setup(
31
54
  sessionId: String,
@@ -527,6 +550,7 @@ class PosthogReactNativePluginModule(
527
550
  fun removeListeners(count: Int) = Unit
528
551
 
529
552
  override fun invalidate() {
553
+ reactApplicationContext.removeActivityEventListener(this)
530
554
  if (pushModule === this) {
531
555
  // Decline mints fast after teardown instead of stalling the native 10s watchdog.
532
556
  pushModule = null
@@ -111,13 +111,13 @@ function setPushIdentityProvider(provider) {
111
111
  const minted = await provider(request.distinctId, request.appId);
112
112
  token = typeof minted === 'string' ? minted : null;
113
113
  } catch (e) {
114
- // eslint-disable-next-line no-console
114
+ // oxlint-disable-next-line no-console
115
115
  console.warn(`[PostHog] pushIdentityProvider threw: ${e}. Push subscription will be sent unauthenticated.`);
116
116
  }
117
117
  try {
118
118
  await PosthogReactNativePlugin.providePushIdentityToken(request.requestId, token);
119
119
  } catch (e) {
120
- // eslint-disable-next-line no-console
120
+ // oxlint-disable-next-line no-console
121
121
  console.warn(`[PostHog] Failed to deliver push identity token to native: ${e}`);
122
122
  }
123
123
  });
@@ -92,13 +92,13 @@ export function setPushIdentityProvider(provider) {
92
92
  const minted = await provider(request.distinctId, request.appId);
93
93
  token = typeof minted === 'string' ? minted : null;
94
94
  } catch (e) {
95
- // eslint-disable-next-line no-console
95
+ // oxlint-disable-next-line no-console
96
96
  console.warn(`[PostHog] pushIdentityProvider threw: ${e}. Push subscription will be sent unauthenticated.`);
97
97
  }
98
98
  try {
99
99
  await PosthogReactNativePlugin.providePushIdentityToken(request.requestId, token);
100
100
  } catch (e) {
101
- // eslint-disable-next-line no-console
101
+ // oxlint-disable-next-line no-console
102
102
  console.warn(`[PostHog] Failed to deliver push identity token to native: ${e}`);
103
103
  }
104
104
  });
@@ -0,0 +1,3 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;
3
+ //# sourceMappingURL=vitest.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../../../vitest.config.ts"],"names":[],"mappings":";AAEA,wBAME"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;
3
+ //# sourceMappingURL=vitest.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../../../vitest.config.ts"],"names":[],"mappings":";AAEA,wBAME"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/react-native-plugin",
3
- "version": "2.5.1",
3
+ "version": "2.6.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",
@@ -57,28 +57,18 @@
57
57
  "homepage": "https://github.com/PostHog/posthog-js/tree/main/packages/react-native-plugin#readme",
58
58
  "devDependencies": {
59
59
  "@react-native-community/cli": "20.0.0",
60
- "@types/jest": "^29.5.14",
61
60
  "@types/react": "^18.2.44",
62
61
  "del-cli": "^5.1.0",
63
- "jest": "29.7.0",
64
62
  "react": "18.3.1",
65
63
  "react-native": "0.75.3",
66
64
  "react-native-builder-bob": "^0.30.2",
67
- "typescript": "5.8.2"
65
+ "typescript": "5.8.2",
66
+ "vitest": "^1.6.1"
68
67
  },
69
68
  "peerDependencies": {
70
69
  "react": "*",
71
70
  "react-native": "*"
72
71
  },
73
- "jest": {
74
- "modulePathIgnorePatterns": [
75
- "<rootDir>/lib/"
76
- ],
77
- "testPathIgnorePatterns": [
78
- "/node_modules/",
79
- "<rootDir>/lib/"
80
- ]
81
- },
82
72
  "react-native-builder-bob": {
83
73
  "source": "src",
84
74
  "output": "lib",
@@ -106,10 +96,10 @@
106
96
  },
107
97
  "scripts": {
108
98
  "clean": "del-cli android/build lib",
109
- "lint": "eslint \"**/*.{js,ts,tsx}\"",
110
- "lint:fix": "eslint \"**/*.{js,ts,tsx}\" --fix",
99
+ "lint": "oxlint --report-unused-disable-directives-severity error .",
100
+ "lint:fix": "oxlint --report-unused-disable-directives-severity error . --fix",
111
101
  "typecheck": "tsc",
112
- "test:unit": "jest --passWithNoTests && node scripts/check-spm-manifest.mjs",
102
+ "test:unit": "vitest run --passWithNoTests && node scripts/check-spm-manifest.mjs",
113
103
  "test": "pnpm test:unit",
114
104
  "build": "bob build",
115
105
  "package": "pnpm pack --out $PACKAGE_DEST/%s.tgz"
package/src/index.tsx CHANGED
@@ -160,13 +160,13 @@ export function setPushIdentityProvider(provider: PostHogPushIdentityProvider):
160
160
  const minted = await provider(request.distinctId, request.appId)
161
161
  token = typeof minted === 'string' ? minted : null
162
162
  } catch (e) {
163
- // eslint-disable-next-line no-console
163
+ // oxlint-disable-next-line no-console
164
164
  console.warn(`[PostHog] pushIdentityProvider threw: ${e}. Push subscription will be sent unauthenticated.`)
165
165
  }
166
166
  try {
167
167
  await PosthogReactNativePlugin.providePushIdentityToken(request.requestId, token)
168
168
  } catch (e) {
169
- // eslint-disable-next-line no-console
169
+ // oxlint-disable-next-line no-console
170
170
  console.warn(`[PostHog] Failed to deliver push identity token to native: ${e}`)
171
171
  }
172
172
  }