posthog-node 5.9.0 → 5.9.1

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.
Files changed (74) hide show
  1. package/dist/client.d.ts.map +1 -1
  2. package/dist/client.js +1 -2
  3. package/dist/client.mjs +1 -2
  4. package/dist/entrypoints/index.edge.d.ts.map +1 -1
  5. package/dist/entrypoints/index.edge.js +12 -5
  6. package/dist/entrypoints/index.edge.mjs +10 -3
  7. package/dist/entrypoints/index.node.d.ts.map +1 -1
  8. package/dist/entrypoints/index.node.js +23 -15
  9. package/dist/entrypoints/index.node.mjs +14 -6
  10. package/dist/extensions/error-tracking/autocapture.d.ts +3 -3
  11. package/dist/extensions/error-tracking/autocapture.d.ts.map +1 -1
  12. package/dist/extensions/error-tracking/index.d.ts +3 -4
  13. package/dist/extensions/error-tracking/index.d.ts.map +1 -1
  14. package/dist/extensions/error-tracking/index.js +3 -3
  15. package/dist/extensions/error-tracking/index.mjs +3 -3
  16. package/dist/extensions/error-tracking/modifiers/context-lines.node.d.ts +5 -0
  17. package/dist/extensions/error-tracking/modifiers/context-lines.node.d.ts.map +1 -0
  18. package/dist/extensions/error-tracking/{context-lines.node.js → modifiers/context-lines.node.js} +3 -3
  19. package/dist/extensions/error-tracking/{context-lines.node.mjs → modifiers/context-lines.node.mjs} +3 -3
  20. package/dist/extensions/error-tracking/modifiers/module.node.d.ts +3 -0
  21. package/dist/extensions/error-tracking/modifiers/module.node.d.ts.map +1 -0
  22. package/dist/extensions/error-tracking/{get-module.node.js → modifiers/module.node.js} +10 -3
  23. package/dist/extensions/error-tracking/{get-module.node.mjs → modifiers/module.node.mjs} +8 -1
  24. package/dist/extensions/express.d.ts.map +1 -1
  25. package/dist/extensions/sentry-integration.d.ts +3 -3
  26. package/dist/extensions/sentry-integration.d.ts.map +1 -1
  27. package/dist/version.d.ts +1 -1
  28. package/dist/version.js +1 -1
  29. package/dist/version.mjs +1 -1
  30. package/package.json +2 -2
  31. package/src/client.ts +1 -1
  32. package/src/entrypoints/index.edge.ts +11 -4
  33. package/src/entrypoints/index.node.ts +14 -5
  34. package/src/extensions/error-tracking/autocapture.ts +6 -4
  35. package/src/extensions/error-tracking/index.ts +10 -9
  36. package/src/extensions/error-tracking/{context-lines.node.ts → modifiers/context-lines.node.ts} +23 -11
  37. package/src/extensions/error-tracking/{get-module.node.ts → modifiers/module.node.ts} +12 -1
  38. package/src/extensions/express.ts +2 -1
  39. package/src/extensions/sentry-integration.ts +4 -4
  40. package/src/version.ts +1 -1
  41. package/dist/extensions/error-tracking/chunk-ids.d.ts +0 -5
  42. package/dist/extensions/error-tracking/chunk-ids.d.ts.map +0 -1
  43. package/dist/extensions/error-tracking/chunk-ids.js +0 -68
  44. package/dist/extensions/error-tracking/chunk-ids.mjs +0 -34
  45. package/dist/extensions/error-tracking/context-lines.node.d.ts +0 -5
  46. package/dist/extensions/error-tracking/context-lines.node.d.ts.map +0 -1
  47. package/dist/extensions/error-tracking/error-conversion.d.ts +0 -4
  48. package/dist/extensions/error-tracking/error-conversion.d.ts.map +0 -1
  49. package/dist/extensions/error-tracking/error-conversion.js +0 -183
  50. package/dist/extensions/error-tracking/error-conversion.mjs +0 -146
  51. package/dist/extensions/error-tracking/get-module.node.d.ts +0 -3
  52. package/dist/extensions/error-tracking/get-module.node.d.ts.map +0 -1
  53. package/dist/extensions/error-tracking/reduceable-cache.d.ts +0 -13
  54. package/dist/extensions/error-tracking/reduceable-cache.d.ts.map +0 -1
  55. package/dist/extensions/error-tracking/reduceable-cache.js +0 -57
  56. package/dist/extensions/error-tracking/reduceable-cache.mjs +0 -23
  57. package/dist/extensions/error-tracking/stack-parser.d.ts +0 -3
  58. package/dist/extensions/error-tracking/stack-parser.d.ts.map +0 -1
  59. package/dist/extensions/error-tracking/stack-parser.js +0 -148
  60. package/dist/extensions/error-tracking/stack-parser.mjs +0 -114
  61. package/dist/extensions/error-tracking/type-checking.d.ts +0 -8
  62. package/dist/extensions/error-tracking/type-checking.d.ts.map +0 -1
  63. package/dist/extensions/error-tracking/type-checking.js +0 -80
  64. package/dist/extensions/error-tracking/type-checking.mjs +0 -31
  65. package/dist/extensions/error-tracking/types.d.ts +0 -61
  66. package/dist/extensions/error-tracking/types.d.ts.map +0 -1
  67. package/dist/extensions/error-tracking/types.js +0 -43
  68. package/dist/extensions/error-tracking/types.mjs +0 -9
  69. package/src/extensions/error-tracking/chunk-ids.ts +0 -58
  70. package/src/extensions/error-tracking/error-conversion.ts +0 -291
  71. package/src/extensions/error-tracking/reduceable-cache.ts +0 -39
  72. package/src/extensions/error-tracking/stack-parser.ts +0 -212
  73. package/src/extensions/error-tracking/type-checking.ts +0 -40
  74. package/src/extensions/error-tracking/types.ts +0 -71
