posthog-react-native 4.46.12 → 4.46.14

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/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "4.46.12";
1
+ export declare const version = "4.46.14";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.version=void 0;var version=exports.version="4.46.12";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.version=void 0;var version=exports.version="4.46.14";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-react-native",
3
- "version": "4.46.12",
3
+ "version": "4.46.14",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,8 +28,8 @@
28
28
  "directory": "packages/react-native"
29
29
  },
30
30
  "dependencies": {
31
- "@posthog/core": "1.30.6",
32
- "@posthog/types": "1.379.3"
31
+ "@posthog/core": "1.30.7",
32
+ "@posthog/types": "1.380.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@babel/cli": "^7.19.3",
@@ -68,8 +68,8 @@
68
68
  "react-native-svg": "^15.0.0",
69
69
  "ts-jest": "29.4.0",
70
70
  "typescript": "5.8.2",
71
- "@posthog-tooling/tsconfig-base": "1.1.1",
72
- "@posthog-tooling/rollup-utils": "1.1.1"
71
+ "@posthog-tooling/rollup-utils": "1.1.1",
72
+ "@posthog-tooling/tsconfig-base": "1.1.1"
73
73
  },
74
74
  "peerDependencies": {
75
75
  "@react-native-async-storage/async-storage": ">=1.0.0",
@@ -7,6 +7,8 @@ import org.apache.tools.ant.taskdefs.condition.Os
7
7
  import java.util.regex.Matcher
8
8
  import java.util.regex.Pattern
9
9
 
10
+ import org.gradle.api.logging.Logging
11
+
10
12
  interface InjectedExecOps {
11
13
  @Inject //@javax.inject.Inject
12
14
  ExecOperations getExecOps()
@@ -91,44 +93,47 @@ plugins.withId('com.android.application') {
91
93
  }
92
94
 
93
95
  def injected = project.objects.newInstance(InjectedExecOps)
94
- doFirst {
95
- injected.execOps.exec {
96
- workingDir reactRoot
97
-
98
- def cliPackage = resolvePostHogCliPackagePath(reactRoot)
99
- def args = [cliPackage]
100
96
 
101
- args.addAll(["hermes", "clone",
102
- "--minified-map-path", packagerSourcemapOutput, // The path to a sourcemap
103
- "--composed-map-path", sourcemapOutput // The path of the composed source map
104
- ])
97
+ // Resolve the posthog-cli path at execution time, not during
98
+ // configuration. The resolver starts node/npm via Groovy's `.execute()`,
99
+ // and Gradle's configuration cache forbids starting external processes at
100
+ // configuration time. Resolution lives in the static
101
+ // PostHogCli.resolveCliPackagePath() so these serialized task actions can
102
+ // call it without relying on the apply-from script's owner chain — a
103
+ // script-level method fails under the configuration cache with "Could not
104
+ // find method ... on object of type DefaultExecAction_Decorated". rootDir
105
+ // is captured as plain serializable state; `Task.project` must not be read
106
+ // at execution time, so logging uses the task's own `logger`.
107
+ def rootDirFile = rootDir
108
+ def osCompatibility = Os.isFamily(Os.FAMILY_WINDOWS) ? ['cmd', '/c', 'node'] : []
105
109
 
106
- args.addAll(extraArgs)
107
-
108
- project.logger.info("posthog-cli clone arguments: ${args}")
109
- def osCompatibility = Os.isFamily(Os.FAMILY_WINDOWS) ? ['cmd', '/c', 'node'] : []
110
+ doFirst {
111
+ def cliPackage = PostHogCli.resolveCliPackagePath(rootDirFile, reactRoot)
112
+ def args = [cliPackage]
113
+ args.addAll(["hermes", "clone",
114
+ "--minified-map-path", packagerSourcemapOutput, // The path to a sourcemap
115
+ "--composed-map-path", sourcemapOutput // The path of the composed source map
116
+ ])
117
+ args.addAll(extraArgs)
118
+ logger.info("posthog-cli clone arguments: ${args}")
110
119
 
120
+ injected.execOps.exec {
121
+ workingDir reactRoot
111
122
  commandLine(*osCompatibility, *args)
112
123
  }
113
124
  }
114
125
 
115
126
  doLast {
127
+ def cliPackage = PostHogCli.resolveCliPackagePath(rootDirFile, reactRoot)
128
+ def args = [cliPackage]
129
+ args.addAll(["hermes", "upload",
130
+ "--directory", sourcemapOutput.getParent() // The path to a sourcemap that should be uploaded.
131
+ ])
132
+ args.addAll(extraArgs)
133
+ logger.info("posthog-cli upload arguments: ${args}")
134
+
116
135
  injected.execOps.exec {
117
136
  workingDir reactRoot
118
-
119
- def cliPackage = resolvePostHogCliPackagePath(reactRoot)
120
- def args = [cliPackage]
121
-
122
- def sourcemapDir = sourcemapOutput.getParent()
123
- args.addAll(["hermes", "upload",
124
- "--directory", sourcemapDir // The path to a sourcemap that should be uploaded.
125
- ])
126
-
127
- args.addAll(extraArgs)
128
-
129
- project.logger.info("posthog-cli upload arguments: ${args}")
130
- def osCompatibility = Os.isFamily(Os.FAMILY_WINDOWS) ? ['cmd', '/c', 'node'] : []
131
-
132
137
  commandLine(*osCompatibility, *args)
133
138
  }
134
139
  }
@@ -170,65 +175,74 @@ plugins.withId('com.android.application') {
170
175
  }
171
176
  }
172
177
 
173
- def resolvePostHogCliPackagePath(reactRoot) {
174
- // First, try to find @posthog/cli folder from require.resolve
175
- try {
176
- def resolvedPath = new File(["node", "--print", "require.resolve('@posthog/cli/package.json')"].execute(null, rootDir).text.trim()).getParentFile()
177
- if (resolvedPath != null && resolvedPath.exists()) {
178
- def runPostHogCliFile = new File(resolvedPath, "run-posthog-cli.js")
179
- if (runPostHogCliFile.exists()) {
180
- project.logger.info("resolved posthog-cli dynamically: `${runPostHogCliFile.getAbsolutePath()}`")
181
- return runPostHogCliFile.getAbsolutePath()
178
+ // Static so the serialized sourcemap-upload task actions can call it under the
179
+ // Gradle configuration cache. It starts node/npm, so it must run at execution
180
+ // time — starting external processes at configuration time is rejected by the
181
+ // configuration cache. Uses its own logger (not `project.logger`) and takes
182
+ // rootDir as a parameter so it never touches `Task.project` at execution time.
183
+ abstract class PostHogCli {
184
+ static String resolveCliPackagePath(File rootDir, reactRoot) {
185
+ def logger = Logging.getLogger(PostHogCli)
186
+
187
+ // First, try to find @posthog/cli folder from require.resolve
188
+ try {
189
+ def resolvedPath = new File(["node", "--print", "require.resolve('@posthog/cli/package.json')"].execute(null, rootDir).text.trim()).getParentFile()
190
+ if (resolvedPath != null && resolvedPath.exists()) {
191
+ def runPostHogCliFile = new File(resolvedPath, "run-posthog-cli.js")
192
+ if (runPostHogCliFile.exists()) {
193
+ logger.info("resolved posthog-cli dynamically: `${runPostHogCliFile.getAbsolutePath()}`")
194
+ return runPostHogCliFile.getAbsolutePath()
195
+ }
182
196
  }
183
- }
184
- } catch (Throwable ignored) {}
185
-
186
- // Second, check if @posthog/cli exists in $reactRoot/node_modules
187
- def nodeModulesPath = new File("$reactRoot/node_modules/@posthog/cli")
188
- if (nodeModulesPath.exists()) {
189
- def runPostHogCliFile = new File(nodeModulesPath, "run-posthog-cli.js")
190
- if (runPostHogCliFile.exists()) {
191
- project.logger.info("resolved posthog-cli hard-coded path (yarn or npm): `${runPostHogCliFile.getAbsolutePath()}`")
192
- return runPostHogCliFile.getAbsolutePath()
193
- }
194
- }
197
+ } catch (Throwable ignored) {}
195
198
 
196
- // Third, check for pnpm installation with node_modules/.bin/posthog-cli
197
- def pnpmBinPath = new File("$reactRoot/node_modules/.bin/posthog-cli")
198
- if (pnpmBinPath.exists()) {
199
- project.logger.info("resolved posthog-cli hard-coded path (pnpm): `${pnpmBinPath.getAbsolutePath()}`")
200
- return pnpmBinPath.getAbsolutePath()
201
- }
202
-
203
- // Fourth, check using npm root for local installation
204
- try {
205
- def npmRoot = ["npm", "root"].execute(null, rootDir).text.trim()
206
- def npmPostHogCliPath = new File(npmRoot, "@posthog/cli")
207
- if (npmPostHogCliPath.exists()) {
208
- def runPostHogCliFile = new File(npmPostHogCliPath, "run-posthog-cli.js")
199
+ // Second, check if @posthog/cli exists in $reactRoot/node_modules
200
+ def nodeModulesPath = new File("$reactRoot/node_modules/@posthog/cli")
201
+ if (nodeModulesPath.exists()) {
202
+ def runPostHogCliFile = new File(nodeModulesPath, "run-posthog-cli.js")
209
203
  if (runPostHogCliFile.exists()) {
210
- project.logger.info("resolved posthog-cli via npm root: `${runPostHogCliFile.getAbsolutePath()}`")
204
+ logger.info("resolved posthog-cli hard-coded path (yarn or npm): `${runPostHogCliFile.getAbsolutePath()}`")
211
205
  return runPostHogCliFile.getAbsolutePath()
212
206
  }
213
207
  }
214
- } catch (Throwable ignored) {}
215
208
 
216
- // Fifth, check for global npm installation of @posthog/cli
217
- try {
218
- def globalPrefix = ["npm", "prefix", "-g"].execute().text.trim()
219
- def globalPostHogCliPath = new File(globalPrefix, "lib/node_modules/@posthog/cli")
220
- if (globalPostHogCliPath.exists()) {
221
- def runPostHogCliFile = new File(globalPostHogCliPath, "run-posthog-cli.js")
222
- if (runPostHogCliFile.exists()) {
223
- project.logger.info("resolved posthog-cli from global npm installation: `${runPostHogCliFile.getAbsolutePath()}`")
224
- return runPostHogCliFile.getAbsolutePath()
225
- }
209
+ // Third, check for pnpm installation with node_modules/.bin/posthog-cli
210
+ def pnpmBinPath = new File("$reactRoot/node_modules/.bin/posthog-cli")
211
+ if (pnpmBinPath.exists()) {
212
+ logger.info("resolved posthog-cli hard-coded path (pnpm): `${pnpmBinPath.getAbsolutePath()}`")
213
+ return pnpmBinPath.getAbsolutePath()
226
214
  }
227
- } catch (Throwable ignored) {}
228
215
 
229
- // Finally, fallback to global install
230
- project.logger.info("falling back to global posthog-cli")
231
- return "posthog-cli"
216
+ // Fourth, check using npm root for local installation
217
+ try {
218
+ def npmRoot = ["npm", "root"].execute(null, rootDir).text.trim()
219
+ def npmPostHogCliPath = new File(npmRoot, "@posthog/cli")
220
+ if (npmPostHogCliPath.exists()) {
221
+ def runPostHogCliFile = new File(npmPostHogCliPath, "run-posthog-cli.js")
222
+ if (runPostHogCliFile.exists()) {
223
+ logger.info("resolved posthog-cli via npm root: `${runPostHogCliFile.getAbsolutePath()}`")
224
+ return runPostHogCliFile.getAbsolutePath()
225
+ }
226
+ }
227
+ } catch (Throwable ignored) {}
228
+
229
+ // Fifth, check for global npm installation of @posthog/cli
230
+ try {
231
+ def globalPrefix = ["npm", "prefix", "-g"].execute().text.trim()
232
+ def globalPostHogCliPath = new File(globalPrefix, "lib/node_modules/@posthog/cli")
233
+ if (globalPostHogCliPath.exists()) {
234
+ def runPostHogCliFile = new File(globalPostHogCliPath, "run-posthog-cli.js")
235
+ if (runPostHogCliFile.exists()) {
236
+ logger.info("resolved posthog-cli from global npm installation: `${runPostHogCliFile.getAbsolutePath()}`")
237
+ return runPostHogCliFile.getAbsolutePath()
238
+ }
239
+ }
240
+ } catch (Throwable ignored) {}
241
+
242
+ // Finally, fallback to global install
243
+ logger.info("falling back to global posthog-cli")
244
+ return "posthog-cli"
245
+ }
232
246
  }
233
247
 
234
248
  def resolvePostHogReactNativeSDKPath(reactRoot) {