@wtfalch/reporting 0.3.0 → 0.3.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/browser/index.d.ts +8 -0
- package/dist/browser/index.js +6 -0
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -47,6 +47,14 @@ export interface Beacon {
|
|
|
47
47
|
decline(): void;
|
|
48
48
|
answer(): ConsentAnswer;
|
|
49
49
|
visitorId(): string | null;
|
|
50
|
+
/**
|
|
51
|
+
* Report an error the browser never threw at `window` -- the one a React
|
|
52
|
+
* error boundary caught, which is swallowed before `window.onerror` can
|
|
53
|
+
* see it, and is exactly the case `error.tsx` exists for. Subject to the
|
|
54
|
+
* same de-duplication and the same per-page caps as a thrown one; a no-op
|
|
55
|
+
* when `errors` is off.
|
|
56
|
+
*/
|
|
57
|
+
captureError(error: unknown, kind?: string): void;
|
|
50
58
|
flush(): void;
|
|
51
59
|
destroy(): void;
|
|
52
60
|
}
|
package/dist/browser/index.js
CHANGED
|
@@ -134,6 +134,7 @@ export function createBeacon(options) {
|
|
|
134
134
|
const ERROR_DISTINCT_MAX = 5;
|
|
135
135
|
const ERROR_TOTAL_MAX = 20;
|
|
136
136
|
let errCleanup = null;
|
|
137
|
+
let recordError = null;
|
|
137
138
|
if (options.errors && options.errorCollector) {
|
|
138
139
|
const errorCollector = options.errorCollector;
|
|
139
140
|
const seen = new Map();
|
|
@@ -217,6 +218,10 @@ export function createBeacon(options) {
|
|
|
217
218
|
return { kind: fallbackKind, message: fallbackKind, stack: null };
|
|
218
219
|
}
|
|
219
220
|
}
|
|
221
|
+
recordError = (error, kind) => {
|
|
222
|
+
const info = describeReason(error, kind ?? 'Error');
|
|
223
|
+
record(info.kind, info.message, info.stack);
|
|
224
|
+
};
|
|
220
225
|
const onError = (event) => {
|
|
221
226
|
// A cross-origin script with no CORS grant reports exactly this
|
|
222
227
|
// message, with no line, column or Error object: nothing here is
|
|
@@ -316,6 +321,7 @@ export function createBeacon(options) {
|
|
|
316
321
|
},
|
|
317
322
|
answer: () => answer,
|
|
318
323
|
visitorId: () => (declined() ? null : (cookie?.id ?? null)),
|
|
324
|
+
captureError: (error, kind) => recordError?.(error, kind),
|
|
319
325
|
flush,
|
|
320
326
|
destroy() {
|
|
321
327
|
flush();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wtfalch/reporting",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "The estate's operational event log and housekeeping tick: a writer that never fails a request, a claim protocol that needs no scheduler, and the readers an operator opens. Per-app Postgres, host-supplied logger, framework-neutral core with a Next entry.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|