@diegotsi/flint-core 1.10.2 → 1.11.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.cjs +24 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +24 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -15,6 +15,7 @@ interface ConsoleCollector {
|
|
|
15
15
|
start(): void;
|
|
16
16
|
stop(): void;
|
|
17
17
|
getEntries(): ConsoleEntry[];
|
|
18
|
+
getErrors(): CapturedError[];
|
|
18
19
|
}
|
|
19
20
|
declare function createConsoleCollector(): ConsoleCollector;
|
|
20
21
|
|
|
@@ -54,6 +55,15 @@ interface ConsoleEntry {
|
|
|
54
55
|
args: string;
|
|
55
56
|
timestamp: number;
|
|
56
57
|
}
|
|
58
|
+
/** A structured uncaught error / unhandled rejection, captured with its stack. */
|
|
59
|
+
interface CapturedError {
|
|
60
|
+
message: string;
|
|
61
|
+
/** Raw (possibly minified) stack; symbolicated server-side against uploaded source maps. */
|
|
62
|
+
stack?: string;
|
|
63
|
+
/** Error constructor name, e.g. "TypeError". */
|
|
64
|
+
errorClass?: string;
|
|
65
|
+
timestamp: number;
|
|
66
|
+
}
|
|
57
67
|
interface NetworkEntry {
|
|
58
68
|
method: string;
|
|
59
69
|
url: string;
|
|
@@ -199,6 +209,14 @@ interface CollectedMeta {
|
|
|
199
209
|
consoleLogs: ConsoleEntry[];
|
|
200
210
|
networkErrors: NetworkEntry[];
|
|
201
211
|
formErrors: FormErrorEntry[];
|
|
212
|
+
/** Structured uncaught errors captured during the session (newest last). */
|
|
213
|
+
errors?: CapturedError[];
|
|
214
|
+
/** Epoch ms when the user opened the report — anchors the bug moment. */
|
|
215
|
+
reportedAt?: number;
|
|
216
|
+
/** Epoch ms of the most recent captured error before the report, if any. */
|
|
217
|
+
errorAt?: number;
|
|
218
|
+
/** Raw stack of the most recent captured error, if any (symbolicated server-side). */
|
|
219
|
+
errorStack?: string;
|
|
202
220
|
}
|
|
203
221
|
interface ReportPayload {
|
|
204
222
|
reporterId: string;
|
|
@@ -396,4 +414,4 @@ interface ResolvedTheme {
|
|
|
396
414
|
}
|
|
397
415
|
declare function resolveTheme(theme: Theme): ResolvedTheme;
|
|
398
416
|
|
|
399
|
-
export { type CollectedMeta, type ConsoleCollector, type ConsoleEntry, DATADOG_BLOCKED_HOSTS, type EnvironmentInfo, type ErrorBreadcrumbs, type ErrorCaptureCollector, type ErrorCaptureOptions, type ErrorEventPayload, Flint, type FlintConfig, type FlintState, type FlintUser, type FlintWidgetProps, type FormErrorCollector, type FormErrorEntry, type FrustrationCollector, type FrustrationEvent, type Locale, type NetworkCollector, type NetworkEntry, type ReportPayload, type ReportResult, type ResolvedTheme, type Severity, type Theme, type ThemeOverride, _setFormErrorCollector, collectEnvironment, createConsoleCollector, createDatadogReplayProvider, createErrorCaptureCollector, createFormErrorCollector, createFrustrationCollector, createNetworkCollector, getSnapshot, resolveTheme, submitReplay, submitReport, subscribe, trackDatadogBugReported };
|
|
417
|
+
export { type CapturedError, type CollectedMeta, type ConsoleCollector, type ConsoleEntry, DATADOG_BLOCKED_HOSTS, type EnvironmentInfo, type ErrorBreadcrumbs, type ErrorCaptureCollector, type ErrorCaptureOptions, type ErrorEventPayload, Flint, type FlintConfig, type FlintState, type FlintUser, type FlintWidgetProps, type FormErrorCollector, type FormErrorEntry, type FrustrationCollector, type FrustrationEvent, type Locale, type NetworkCollector, type NetworkEntry, type ReportPayload, type ReportResult, type ResolvedTheme, type Severity, type Theme, type ThemeOverride, _setFormErrorCollector, collectEnvironment, createConsoleCollector, createDatadogReplayProvider, createErrorCaptureCollector, createFormErrorCollector, createFrustrationCollector, createNetworkCollector, getSnapshot, resolveTheme, submitReplay, submitReport, subscribe, trackDatadogBugReported };
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ interface ConsoleCollector {
|
|
|
15
15
|
start(): void;
|
|
16
16
|
stop(): void;
|
|
17
17
|
getEntries(): ConsoleEntry[];
|
|
18
|
+
getErrors(): CapturedError[];
|
|
18
19
|
}
|
|
19
20
|
declare function createConsoleCollector(): ConsoleCollector;
|
|
20
21
|
|
|
@@ -54,6 +55,15 @@ interface ConsoleEntry {
|
|
|
54
55
|
args: string;
|
|
55
56
|
timestamp: number;
|
|
56
57
|
}
|
|
58
|
+
/** A structured uncaught error / unhandled rejection, captured with its stack. */
|
|
59
|
+
interface CapturedError {
|
|
60
|
+
message: string;
|
|
61
|
+
/** Raw (possibly minified) stack; symbolicated server-side against uploaded source maps. */
|
|
62
|
+
stack?: string;
|
|
63
|
+
/** Error constructor name, e.g. "TypeError". */
|
|
64
|
+
errorClass?: string;
|
|
65
|
+
timestamp: number;
|
|
66
|
+
}
|
|
57
67
|
interface NetworkEntry {
|
|
58
68
|
method: string;
|
|
59
69
|
url: string;
|
|
@@ -199,6 +209,14 @@ interface CollectedMeta {
|
|
|
199
209
|
consoleLogs: ConsoleEntry[];
|
|
200
210
|
networkErrors: NetworkEntry[];
|
|
201
211
|
formErrors: FormErrorEntry[];
|
|
212
|
+
/** Structured uncaught errors captured during the session (newest last). */
|
|
213
|
+
errors?: CapturedError[];
|
|
214
|
+
/** Epoch ms when the user opened the report — anchors the bug moment. */
|
|
215
|
+
reportedAt?: number;
|
|
216
|
+
/** Epoch ms of the most recent captured error before the report, if any. */
|
|
217
|
+
errorAt?: number;
|
|
218
|
+
/** Raw stack of the most recent captured error, if any (symbolicated server-side). */
|
|
219
|
+
errorStack?: string;
|
|
202
220
|
}
|
|
203
221
|
interface ReportPayload {
|
|
204
222
|
reporterId: string;
|
|
@@ -396,4 +414,4 @@ interface ResolvedTheme {
|
|
|
396
414
|
}
|
|
397
415
|
declare function resolveTheme(theme: Theme): ResolvedTheme;
|
|
398
416
|
|
|
399
|
-
export { type CollectedMeta, type ConsoleCollector, type ConsoleEntry, DATADOG_BLOCKED_HOSTS, type EnvironmentInfo, type ErrorBreadcrumbs, type ErrorCaptureCollector, type ErrorCaptureOptions, type ErrorEventPayload, Flint, type FlintConfig, type FlintState, type FlintUser, type FlintWidgetProps, type FormErrorCollector, type FormErrorEntry, type FrustrationCollector, type FrustrationEvent, type Locale, type NetworkCollector, type NetworkEntry, type ReportPayload, type ReportResult, type ResolvedTheme, type Severity, type Theme, type ThemeOverride, _setFormErrorCollector, collectEnvironment, createConsoleCollector, createDatadogReplayProvider, createErrorCaptureCollector, createFormErrorCollector, createFrustrationCollector, createNetworkCollector, getSnapshot, resolveTheme, submitReplay, submitReport, subscribe, trackDatadogBugReported };
|
|
417
|
+
export { type CapturedError, type CollectedMeta, type ConsoleCollector, type ConsoleEntry, DATADOG_BLOCKED_HOSTS, type EnvironmentInfo, type ErrorBreadcrumbs, type ErrorCaptureCollector, type ErrorCaptureOptions, type ErrorEventPayload, Flint, type FlintConfig, type FlintState, type FlintUser, type FlintWidgetProps, type FormErrorCollector, type FormErrorEntry, type FrustrationCollector, type FrustrationEvent, type Locale, type NetworkCollector, type NetworkEntry, type ReportPayload, type ReportResult, type ResolvedTheme, type Severity, type Theme, type ThemeOverride, _setFormErrorCollector, collectEnvironment, createConsoleCollector, createDatadogReplayProvider, createErrorCaptureCollector, createFormErrorCollector, createFrustrationCollector, createNetworkCollector, getSnapshot, resolveTheme, submitReplay, submitReport, subscribe, trackDatadogBugReported };
|
package/dist/index.js
CHANGED
|
@@ -92,8 +92,10 @@ function sanitize(str) {
|
|
|
92
92
|
|
|
93
93
|
// src/collectors/console.ts
|
|
94
94
|
var MAX_ENTRIES = 50;
|
|
95
|
+
var MAX_ERRORS = 10;
|
|
95
96
|
function createConsoleCollector() {
|
|
96
97
|
const entries = [];
|
|
98
|
+
const errors = [];
|
|
97
99
|
let active = false;
|
|
98
100
|
const originals = {
|
|
99
101
|
log: console.log.bind(console),
|
|
@@ -114,6 +116,15 @@ function createConsoleCollector() {
|
|
|
114
116
|
entries.push({ level, args: str, timestamp: Date.now() });
|
|
115
117
|
if (entries.length > MAX_ENTRIES) entries.shift();
|
|
116
118
|
}
|
|
119
|
+
function pushError(message, stack, errorClass) {
|
|
120
|
+
errors.push({
|
|
121
|
+
message: sanitize(message),
|
|
122
|
+
stack: stack ? sanitize(stack) : void 0,
|
|
123
|
+
errorClass,
|
|
124
|
+
timestamp: Date.now()
|
|
125
|
+
});
|
|
126
|
+
if (errors.length > MAX_ERRORS) errors.shift();
|
|
127
|
+
}
|
|
117
128
|
return {
|
|
118
129
|
start() {
|
|
119
130
|
if (active) return;
|
|
@@ -132,14 +143,22 @@ function createConsoleCollector() {
|
|
|
132
143
|
};
|
|
133
144
|
origOnerror = window.onerror;
|
|
134
145
|
window.onerror = (msg, src, line, col, err) => {
|
|
135
|
-
|
|
146
|
+
const message = err?.message ?? String(msg);
|
|
147
|
+
push("error", [message, `${src}:${line}:${col}`]);
|
|
148
|
+
pushError(message, err?.stack, err?.name);
|
|
136
149
|
if (typeof origOnerror === "function") return origOnerror(msg, src, line, col, err);
|
|
137
150
|
return false;
|
|
138
151
|
};
|
|
139
152
|
origUnhandled = window.onunhandledrejection;
|
|
140
153
|
window.onunhandledrejection = (event) => {
|
|
141
|
-
const
|
|
154
|
+
const isError = event.reason instanceof Error;
|
|
155
|
+
const reason = isError ? event.reason.message : JSON.stringify(event.reason);
|
|
142
156
|
push("error", ["UnhandledRejection:", reason]);
|
|
157
|
+
pushError(
|
|
158
|
+
reason,
|
|
159
|
+
isError ? event.reason.stack : void 0,
|
|
160
|
+
isError ? event.reason.name : void 0
|
|
161
|
+
);
|
|
143
162
|
if (typeof origUnhandled === "function") origUnhandled.call(window, event);
|
|
144
163
|
};
|
|
145
164
|
},
|
|
@@ -154,6 +173,9 @@ function createConsoleCollector() {
|
|
|
154
173
|
},
|
|
155
174
|
getEntries() {
|
|
156
175
|
return [...entries];
|
|
176
|
+
},
|
|
177
|
+
getErrors() {
|
|
178
|
+
return [...errors];
|
|
157
179
|
}
|
|
158
180
|
};
|
|
159
181
|
}
|