@posthog/core 1.2.3 → 1.2.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.
@@ -29,7 +29,7 @@ export interface Exception {
29
29
  export type ExceptionList = Exception[];
30
30
  export interface Mechanism {
31
31
  handled?: boolean;
32
- type?: 'generic' | 'onunhandledrejection' | 'onuncaughtexception' | 'middleware';
32
+ type?: 'generic' | 'onunhandledrejection' | 'onuncaughtexception' | 'onconsole' | 'middleware';
33
33
  source?: string;
34
34
  synthetic?: boolean;
35
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/error-tracking/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAKxC,eAAO,MAAM,cAAc,gEAAiE,CAAA;AAC5F,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CACjC;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IAC9B,kBAAkB,CAAC,EAAE,KAAK,GAAG,IAAI,CAAA;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,SAAS,EAAE,CAAA;IAC5B,gBAAgB,CAAC,EAAE,aAAa,CAAA;CACjC;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,MAAM,C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IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,aAAa,GAAG,SAAS,CAAA;CACpD;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEnD,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,cAAc,CAAA;CAC5B;AAED,UAAU,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACvB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,CAAA;IACjC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;CAC5B;AAED,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,aAAa,GAAG,SAAS,EAAE,eAAe,CAAC,CAAA;AAE5F,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,KAAK,CAAC,EAAE,aAAa,CAAA;CACtB;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,KAAK,CAAC,EAAE,UAAU,EAAE,CAAA;IACpB,KAAK,CAAC,EAAE,eAAe,CAAA;CACxB"}
@@ -0,0 +1,2 @@
1
+ export * from './spawn-local';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/process/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __webpack_modules__ = {
3
+ "./spawn-local": function(module) {
4
+ module.exports = require("./spawn-local.js");
5
+ }
6
+ };
7
+ var __webpack_module_cache__ = {};
8
+ function __webpack_require__(moduleId) {
9
+ var cachedModule = __webpack_module_cache__[moduleId];
10
+ if (void 0 !== cachedModule) return cachedModule.exports;
11
+ var module = __webpack_module_cache__[moduleId] = {
12
+ exports: {}
13
+ };
14
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
+ return module.exports;
16
+ }
17
+ (()=>{
18
+ __webpack_require__.n = (module)=>{
19
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
20
+ __webpack_require__.d(getter, {
21
+ a: getter
22
+ });
23
+ return getter;
24
+ };
25
+ })();
26
+ (()=>{
27
+ __webpack_require__.d = (exports1, definition)=>{
28
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
+ enumerable: true,
30
+ get: definition[key]
31
+ });
32
+ };
33
+ })();
34
+ (()=>{
35
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
36
+ })();
37
+ (()=>{
38
+ __webpack_require__.r = (exports1)=>{
39
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
40
+ value: 'Module'
41
+ });
42
+ Object.defineProperty(exports1, '__esModule', {
43
+ value: true
44
+ });
45
+ };
46
+ })();
47
+ var __webpack_exports__ = {};
48
+ (()=>{
49
+ __webpack_require__.r(__webpack_exports__);
50
+ var _spawn_local__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./spawn-local");
51
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
52
+ for(var __WEBPACK_IMPORT_KEY__ in _spawn_local__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
53
+ return _spawn_local__WEBPACK_IMPORTED_MODULE_0__[key];
54
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
55
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
56
+ })();
57
+ for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
58
+ Object.defineProperty(exports, '__esModule', {
59
+ value: true
60
+ });
@@ -0,0 +1 @@
1
+ export * from "./spawn-local.mjs";
@@ -0,0 +1,8 @@
1
+ export declare function spawnLocal(binaryName: string, args: string[], options: {
2
+ env: NodeJS.ProcessEnv;
3
+ stdio: 'inherit' | 'ignore';
4
+ resolveFrom: string;
5
+ cwd: string;
6
+ onBinaryFound: (binaryLocation: string) => void;
7
+ }): Promise<void>;
8
+ //# sourceMappingURL=spawn-local.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn-local.d.ts","sourceRoot":"","sources":["../../src/process/spawn-local.ts"],"names":[],"mappings":"AAGA,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;IACtB,KAAK,EAAE,SAAS,GAAG,QAAQ,CAAA;IAE3B,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAA;CAChD,GACA,OAAO,CAAC,IAAI,CAAC,CAgCf"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ spawnLocal: ()=>spawnLocal
28
+ });
29
+ const external_node_child_process_namespaceObject = require("node:child_process");
30
+ const external_utils_js_namespaceObject = require("./utils.js");
31
+ async function spawnLocal(binaryName, args, options) {
32
+ let binaryLocation;
33
+ try {
34
+ binaryLocation = (0, external_utils_js_namespaceObject.resolveBinaryPath)(options.env.PATH ?? '', options.resolveFrom, binaryName);
35
+ options.onBinaryFound(binaryLocation);
36
+ } catch (e) {
37
+ console.error(e);
38
+ throw new Error(`Binary ${binaryName} not found. Make sure postinstall script was allowed if it installs the binary`);
39
+ }
40
+ const child = (0, external_node_child_process_namespaceObject.spawn)(binaryLocation, [
41
+ ...args
42
+ ], {
43
+ shell: true,
44
+ stdio: options?.stdio ?? 'inherit',
45
+ env: options.env,
46
+ cwd: options.cwd
47
+ });
48
+ await new Promise((resolve, reject)=>{
49
+ child.on('close', (code)=>{
50
+ if (0 === code) resolve();
51
+ else reject(new Error(`Command failed with code ${code}`));
52
+ });
53
+ child.on('error', (error)=>{
54
+ reject(error);
55
+ });
56
+ });
57
+ }
58
+ exports.spawnLocal = __webpack_exports__.spawnLocal;
59
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
60
+ "spawnLocal"
61
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
62
+ Object.defineProperty(exports, '__esModule', {
63
+ value: true
64
+ });
@@ -0,0 +1,30 @@
1
+ import { spawn } from "node:child_process";
2
+ import { resolveBinaryPath } from "./utils.mjs";
3
+ async function spawnLocal(binaryName, args, options) {
4
+ let binaryLocation;
5
+ try {
6
+ binaryLocation = resolveBinaryPath(options.env.PATH ?? '', options.resolveFrom, binaryName);
7
+ options.onBinaryFound(binaryLocation);
8
+ } catch (e) {
9
+ console.error(e);
10
+ throw new Error(`Binary ${binaryName} not found. Make sure postinstall script was allowed if it installs the binary`);
11
+ }
12
+ const child = spawn(binaryLocation, [
13
+ ...args
14
+ ], {
15
+ shell: true,
16
+ stdio: options?.stdio ?? 'inherit',
17
+ env: options.env,
18
+ cwd: options.cwd
19
+ });
20
+ await new Promise((resolve, reject)=>{
21
+ child.on('close', (code)=>{
22
+ if (0 === code) resolve();
23
+ else reject(new Error(`Command failed with code ${code}`));
24
+ });
25
+ child.on('error', (error)=>{
26
+ reject(error);
27
+ });
28
+ });
29
+ }
30
+ export { spawnLocal };
@@ -0,0 +1,3 @@
1
+ export declare const buildLocalBinaryPaths: (cwd: string) => string[];
2
+ export declare function resolveBinaryPath(envPath: string, cwd: string, binName: string): string;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/process/utils.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,KAAG,MAAM,EAKzD,CAAA;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAWvF"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ buildLocalBinaryPaths: ()=>buildLocalBinaryPaths,
37
+ resolveBinaryPath: ()=>resolveBinaryPath
38
+ });
39
+ const external_node_path_namespaceObject = require("node:path");
40
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
41
+ const external_node_fs_namespaceObject = require("node:fs");
42
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
43
+ const getLocalPaths = (startPath)=>{
44
+ const paths = [];
45
+ let currentPath = startPath;
46
+ while(true){
47
+ paths.push(currentPath);
48
+ const parentPath = external_node_path_default().resolve(currentPath, '..');
49
+ if (parentPath === currentPath) break;
50
+ currentPath = parentPath;
51
+ }
52
+ return paths;
53
+ };
54
+ const buildLocalBinaryPaths = (cwd)=>{
55
+ const localPaths = getLocalPaths(external_node_path_default().resolve(cwd)).map((localPath)=>external_node_path_default().join(localPath, 'node_modules/.bin'));
56
+ return localPaths;
57
+ };
58
+ function resolveBinaryPath(envPath, cwd, binName) {
59
+ const envLocations = envPath.split(external_node_path_default().delimiter);
60
+ const localLocations = buildLocalBinaryPaths(cwd);
61
+ const directories = [
62
+ ...new Set([
63
+ ...localLocations,
64
+ ...envLocations
65
+ ])
66
+ ];
67
+ for (const directory of directories){
68
+ const binaryPath = external_node_path_default().join(directory, binName);
69
+ if (external_node_fs_default().existsSync(binaryPath)) return binaryPath;
70
+ }
71
+ throw new Error(`Binary ${binName} not found`);
72
+ }
73
+ exports.buildLocalBinaryPaths = __webpack_exports__.buildLocalBinaryPaths;
74
+ exports.resolveBinaryPath = __webpack_exports__.resolveBinaryPath;
75
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
76
+ "buildLocalBinaryPaths",
77
+ "resolveBinaryPath"
78
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
79
+ Object.defineProperty(exports, '__esModule', {
80
+ value: true
81
+ });
@@ -0,0 +1,33 @@
1
+ import node_path from "node:path";
2
+ import node_fs from "node:fs";
3
+ const getLocalPaths = (startPath)=>{
4
+ const paths = [];
5
+ let currentPath = startPath;
6
+ while(true){
7
+ paths.push(currentPath);
8
+ const parentPath = node_path.resolve(currentPath, '..');
9
+ if (parentPath === currentPath) break;
10
+ currentPath = parentPath;
11
+ }
12
+ return paths;
13
+ };
14
+ const buildLocalBinaryPaths = (cwd)=>{
15
+ const localPaths = getLocalPaths(node_path.resolve(cwd)).map((localPath)=>node_path.join(localPath, 'node_modules/.bin'));
16
+ return localPaths;
17
+ };
18
+ function resolveBinaryPath(envPath, cwd, binName) {
19
+ const envLocations = envPath.split(node_path.delimiter);
20
+ const localLocations = buildLocalBinaryPaths(cwd);
21
+ const directories = [
22
+ ...new Set([
23
+ ...localLocations,
24
+ ...envLocations
25
+ ])
26
+ ];
27
+ for (const directory of directories){
28
+ const binaryPath = node_path.join(directory, binName);
29
+ if (node_fs.existsSync(binaryPath)) return binaryPath;
30
+ }
31
+ throw new Error(`Binary ${binName} not found`);
32
+ }
33
+ export { buildLocalBinaryPaths, resolveBinaryPath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/core",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -40,6 +40,11 @@
40
40
  "types": "./dist/utils/index.d.ts",
41
41
  "require": "./dist/utils/index.js",
42
42
  "import": "./dist/utils/index.mjs"
43
+ },
44
+ "./process": {
45
+ "types": "./dist/process/index.d.ts",
46
+ "require": "./dist/process/index.js",
47
+ "import": "./dist/process/index.mjs"
43
48
  }
