@posthog/react-native-plugin 2.3.0 → 2.4.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/android/src/main/java/com/posthogreactnativeplugin/PosthogReactNativePluginModule.kt
CHANGED
|
@@ -485,7 +485,7 @@ class PosthogReactNativePluginModule(
|
|
|
485
485
|
if (!config.capturePushNotificationOpened) {
|
|
486
486
|
return
|
|
487
487
|
}
|
|
488
|
-
val intent = currentActivity?.intent ?: return
|
|
488
|
+
val intent = reactApplicationContext.currentActivity?.intent ?: return
|
|
489
489
|
// A relaunch from recents redelivers the original tray intent to a fresh activity;
|
|
490
490
|
// capturing it would count a days-old tap as a new open.
|
|
491
491
|
if (intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY != 0) {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// swift-tools-version: 6.0
|
|
2
|
+
|
|
3
|
+
import PackageDescription
|
|
4
|
+
|
|
5
|
+
// React Native's SwiftPM autolinker references this package through
|
|
6
|
+
// build/generated/autolinking/libs/ReactNativePlugin. These paths are relative
|
|
7
|
+
// to that stable alias, not to node_modules.
|
|
8
|
+
let reactNativeDependencies: [Package.Dependency] = [
|
|
9
|
+
.package(name: "ReactNative", path: "../../../../xcframeworks"),
|
|
10
|
+
.package(name: "React-GeneratedCode", path: "../../../ios"),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
let reactHeaderDependencies: [Target.Dependency] = [
|
|
14
|
+
.product(name: "ReactHeaders", package: "ReactNative"),
|
|
15
|
+
.product(name: "ReactNativeHeaders", package: "ReactNative"),
|
|
16
|
+
.product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"),
|
|
17
|
+
.product(name: "ReactAppHeaders", package: "React-GeneratedCode"),
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
let package = Package(
|
|
21
|
+
// This name must match React Native's Swift-name derivation for
|
|
22
|
+
// @posthog/react-native-plugin.
|
|
23
|
+
name: "ReactNativePlugin",
|
|
24
|
+
platforms: [.iOS(.v15)],
|
|
25
|
+
products: [
|
|
26
|
+
.library(
|
|
27
|
+
name: "ReactNativePlugin",
|
|
28
|
+
targets: ["PosthogReactNativePlugin", "PosthogReactNativePluginBridge"]
|
|
29
|
+
),
|
|
30
|
+
],
|
|
31
|
+
dependencies: reactNativeDependencies + [
|
|
32
|
+
.package(
|
|
33
|
+
url: "https://github.com/PostHog/posthog-ios.git",
|
|
34
|
+
.upToNextMinor(from: "3.69.2")
|
|
35
|
+
),
|
|
36
|
+
],
|
|
37
|
+
targets: [
|
|
38
|
+
.target(
|
|
39
|
+
name: "PosthogReactNativePlugin",
|
|
40
|
+
dependencies: reactHeaderDependencies + [
|
|
41
|
+
.product(name: "PostHog", package: "posthog-ios"),
|
|
42
|
+
],
|
|
43
|
+
path: ".",
|
|
44
|
+
exclude: [
|
|
45
|
+
"Package.swift",
|
|
46
|
+
"PosthogReactNativePlugin-Bridging-Header.h",
|
|
47
|
+
"PosthogReactNativePlugin.mm",
|
|
48
|
+
],
|
|
49
|
+
sources: ["PosthogReactNativePlugin.swift"]
|
|
50
|
+
),
|
|
51
|
+
// SwiftPM cannot compile Swift and Objective-C++ in one target. The
|
|
52
|
+
// RCT_EXTERN_MODULE registration bridge is independent and is linked
|
|
53
|
+
// into the same library product as the Swift implementation.
|
|
54
|
+
.target(
|
|
55
|
+
name: "PosthogReactNativePluginBridge",
|
|
56
|
+
dependencies: reactHeaderDependencies,
|
|
57
|
+
path: ".",
|
|
58
|
+
exclude: [
|
|
59
|
+
"Package.swift",
|
|
60
|
+
"PosthogReactNativePlugin.swift",
|
|
61
|
+
],
|
|
62
|
+
sources: ["PosthogReactNativePlugin.mm"],
|
|
63
|
+
publicHeadersPath: "."
|
|
64
|
+
),
|
|
65
|
+
],
|
|
66
|
+
// Match the CocoaPods integration's Swift 5 language mode. The plugin has
|
|
67
|
+
// main-thread-confined Objective-C bridge state that is not yet annotated
|
|
68
|
+
// for Swift 6's strict concurrency checks.
|
|
69
|
+
swiftLanguageModes: [.v5]
|
|
70
|
+
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import PostHog
|
|
2
|
+
import React
|
|
2
3
|
|
|
3
4
|
/// Meant for internally logging PostHog related things
|
|
4
5
|
private func hedgeLog(_ message: String) {
|
|
@@ -55,7 +56,7 @@ private func declinePushIdentity(_ completion: (String?) -> Void, _ reason: Stri
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
@objc(PosthogReactNativePlugin)
|
|
58
|
-
class PosthogReactNativePlugin: RCTEventEmitter {
|
|
59
|
+
public class PosthogReactNativePlugin: RCTEventEmitter {
|
|
59
60
|
private var config: PostHogConfig?
|
|
60
61
|
|
|
61
62
|
private static let pushIdentityEvent = "PostHogPushIdentityRequest"
|
|
@@ -68,15 +69,15 @@ class PosthogReactNativePlugin: RCTEventEmitter {
|
|
|
68
69
|
private var hasPushListeners = false
|
|
69
70
|
private var pushIdentityCompletions: [String: (String?) -> Void] = [:]
|
|
70
71
|
|
|
71
|
-
override func supportedEvents() -> [String]! {
|
|
72
|
+
public override func supportedEvents() -> [String]! {
|
|
72
73
|
[PosthogReactNativePlugin.pushIdentityEvent]
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
override func startObserving() {
|
|
76
|
+
public override func startObserving() {
|
|
76
77
|
DispatchQueue.main.async { self.hasPushListeners = true }
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
override func stopObserving() {
|
|
80
|
+
public override func stopObserving() {
|
|
80
81
|
DispatchQueue.main.async { self.hasPushListeners = false }
|
|
81
82
|
}
|
|
82
83
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/react-native-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.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",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
108
108
|
"lint:fix": "eslint \"**/*.{js,ts,tsx}\" --fix",
|
|
109
109
|
"typecheck": "tsc",
|
|
110
|
-
"test:unit": "jest --passWithNoTests",
|
|
110
|
+
"test:unit": "jest --passWithNoTests && node scripts/check-spm-manifest.mjs",
|
|
111
111
|
"test": "pnpm test:unit",
|
|
112
112
|
"build": "bob build",
|
|
113
113
|
"package": "pnpm pack --out $PACKAGE_DEST/%s.tgz"
|
|
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
|
|
|
19
19
|
s.platforms = { :ios => min_ios_version_supported, :osx => '10.15' }
|
|
20
20
|
s.source = { :git => "https://github.com/PostHog/posthog-js.git", :tag => "@posthog/react-native-plugin@#{s.version}" }
|
|
21
21
|
|
|
22
|
-
s.source_files = "ios
|
|
22
|
+
s.source_files = "ios/PosthogReactNativePlugin.{swift,h,hpp,m,mm,c,cpp}"
|
|
23
23
|
|
|
24
24
|
# Default: resolve posthog-ios via CocoaPods trunk.
|
|
25
25
|
# Opt-in: set `posthog.useSpm` to `"true"` in the consumer's
|