@posthog/core 1.2.0 → 1.2.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.
- package/dist/error-tracking/error-properties-builder.d.ts +6 -6
- package/dist/error-tracking/error-properties-builder.d.ts.map +1 -1
- package/dist/error-tracking/error-properties-builder.js +7 -13
- package/dist/error-tracking/error-properties-builder.mjs +5 -11
- package/package.json +1 -1
- package/src/error-tracking/error-properties-builder.ts +14 -16
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ErrorProperties,
|
|
1
|
+
import { ErrorProperties, StackFrameModifierFn, StackParser, ErrorTrackingCoercer, EventHint, StackLineParser } from './types';
|
|
2
2
|
export declare class ErrorPropertiesBuilder {
|
|
3
3
|
private coercers;
|
|
4
4
|
private modifiers;
|
|
5
5
|
stackParser: StackParser;
|
|
6
6
|
constructor(coercers?: ErrorTrackingCoercer<any>[], parsers?: StackLineParser[], modifiers?: StackFrameModifierFn[]);
|
|
7
7
|
buildFromUnknown(input: unknown, hint?: EventHint): ErrorProperties;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
modifyFrames(exceptionList: ErrorProperties['$exception_list']): Promise<ErrorProperties['$exception_list']>;
|
|
9
|
+
private coerceFallback;
|
|
10
|
+
private parseStacktrace;
|
|
10
11
|
private applyChunkIds;
|
|
11
12
|
private applyCoercers;
|
|
12
13
|
private applyModifiers;
|
|
13
|
-
private modifyFrames;
|
|
14
14
|
private convertToExceptionList;
|
|
15
|
-
buildParsingContext
|
|
16
|
-
buildCoercingContext
|
|
15
|
+
private buildParsingContext;
|
|
16
|
+
private buildCoercingContext;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=error-properties-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-properties-builder.d.ts","sourceRoot":"","sources":["../../src/error-tracking/error-properties-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error-properties-builder.d.ts","sourceRoot":"","sources":["../../src/error-tracking/error-properties-builder.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,eAAe,EAKf,oBAAoB,EACpB,WAAW,EACX,oBAAoB,EACpB,SAAS,EACT,eAAe,EAMhB,MAAM,SAAS,CAAA;AAIhB,qBAAa,sBAAsB;IAI/B,OAAO,CAAC,QAAQ;IAEhB,OAAO,CAAC,SAAS;IALnB,WAAW,EAAE,WAAW,CAAA;gBAGd,QAAQ,GAAE,oBAAoB,CAAC,GAAG,CAAC,EAAO,EAClD,OAAO,GAAE,eAAe,EAAO,EACvB,SAAS,GAAE,oBAAoB,EAAO;IAKhD,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,GAAE,SAAc,GAAG,eAAe;IAiBjE,YAAY,CAAC,aAAa,EAAE,eAAe,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;IASlH,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,aAAa;YASP,cAAc;IAQ5B,OAAO,CAAC,sBAAsB;IA6B9B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,oBAAoB;CAuB7B"}
|
|
@@ -26,14 +26,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
ErrorPropertiesBuilder: ()=>ErrorPropertiesBuilder
|
|
28
28
|
});
|
|
29
|
+
const index_js_namespaceObject = require("../utils/index.js");
|
|
29
30
|
const external_chunk_ids_js_namespaceObject = require("./chunk-ids.js");
|
|
30
|
-
const
|
|
31
|
+
const external_parsers_index_js_namespaceObject = require("./parsers/index.js");
|
|
31
32
|
const MAX_CAUSE_RECURSION = 4;
|
|
32
33
|
class ErrorPropertiesBuilder {
|
|
33
34
|
constructor(coercers = [], parsers = [], modifiers = []){
|
|
34
35
|
this.coercers = coercers;
|
|
35
36
|
this.modifiers = modifiers;
|
|
36
|
-
this.stackParser = (0,
|
|
37
|
+
this.stackParser = (0, external_parsers_index_js_namespaceObject.createStackParser)(...parsers);
|
|
37
38
|
}
|
|
38
39
|
buildFromUnknown(input, hint = {}) {
|
|
39
40
|
const providedMechanism = hint && hint.mechanism;
|
|
@@ -51,6 +52,10 @@ class ErrorPropertiesBuilder {
|
|
|
51
52
|
$exception_level: 'error'
|
|
52
53
|
};
|
|
53
54
|
}
|
|
55
|
+
async modifyFrames(exceptionList) {
|
|
56
|
+
for (const exc of exceptionList)if (exc.stacktrace && exc.stacktrace.frames && (0, index_js_namespaceObject.isArray)(exc.stacktrace.frames)) exc.stacktrace.frames = await this.applyModifiers(exc.stacktrace.frames);
|
|
57
|
+
return exceptionList;
|
|
58
|
+
}
|
|
54
59
|
coerceFallback(ctx) {
|
|
55
60
|
return {
|
|
56
61
|
type: 'Error',
|
|
@@ -85,17 +90,6 @@ class ErrorPropertiesBuilder {
|
|
|
85
90
|
for (const modifier of this.modifiers)newFrames = await modifier(newFrames);
|
|
86
91
|
return newFrames;
|
|
87
92
|
}
|
|
88
|
-
async modifyFrames(exceptionWithStack) {
|
|
89
|
-
let cause;
|
|
90
|
-
if (null != exceptionWithStack.cause) cause = await this.modifyFrames(exceptionWithStack.cause);
|
|
91
|
-
let stack = [];
|
|
92
|
-
if (null != exceptionWithStack.stack) stack = await this.applyModifiers(exceptionWithStack.stack);
|
|
93
|
-
return {
|
|
94
|
-
...exceptionWithStack,
|
|
95
|
-
cause,
|
|
96
|
-
stack
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
93
|
convertToExceptionList(exceptionWithStack, mechanism) {
|
|
100
94
|
const currentException = {
|
|
101
95
|
type: exceptionWithStack.type,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isArray } from "../utils/index.mjs";
|
|
1
2
|
import { getFilenameToChunkIdMap } from "./chunk-ids.mjs";
|
|
2
3
|
import { createStackParser } from "./parsers/index.mjs";
|
|
3
4
|
const MAX_CAUSE_RECURSION = 4;
|
|
@@ -23,6 +24,10 @@ class ErrorPropertiesBuilder {
|
|
|
23
24
|
$exception_level: 'error'
|
|
24
25
|
};
|
|
25
26
|
}
|
|
27
|
+
async modifyFrames(exceptionList) {
|
|
28
|
+
for (const exc of exceptionList)if (exc.stacktrace && exc.stacktrace.frames && isArray(exc.stacktrace.frames)) exc.stacktrace.frames = await this.applyModifiers(exc.stacktrace.frames);
|
|
29
|
+
return exceptionList;
|
|
30
|
+
}
|
|
26
31
|
coerceFallback(ctx) {
|
|
27
32
|
return {
|
|
28
33
|
type: 'Error',
|
|
@@ -57,17 +62,6 @@ class ErrorPropertiesBuilder {
|
|
|
57
62
|
for (const modifier of this.modifiers)newFrames = await modifier(newFrames);
|
|
58
63
|
return newFrames;
|
|
59
64
|
}
|
|
60
|
-
async modifyFrames(exceptionWithStack) {
|
|
61
|
-
let cause;
|
|
62
|
-
if (null != exceptionWithStack.cause) cause = await this.modifyFrames(exceptionWithStack.cause);
|
|
63
|
-
let stack = [];
|
|
64
|
-
if (null != exceptionWithStack.stack) stack = await this.applyModifiers(exceptionWithStack.stack);
|
|
65
|
-
return {
|
|
66
|
-
...exceptionWithStack,
|
|
67
|
-
cause,
|
|
68
|
-
stack
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
65
|
convertToExceptionList(exceptionWithStack, mechanism) {
|
|
72
66
|
const currentException = {
|
|
73
67
|
type: exceptionWithStack.type,
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isArray } from '@/utils'
|
|
1
2
|
import { getFilenameToChunkIdMap } from './chunk-ids'
|
|
2
3
|
import { createStackParser } from './parsers'
|
|
3
4
|
import {
|
|
@@ -48,7 +49,16 @@ export class ErrorPropertiesBuilder {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
async modifyFrames(exceptionList: ErrorProperties['$exception_list']): Promise<ErrorProperties['$exception_list']> {
|
|
53
|
+
for (const exc of exceptionList) {
|
|
54
|
+
if (exc.stacktrace && exc.stacktrace.frames && isArray(exc.stacktrace.frames)) {
|
|
55
|
+
exc.stacktrace.frames = await this.applyModifiers(exc.stacktrace.frames)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return exceptionList
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private coerceFallback(ctx: CoercingContext): ExceptionLike {
|
|
52
62
|
return {
|
|
53
63
|
type: 'Error',
|
|
54
64
|
value: 'Unknown error',
|
|
@@ -57,7 +67,7 @@ export class ErrorPropertiesBuilder {
|
|
|
57
67
|
}
|
|
58
68
|
}
|
|
59
69
|
|
|
60
|
-
parseStacktrace(err: ExceptionLike, ctx: ParsingContext): ParsedException {
|
|
70
|
+
private parseStacktrace(err: ExceptionLike, ctx: ParsingContext): ParsedException {
|
|
61
71
|
let cause: ParsedException | undefined = undefined
|
|
62
72
|
if (err.cause != null) {
|
|
63
73
|
cause = this.parseStacktrace(err.cause, ctx)
|
|
@@ -95,18 +105,6 @@ export class ErrorPropertiesBuilder {
|
|
|
95
105
|
return newFrames
|
|
96
106
|
}
|
|
97
107
|
|
|
98
|
-
private async modifyFrames(exceptionWithStack: ParsedException): Promise<ParsedException> {
|
|
99
|
-
let cause: ParsedException | undefined = undefined
|
|
100
|
-
if (exceptionWithStack.cause != null) {
|
|
101
|
-
cause = await this.modifyFrames(exceptionWithStack.cause)
|
|
102
|
-
}
|
|
103
|
-
let stack: StackFrame[] = []
|
|
104
|
-
if (exceptionWithStack.stack != null) {
|
|
105
|
-
stack = await this.applyModifiers(exceptionWithStack.stack)
|
|
106
|
-
}
|
|
107
|
-
return { ...exceptionWithStack, cause, stack }
|
|
108
|
-
}
|
|
109
|
-
|
|
110
108
|
private convertToExceptionList(exceptionWithStack: ParsedException, mechanism: Mechanism): ExceptionList {
|
|
111
109
|
const currentException: Exception = {
|
|
112
110
|
type: exceptionWithStack.type,
|
|
@@ -136,14 +134,14 @@ export class ErrorPropertiesBuilder {
|
|
|
136
134
|
return exceptionList
|
|
137
135
|
}
|
|
138
136
|
|
|
139
|
-
buildParsingContext(): ParsingContext {
|
|
137
|
+
private buildParsingContext(): ParsingContext {
|
|
140
138
|
const context = {
|
|
141
139
|
chunkIdMap: getFilenameToChunkIdMap(this.stackParser),
|
|
142
140
|
} as ParsingContext
|
|
143
141
|
return context
|
|
144
142
|
}
|
|
145
143
|
|
|
146
|
-
buildCoercingContext(mechanism: Mechanism, hint: EventHint, depth: number = 0): CoercingContext {
|
|
144
|
+
private buildCoercingContext(mechanism: Mechanism, hint: EventHint, depth: number = 0): CoercingContext {
|
|
147
145
|
const coerce = (input: unknown, depth: number) => {
|
|
148
146
|
if (depth <= MAX_CAUSE_RECURSION) {
|
|
149
147
|
const ctx = this.buildCoercingContext(mechanism, hint, depth)
|