44
49
  },
45
50
  "devDependencies": {
@@ -39,7 +39,7 @@ export type ExceptionList = Exception[]
39
39
 
40
40
  export interface Mechanism {
41
41
  handled?: boolean
42
- type?: 'generic' | 'onunhandledrejection' | 'onuncaughtexception' | 'middleware'
42
+ type?: 'generic' | 'onunhandledrejection' | 'onuncaughtexception' | 'onconsole' | 'middleware'
43
43
  source?: string
44
44
  synthetic?: boolean
45
45
  }
@@ -0,0 +1 @@
1
+ export * from './spawn-local'
@@ -0,0 +1,47 @@
1
+ import { spawn } from 'node:child_process'
2
+ import { resolveBinaryPath } from './utils'
3
+
4
+ export async function spawnLocal(
5
+ binaryName: string,
6
+ args: string[],
7
+ options: {
8
+ env: NodeJS.ProcessEnv
9
+ stdio: 'inherit' | 'ignore'
10
+ // We start traversing the file system tree from this directory and we go up until we find the binary
11
+ resolveFrom: string
12
+ cwd: string
13
+ onBinaryFound: (binaryLocation: string) => void
14
+ }
15
+ ): Promise<void> {
16
+ let binaryLocation
17
+ try {
18
+ binaryLocation = resolveBinaryPath(options.env.PATH ?? '', options.resolveFrom, binaryName)
19
+ options.onBinaryFound(binaryLocation)
20
+ } catch (e) {
21
+ console.error(e)
22
+ throw new Error(
23
+ `Binary ${binaryName} not found. Make sure postinstall script was allowed if it installs the binary`
24
+ )
25
+ }
26
+
27
+ const child = spawn(binaryLocation, [...args], {
28
+ shell: true,
29
+ stdio: options?.stdio ?? 'inherit',
30
+ env: options.env,
31
+ cwd: options.cwd,
32
+ })
33
+
34
+ await new Promise<void>((resolve, reject) => {
35
+ child.on('close', (code) => {
36
+ if (code === 0) {
37
+ resolve()
38
+ } else {
39
+ reject(new Error(`Command failed with code ${code}`))
40
+ }
41
+ })
42
+
43
+ child.on('error', (error) => {
44
+ reject(error)
45
+ })
46
+ })
47
+ }
@@ -0,0 +1,11 @@
1
+ import { buildLocalBinaryPaths } from './utils'
2
+
3
+ describe('buildLocalBinaryPaths', () => {
4
+ it('generates possible binary locations', () => {
5
+ const cwd = '/home/user'
6
+ const result = buildLocalBinaryPaths(cwd)
7
+ expect(result.includes('/home/user/node_modules/.bin')).toBe(true)
8
+ expect(result.includes('/home/node_modules/.bin')).toBe(true)
9
+ expect(result.includes('/node_modules/.bin')).toBe(true)
10
+ })
11
+ })
@@ -0,0 +1,41 @@
1
+ import path from 'node:path'
2
+ import fs from 'node:fs'
3
+
4
+ const getLocalPaths = (startPath: string): string[] => {
5
+ const paths: string[] = []
6
+ let currentPath = startPath
7
+
8
+ while (true) {
9
+ paths.push(currentPath)
10
+ const parentPath = path.resolve(currentPath, '..')
11
+
12
+ // If we've reached the root directory, stop
13
+ if (parentPath === currentPath) {
14
+ break
15
+ }
16
+
17
+ currentPath = parentPath
18
+ }
19
+
20
+ return paths
21
+ }
22
+
23
+ export const buildLocalBinaryPaths = (cwd: string): string[] => {
24
+ const localPaths = getLocalPaths(path.resolve(cwd)).map((localPath: string) =>
25
+ path.join(localPath, 'node_modules/.bin')
26
+ )
27
+ return localPaths
28
+ }
29
+
30
+ export function resolveBinaryPath(envPath: string, cwd: string, binName: string): string {
31
+ const envLocations = envPath.split(path.delimiter)
32
+ const localLocations = buildLocalBinaryPaths(cwd)
33
+ const directories = [...new Set([...localLocations, ...envLocations])]
34
+ for (const directory of directories) {
35
+ const binaryPath = path.join(directory, binName)
36
+ if (fs.existsSync(binaryPath)) {
37
+ return binaryPath
38
+ }
39
+ }
40
+ throw new Error(`Binary ${binName} not found`)
41
+ }