catchfn 0.0.1 → 0.1.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/README.md +313 -278
- package/dist/index.cjs +1736 -635
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +501 -388
- package/dist/index.d.ts +501 -388
- package/dist/index.js +1736 -616
- package/dist/index.js.map +1 -1
- package/package.json +37 -25
package/dist/index.d.cts
CHANGED
|
@@ -1,409 +1,564 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
* Bounded, JSON-safe snapshots of captured values.
|
|
3
|
+
*
|
|
4
|
+
* The closed set of forms:
|
|
5
|
+
* - JSON primitives (strings, finite numbers, booleans, null) are kept;
|
|
6
|
+
* - `Error` becomes `{ name, message, stack, ...own properties }`;
|
|
7
|
+
* - plain objects and arrays are copied, at most {@link MAX_DEPTH} container
|
|
8
|
+
* levels deep (deeper containers become `"[Max Depth]"`) and with at most
|
|
9
|
+
* {@link MAX_KEYS} keys or items each, a truncation marker included;
|
|
10
|
+
* - a container that refers back to one of its ancestors becomes `"[Circular]"`;
|
|
11
|
+
* - DOM nodes become `"<tag#id.class>"`;
|
|
12
|
+
* - everything else (undefined, NaN, bigint, symbol, functions, Date, Map,
|
|
13
|
+
* class instances, ...) becomes `String(value)`, or `"[Unserializable]"`
|
|
14
|
+
* when that conversion throws.
|
|
15
|
+
*
|
|
16
|
+
* One entry never exceeds {@link MAX_ENTRY_BYTES} bytes of UTF-8 JSON: strings
|
|
17
|
+
* are cut, and containers stop adding keys or items once the next one would
|
|
18
|
+
* not fit and record the cut with a `"[Truncated]"` marker: the last array
|
|
19
|
+
* item, or a record key `"[Truncated]"` (`"[Truncated 2]"`, ... when the
|
|
20
|
+
* record already has that key) whose value counts the omitted keys.
|
|
21
|
+
*/
|
|
22
|
+
type SerializedValue = string | number | boolean | null | SerializedValue[] | {
|
|
23
|
+
[key: string]: SerializedValue;
|
|
24
|
+
};
|
|
25
|
+
declare const MAX_DEPTH = 5;
|
|
26
|
+
declare const MAX_KEYS = 200;
|
|
27
|
+
declare const MAX_ENTRY_BYTES: number;
|
|
28
|
+
declare const CIRCULAR = "[Circular]";
|
|
29
|
+
declare const MAX_DEPTH_MARKER = "[Max Depth]";
|
|
30
|
+
declare const TRUNCATED = "[Truncated]";
|
|
31
|
+
declare const UNSERIALIZABLE = "[Unserializable]";
|
|
32
|
+
/**
|
|
33
|
+
* Serialize one entry under the closed set and the per-entry caps.
|
|
34
|
+
*
|
|
35
|
+
* `rootDepth` is the container level the value itself occupies; collectors
|
|
36
|
+
* pass 0 for an argument list so that each argument keeps all five levels.
|
|
37
|
+
*/
|
|
38
|
+
declare function serializeEntry(value: unknown, rootDepth?: number): SerializedValue;
|
|
39
|
+
/** Serialize a value under the closed set. Alias of {@link serializeEntry}. */
|
|
40
|
+
declare function safeSerialize(value: unknown): SerializedValue;
|
|
41
|
+
/** Cut a string to at most `maxLength` UTF-16 units, ending in "..." when cut. */
|
|
42
|
+
declare function truncateString(value: string, maxLength: number): string;
|
|
43
|
+
|
|
12
44
|
/**
|
|
13
|
-
*
|
|
45
|
+
* Evidence events, schema version 1.
|
|
46
|
+
*
|
|
47
|
+
* Every collector records its observations as one of these events. The
|
|
48
|
+
* format is closed: a v1 event has exactly the fields below, and a consumer
|
|
49
|
+
* can check one with {@link validateEvidenceEvent} or with any JSON Schema
|
|
50
|
+
* validator and {@link evidenceEventSchema}.
|
|
14
51
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
52
|
+
|
|
53
|
+
declare const EVIDENCE_SCHEMA_VERSION: 1;
|
|
54
|
+
declare const EVIDENCE_KINDS: readonly ["console", "network", "breadcrumb", "error", "websocket"];
|
|
55
|
+
type EvidenceKind = (typeof EVIDENCE_KINDS)[number];
|
|
56
|
+
declare const CONSOLE_LEVELS: readonly ["log", "info", "warn", "error", "debug"];
|
|
57
|
+
type ConsoleLevel = (typeof CONSOLE_LEVELS)[number];
|
|
58
|
+
declare const NETWORK_TRANSPORTS: readonly ["fetch", "xhr"];
|
|
59
|
+
type NetworkTransport = (typeof NETWORK_TRANSPORTS)[number];
|
|
60
|
+
declare const BREADCRUMB_TYPES: readonly ["navigation", "console", "network", "user", "custom"];
|
|
61
|
+
type BreadcrumbType = (typeof BREADCRUMB_TYPES)[number];
|
|
62
|
+
declare const BREADCRUMB_LEVELS: readonly ["debug", "info", "warning", "error"];
|
|
63
|
+
type BreadcrumbLevel = (typeof BREADCRUMB_LEVELS)[number];
|
|
64
|
+
declare const ERROR_SOURCES: readonly ["error", "unhandledrejection"];
|
|
65
|
+
type ErrorSource = (typeof ERROR_SOURCES)[number];
|
|
66
|
+
declare const WEBSOCKET_EVENT_TYPES: readonly ["open", "message", "close", "error"];
|
|
67
|
+
type WebSocketEventType = (typeof WEBSOCKET_EVENT_TYPES)[number];
|
|
68
|
+
declare const WEBSOCKET_DIRECTIONS: readonly ["sent", "received"];
|
|
69
|
+
type WebSocketDirection = (typeof WEBSOCKET_DIRECTIONS)[number];
|
|
70
|
+
interface EvidenceEventBase {
|
|
71
|
+
schemaVersion: typeof EVIDENCE_SCHEMA_VERSION;
|
|
72
|
+
kind: EvidenceKind;
|
|
73
|
+
/** Capture order within one loaded copy of catchfn, starting at 0. */
|
|
74
|
+
seq: number;
|
|
75
|
+
/** Capture time in milliseconds since the Unix epoch (`Date.now()`). */
|
|
17
76
|
timestamp: number;
|
|
18
|
-
message?: string;
|
|
19
|
-
data?: Record<string, any>;
|
|
20
|
-
category?: string;
|
|
21
|
-
level?: "debug" | "info" | "warning" | "error";
|
|
22
77
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
level: "log" | "info" | "warn" | "error" | "debug";
|
|
28
|
-
args: any[];
|
|
29
|
-
timestamp: number;
|
|
78
|
+
interface ConsoleEvidenceEvent extends EvidenceEventBase {
|
|
79
|
+
kind: "console";
|
|
80
|
+
level: ConsoleLevel;
|
|
81
|
+
args: SerializedValue[];
|
|
30
82
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
interface NetworkRequest {
|
|
35
|
-
url: string;
|
|
83
|
+
interface NetworkEvidenceEvent extends EvidenceEventBase {
|
|
84
|
+
kind: "network";
|
|
85
|
+
transport: NetworkTransport;
|
|
36
86
|
method: string;
|
|
87
|
+
/** Redacted with `redactUrl`; never the application's raw URL. */
|
|
88
|
+
url: string;
|
|
89
|
+
/** Absent when the request failed before a response arrived. */
|
|
37
90
|
status?: number;
|
|
38
91
|
statusText?: string;
|
|
92
|
+
/** Milliseconds from the call to its settlement. */
|
|
39
93
|
duration?: number;
|
|
40
|
-
|
|
94
|
+
/** Redacted with `redactHeaders`. */
|
|
41
95
|
requestHeaders?: Record<string, string>;
|
|
96
|
+
/** Redacted with `redactHeaders`. */
|
|
42
97
|
responseHeaders?: Record<string, string>;
|
|
43
98
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
language?: string;
|
|
51
|
-
screenResolution?: string;
|
|
52
|
-
viewportSize?: string;
|
|
53
|
-
timezone?: string;
|
|
54
|
-
nodeVersion?: string;
|
|
55
|
-
memoryUsage?: {
|
|
56
|
-
rss: number;
|
|
57
|
-
heapTotal: number;
|
|
58
|
-
heapUsed: number;
|
|
59
|
-
external: number;
|
|
99
|
+
interface BreadcrumbEvidenceEvent extends EvidenceEventBase {
|
|
100
|
+
kind: "breadcrumb";
|
|
101
|
+
type: BreadcrumbType;
|
|
102
|
+
message?: string;
|
|
103
|
+
data?: {
|
|
104
|
+
[key: string]: SerializedValue;
|
|
60
105
|
};
|
|
106
|
+
category?: string;
|
|
107
|
+
level?: BreadcrumbLevel;
|
|
61
108
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
description?: string;
|
|
81
|
-
severity: BugSeverity;
|
|
82
|
-
tags?: string[];
|
|
83
|
-
breadcrumbs?: Breadcrumb[];
|
|
84
|
-
consoleLogs?: ConsoleLogEntry[];
|
|
85
|
-
networkRequests?: NetworkRequest[];
|
|
86
|
-
deviceInfo?: DeviceInfo;
|
|
87
|
-
user?: {
|
|
88
|
-
id?: string;
|
|
89
|
-
email?: string;
|
|
90
|
-
username?: string;
|
|
91
|
-
[key: string]: any;
|
|
92
|
-
};
|
|
93
|
-
environment?: string;
|
|
94
|
-
release?: string;
|
|
95
|
-
attachments?: AttachmentReference[];
|
|
96
|
-
integration?: {
|
|
97
|
-
issueId?: string;
|
|
98
|
-
issueUrl?: string;
|
|
99
|
-
};
|
|
100
|
-
metadata?: Record<string, any>;
|
|
109
|
+
interface ErrorEvidenceEvent extends EvidenceEventBase {
|
|
110
|
+
kind: "error";
|
|
111
|
+
/** The window event that reported it: an uncaught error or an unhandled rejection. */
|
|
112
|
+
source: ErrorSource;
|
|
113
|
+
message: string;
|
|
114
|
+
/** Present when the thrown value or rejection reason is an `Error`. */
|
|
115
|
+
name?: string;
|
|
116
|
+
stack?: string;
|
|
117
|
+
/** Script URL of an uncaught error, redacted with `redactUrl`. */
|
|
118
|
+
filename?: string;
|
|
119
|
+
lineno?: number;
|
|
120
|
+
colno?: number;
|
|
121
|
+
/**
|
|
122
|
+
* The thrown value or rejection reason when it is not an `Error`, serialized.
|
|
123
|
+
* Absent for an uncaught error whose `ErrorEvent.error` is null or undefined
|
|
124
|
+
* (a cross-origin "Script error.", or `throw null` / `throw undefined`).
|
|
125
|
+
*/
|
|
126
|
+
value?: SerializedValue;
|
|
101
127
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
attachments?: AttachmentReference[];
|
|
128
|
+
interface WebSocketEvidenceEvent extends EvidenceEventBase {
|
|
129
|
+
kind: "websocket";
|
|
130
|
+
type: WebSocketEventType;
|
|
131
|
+
/** Redacted with `redactUrl`; never the application's raw URL. */
|
|
132
|
+
url: string;
|
|
133
|
+
/** Message events only: whether the page sent or received it. */
|
|
134
|
+
direction?: WebSocketDirection;
|
|
135
|
+
/** Message events only: the payload size in bytes. The payload itself is never recorded. */
|
|
136
|
+
size?: number;
|
|
137
|
+
/** Close events only. */
|
|
138
|
+
code?: number;
|
|
139
|
+
wasClean?: boolean;
|
|
115
140
|
}
|
|
141
|
+
type EvidenceEvent = ConsoleEvidenceEvent | NetworkEvidenceEvent | BreadcrumbEvidenceEvent | ErrorEvidenceEvent | WebSocketEvidenceEvent;
|
|
142
|
+
/** JSON Schema (draft 2020-12) for one v1 evidence event. */
|
|
143
|
+
declare const evidenceEventSchema: {
|
|
144
|
+
readonly $schema: "https://json-schema.org/draft/2020-12/schema";
|
|
145
|
+
readonly $id: "urn:catchfn:evidence-event:v1";
|
|
146
|
+
readonly title: "catchfn evidence event v1";
|
|
147
|
+
readonly oneOf: readonly [{
|
|
148
|
+
readonly type: "object";
|
|
149
|
+
readonly additionalProperties: false;
|
|
150
|
+
readonly required: readonly ["schemaVersion", "kind", "seq", "timestamp", "level", "args"];
|
|
151
|
+
readonly properties: {
|
|
152
|
+
readonly kind: {
|
|
153
|
+
readonly const: "console";
|
|
154
|
+
};
|
|
155
|
+
readonly level: {
|
|
156
|
+
readonly enum: readonly ["log", "info", "warn", "error", "debug"];
|
|
157
|
+
};
|
|
158
|
+
readonly args: {
|
|
159
|
+
readonly type: "array";
|
|
160
|
+
};
|
|
161
|
+
readonly schemaVersion: {
|
|
162
|
+
readonly const: 1;
|
|
163
|
+
};
|
|
164
|
+
readonly seq: {
|
|
165
|
+
readonly type: "integer";
|
|
166
|
+
readonly minimum: 0;
|
|
167
|
+
readonly maximum: number;
|
|
168
|
+
};
|
|
169
|
+
readonly timestamp: {
|
|
170
|
+
readonly type: "integer";
|
|
171
|
+
readonly minimum: 0;
|
|
172
|
+
readonly maximum: number;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
}, {
|
|
176
|
+
readonly type: "object";
|
|
177
|
+
readonly additionalProperties: false;
|
|
178
|
+
readonly required: readonly ["schemaVersion", "kind", "seq", "timestamp", "transport", "method", "url"];
|
|
179
|
+
readonly properties: {
|
|
180
|
+
readonly kind: {
|
|
181
|
+
readonly const: "network";
|
|
182
|
+
};
|
|
183
|
+
readonly transport: {
|
|
184
|
+
readonly enum: readonly ["fetch", "xhr"];
|
|
185
|
+
};
|
|
186
|
+
readonly method: {
|
|
187
|
+
readonly type: "string";
|
|
188
|
+
};
|
|
189
|
+
readonly url: {
|
|
190
|
+
readonly type: "string";
|
|
191
|
+
};
|
|
192
|
+
readonly status: {
|
|
193
|
+
readonly type: "integer";
|
|
194
|
+
readonly minimum: 0;
|
|
195
|
+
readonly maximum: number;
|
|
196
|
+
};
|
|
197
|
+
readonly statusText: {
|
|
198
|
+
readonly type: "string";
|
|
199
|
+
};
|
|
200
|
+
readonly duration: {
|
|
201
|
+
readonly type: "number";
|
|
202
|
+
readonly minimum: 0;
|
|
203
|
+
};
|
|
204
|
+
readonly requestHeaders: {
|
|
205
|
+
readonly type: "object";
|
|
206
|
+
readonly additionalProperties: {
|
|
207
|
+
readonly type: "string";
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
readonly responseHeaders: {
|
|
211
|
+
readonly type: "object";
|
|
212
|
+
readonly additionalProperties: {
|
|
213
|
+
readonly type: "string";
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
readonly schemaVersion: {
|
|
217
|
+
readonly const: 1;
|
|
218
|
+
};
|
|
219
|
+
readonly seq: {
|
|
220
|
+
readonly type: "integer";
|
|
221
|
+
readonly minimum: 0;
|
|
222
|
+
readonly maximum: number;
|
|
223
|
+
};
|
|
224
|
+
readonly timestamp: {
|
|
225
|
+
readonly type: "integer";
|
|
226
|
+
readonly minimum: 0;
|
|
227
|
+
readonly maximum: number;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
}, {
|
|
231
|
+
readonly type: "object";
|
|
232
|
+
readonly additionalProperties: false;
|
|
233
|
+
readonly required: readonly ["schemaVersion", "kind", "seq", "timestamp", "type"];
|
|
234
|
+
readonly properties: {
|
|
235
|
+
readonly kind: {
|
|
236
|
+
readonly const: "breadcrumb";
|
|
237
|
+
};
|
|
238
|
+
readonly type: {
|
|
239
|
+
readonly enum: readonly ["navigation", "console", "network", "user", "custom"];
|
|
240
|
+
};
|
|
241
|
+
readonly message: {
|
|
242
|
+
readonly type: "string";
|
|
243
|
+
};
|
|
244
|
+
readonly data: {
|
|
245
|
+
readonly type: "object";
|
|
246
|
+
};
|
|
247
|
+
readonly category: {
|
|
248
|
+
readonly type: "string";
|
|
249
|
+
};
|
|
250
|
+
readonly level: {
|
|
251
|
+
readonly enum: readonly ["debug", "info", "warning", "error"];
|
|
252
|
+
};
|
|
253
|
+
readonly schemaVersion: {
|
|
254
|
+
readonly const: 1;
|
|
255
|
+
};
|
|
256
|
+
readonly seq: {
|
|
257
|
+
readonly type: "integer";
|
|
258
|
+
readonly minimum: 0;
|
|
259
|
+
readonly maximum: number;
|
|
260
|
+
};
|
|
261
|
+
readonly timestamp: {
|
|
262
|
+
readonly type: "integer";
|
|
263
|
+
readonly minimum: 0;
|
|
264
|
+
readonly maximum: number;
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
}, {
|
|
268
|
+
readonly type: "object";
|
|
269
|
+
readonly additionalProperties: false;
|
|
270
|
+
readonly required: readonly ["schemaVersion", "kind", "seq", "timestamp", "source", "message"];
|
|
271
|
+
readonly properties: {
|
|
272
|
+
readonly kind: {
|
|
273
|
+
readonly const: "error";
|
|
274
|
+
};
|
|
275
|
+
readonly source: {
|
|
276
|
+
readonly enum: readonly ["error", "unhandledrejection"];
|
|
277
|
+
};
|
|
278
|
+
readonly message: {
|
|
279
|
+
readonly type: "string";
|
|
280
|
+
};
|
|
281
|
+
readonly name: {
|
|
282
|
+
readonly type: "string";
|
|
283
|
+
};
|
|
284
|
+
readonly stack: {
|
|
285
|
+
readonly type: "string";
|
|
286
|
+
};
|
|
287
|
+
readonly filename: {
|
|
288
|
+
readonly type: "string";
|
|
289
|
+
};
|
|
290
|
+
readonly lineno: {
|
|
291
|
+
readonly type: "integer";
|
|
292
|
+
readonly minimum: 0;
|
|
293
|
+
readonly maximum: number;
|
|
294
|
+
};
|
|
295
|
+
readonly colno: {
|
|
296
|
+
readonly type: "integer";
|
|
297
|
+
readonly minimum: 0;
|
|
298
|
+
readonly maximum: number;
|
|
299
|
+
};
|
|
300
|
+
readonly value: {};
|
|
301
|
+
readonly schemaVersion: {
|
|
302
|
+
readonly const: 1;
|
|
303
|
+
};
|
|
304
|
+
readonly seq: {
|
|
305
|
+
readonly type: "integer";
|
|
306
|
+
readonly minimum: 0;
|
|
307
|
+
readonly maximum: number;
|
|
308
|
+
};
|
|
309
|
+
readonly timestamp: {
|
|
310
|
+
readonly type: "integer";
|
|
311
|
+
readonly minimum: 0;
|
|
312
|
+
readonly maximum: number;
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
}, {
|
|
316
|
+
readonly type: "object";
|
|
317
|
+
readonly additionalProperties: false;
|
|
318
|
+
readonly required: readonly ["schemaVersion", "kind", "seq", "timestamp", "type", "url"];
|
|
319
|
+
readonly properties: {
|
|
320
|
+
readonly kind: {
|
|
321
|
+
readonly const: "websocket";
|
|
322
|
+
};
|
|
323
|
+
readonly type: {
|
|
324
|
+
readonly enum: readonly ["open", "message", "close", "error"];
|
|
325
|
+
};
|
|
326
|
+
readonly url: {
|
|
327
|
+
readonly type: "string";
|
|
328
|
+
};
|
|
329
|
+
readonly direction: {
|
|
330
|
+
readonly enum: readonly ["sent", "received"];
|
|
331
|
+
};
|
|
332
|
+
readonly size: {
|
|
333
|
+
readonly type: "integer";
|
|
334
|
+
readonly minimum: 0;
|
|
335
|
+
readonly maximum: number;
|
|
336
|
+
};
|
|
337
|
+
readonly code: {
|
|
338
|
+
readonly type: "integer";
|
|
339
|
+
readonly minimum: 0;
|
|
340
|
+
readonly maximum: number;
|
|
341
|
+
};
|
|
342
|
+
readonly wasClean: {
|
|
343
|
+
readonly type: "boolean";
|
|
344
|
+
};
|
|
345
|
+
readonly schemaVersion: {
|
|
346
|
+
readonly const: 1;
|
|
347
|
+
};
|
|
348
|
+
readonly seq: {
|
|
349
|
+
readonly type: "integer";
|
|
350
|
+
readonly minimum: 0;
|
|
351
|
+
readonly maximum: number;
|
|
352
|
+
};
|
|
353
|
+
readonly timestamp: {
|
|
354
|
+
readonly type: "integer";
|
|
355
|
+
readonly minimum: 0;
|
|
356
|
+
readonly maximum: number;
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
readonly allOf: readonly [{
|
|
360
|
+
readonly if: {
|
|
361
|
+
readonly properties: {
|
|
362
|
+
readonly type: {
|
|
363
|
+
readonly const: "message";
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
readonly else: {
|
|
368
|
+
readonly properties: {
|
|
369
|
+
readonly direction: false;
|
|
370
|
+
readonly size: false;
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
}, {
|
|
374
|
+
readonly if: {
|
|
375
|
+
readonly properties: {
|
|
376
|
+
readonly type: {
|
|
377
|
+
readonly const: "close";
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
readonly else: {
|
|
382
|
+
readonly properties: {
|
|
383
|
+
readonly code: false;
|
|
384
|
+
readonly wasClean: false;
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
}];
|
|
388
|
+
}];
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* Check a value against the v1 event format. Returns the list of problems;
|
|
392
|
+
* an empty list means the value is a valid v1 event.
|
|
393
|
+
*/
|
|
394
|
+
declare function validateEvidenceEvent(value: unknown): string[];
|
|
395
|
+
declare function isEvidenceEvent(value: unknown): value is EvidenceEvent;
|
|
396
|
+
|
|
116
397
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*/
|
|
120
|
-
type BeforeSendHook = (event: BugReportEvent) => BugReportEvent | null | Promise<BugReportEvent | null>;
|
|
121
|
-
/**
|
|
122
|
-
* Ignore pattern - string or regex
|
|
123
|
-
*/
|
|
124
|
-
type IgnorePattern = string | RegExp;
|
|
125
|
-
/**
|
|
126
|
-
* CatchFn configuration
|
|
398
|
+
* A fixed-capacity buffer that keeps the newest entries, plus the time-window
|
|
399
|
+
* query the collectors expose as `collect({ since, until })`.
|
|
127
400
|
*/
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
* Enable breadcrumb collection
|
|
135
|
-
* @default true
|
|
136
|
-
*/
|
|
137
|
-
enableBreadcrumbs?: boolean;
|
|
138
|
-
/**
|
|
139
|
-
* Maximum number of breadcrumbs to keep
|
|
140
|
-
* @default 50
|
|
141
|
-
*/
|
|
142
|
-
maxBreadcrumbs?: number;
|
|
143
|
-
/**
|
|
144
|
-
* Enable console log capture
|
|
145
|
-
* @default false
|
|
146
|
-
*/
|
|
147
|
-
enableConsoleCapture?: boolean;
|
|
148
|
-
/**
|
|
149
|
-
* Maximum number of console logs to keep
|
|
150
|
-
* @default 100
|
|
151
|
-
*/
|
|
152
|
-
maxConsoleLogs?: number;
|
|
153
|
-
/**
|
|
154
|
-
* Enable network request tracking
|
|
155
|
-
* @default false
|
|
156
|
-
*/
|
|
157
|
-
enableNetworkCapture?: boolean;
|
|
158
|
-
/**
|
|
159
|
-
* Maximum number of network requests to keep
|
|
160
|
-
* @default 20
|
|
161
|
-
*/
|
|
162
|
-
maxNetworkRequests?: number;
|
|
163
|
-
/**
|
|
164
|
-
* Default severity for bug reports
|
|
165
|
-
* @default "medium"
|
|
166
|
-
*/
|
|
167
|
-
defaultSeverity?: BugSeverity;
|
|
168
|
-
/**
|
|
169
|
-
* Default environment
|
|
170
|
-
*/
|
|
171
|
-
environment?: string;
|
|
172
|
-
/**
|
|
173
|
-
* Release version
|
|
174
|
-
*/
|
|
175
|
-
release?: string;
|
|
176
|
-
/**
|
|
177
|
-
* Default user context
|
|
178
|
-
*/
|
|
179
|
-
user?: BugReportEvent["user"];
|
|
180
|
-
/**
|
|
181
|
-
* BeforeSend hook
|
|
182
|
-
*/
|
|
183
|
-
beforeSend?: BeforeSendHook;
|
|
184
|
-
/**
|
|
185
|
-
* Patterns to ignore
|
|
186
|
-
*/
|
|
187
|
-
ignorePatterns?: IgnorePattern[];
|
|
188
|
-
/**
|
|
189
|
-
* Maximum payload size in bytes
|
|
190
|
-
* @default 262144 (256KB)
|
|
191
|
-
*/
|
|
192
|
-
maxPayloadSize?: number;
|
|
193
|
-
/**
|
|
194
|
-
* Sensitive fields to redact
|
|
195
|
-
*/
|
|
196
|
-
sensitiveFields?: string[];
|
|
401
|
+
/** Inclusive time window in milliseconds since the Unix epoch. */
|
|
402
|
+
interface CollectWindow {
|
|
403
|
+
/** Keep entries with `timestamp >= since`. */
|
|
404
|
+
since?: number;
|
|
405
|
+
/** Keep entries with `timestamp <= until`. */
|
|
406
|
+
until?: number;
|
|
197
407
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
408
|
+
declare class RingBuffer<T extends {
|
|
409
|
+
timestamp: number;
|
|
410
|
+
}> {
|
|
411
|
+
readonly capacity: number;
|
|
412
|
+
private readonly slots;
|
|
413
|
+
private start;
|
|
414
|
+
private count;
|
|
415
|
+
constructor(capacity: number);
|
|
416
|
+
/** Append an entry, evicting the oldest one when the buffer is full. */
|
|
417
|
+
push(entry: T): void;
|
|
418
|
+
/** Entries in insertion order, oldest first. */
|
|
419
|
+
toArray(): T[];
|
|
420
|
+
/**
|
|
421
|
+
* Entries whose timestamp lies in the inclusive window, in insertion order.
|
|
422
|
+
* Either bound may be omitted; an empty window (`since > until`) matches
|
|
423
|
+
* nothing. Entries are filtered rather than searched, so a wall clock that
|
|
424
|
+
* stepped backwards cannot hide an entry.
|
|
425
|
+
*/
|
|
426
|
+
query(window?: CollectWindow): T[];
|
|
203
427
|
clear(): void;
|
|
428
|
+
get size(): number;
|
|
204
429
|
}
|
|
205
430
|
|
|
206
431
|
/**
|
|
207
|
-
*
|
|
432
|
+
* Records `console.log/info/warn/error/debug` calls as console evidence
|
|
433
|
+
* events in a bounded buffer. Runs on its own, without a reporter or server.
|
|
208
434
|
*/
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
private
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
constructor(config: CatchFnConfig);
|
|
218
|
-
/**
|
|
219
|
-
* Add a breadcrumb
|
|
220
|
-
*/
|
|
221
|
-
addBreadcrumb(breadcrumb: Omit<Breadcrumb, "timestamp">): void;
|
|
222
|
-
/**
|
|
223
|
-
* Register a beforeSend hook
|
|
224
|
-
*/
|
|
225
|
-
beforeSend(hook: BeforeSendHook): void;
|
|
226
|
-
/**
|
|
227
|
-
* Add an ignore pattern
|
|
228
|
-
*/
|
|
229
|
-
addIgnorePattern(pattern: IgnorePattern): void;
|
|
230
|
-
/**
|
|
231
|
-
* Check if an event should be ignored
|
|
232
|
-
*/
|
|
233
|
-
private shouldIgnore;
|
|
234
|
-
/**
|
|
235
|
-
* Apply beforeSend hooks
|
|
236
|
-
*/
|
|
237
|
-
private applyHooks;
|
|
238
|
-
/**
|
|
239
|
-
* Capture a bug report
|
|
240
|
-
*/
|
|
241
|
-
captureBug(options: CaptureBugOptions): Promise<BugReportEvent>;
|
|
242
|
-
/**
|
|
243
|
-
* Clear all collected context
|
|
244
|
-
*/
|
|
435
|
+
declare class ConsoleCollector {
|
|
436
|
+
private readonly events;
|
|
437
|
+
private unsubscribe?;
|
|
438
|
+
constructor(maxSize?: number);
|
|
439
|
+
start(): void;
|
|
440
|
+
stop(): void;
|
|
441
|
+
/** Captured events, oldest first, optionally limited to a time window. */
|
|
442
|
+
collect(window?: CollectWindow): ConsoleEvidenceEvent[];
|
|
245
443
|
clear(): void;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
444
|
+
size(): number;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
type IgnorePattern = string | RegExp;
|
|
448
|
+
interface NetworkCollectorOptions {
|
|
449
|
+
/** Record only requests whose redacted URL matches one of these. */
|
|
450
|
+
allowUrls?: IgnorePattern[];
|
|
451
|
+
/** Never record requests whose redacted URL matches one of these. */
|
|
452
|
+
blockUrls?: IgnorePattern[];
|
|
453
|
+
/** Keep only these headers (case-insensitive). */
|
|
454
|
+
allowedHeaders?: string[];
|
|
455
|
+
/** Drop these headers (case-insensitive). */
|
|
456
|
+
blockedHeaders?: string[];
|
|
457
|
+
}
|
|
458
|
+
/** Recorded for a request URL that is not a string, `URL` or `Request`. */
|
|
459
|
+
declare const UNREAD_URL = "[UNREAD_URL]";
|
|
460
|
+
/** Recorded for a request method that is not a string data value. */
|
|
461
|
+
declare const UNREAD_METHOD = "[UNREAD_METHOD]";
|
|
462
|
+
/**
|
|
463
|
+
* Records `fetch` and `XMLHttpRequest` calls as network evidence events in a
|
|
464
|
+
* bounded buffer. URLs and headers are redacted before they are stored; the
|
|
465
|
+
* application's requests are never modified. Runs on its own, without a
|
|
466
|
+
* reporter or server.
|
|
467
|
+
*/
|
|
468
|
+
declare class NetworkCollector {
|
|
469
|
+
private readonly options;
|
|
470
|
+
private readonly events;
|
|
471
|
+
private unsubscribe?;
|
|
472
|
+
constructor(maxSize?: number, options?: NetworkCollectorOptions);
|
|
473
|
+
start(): void;
|
|
249
474
|
stop(): void;
|
|
250
|
-
/**
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
475
|
+
/** Captured events, oldest first, optionally limited to a time window. */
|
|
476
|
+
collect(window?: CollectWindow): NetworkEvidenceEvent[];
|
|
477
|
+
clear(): void;
|
|
478
|
+
size(): number;
|
|
479
|
+
private filterHeaders;
|
|
254
480
|
}
|
|
255
481
|
|
|
256
482
|
/**
|
|
257
|
-
* Breadcrumb collector -
|
|
483
|
+
* Breadcrumb collector - a bounded buffer of user actions and milestones.
|
|
258
484
|
*/
|
|
259
485
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
486
|
+
interface BreadcrumbInput {
|
|
487
|
+
type: BreadcrumbType;
|
|
488
|
+
message?: string;
|
|
489
|
+
data?: Record<string, unknown>;
|
|
490
|
+
category?: string;
|
|
491
|
+
level?: BreadcrumbLevel;
|
|
492
|
+
}
|
|
493
|
+
declare class BreadcrumbCollector {
|
|
494
|
+
private readonly events;
|
|
263
495
|
constructor(maxSize?: number);
|
|
264
496
|
/**
|
|
265
|
-
* Add a breadcrumb
|
|
266
|
-
|
|
267
|
-
add(breadcrumb: Omit<Breadcrumb, "timestamp">): void;
|
|
268
|
-
/**
|
|
269
|
-
* Add a navigation breadcrumb
|
|
497
|
+
* Add a breadcrumb. Throws a TypeError for a type or level outside the v1
|
|
498
|
+
* event format.
|
|
270
499
|
*/
|
|
500
|
+
add(breadcrumb: BreadcrumbInput): void;
|
|
501
|
+
/** Add a navigation breadcrumb. */
|
|
271
502
|
addNavigation(from: string, to: string): void;
|
|
272
|
-
/**
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
addConsole(level: Breadcrumb["level"], message: string): void;
|
|
276
|
-
/**
|
|
277
|
-
* Add a network breadcrumb
|
|
278
|
-
*/
|
|
503
|
+
/** Add a console breadcrumb. */
|
|
504
|
+
addConsole(level: BreadcrumbLevel, message: string): void;
|
|
505
|
+
/** Add a network breadcrumb. The URL is redacted with `redactUrl`. */
|
|
279
506
|
addNetwork(method: string, url: string, status?: number): void;
|
|
280
|
-
/**
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Collect all breadcrumbs
|
|
286
|
-
*/
|
|
287
|
-
collect(): Breadcrumb[];
|
|
288
|
-
/**
|
|
289
|
-
* Clear all breadcrumbs
|
|
290
|
-
*/
|
|
507
|
+
/** Add a user interaction breadcrumb. */
|
|
508
|
+
addUser(action: string, target: string, data?: Record<string, unknown>): void;
|
|
509
|
+
/** Captured events, oldest first, optionally limited to a time window. */
|
|
510
|
+
collect(window?: CollectWindow): BreadcrumbEvidenceEvent[];
|
|
291
511
|
clear(): void;
|
|
292
|
-
/**
|
|
293
|
-
* Get the current number of breadcrumbs
|
|
294
|
-
*/
|
|
295
512
|
size(): number;
|
|
296
513
|
}
|
|
297
514
|
|
|
298
515
|
/**
|
|
299
|
-
*
|
|
516
|
+
* Records uncaught errors (the window `error` event) and unhandled promise
|
|
517
|
+
* rejections (`unhandledrejection`) as error evidence events in a bounded
|
|
518
|
+
* buffer. It only listens: it never cancels an event, so the page's own
|
|
519
|
+
* handlers and the browser's console report run as before. Runs on its own,
|
|
520
|
+
* without a reporter or server.
|
|
300
521
|
*/
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
private
|
|
304
|
-
private maxSize;
|
|
305
|
-
private originalMethods;
|
|
306
|
-
private isActive;
|
|
522
|
+
declare class ErrorCollector {
|
|
523
|
+
private readonly events;
|
|
524
|
+
private subscription?;
|
|
307
525
|
constructor(maxSize?: number);
|
|
308
|
-
/**
|
|
309
|
-
* Start intercepting console methods
|
|
310
|
-
*/
|
|
311
526
|
start(): void;
|
|
312
|
-
/**
|
|
313
|
-
* Stop intercepting console methods
|
|
314
|
-
*/
|
|
315
527
|
stop(): void;
|
|
316
|
-
/**
|
|
317
|
-
|
|
318
|
-
*/
|
|
319
|
-
private capture;
|
|
320
|
-
/**
|
|
321
|
-
* Serialize console arguments
|
|
322
|
-
*/
|
|
323
|
-
private serializeArgs;
|
|
324
|
-
/**
|
|
325
|
-
* Collect all console logs
|
|
326
|
-
*/
|
|
327
|
-
collect(): ConsoleLogEntry[];
|
|
328
|
-
/**
|
|
329
|
-
* Clear all console logs
|
|
330
|
-
*/
|
|
528
|
+
/** Captured events, oldest first, optionally limited to a time window. */
|
|
529
|
+
collect(window?: CollectWindow): ErrorEvidenceEvent[];
|
|
331
530
|
clear(): void;
|
|
332
|
-
/**
|
|
333
|
-
* Get the current number of logs
|
|
334
|
-
*/
|
|
335
531
|
size(): number;
|
|
336
532
|
}
|
|
337
533
|
|
|
338
534
|
/**
|
|
339
|
-
*
|
|
535
|
+
* Records the `open`, `message`, `close` and `error` events of WebSocket
|
|
536
|
+
* connections as websocket evidence events in a bounded buffer: messages in
|
|
537
|
+
* both directions with their size in bytes, never their payload, and the
|
|
538
|
+
* socket URL redacted with `redactUrl`. Only sockets constructed while a
|
|
539
|
+
* collector runs are observed. Runs on its own, without a reporter or server.
|
|
340
540
|
*/
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
private
|
|
344
|
-
private maxSize;
|
|
345
|
-
private originalFetch?;
|
|
346
|
-
private originalXHROpen?;
|
|
347
|
-
private originalXHRSend?;
|
|
348
|
-
private isActive;
|
|
349
|
-
private sensitiveHeaders;
|
|
541
|
+
declare class WebSocketCollector {
|
|
542
|
+
private readonly events;
|
|
543
|
+
private unsubscribe?;
|
|
350
544
|
constructor(maxSize?: number);
|
|
351
|
-
/**
|
|
352
|
-
* Start intercepting network requests
|
|
353
|
-
*/
|
|
354
545
|
start(): void;
|
|
355
|
-
/**
|
|
356
|
-
* Stop intercepting network requests
|
|
357
|
-
*/
|
|
358
546
|
stop(): void;
|
|
359
|
-
/**
|
|
360
|
-
|
|
361
|
-
*/
|
|
362
|
-
private interceptFetch;
|
|
363
|
-
/**
|
|
364
|
-
* Intercept XMLHttpRequest
|
|
365
|
-
*/
|
|
366
|
-
private interceptXHR;
|
|
367
|
-
/**
|
|
368
|
-
* Extract and sanitize headers
|
|
369
|
-
*/
|
|
370
|
-
private extractHeaders;
|
|
371
|
-
/**
|
|
372
|
-
* Add a network request
|
|
373
|
-
*/
|
|
374
|
-
private addRequest;
|
|
375
|
-
/**
|
|
376
|
-
* Collect all network requests
|
|
377
|
-
*/
|
|
378
|
-
collect(): NetworkRequest[];
|
|
379
|
-
/**
|
|
380
|
-
* Clear all network requests
|
|
381
|
-
*/
|
|
547
|
+
/** Captured events, oldest first, optionally limited to a time window. */
|
|
548
|
+
collect(window?: CollectWindow): WebSocketEvidenceEvent[];
|
|
382
549
|
clear(): void;
|
|
383
|
-
/**
|
|
384
|
-
* Get the current number of requests
|
|
385
|
-
*/
|
|
386
550
|
size(): number;
|
|
387
551
|
}
|
|
388
552
|
|
|
389
553
|
/**
|
|
390
|
-
*
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
*/
|
|
397
|
-
static collect(): DeviceInfo;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Data redaction utilities
|
|
554
|
+
* Redact sensitive values from an object. The input is first snapshotted
|
|
555
|
+
* under the serialization closed set, so the result is bounded JSON data.
|
|
556
|
+
* Keys matching a sensitive pattern become "[REDACTED]", and strings under a
|
|
557
|
+
* key that names a URL or href are passed through {@link redactUrl}. The
|
|
558
|
+
* redacted result is bounded again, since a replacement can be longer than
|
|
559
|
+
* the value it replaces.
|
|
402
560
|
*/
|
|
403
|
-
|
|
404
|
-
* Redact sensitive values from an object
|
|
405
|
-
*/
|
|
406
|
-
declare function redactObject(obj: any, customPatterns?: RegExp[]): any;
|
|
561
|
+
declare function redactObject(obj: unknown, customPatterns?: RegExp[]): any;
|
|
407
562
|
/**
|
|
408
563
|
* Redact sensitive data from strings
|
|
409
564
|
*/
|
|
@@ -417,46 +572,4 @@ declare function redactUrl(url: string, sensitiveParams?: string[]): string;
|
|
|
417
572
|
*/
|
|
418
573
|
declare function redactHeaders(headers: Record<string, string>): Record<string, string>;
|
|
419
574
|
|
|
420
|
-
|
|
421
|
-
* Error and data serialization utilities
|
|
422
|
-
*/
|
|
423
|
-
/**
|
|
424
|
-
* Serialize an Error object
|
|
425
|
-
*/
|
|
426
|
-
declare function serializeError(error: Error): Record<string, any>;
|
|
427
|
-
/**
|
|
428
|
-
* Safely serialize any value, handling circular references
|
|
429
|
-
*/
|
|
430
|
-
declare function safeSerialize(value: any, maxDepth?: number): any;
|
|
431
|
-
/**
|
|
432
|
-
* Estimate the size of a serialized object in bytes
|
|
433
|
-
*/
|
|
434
|
-
declare function estimateSize(obj: any): number;
|
|
435
|
-
/**
|
|
436
|
-
* Truncate a string to a maximum length
|
|
437
|
-
*/
|
|
438
|
-
declare function truncateString(str: string, maxLength: number): string;
|
|
439
|
-
/**
|
|
440
|
-
* Trim an array to a maximum size
|
|
441
|
-
*/
|
|
442
|
-
declare function trimArray<T>(arr: T[], maxSize: number): T[];
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* Size limiting utilities
|
|
446
|
-
*/
|
|
447
|
-
/**
|
|
448
|
-
* Limit the size of a payload
|
|
449
|
-
*/
|
|
450
|
-
declare function limitPayloadSize(payload: any, maxSize: number): any;
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* CatchFn - Self-hosted bug reporting and context collection
|
|
454
|
-
* @module catchfn
|
|
455
|
-
*/
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* Create a new CatchFn instance
|
|
459
|
-
*/
|
|
460
|
-
declare function catchFn(config: CatchFnConfig): CatchFn;
|
|
461
|
-
|
|
462
|
-
export { type AttachmentReference, type BeforeSendHook, type Breadcrumb, BreadcrumbCollector, type BreadcrumbType, type BugReportEvent, type BugSeverity, type CaptureBugOptions, CatchFn, type CatchFnConfig, ConsoleCollector, type ConsoleLogEntry, type ContextCollector, DeviceCollector, type DeviceInfo, type IgnorePattern, NetworkCollector, type NetworkRequest, catchFn, catchFn as default, estimateSize, limitPayloadSize, redactHeaders, redactObject, redactString, redactUrl, safeSerialize, serializeError, trimArray, truncateString };
|
|
575
|
+
export { BREADCRUMB_LEVELS, BREADCRUMB_TYPES, BreadcrumbCollector, type BreadcrumbEvidenceEvent, type BreadcrumbInput, type BreadcrumbLevel, type BreadcrumbType, CIRCULAR, CONSOLE_LEVELS, type CollectWindow, ConsoleCollector, type ConsoleEvidenceEvent, type ConsoleLevel, ERROR_SOURCES, EVIDENCE_KINDS, EVIDENCE_SCHEMA_VERSION, ErrorCollector, type ErrorEvidenceEvent, type ErrorSource, type EvidenceEvent, type EvidenceEventBase, type EvidenceKind, type IgnorePattern, MAX_DEPTH, MAX_DEPTH_MARKER, MAX_ENTRY_BYTES, MAX_KEYS, NETWORK_TRANSPORTS, NetworkCollector, type NetworkCollectorOptions, type NetworkEvidenceEvent, type NetworkTransport, RingBuffer, type SerializedValue, TRUNCATED, UNREAD_METHOD, UNREAD_URL, UNSERIALIZABLE, WEBSOCKET_DIRECTIONS, WEBSOCKET_EVENT_TYPES, WebSocketCollector, type WebSocketDirection, type WebSocketEventType, type WebSocketEvidenceEvent, evidenceEventSchema, isEvidenceEvent, redactHeaders, redactObject, redactString, redactUrl, safeSerialize, serializeEntry, truncateString, validateEvidenceEvent };
|