@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.cjs
CHANGED
|
@@ -180,8 +180,10 @@ function sanitize(str) {
|
|
|
180
180
|
|
|
181
181
|
// src/collectors/console.ts
|
|
182
182
|
var MAX_ENTRIES = 50;
|
|
183
|
+
var MAX_ERRORS = 10;
|
|
183
184
|
function createConsoleCollector() {
|
|
184
185
|
const entries = [];
|
|
186
|
+
const errors = [];
|
|
185
187
|
let active = false;
|
|
186
188
|
const originals = {
|
|
187
189
|
log: console.log.bind(console),
|
|
@@ -202,6 +204,15 @@ function createConsoleCollector() {
|
|
|
202
204
|
entries.push({ level, args: str, timestamp: Date.now() });
|
|
203
205
|
if (entries.length > MAX_ENTRIES) entries.shift();
|
|
204
206
|
}
|
|
207
|
+
function pushError(message, stack, errorClass) {
|
|
208
|
+
errors.push({
|
|
209
|
+
message: sanitize(message),
|
|
210
|
+
stack: stack ? sanitize(stack) : void 0,
|
|
211
|
+
errorClass,
|
|
212
|
+
timestamp: Date.now()
|
|
213
|
+
});
|
|
214
|
+
if (errors.length > MAX_ERRORS) errors.shift();
|
|
215
|
+
}
|
|
205
216
|
return {
|
|
206
217
|
start() {
|
|
207
218
|
if (active) return;
|
|
@@ -220,14 +231,22 @@ function createConsoleCollector() {
|
|
|
220
231
|
};
|
|
221
232
|
origOnerror = window.onerror;
|
|
222
233
|
window.onerror = (msg, src, line, col, err) => {
|
|
223
|
-
|
|
234
|
+
const message = err?.message ?? String(msg);
|
|
235
|
+
push("error", [message, `${src}:${line}:${col}`]);
|
|
236
|
+
pushError(message, err?.stack, err?.name);
|
|
224
237
|
if (typeof origOnerror === "function") return origOnerror(msg, src, line, col, err);
|
|
225
238
|
return false;
|
|
226
239
|
};
|
|
227
240
|
origUnhandled = window.onunhandledrejection;
|
|
228
241
|
window.onunhandledrejection = (event) => {
|
|
229
|
-
const
|
|
242
|
+
const isError = event.reason instanceof Error;
|
|
243
|
+
const reason = isError ? event.reason.message : JSON.stringify(event.reason);
|
|
230
244
|
push("error", ["UnhandledRejection:", reason]);
|
|
245
|
+
pushError(
|
|
246
|
+
reason,
|
|
247
|
+
isError ? event.reason.stack : void 0,
|
|
248
|
+
isError ? event.reason.name : void 0
|
|
249
|
+
);
|
|
231
250
|
if (typeof origUnhandled === "function") origUnhandled.call(window, event);
|
|
232
251
|
};
|
|
233
252
|
},
|
|
@@ -242,6 +261,9 @@ function createConsoleCollector() {
|
|
|
242
261
|
},
|
|
243
262
|
getEntries() {
|
|
244
263
|
return [...entries];
|
|
264
|
+
},
|
|
265
|
+
getErrors() {
|
|
266
|
+
return [...errors];
|
|
245
267
|
}
|
|
246
268
|
};
|
|
247
269
|
}
|