@absolutejs/beacon 0.6.45 → 0.6.47
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 +5 -1
- package/dist/index.d.ts +17 -12
- package/dist/index.js +29 -17
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -186,7 +186,10 @@ beacon.captureMessage("checkout started", "info");
|
|
|
186
186
|
exposes it; missing browser attribution is labeled explicitly. Layout
|
|
187
187
|
Instability names shifted elements. Successful HTTP responses can be
|
|
188
188
|
classified through the host-owned `instrument.classifyResponse` callback for
|
|
189
|
-
GraphQL-style errors
|
|
189
|
+
GraphQL-style errors. Selected HTTP 4xx/5xx responses can be promoted through
|
|
190
|
+
the opt-in `instrument.classifyErrorResponse` callback when application context
|
|
191
|
+
proves they are internal contract failures. Beacon never retains response
|
|
192
|
+
bodies.
|
|
190
193
|
- **Lifecycle and platform gaps** — marked empty application roots, marked dirty
|
|
191
194
|
forms abandoned during navigation, marked media errors/stalls, Web Storage and
|
|
192
195
|
IndexedDB failures, discarded documents, bfcache rejection reasons, slow
|
|
@@ -216,6 +219,7 @@ close() => Promise<void> // remove listeners + final flush
|
|
|
216
219
|
BEACON_SIGNAL.FETCH_FAILED
|
|
217
220
|
BEACON_SIGNAL.SLOW_RESPONSE
|
|
218
221
|
BEACON_SIGNAL.HTTP_5XX
|
|
222
|
+
BEACON_SIGNAL.HTTP_RESPONSE_FAILURE
|
|
219
223
|
BEACON_TRACE_HEADER // "x-absolute-trace-id"
|
|
220
224
|
|
|
221
225
|
// Global helpers (no-op until initBeacon): captureException, captureMessage,
|
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare const BEACON_SIGNAL: {
|
|
|
42
42
|
readonly FORM_ABANDONMENT: "form_abandonment";
|
|
43
43
|
readonly FOCUSED_CONTROL_OFFSCREEN: "focused_control_offscreen";
|
|
44
44
|
readonly HTTP_5XX: "http_5xx";
|
|
45
|
+
readonly HTTP_RESPONSE_FAILURE: "http_response_failure";
|
|
45
46
|
readonly INVISIBLE_TEXT: "invisible_text";
|
|
46
47
|
readonly EMBEDDED_CONTENT_STALLED: "embedded_content_stalled";
|
|
47
48
|
readonly LAYOUT_OVERFLOW: "layout_overflow";
|
|
@@ -155,6 +156,16 @@ export type BeaconTransport = (request: {
|
|
|
155
156
|
/** True on unload-time flushes — prefer `navigator.sendBeacon`. */
|
|
156
157
|
useBeacon: boolean;
|
|
157
158
|
}) => void | Promise<void>;
|
|
159
|
+
export type BeaconResponseClassification = {
|
|
160
|
+
groupingKey: string;
|
|
161
|
+
level?: BeaconLevel;
|
|
162
|
+
message: string;
|
|
163
|
+
tags?: Record<string, string>;
|
|
164
|
+
};
|
|
165
|
+
export type BeaconResponseClassifier = (response: Response, request: {
|
|
166
|
+
method: string;
|
|
167
|
+
url: string;
|
|
168
|
+
}) => void | false | BeaconResponseClassification | Promise<void | false | BeaconResponseClassification>;
|
|
158
169
|
export type BeaconInstrumentation = {
|
|
159
170
|
/** `window.onerror` / `error` events. Default true. */
|
|
160
171
|
globalErrors?: boolean;
|
|
@@ -184,18 +195,12 @@ export type BeaconInstrumentation = {
|
|
|
184
195
|
/** Privacy-owned application classifier for successful HTTP responses that
|
|
185
196
|
* encode a semantic failure (for example GraphQL errors in an HTTP 200).
|
|
186
197
|
* Beacon never reads or stores the response body itself. */
|
|
187
|
-
classifyResponse?:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
tags?: Record<string, string>;
|
|
194
|
-
} | Promise<void | false | {
|
|
195
|
-
groupingKey: string;
|
|
196
|
-
message: string;
|
|
197
|
-
tags?: Record<string, string>;
|
|
198
|
-
}>;
|
|
198
|
+
classifyResponse?: BeaconResponseClassifier;
|
|
199
|
+
/** Opt-in classifier for HTTP responses with status >= 400. Use this when
|
|
200
|
+
* application context can distinguish an internal contract failure carried
|
|
201
|
+
* as 4xx from an expected user/input rejection. Ordinary 4xx responses stay
|
|
202
|
+
* silent by default, and Beacon never reads or stores the body itself. */
|
|
203
|
+
classifyErrorResponse?: BeaconResponseClassifier;
|
|
199
204
|
};
|
|
200
205
|
export type BeaconResourceFailure = {
|
|
201
206
|
crossOrigin: boolean;
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ var BEACON_SIGNAL = {
|
|
|
29
29
|
FORM_ABANDONMENT: "form_abandonment",
|
|
30
30
|
FOCUSED_CONTROL_OFFSCREEN: "focused_control_offscreen",
|
|
31
31
|
HTTP_5XX: "http_5xx",
|
|
32
|
+
HTTP_RESPONSE_FAILURE: "http_response_failure",
|
|
32
33
|
INVISIBLE_TEXT: "invisible_text",
|
|
33
34
|
EMBEDDED_CONTENT_STALLED: "embedded_content_stalled",
|
|
34
35
|
LAYOUT_OVERFLOW: "layout_overflow",
|
|
@@ -321,7 +322,7 @@ var matchesErrorMessage = (event, expected) => expected.has(event.message) || ex
|
|
|
321
322
|
var isInstagramIosBridgeInjection = (event, userAgent) => INSTAGRAM_IOS_IN_APP_BROWSER.test(userAgent) && matchesErrorMessage(event, META_IOS_WEBKIT_BRIDGE_FAILURES) && event.stack?.includes("sendDataToNative") === true && event.stack.includes("sendPageHideMessage");
|
|
322
323
|
var FACEBOOK_ANDROID_DETACHED_BRIDGE_MESSAGE = "Error invoking postMessage: Java object is gone";
|
|
323
324
|
var FACEBOOK_ANDROID_PERFORMANCE_LOGGER = "iabjs://navigation_performance_logger_android";
|
|
324
|
-
var KNOWN_CRAWLER_USER_AGENT = /(?:AdsBot-Google|Googlebot|bingbot|Baiduspider|YandexBot|DuckDuckBot|Applebot|Bytespider|PetalBot|SemrushBot|AhrefsBot|DotBot|MJ12bot|GPTBot|ClaudeBot|PerplexityBot|Google-NotebookLM|BitSightBot|Dataprovider\.com|meta-external(?:agent|ads))/i;
|
|
325
|
+
var KNOWN_CRAWLER_USER_AGENT = /(?:AdsBot-Google|Googlebot|bingbot|Baiduspider|YandexBot|DuckDuckBot|Applebot|Bytespider|PetalBot|SemrushBot|AhrefsBot|DotBot|MJ12bot|GPTBot|ClaudeBot|PerplexityBot|Google-NotebookLM|BitSightBot|Dataprovider\.com|HubSpot Crawler|meta-external(?:agent|ads))/i;
|
|
325
326
|
var GOOGLE_WEB_RENDERER_SERVICE_WORKER_WRAPPER = "wrsParams.serviceWorkers.navigator.serviceWorker.register";
|
|
326
327
|
var EXTENSION_STACK_PROTOCOL = /(?:chrome|moz|safari-web)-extension:\/\//u;
|
|
327
328
|
var isExtensionOnlyStack = (event) => {
|
|
@@ -474,6 +475,7 @@ var UUID_PATH_SEGMENT = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-
|
|
|
474
475
|
var LONG_IDENTIFIER_SEGMENT = /\b(?:[0-9a-f]{16,}|\d{8,})\b/giu;
|
|
475
476
|
var VOLATILE_SIGNAL_TAGS = new Set([
|
|
476
477
|
"actionId",
|
|
478
|
+
"attemptCount",
|
|
477
479
|
"blockingDurationMs",
|
|
478
480
|
"blockingFrameDurationMs",
|
|
479
481
|
"blockerLocations",
|
|
@@ -490,6 +492,7 @@ var VOLATILE_SIGNAL_TAGS = new Set([
|
|
|
490
492
|
"obscuredPx",
|
|
491
493
|
"presentationDelayMs",
|
|
492
494
|
"processingDurationMs",
|
|
495
|
+
"reportDelayMs",
|
|
493
496
|
"responseMs",
|
|
494
497
|
"shiftValue",
|
|
495
498
|
"signal",
|
|
@@ -1222,17 +1225,19 @@ var createBeacon = (options) => {
|
|
|
1222
1225
|
for (const [kind, failures] of groups) {
|
|
1223
1226
|
const newestFailureAt = Math.max(...failures.map(({ at }) => at));
|
|
1224
1227
|
const reportDelayMs = Math.max(0, Date.now() - newestFailureAt);
|
|
1225
|
-
const endpoints = [
|
|
1226
|
-
|
|
1228
|
+
const endpoints = [
|
|
1229
|
+
...new Set(failures.map(({ endpoint: endpoint2 }) => endpoint2))
|
|
1230
|
+
].sort();
|
|
1231
|
+
const methods = [...new Set(failures.map(({ method }) => method))].sort();
|
|
1227
1232
|
const onlineStates = [
|
|
1228
1233
|
...new Set(failures.map(({ online }) => String(online)))
|
|
1229
|
-
];
|
|
1234
|
+
].sort();
|
|
1230
1235
|
const transports = [
|
|
1231
1236
|
...new Set(failures.map(({ transport: transport2 }) => transport2))
|
|
1232
|
-
];
|
|
1237
|
+
].sort();
|
|
1233
1238
|
const visibilityStates = [
|
|
1234
1239
|
...new Set(failures.map(({ visibilityState }) => visibilityState))
|
|
1235
|
-
];
|
|
1240
|
+
].sort();
|
|
1236
1241
|
const suspendedBackgroundTransport = kind === "transport" && failures.every(({ visibilityState }) => visibilityState === "hidden") && reportDelayMs >= SUSPENDED_BACKGROUND_FAILURE_MS;
|
|
1237
1242
|
if (suspendedBackgroundTransport) {
|
|
1238
1243
|
addBreadcrumb({
|
|
@@ -1879,6 +1884,9 @@ var createBeacon = (options) => {
|
|
|
1879
1884
|
const hasHiddenAncestor = (element, requirePointerEvents = false) => {
|
|
1880
1885
|
let current = element;
|
|
1881
1886
|
while (current !== null) {
|
|
1887
|
+
if (current instanceof HTMLDetailsElement && !current.open && current.querySelector(":scope > summary")?.contains(element) !== true) {
|
|
1888
|
+
return true;
|
|
1889
|
+
}
|
|
1882
1890
|
if (current.hasAttribute("hidden") || current.hasAttribute("inert") || current.getAttribute("aria-hidden") === "true") {
|
|
1883
1891
|
return true;
|
|
1884
1892
|
}
|
|
@@ -4039,22 +4047,26 @@ var createBeacon = (options) => {
|
|
|
4039
4047
|
recordRequestForStorm = null;
|
|
4040
4048
|
});
|
|
4041
4049
|
}
|
|
4042
|
-
const
|
|
4043
|
-
const
|
|
4044
|
-
|
|
4050
|
+
const classifyInstrumentedResponse = (response, request) => {
|
|
4051
|
+
const errorResponse = response.status >= 400;
|
|
4052
|
+
const classifier = errorResponse ? instrument.classifyErrorResponse : response.ok ? instrument.classifyResponse : undefined;
|
|
4053
|
+
if (classifier === undefined)
|
|
4045
4054
|
return;
|
|
4055
|
+
const traceId = responseTraceId(response.headers.get(BEACON_TRACE_HEADER));
|
|
4046
4056
|
Promise.resolve(classifier(response.clone(), request)).then((result) => {
|
|
4047
4057
|
if (result === undefined || result === false)
|
|
4048
4058
|
return;
|
|
4049
|
-
captureException(errorWithoutStack("SemanticResponseFailure", result.message), {
|
|
4059
|
+
captureException(errorWithoutStack(errorResponse ? "HttpResponseFailure" : "SemanticResponseFailure", result.message), {
|
|
4050
4060
|
groupingKey: result.groupingKey,
|
|
4051
|
-
level: "warning",
|
|
4061
|
+
level: result.level ?? "warning",
|
|
4052
4062
|
tags: {
|
|
4053
4063
|
endpoint: shortUrl(request.url),
|
|
4054
4064
|
method: request.method.toUpperCase(),
|
|
4055
|
-
signal: BEACON_SIGNAL.SEMANTIC_RESPONSE_FAILURE,
|
|
4065
|
+
signal: errorResponse ? BEACON_SIGNAL.HTTP_RESPONSE_FAILURE : BEACON_SIGNAL.SEMANTIC_RESPONSE_FAILURE,
|
|
4066
|
+
status: String(response.status),
|
|
4056
4067
|
...result.tags ?? {}
|
|
4057
|
-
}
|
|
4068
|
+
},
|
|
4069
|
+
...traceId === undefined ? {} : { traceId }
|
|
4058
4070
|
});
|
|
4059
4071
|
}).catch(() => {});
|
|
4060
4072
|
};
|
|
@@ -4077,7 +4089,7 @@ var createBeacon = (options) => {
|
|
|
4077
4089
|
type: "fetch"
|
|
4078
4090
|
});
|
|
4079
4091
|
reportResponseSignal(url, method, response.status, Date.now() - start, responseTraceId(response.headers.get(BEACON_TRACE_HEADER)));
|
|
4080
|
-
|
|
4092
|
+
classifyInstrumentedResponse(response, { method, url });
|
|
4081
4093
|
return response;
|
|
4082
4094
|
} catch (error) {
|
|
4083
4095
|
const resolved = toError(error);
|
|
@@ -4132,7 +4144,7 @@ var createBeacon = (options) => {
|
|
|
4132
4144
|
});
|
|
4133
4145
|
if (!failed) {
|
|
4134
4146
|
reportResponseSignal(request.url, request.method, this.status, Date.now() - start, responseTraceId(this.getResponseHeader(BEACON_TRACE_HEADER)));
|
|
4135
|
-
if (instrument.classifyResponse !== undefined && this.status >= 200 && this.status < 300 && (this.responseType === "" || this.responseType === "text")) {
|
|
4147
|
+
if ((instrument.classifyResponse !== undefined && this.status >= 200 && this.status < 300 || instrument.classifyErrorResponse !== undefined && this.status >= 400) && (this.responseType === "" || this.responseType === "text")) {
|
|
4136
4148
|
const headers = new Headers;
|
|
4137
4149
|
for (const line of this.getAllResponseHeaders().split(/\r?\n/u)) {
|
|
4138
4150
|
const separator = line.indexOf(":");
|
|
@@ -4140,7 +4152,7 @@ var createBeacon = (options) => {
|
|
|
4140
4152
|
continue;
|
|
4141
4153
|
headers.append(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
|
|
4142
4154
|
}
|
|
4143
|
-
|
|
4155
|
+
classifyInstrumentedResponse(new Response(this.responseText, {
|
|
4144
4156
|
headers,
|
|
4145
4157
|
status: this.status,
|
|
4146
4158
|
statusText: this.statusText
|
|
@@ -4295,5 +4307,5 @@ export {
|
|
|
4295
4307
|
BEACON_ATTRIBUTE
|
|
4296
4308
|
};
|
|
4297
4309
|
|
|
4298
|
-
//# debugId=
|
|
4310
|
+
//# debugId=277BC42792EF07E964756E2164756E21
|
|
4299
4311
|
//# sourceMappingURL=index.js.map
|