posthog-node 5.8.8 → 5.9.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/dist/{index.d.ts → client.d.ts} +7 -378
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +481 -0
- package/dist/client.mjs +437 -0
- package/dist/entrypoints/index.edge.d.ts +6 -0
- package/dist/entrypoints/index.edge.d.ts.map +1 -0
- package/dist/entrypoints/index.edge.js +89 -0
- package/dist/entrypoints/index.edge.mjs +12 -0
- package/dist/entrypoints/index.node.d.ts +6 -0
- package/dist/entrypoints/index.node.d.ts.map +1 -0
- package/dist/entrypoints/index.node.js +99 -0
- package/dist/entrypoints/index.node.mjs +16 -0
- package/dist/exports.d.ts +4 -0
- package/dist/exports.d.ts.map +1 -0
- package/dist/exports.js +78 -0
- package/dist/exports.mjs +3 -0
- package/dist/extensions/error-tracking/autocapture.d.ts +4 -0
- package/dist/extensions/error-tracking/autocapture.d.ts.map +1 -0
- package/dist/extensions/error-tracking/autocapture.js +68 -0
- package/dist/extensions/error-tracking/autocapture.mjs +31 -0
- package/dist/extensions/error-tracking/chunk-ids.d.ts +5 -0
- package/dist/extensions/error-tracking/chunk-ids.d.ts.map +1 -0
- package/dist/extensions/error-tracking/chunk-ids.js +68 -0
- package/dist/extensions/error-tracking/chunk-ids.mjs +34 -0
- package/dist/extensions/error-tracking/context-lines.node.d.ts +5 -0
- package/dist/extensions/error-tracking/context-lines.node.d.ts.map +1 -0
- package/dist/extensions/error-tracking/context-lines.node.js +227 -0
- package/dist/extensions/error-tracking/context-lines.node.mjs +187 -0
- package/dist/extensions/error-tracking/error-conversion.d.ts +4 -0
- package/dist/extensions/error-tracking/error-conversion.d.ts.map +1 -0
- package/dist/extensions/error-tracking/error-conversion.js +183 -0
- package/dist/extensions/error-tracking/error-conversion.mjs +146 -0
- package/dist/extensions/error-tracking/get-module.node.d.ts +3 -0
- package/dist/extensions/error-tracking/get-module.node.d.ts.map +1 -0
- package/dist/extensions/error-tracking/get-module.node.js +57 -0
- package/dist/extensions/error-tracking/get-module.node.mjs +23 -0
- package/dist/extensions/error-tracking/index.d.ts +20 -0
- package/dist/extensions/error-tracking/index.d.ts.map +1 -0
- package/dist/extensions/error-tracking/index.js +97 -0
- package/dist/extensions/error-tracking/index.mjs +63 -0
- package/dist/extensions/error-tracking/reduceable-cache.d.ts +13 -0
- package/dist/extensions/error-tracking/reduceable-cache.d.ts.map +1 -0
- package/dist/extensions/error-tracking/reduceable-cache.js +57 -0
- package/dist/extensions/error-tracking/reduceable-cache.mjs +23 -0
- package/dist/extensions/error-tracking/stack-parser.d.ts +3 -0
- package/dist/extensions/error-tracking/stack-parser.d.ts.map +1 -0
- package/dist/extensions/error-tracking/stack-parser.js +148 -0
- package/dist/extensions/error-tracking/stack-parser.mjs +114 -0
- package/dist/extensions/error-tracking/type-checking.d.ts +8 -0
- package/dist/extensions/error-tracking/type-checking.d.ts.map +1 -0
- package/dist/extensions/error-tracking/type-checking.js +80 -0
- package/dist/extensions/error-tracking/type-checking.mjs +31 -0
- package/dist/extensions/error-tracking/types.d.ts +61 -0
- package/dist/extensions/error-tracking/types.d.ts.map +1 -0
- package/dist/extensions/error-tracking/types.js +43 -0
- package/dist/extensions/error-tracking/types.mjs +9 -0
- package/dist/extensions/express.d.ts +17 -0
- package/dist/extensions/express.d.ts.map +1 -0
- package/dist/extensions/express.js +61 -0
- package/dist/extensions/express.mjs +17 -0
- package/dist/extensions/feature-flags/crypto-helpers.d.ts +3 -0
- package/dist/extensions/feature-flags/crypto-helpers.d.ts.map +1 -0
- package/dist/extensions/feature-flags/crypto-helpers.js +77 -0
- package/dist/extensions/feature-flags/crypto-helpers.mjs +22 -0
- package/dist/extensions/feature-flags/crypto.d.ts +2 -0
- package/dist/extensions/feature-flags/crypto.d.ts.map +1 -0
- package/dist/extensions/feature-flags/crypto.js +47 -0
- package/dist/extensions/feature-flags/crypto.mjs +13 -0
- package/dist/extensions/feature-flags/feature-flags.d.ts +89 -0
- package/dist/extensions/feature-flags/feature-flags.d.ts.map +1 -0
- package/dist/extensions/feature-flags/feature-flags.js +529 -0
- package/dist/extensions/feature-flags/feature-flags.mjs +483 -0
- package/dist/extensions/feature-flags/lazy.d.ts +24 -0
- package/dist/extensions/feature-flags/lazy.d.ts.map +1 -0
- package/dist/extensions/feature-flags/lazy.js +60 -0
- package/dist/extensions/feature-flags/lazy.mjs +26 -0
- package/dist/extensions/sentry-integration.d.ts +54 -0
- package/dist/extensions/sentry-integration.d.ts.map +1 -0
- package/dist/extensions/sentry-integration.js +113 -0
- package/dist/extensions/sentry-integration.mjs +73 -0
- package/dist/storage-memory.d.ts +7 -0
- package/dist/storage-memory.d.ts.map +1 -0
- package/dist/storage-memory.js +46 -0
- package/dist/storage-memory.mjs +12 -0
- package/dist/types.d.ts +253 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +18 -0
- package/dist/types.mjs +0 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +63 -0
- package/dist/utils/logger.mjs +29 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +36 -0
- package/dist/version.mjs +2 -0
- package/package.json +32 -31
- package/src/client.ts +1532 -0
- package/src/entrypoints/index.edge.ts +15 -0
- package/src/entrypoints/index.node.ts +17 -0
- package/src/exports.ts +3 -0
- package/src/extensions/error-tracking/autocapture.ts +65 -0
- package/src/extensions/error-tracking/chunk-ids.ts +58 -0
- package/src/extensions/error-tracking/context-lines.node.ts +392 -0
- package/src/extensions/error-tracking/error-conversion.ts +291 -0
- package/src/extensions/error-tracking/get-module.node.ts +57 -0
- package/src/extensions/error-tracking/index.ts +103 -0
- package/src/extensions/error-tracking/reduceable-cache.ts +39 -0
- package/src/extensions/error-tracking/stack-parser.ts +212 -0
- package/src/extensions/error-tracking/type-checking.ts +40 -0
- package/src/extensions/error-tracking/types.ts +71 -0
- package/src/extensions/express.ts +39 -0
- package/src/extensions/feature-flags/crypto-helpers.ts +36 -0
- package/src/extensions/feature-flags/crypto.ts +22 -0
- package/src/extensions/feature-flags/feature-flags.ts +1003 -0
- package/src/extensions/feature-flags/lazy.ts +55 -0
- package/src/extensions/sentry-integration.ts +216 -0
- package/src/storage-memory.ts +13 -0
- package/src/types.ts +294 -0
- package/src/utils/logger.ts +39 -0
- package/src/version.ts +1 -0
- package/dist/edge/index.cjs +0 -3150
- package/dist/edge/index.cjs.map +0 -1
- package/dist/edge/index.mjs +0 -3144
- package/dist/edge/index.mjs.map +0 -1
- package/dist/node/index.cjs +0 -3556
- package/dist/node/index.cjs.map +0 -1
- package/dist/node/index.mjs +0 -3550
- package/dist/node/index.mjs.map +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
default: ()=>ErrorTracking
|
|
28
|
+
});
|
|
29
|
+
const external_autocapture_js_namespaceObject = require("./autocapture.js");
|
|
30
|
+
const core_namespaceObject = require("@posthog/core");
|
|
31
|
+
const external_error_conversion_js_namespaceObject = require("./error-conversion.js");
|
|
32
|
+
const SHUTDOWN_TIMEOUT = 2000;
|
|
33
|
+
class ErrorTracking {
|
|
34
|
+
constructor(client, options, _logger){
|
|
35
|
+
this.client = client;
|
|
36
|
+
this._exceptionAutocaptureEnabled = options.enableExceptionAutocapture || false;
|
|
37
|
+
this._logger = _logger;
|
|
38
|
+
this._rateLimiter = new core_namespaceObject.BucketedRateLimiter({
|
|
39
|
+
refillRate: 1,
|
|
40
|
+
bucketSize: 10,
|
|
41
|
+
refillInterval: 10000,
|
|
42
|
+
_logger: this._logger
|
|
43
|
+
});
|
|
44
|
+
this.startAutocaptureIfEnabled();
|
|
45
|
+
}
|
|
46
|
+
static async buildEventMessage(error, hint, distinctId, additionalProperties) {
|
|
47
|
+
const properties = {
|
|
48
|
+
...additionalProperties
|
|
49
|
+
};
|
|
50
|
+
if (!distinctId) properties.$process_person_profile = false;
|
|
51
|
+
const exceptionProperties = await (0, external_error_conversion_js_namespaceObject.propertiesFromUnknownInput)(this.stackParser, this.frameModifiers, error, hint);
|
|
52
|
+
return {
|
|
53
|
+
event: '$exception',
|
|
54
|
+
distinctId: distinctId || (0, core_namespaceObject.uuidv7)(),
|
|
55
|
+
properties: {
|
|
56
|
+
...exceptionProperties,
|
|
57
|
+
...properties
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
startAutocaptureIfEnabled() {
|
|
62
|
+
if (this.isEnabled()) {
|
|
63
|
+
(0, external_autocapture_js_namespaceObject.addUncaughtExceptionListener)(this.onException.bind(this), this.onFatalError.bind(this));
|
|
64
|
+
(0, external_autocapture_js_namespaceObject.addUnhandledRejectionListener)(this.onException.bind(this));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async onException(exception, hint) {
|
|
68
|
+
this.client.addPendingPromise((async ()=>{
|
|
69
|
+
const eventMessage = await ErrorTracking.buildEventMessage(exception, hint);
|
|
70
|
+
const exceptionProperties = eventMessage.properties;
|
|
71
|
+
const exceptionType = exceptionProperties?.$exception_list[0]?.type ?? 'Exception';
|
|
72
|
+
const isRateLimited = this._rateLimiter.consumeRateLimit(exceptionType);
|
|
73
|
+
if (isRateLimited) return void this._logger.info('Skipping exception capture because of client rate limiting.', {
|
|
74
|
+
exception: exceptionType
|
|
75
|
+
});
|
|
76
|
+
return this.client.capture(eventMessage);
|
|
77
|
+
})());
|
|
78
|
+
}
|
|
79
|
+
async onFatalError(exception) {
|
|
80
|
+
console.error(exception);
|
|
81
|
+
await this.client.shutdown(SHUTDOWN_TIMEOUT);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
isEnabled() {
|
|
85
|
+
return !this.client.isDisabled && this._exceptionAutocaptureEnabled;
|
|
86
|
+
}
|
|
87
|
+
shutdown() {
|
|
88
|
+
this._rateLimiter.stop();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports["default"] = __webpack_exports__["default"];
|
|
92
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
93
|
+
"default"
|
|
94
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
95
|
+
Object.defineProperty(exports, '__esModule', {
|
|
96
|
+
value: true
|
|
97
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { addUncaughtExceptionListener, addUnhandledRejectionListener } from "./autocapture.mjs";
|
|
2
|
+
import { BucketedRateLimiter, uuidv7 } from "@posthog/core";
|
|
3
|
+
import { propertiesFromUnknownInput } from "./error-conversion.mjs";
|
|
4
|
+
const SHUTDOWN_TIMEOUT = 2000;
|
|
5
|
+
class ErrorTracking {
|
|
6
|
+
constructor(client, options, _logger){
|
|
7
|
+
this.client = client;
|
|
8
|
+
this._exceptionAutocaptureEnabled = options.enableExceptionAutocapture || false;
|
|
9
|
+
this._logger = _logger;
|
|
10
|
+
this._rateLimiter = new BucketedRateLimiter({
|
|
11
|
+
refillRate: 1,
|
|
12
|
+
bucketSize: 10,
|
|
13
|
+
refillInterval: 10000,
|
|
14
|
+
_logger: this._logger
|
|
15
|
+
});
|
|
16
|
+
this.startAutocaptureIfEnabled();
|
|
17
|
+
}
|
|
18
|
+
static async buildEventMessage(error, hint, distinctId, additionalProperties) {
|
|
19
|
+
const properties = {
|
|
20
|
+
...additionalProperties
|
|
21
|
+
};
|
|
22
|
+
if (!distinctId) properties.$process_person_profile = false;
|
|
23
|
+
const exceptionProperties = await propertiesFromUnknownInput(this.stackParser, this.frameModifiers, error, hint);
|
|
24
|
+
return {
|
|
25
|
+
event: '$exception',
|
|
26
|
+
distinctId: distinctId || uuidv7(),
|
|
27
|
+
properties: {
|
|
28
|
+
...exceptionProperties,
|
|
29
|
+
...properties
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
startAutocaptureIfEnabled() {
|
|
34
|
+
if (this.isEnabled()) {
|
|
35
|
+
addUncaughtExceptionListener(this.onException.bind(this), this.onFatalError.bind(this));
|
|
36
|
+
addUnhandledRejectionListener(this.onException.bind(this));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async onException(exception, hint) {
|
|
40
|
+
this.client.addPendingPromise((async ()=>{
|
|
41
|
+
const eventMessage = await ErrorTracking.buildEventMessage(exception, hint);
|
|
42
|
+
const exceptionProperties = eventMessage.properties;
|
|
43
|
+
const exceptionType = exceptionProperties?.$exception_list[0]?.type ?? 'Exception';
|
|
44
|
+
const isRateLimited = this._rateLimiter.consumeRateLimit(exceptionType);
|
|
45
|
+
if (isRateLimited) return void this._logger.info('Skipping exception capture because of client rate limiting.', {
|
|
46
|
+
exception: exceptionType
|
|
47
|
+
});
|
|
48
|
+
return this.client.capture(eventMessage);
|
|
49
|
+
})());
|
|
50
|
+
}
|
|
51
|
+
async onFatalError(exception) {
|
|
52
|
+
console.error(exception);
|
|
53
|
+
await this.client.shutdown(SHUTDOWN_TIMEOUT);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
isEnabled() {
|
|
57
|
+
return !this.client.isDisabled && this._exceptionAutocaptureEnabled;
|
|
58
|
+
}
|
|
59
|
+
shutdown() {
|
|
60
|
+
this._rateLimiter.stop();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export { ErrorTracking as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
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 };
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
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 };
|