@@ -1,146 +0,0 @@
1
- import { getFilenameToChunkIdMap } from "./chunk-ids.mjs";
2
- import { isError, isErrorEvent, isEvent, isPlainObject } from "./type-checking.mjs";
3
- async function propertiesFromUnknownInput(stackParser, frameModifiers, input, hint) {
4
- const providedMechanism = hint && hint.mechanism;
5
- const mechanism = providedMechanism || {
6
- handled: true,
7
- type: 'generic'
8
- };
9
- const errorList = getErrorList(mechanism, input, hint);
10
- const exceptionList = await Promise.all(errorList.map(async (error)=>{
11
- const exception = await exceptionFromError(stackParser, frameModifiers, error);
12
- exception.value = exception.value || '';
13
- exception.type = exception.type || 'Error';
14
- exception.mechanism = mechanism;
15
- return exception;
16
- }));
17
- const properties = {
18
- $exception_list: exceptionList
19
- };
20
- return properties;
21
- }
22
- function getErrorList(mechanism, input, hint) {
23
- const error = getError(mechanism, input, hint);
24
- if (error.cause) return [
25
- error,
26
- ...getErrorList(mechanism, error.cause, hint)
27
- ];
28
- return [
29
- error
30
- ];
31
- }
32
- function getError(mechanism, exception, hint) {
33
- if (isError(exception)) return exception;
34
- mechanism.synthetic = true;
35
- if (isPlainObject(exception)) {
36
- const errorFromProp = getErrorPropertyFromObject(exception);
37
- if (errorFromProp) return errorFromProp;
38
- const message = getMessageForObject(exception);
39
- const ex = hint?.syntheticException || new Error(message);
40
- ex.message = message;
41
- return ex;
42
- }
43
- const ex = hint?.syntheticException || new Error(exception);
44
- ex.message = `${exception}`;
45
- return ex;
46
- }
47
- function getErrorPropertyFromObject(obj) {
48
- for(const prop in obj)if (Object.prototype.hasOwnProperty.call(obj, prop)) {
49
- const value = obj[prop];
50
- if (isError(value)) return value;
51
- }
52
- }
53
- function getMessageForObject(exception) {
54
- if ('name' in exception && 'string' == typeof exception.name) {
55
- let message = `'${exception.name}' captured as exception`;
56
- if ('message' in exception && 'string' == typeof exception.message) message += ` with message '${exception.message}'`;
57
- return message;
58
- }
59
- if ('message' in exception && 'string' == typeof exception.message) return exception.message;
60
- const keys = extractExceptionKeysForMessage(exception);
61
- if (isErrorEvent(exception)) return `Event \`ErrorEvent\` captured as exception with message \`${exception.message}\``;
62
- const className = getObjectClassName(exception);
63
- return `${className && 'Object' !== className ? `'${className}'` : 'Object'} captured as exception with keys: ${keys}`;
64
- }
65
- function getObjectClassName(obj) {
66
- try {
67
- const prototype = Object.getPrototypeOf(obj);
68
- return prototype ? prototype.constructor.name : void 0;
69
- } catch (e) {}
70
- }
71
- function extractExceptionKeysForMessage(exception, maxLength = 40) {
72
- const keys = Object.keys(convertToPlainObject(exception));
73
- keys.sort();
74
- const firstKey = keys[0];
75
- if (!firstKey) return '[object has no keys]';
76
- if (firstKey.length >= maxLength) return truncate(firstKey, maxLength);
77
- for(let includedKeys = keys.length; includedKeys > 0; includedKeys--){
78
- const serialized = keys.slice(0, includedKeys).join(', ');
79
- if (!(serialized.length > maxLength)) {
80
- if (includedKeys === keys.length) return serialized;
81
- return truncate(serialized, maxLength);
82
- }
83
- }
84
- return '';
85
- }
86
- function truncate(str, max = 0) {
87
- if ('string' != typeof str || 0 === max) return str;
88
- return str.length <= max ? str : `${str.slice(0, max)}...`;
89
- }
90
- function convertToPlainObject(value) {
91
- if (isError(value)) return {
92
- message: value.message,
93
- name: value.name,
94
- stack: value.stack,
95
- ...getOwnProperties(value)
96
- };
97
- if (!isEvent(value)) return value;
98
- {
99
- const newObj = {
100
- type: value.type,
101
- target: serializeEventTarget(value.target),
102
- currentTarget: serializeEventTarget(value.currentTarget),
103
- ...getOwnProperties(value)
104
- };
105
- return newObj;
106
- }
107
- }
108
- function getOwnProperties(obj) {
109
- if ('object' != typeof obj || null === obj) return {};
110
- {
111
- const extractedProps = {};
112
- for(const property in obj)if (Object.prototype.hasOwnProperty.call(obj, property)) extractedProps[property] = obj[property];
113
- return extractedProps;
114
- }
115
- }
116
- function serializeEventTarget(target) {
117
- try {
118
- return Object.prototype.toString.call(target);
119
- } catch (_oO) {
120
- return '<unknown>';
121
- }
122
- }
123
- async function exceptionFromError(stackParser, frameModifiers, error) {
124
- const exception = {
125
- type: error.name || error.constructor.name,
126
- value: error.message
127
- };
128
- let frames = parseStackFrames(stackParser, error);
129
- for (const modifier of frameModifiers)frames = await modifier(frames);
130
- if (frames.length) exception.stacktrace = {
131
- frames,
132
- type: 'raw'
133
- };
134
- return exception;
135
- }
136
- function parseStackFrames(stackParser, error) {
137
- return applyChunkIds(stackParser(error.stack || '', 1), stackParser);
138
- }
139
- function applyChunkIds(frames, parser) {
140
- const filenameChunkIdMap = getFilenameToChunkIdMap(parser);
141
- frames.forEach((frame)=>{
142
- if (frame.filename && filenameChunkIdMap) frame.chunk_id = filenameChunkIdMap[frame.filename];
143
- });
144
- return frames;
145
- }
146
- export { applyChunkIds, propertiesFromUnknownInput };
@@ -1,3 +0,0 @@
1
- /** Creates a function that gets the module name from a filename */
2
- export declare function createGetModuleFromFilename(basePath?: string, isWindows?: boolean): (filename: string | undefined) => string | undefined;
3
- //# sourceMappingURL=get-module.node.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-module.node.d.ts","sourceRoot":"","sources":["../../../src/extensions/error-tracking/get-module.node.ts"],"names":[],"mappings":"AAKA,mEAAmE;AACnE,wBAAgB,2BAA2B,CACzC,QAAQ,GAAE,MAAmE,EAC7E,SAAS,GAAE,OAAsB,GAChC,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,GAAG,SAAS,CAwCtD"}
@@ -1,13 +0,0 @@
1
- /** A simple Least Recently Used map */
2
- export declare class ReduceableCache<K, V> {
3
- private readonly _maxSize;
4
- private readonly _cache;
5
- constructor(_maxSize: number);
6
- /** Get an entry or undefined if it was not in the cache. Re-inserts to update the recently used order */
7
- get(key: K): V | undefined;
8
- /** Insert an entry and evict an older entry if we've reached maxSize */
9
- set(key: K, value: V): void;
10
- /** Remove an entry and return the entry if it was in the cache */
11
- reduce(): void;
12
- }
13
- //# sourceMappingURL=reduceable-cache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reduceable-cache.d.ts","sourceRoot":"","sources":["../../../src/extensions/error-tracking/reduceable-cache.ts"],"names":[],"mappings":"AAGA,uCAAuC;AACvC,qBAAa,eAAe,CAAC,CAAC,EAAE,CAAC;IAGZ,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAF5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;gBAEE,QAAQ,EAAE,MAAM;IAIpD,yGAAyG;IAClG,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAWjC,wEAAwE;IACjE,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAIlC,kEAAkE;IAC3D,MAAM,IAAI,IAAI;CAStB"}
@@ -1,57 +0,0 @@
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
- ReduceableCache: ()=>ReduceableCache
28
- });
29
- class ReduceableCache {
30
- constructor(_maxSize){
31
- this._maxSize = _maxSize;
32
- this._cache = new Map();
33
- }
34
- get(key) {
35
- const value = this._cache.get(key);
36
- if (void 0 === value) return;
37
- this._cache.delete(key);
38
- this._cache.set(key, value);
39
- return value;
40
- }
41
- set(key, value) {
42
- this._cache.set(key, value);
43
- }
44
- reduce() {
45
- while(this._cache.size >= this._maxSize){
46
- const value = this._cache.keys().next().value;
47
- if (value) this._cache.delete(value);
48
- }
49
- }
50
- }
51
- exports.ReduceableCache = __webpack_exports__.ReduceableCache;
52
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
53
- "ReduceableCache"
54
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
55
- Object.defineProperty(exports, '__esModule', {
56
- value: true
57
- });
@@ -1,23 +0,0 @@
1
- class ReduceableCache {
2
- constructor(_maxSize){
3
- this._maxSize = _maxSize;
4
- this._cache = new Map();
5
- }
6
- get(key) {
7
- const value = this._cache.get(key);
8
- if (void 0 === value) return;
9
- this._cache.delete(key);
10
- this._cache.set(key, value);
11
- return value;
12
- }
13
- set(key, value) {
14
- this._cache.set(key, value);
15
- }
16
- reduce() {
17
- while(this._cache.size >= this._maxSize){
18
- const value = this._cache.keys().next().value;
19
- if (value) this._cache.delete(value);
20
- }
21
- }
22
- }
23
- export { ReduceableCache };
@@ -1,3 +0,0 @@
1
- import { GetModuleFn, StackParser } from './types';
2
- export declare function createStackParser(getModule?: GetModuleFn): StackParser;
3
- //# sourceMappingURL=stack-parser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stack-parser.d.ts","sourceRoot":"","sources":["../../../src/extensions/error-tracking/stack-parser.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAkD,WAAW,EAAE,MAAM,SAAS,CAAA;AAmJlG,wBAAgB,iBAAiB,CAAC,SAAS,CAAC,EAAE,WAAW,GAAG,WAAW,CAyCtE"}
@@ -1,148 +0,0 @@
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
- createStackParser: ()=>createStackParser
28
- });
29
- const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
30
- const STACKTRACE_FRAME_LIMIT = 50;
31
- const UNKNOWN_FUNCTION = '?';
32
- function node(getModule) {
33
- const FILENAME_MATCH = /^\s*[-]{4,}$/;
34
- const FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
35
- return (line)=>{
36
- const lineMatch = line.match(FULL_MATCH);
37
- if (lineMatch) {
38
- let object;
39
- let method;
40
- let functionName;
41
- let typeName;
42
- let methodName;
43
- if (lineMatch[1]) {
44
- functionName = lineMatch[1];
45
- let methodStart = functionName.lastIndexOf('.');
46
- if ('.' === functionName[methodStart - 1]) methodStart--;
47
- if (methodStart > 0) {
48
- object = functionName.slice(0, methodStart);
49
- method = functionName.slice(methodStart + 1);
50
- const objectEnd = object.indexOf('.Module');
51
- if (objectEnd > 0) {
52
- functionName = functionName.slice(objectEnd + 1);
53
- object = object.slice(0, objectEnd);
54
- }
55
- }
56
- typeName = void 0;
57
- }
58
- if (method) {
59
- typeName = object;
60
- methodName = method;
61
- }
62
- if ('<anonymous>' === method) {
63
- methodName = void 0;
64
- functionName = void 0;
65
- }
66
- if (void 0 === functionName) {
67
- methodName = methodName || UNKNOWN_FUNCTION;
68
- functionName = typeName ? `${typeName}.${methodName}` : methodName;
69
- }
70
- let filename = lineMatch[2]?.startsWith('file://') ? lineMatch[2].slice(7) : lineMatch[2];
71
- const isNative = 'native' === lineMatch[5];
72
- if (filename?.match(/\/[A-Z]:/)) filename = filename.slice(1);
73
- if (!filename && lineMatch[5] && !isNative) filename = lineMatch[5];
74
- return {
75
- filename: filename ? decodeURI(filename) : void 0,
76
- module: getModule ? getModule(filename) : void 0,
77
- function: functionName,
78
- lineno: _parseIntOrUndefined(lineMatch[3]),
79
- colno: _parseIntOrUndefined(lineMatch[4]),
80
- in_app: filenameIsInApp(filename || '', isNative),
81
- platform: "node:javascript"
82
- };
83
- }
84
- if (line.match(FILENAME_MATCH)) return {
85
- filename: line,
86
- platform: "node:javascript"
87
- };
88
- };
89
- }
90
- function filenameIsInApp(filename, isNative = false) {
91
- const isInternal = isNative || filename && !filename.startsWith('/') && !filename.match(/^[A-Z]:/) && !filename.startsWith('.') && !filename.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//);
92
- return !isInternal && void 0 !== filename && !filename.includes('node_modules/');
93
- }
94
- function _parseIntOrUndefined(input) {
95
- return parseInt(input || '', 10) || void 0;
96
- }
97
- function nodeStackLineParser(getModule) {
98
- return [
99
- 90,
100
- node(getModule)
101
- ];
102
- }
103
- function createStackParser(getModule) {
104
- const parsers = [
105
- nodeStackLineParser(getModule)
106
- ];
107
- const sortedParsers = parsers.sort((a, b)=>a[0] - b[0]).map((p)=>p[1]);
108
- return (stack, skipFirstLines = 0)=>{
109
- const frames = [];
110
- const lines = stack.split('\n');
111
- for(let i = skipFirstLines; i < lines.length; i++){
112
- const line = lines[i];
113
- if (line.length > 1024) continue;
114
- const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, '$1') : line;
115
- if (!cleanedLine.match(/\S*Error: /)) {
116
- for (const parser of sortedParsers){
117
- const frame = parser(cleanedLine);
118
- if (frame) {
119
- frames.push(frame);
120
- break;
121
- }
122
- }
123
- if (frames.length >= STACKTRACE_FRAME_LIMIT) break;
124
- }
125
- }
126
- return reverseAndStripFrames(frames);
127
- };
128
- }
129
- function reverseAndStripFrames(stack) {
130
- if (!stack.length) return [];
131
- const localStack = Array.from(stack);
132
- localStack.reverse();
133
- return localStack.slice(0, STACKTRACE_FRAME_LIMIT).map((frame)=>({
134
- ...frame,
135
- filename: frame.filename || getLastStackFrame(localStack).filename,
136
- function: frame.function || UNKNOWN_FUNCTION
137
- }));
138
- }
139
- function getLastStackFrame(arr) {
140
- return arr[arr.length - 1] || {};
141
- }
142
- exports.createStackParser = __webpack_exports__.createStackParser;
143
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
144
- "createStackParser"
145
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
146
- Object.defineProperty(exports, '__esModule', {
147
- value: true
148
- });
@@ -1,114 +0,0 @@
1
- const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
2
- const STACKTRACE_FRAME_LIMIT = 50;
3
- const UNKNOWN_FUNCTION = '?';
4
- function node(getModule) {
5
- const FILENAME_MATCH = /^\s*[-]{4,}$/;
6
- const FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
7
- return (line)=>{
8
- const lineMatch = line.match(FULL_MATCH);
9
- if (lineMatch) {
10
- let object;
11
- let method;
12
- let functionName;
13
- let typeName;
14
- let methodName;
15
- if (lineMatch[1]) {
16
- functionName = lineMatch[1];
17
- let methodStart = functionName.lastIndexOf('.');
18
- if ('.' === functionName[methodStart - 1]) methodStart--;
19
- if (methodStart > 0) {
20
- object = functionName.slice(0, methodStart);
21
- method = functionName.slice(methodStart + 1);
22
- const objectEnd = object.indexOf('.Module');
23
- if (objectEnd > 0) {
24
- functionName = functionName.slice(objectEnd + 1);
25
- object = object.slice(0, objectEnd);
26
- }
27
- }
28
- typeName = void 0;
29
- }
30
- if (method) {
31
- typeName = object;
32
- methodName = method;
33
- }
34
- if ('<anonymous>' === method) {
35
- methodName = void 0;
36
- functionName = void 0;
37
- }
38
- if (void 0 === functionName) {
39
- methodName = methodName || UNKNOWN_FUNCTION;
40
- functionName = typeName ? `${typeName}.${methodName}` : methodName;
41
- }
42
- let filename = lineMatch[2]?.startsWith('file://') ? lineMatch[2].slice(7) : lineMatch[2];
43
- const isNative = 'native' === lineMatch[5];
44
- if (filename?.match(/\/[A-Z]:/)) filename = filename.slice(1);
45
- if (!filename && lineMatch[5] && !isNative) filename = lineMatch[5];
46
- return {
47
- filename: filename ? decodeURI(filename) : void 0,
48
- module: getModule ? getModule(filename) : void 0,
49
- function: functionName,
50
- lineno: _parseIntOrUndefined(lineMatch[3]),
51
- colno: _parseIntOrUndefined(lineMatch[4]),
52
- in_app: filenameIsInApp(filename || '', isNative),
53
- platform: "node:javascript"
54
- };
55
- }
56
- if (line.match(FILENAME_MATCH)) return {
57
- filename: line,
58
- platform: "node:javascript"
59
- };
60
- };
61
- }
62
- function filenameIsInApp(filename, isNative = false) {
63
- const isInternal = isNative || filename && !filename.startsWith('/') && !filename.match(/^[A-Z]:/) && !filename.startsWith('.') && !filename.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//);
64
- return !isInternal && void 0 !== filename && !filename.includes('node_modules/');
65
- }
66
- function _parseIntOrUndefined(input) {
67
- return parseInt(input || '', 10) || void 0;
68
- }
69
- function nodeStackLineParser(getModule) {
70
- return [
71
- 90,
72
- node(getModule)
73
- ];
74
- }
75
- function createStackParser(getModule) {
76
- const parsers = [
77
- nodeStackLineParser(getModule)
78
- ];
79
- const sortedParsers = parsers.sort((a, b)=>a[0] - b[0]).map((p)=>p[1]);
80
- return (stack, skipFirstLines = 0)=>{
81
- const frames = [];
82
- const lines = stack.split('\n');
83
- for(let i = skipFirstLines; i < lines.length; i++){
84
- const line = lines[i];
85
- if (line.length > 1024) continue;
86
- const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, '$1') : line;
87
- if (!cleanedLine.match(/\S*Error: /)) {
88
- for (const parser of sortedParsers){
89
- const frame = parser(cleanedLine);
90
- if (frame) {
91
- frames.push(frame);
92
- break;
93
- }
94
- }
95
- if (frames.length >= STACKTRACE_FRAME_LIMIT) break;
96
- }
97
- }
98
- return reverseAndStripFrames(frames);
99
- };
100
- }
101
- function reverseAndStripFrames(stack) {
102
- if (!stack.length) return [];
103
- const localStack = Array.from(stack);
104
- localStack.reverse();
105
- return localStack.slice(0, STACKTRACE_FRAME_LIMIT).map((frame)=>({
106
- ...frame,
107
- filename: frame.filename || getLastStackFrame(localStack).filename,
108
- function: frame.function || UNKNOWN_FUNCTION
109
- }));
110
- }
111
- function getLastStackFrame(arr) {
112
- return arr[arr.length - 1] || {};
113
- }
114
- export { createStackParser };
@@ -1,8 +0,0 @@
1
- import { PolymorphicEvent } from './types';
2
- export declare function isEvent(candidate: unknown): candidate is PolymorphicEvent;
3
- export declare function isPlainObject(candidate: unknown): candidate is Record<string, unknown>;
4
- export declare function isError(candidate: unknown): candidate is Error;
5
- export declare function isInstanceOf(candidate: unknown, base: any): boolean;
6
- export declare function isErrorEvent(event: unknown): boolean;
7
- export declare function isBuiltin(candidate: unknown, className: string): boolean;
8
- //# sourceMappingURL=type-checking.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-checking.d.ts","sourceRoot":"","sources":["../../../src/extensions/error-tracking/type-checking.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C,wBAAgB,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,gBAAgB,CAEzE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEtF;AAED,wBAAgB,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,KAAK,CAU9D;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAMnE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpD;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAExE"}
@@ -1,80 +0,0 @@
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
- isBuiltin: ()=>isBuiltin,
28
- isError: ()=>isError,
29
- isErrorEvent: ()=>isErrorEvent,
30
- isEvent: ()=>isEvent,
31
- isInstanceOf: ()=>isInstanceOf,
32
- isPlainObject: ()=>isPlainObject
33
- });
34
- function isEvent(candidate) {
35
- return 'undefined' != typeof Event && isInstanceOf(candidate, Event);
36
- }
37
- function isPlainObject(candidate) {
38
- return isBuiltin(candidate, 'Object');
39
- }
40
- function isError(candidate) {
41
- switch(Object.prototype.toString.call(candidate)){
42
- case '[object Error]':
43
- case '[object Exception]':
44
- case '[object DOMException]':
45
- case '[object WebAssembly.Exception]':
46
- return true;
47
- default:
48
- return isInstanceOf(candidate, Error);
49
- }
50
- }
51
- function isInstanceOf(candidate, base) {
52
- try {
53
- return candidate instanceof base;
54
- } catch {
55
- return false;
56
- }
57
- }
58
- function isErrorEvent(event) {
59
- return isBuiltin(event, 'ErrorEvent');
60
- }
61
- function isBuiltin(candidate, className) {
62
- return Object.prototype.toString.call(candidate) === `[object ${className}]`;
63
- }
64
- exports.isBuiltin = __webpack_exports__.isBuiltin;
65
- exports.isError = __webpack_exports__.isError;
66
- exports.isErrorEvent = __webpack_exports__.isErrorEvent;
67
- exports.isEvent = __webpack_exports__.isEvent;
68
- exports.isInstanceOf = __webpack_exports__.isInstanceOf;
69
- exports.isPlainObject = __webpack_exports__.isPlainObject;
70
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
71
- "isBuiltin",
72
- "isError",
73
- "isErrorEvent",
74
- "isEvent",
75
- "isInstanceOf",
76
- "isPlainObject"
77
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
78
- Object.defineProperty(exports, '__esModule', {
79
- value: true
80
- });
@@ -1,31 +0,0 @@
1
- function isEvent(candidate) {
2
- return 'undefined' != typeof Event && isInstanceOf(candidate, Event);
3
- }
4
- function isPlainObject(candidate) {
5
- return isBuiltin(candidate, 'Object');
6
- }
7
- function isError(candidate) {
8
- switch(Object.prototype.toString.call(candidate)){
9
- case '[object Error]':
10
- case '[object Exception]':
11
- case '[object DOMException]':
12
- case '[object WebAssembly.Exception]':
13
- return true;
14
- default:
15
- return isInstanceOf(candidate, Error);
16
- }
17
- }
18
- function isInstanceOf(candidate, base) {
19
- try {
20
- return candidate instanceof base;
21
- } catch {
22
- return false;
23
- }
24
- }
25
- function isErrorEvent(event) {
26
- return isBuiltin(event, 'ErrorEvent');
27
- }
28
- function isBuiltin(candidate, className) {
29
- return Object.prototype.toString.call(candidate) === `[object ${className}]`;
30
- }
31
- export { isBuiltin, isError, isErrorEvent, isEvent, isInstanceOf, isPlainObject };