@absolutejs/beacon 0.6.39 → 0.6.41
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 +3 -2
- package/dist/index.d.ts +7 -0
- package/dist/index.js +108 -14
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -175,10 +175,11 @@ beacon.captureMessage("checkout started", "info");
|
|
|
175
175
|
online state, transport, and page visibility preserved in
|
|
176
176
|
`extra.networkFailures`.
|
|
177
177
|
- **Runtime boundary signals** — abnormal WebSocket closes, WebSocket and SSE
|
|
178
|
-
reconnect flapping,
|
|
178
|
+
reconnect flapping, terminal service-worker registration/install failures, and
|
|
179
179
|
dedicated/shared worker construction, runtime, and message-decoding failures
|
|
180
180
|
become replay-linked warnings. Normal socket closes, page teardown, hidden-tab
|
|
181
|
-
SSE errors,
|
|
181
|
+
SSE errors, transient registrations recovered during the configured grace
|
|
182
|
+
period, and successfully replaced service workers are exempt.
|
|
182
183
|
- **Attributed reliability signals** — Event Timing identifies genuinely slow
|
|
183
184
|
interactions and separates input delay, handler time, and presentation delay.
|
|
184
185
|
Overlapping long animation frames include their worst script when the browser
|
package/dist/index.d.ts
CHANGED
|
@@ -214,6 +214,9 @@ export type BeaconResourceFailure = {
|
|
|
214
214
|
export type BeaconSignals = {
|
|
215
215
|
/** Back/forward navigations the browser could not restore from bfcache. */
|
|
216
216
|
bfcacheBlocks?: boolean;
|
|
217
|
+
/** Browser-specific bfcache reason strings that are inherent to an
|
|
218
|
+
* application's required capabilities and therefore not actionable. */
|
|
219
|
+
ignoredBfcacheReasons?: string[];
|
|
217
220
|
/** Marked application roots that settle without meaningful visible content. */
|
|
218
221
|
blankAppRoots?: boolean;
|
|
219
222
|
/** Delay before an application root is evaluated. Default 3000ms. */
|
|
@@ -348,6 +351,10 @@ export type BeaconSignals = {
|
|
|
348
351
|
scrollJail?: boolean;
|
|
349
352
|
/** Service-worker registration and installation failures. Default true. */
|
|
350
353
|
serviceWorkerFailures?: boolean;
|
|
354
|
+
/** Grace period for a transient service-worker registration failure to
|
|
355
|
+
* recover through an application retry before it becomes an issue. Persistent
|
|
356
|
+
* browser rejections still report immediately. Default 8000ms. */
|
|
357
|
+
serviceWorkerRecoveryMs?: number;
|
|
351
358
|
/** Abnormal WebSocket closes (`wasClean: false` or non-normal codes).
|
|
352
359
|
* Default true. */
|
|
353
360
|
socketAbnormalCloses?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -469,6 +469,7 @@ var LONG_IDENTIFIER_SEGMENT = /\b(?:[0-9a-f]{16,}|\d{8,})\b/giu;
|
|
|
469
469
|
var VOLATILE_SIGNAL_TAGS = new Set([
|
|
470
470
|
"actionId",
|
|
471
471
|
"blockingDurationMs",
|
|
472
|
+
"blockingFrameDurationMs",
|
|
472
473
|
"blockerLocations",
|
|
473
474
|
"blockerScope",
|
|
474
475
|
"closeCount",
|
|
@@ -476,10 +477,13 @@ var VOLATILE_SIGNAL_TAGS = new Set([
|
|
|
476
477
|
"durationMs",
|
|
477
478
|
"elapsedMs",
|
|
478
479
|
"errorCount",
|
|
480
|
+
"inputDelayMs",
|
|
479
481
|
"interactionId",
|
|
480
482
|
"loadCount",
|
|
481
483
|
"newestRelease",
|
|
482
484
|
"obscuredPx",
|
|
485
|
+
"presentationDelayMs",
|
|
486
|
+
"processingDurationMs",
|
|
483
487
|
"responseMs",
|
|
484
488
|
"shiftValue",
|
|
485
489
|
"signal",
|
|
@@ -758,13 +762,16 @@ var createBeacon = (options) => {
|
|
|
758
762
|
const SSE_FLAP_DEFAULT_COUNT = 4;
|
|
759
763
|
const SSE_FLAP_DEFAULT_WINDOW_MS = 60000;
|
|
760
764
|
const STALLED_STREAM_DEFAULT_MS = 60000;
|
|
765
|
+
const SERVICE_WORKER_RECOVERY_DEFAULT_MS = 8000;
|
|
761
766
|
const MODAL_FOCUS_SETTLE_MS = 100;
|
|
762
767
|
const MAIN_THREAD_STALL_DEFAULT_MS = 200;
|
|
763
768
|
const MAIN_THREAD_STALL_DEFAULT_COUNT = 3;
|
|
764
769
|
const MAIN_THREAD_STALL_DEFAULT_WINDOW_MS = 1e4;
|
|
765
770
|
const RELOAD_LOOP_COUNT = 4;
|
|
766
771
|
const RELOAD_LOOP_WINDOW_MS = 60000;
|
|
767
|
-
const
|
|
772
|
+
const NAVIGATION_INTENT_MAX_AGE_MS = 30000;
|
|
773
|
+
const RELOAD_LOOP_STORAGE_KEY = "beacon:reload-history-v4";
|
|
774
|
+
const NAVIGATION_INTENT_STORAGE_KEY = "beacon:navigation-intent-v1";
|
|
768
775
|
const STALE_RELEASE_STORAGE_KEY = "beacon:release-first-seen";
|
|
769
776
|
const STALE_RELEASE_GRACE_MS = 600000;
|
|
770
777
|
const STALE_RELEASE_HISTORY_LIMIT = 5;
|
|
@@ -910,6 +917,7 @@ var createBeacon = (options) => {
|
|
|
910
917
|
pendingClickCleanups.clear();
|
|
911
918
|
});
|
|
912
919
|
let flushPendingNetworkFailures = () => {};
|
|
920
|
+
let pendingNavigationIntentAt;
|
|
913
921
|
let tags = {};
|
|
914
922
|
let user;
|
|
915
923
|
let actionSequence = 0;
|
|
@@ -1451,9 +1459,9 @@ var createBeacon = (options) => {
|
|
|
1451
1459
|
const blockingDuration = entry.entryType === "long-animation-frame" && animationFrame.blockingDuration !== undefined ? animationFrame.blockingDuration : entry.duration;
|
|
1452
1460
|
if (blockingDuration < stallMs)
|
|
1453
1461
|
continue;
|
|
1454
|
-
const
|
|
1455
|
-
stallTimes = stallTimes.filter((at) =>
|
|
1456
|
-
stallTimes.push(
|
|
1462
|
+
const entryAt = entry.startTime;
|
|
1463
|
+
stallTimes = stallTimes.filter((at) => entryAt >= at && entryAt - at < stallWindowMs);
|
|
1464
|
+
stallTimes.push(entryAt);
|
|
1457
1465
|
if (stallTimes.length < stallCount)
|
|
1458
1466
|
continue;
|
|
1459
1467
|
reported = true;
|
|
@@ -1498,6 +1506,7 @@ var createBeacon = (options) => {
|
|
|
1498
1506
|
emitSignal(`Document discarded — the browser reloaded a discarded tab — ${shortUrl(location.href)}`, { signal: BEACON_SIGNAL.DOCUMENT_DISCARDED });
|
|
1499
1507
|
}
|
|
1500
1508
|
if (signals.bfcacheBlocks !== false && typeof performance !== "undefined") {
|
|
1509
|
+
const ignoredBfcacheReasons = new Set(signals.ignoredBfcacheReasons ?? []);
|
|
1501
1510
|
const navigation = performance.getEntriesByType("navigation")[0];
|
|
1502
1511
|
if (navigation?.type === "back_forward" && navigation.notRestoredReasons != null) {
|
|
1503
1512
|
const reasons = new Set;
|
|
@@ -1506,7 +1515,7 @@ var createBeacon = (options) => {
|
|
|
1506
1515
|
if (node === null || typeof node !== "object")
|
|
1507
1516
|
return;
|
|
1508
1517
|
const detail = node;
|
|
1509
|
-
const nodeReasons = (detail.reasons ?? []).map((reason) => reason.reason).filter((reason) => typeof reason === "string" && reason !== "masked").slice(0, 10);
|
|
1518
|
+
const nodeReasons = (detail.reasons ?? []).map((reason) => reason.reason).filter((reason) => typeof reason === "string" && reason !== "masked" && !ignoredBfcacheReasons.has(reason)).slice(0, 10);
|
|
1510
1519
|
for (const reason of nodeReasons)
|
|
1511
1520
|
reasons.add(reason);
|
|
1512
1521
|
if (nodeReasons.length > 0 && blockers.length < 10) {
|
|
@@ -1943,6 +1952,9 @@ var createBeacon = (options) => {
|
|
|
1943
1952
|
const rect = element.getBoundingClientRect();
|
|
1944
1953
|
if (rect.width === 0 && rect.height === 0)
|
|
1945
1954
|
return;
|
|
1955
|
+
if (rect.width <= 2 && rect.height <= 2 && (style.overflowX === "hidden" || style.overflowX === "clip" || style.overflowY === "hidden" || style.overflowY === "clip")) {
|
|
1956
|
+
return;
|
|
1957
|
+
}
|
|
1946
1958
|
if ((style.position === "absolute" || style.position === "fixed") && (rect.right <= 0 || rect.left >= viewportRight || rect.bottom <= 0 || rect.top >= document.documentElement.clientHeight)) {
|
|
1947
1959
|
return;
|
|
1948
1960
|
}
|
|
@@ -2066,6 +2078,9 @@ var createBeacon = (options) => {
|
|
|
2066
2078
|
const overlapY = Math.min(first.rect.bottom, second.rect.bottom) - Math.max(first.rect.top, second.rect.top);
|
|
2067
2079
|
const isOverlap = overlapX > CONTROL_COLLISION_OVERLAP_TOLERANCE_PX && overlapY > CONTROL_COLLISION_OVERLAP_TOLERANCE_PX;
|
|
2068
2080
|
if (isOverlap) {
|
|
2081
|
+
if (first.element.parentElement === second.element.parentElement && (first.positioned || second.positioned)) {
|
|
2082
|
+
continue;
|
|
2083
|
+
}
|
|
2069
2084
|
const axis2 = overlapY <= overlapX ? "vertical" : "horizontal";
|
|
2070
2085
|
reportScanIssue(first.element, BEACON_SIGNAL.CONTROL_COLLISION, `Control collision — ${describeElement(first.element)} overlaps ${describeElement(second.element)}`, {
|
|
2071
2086
|
collidesWith: describeElement(second.element),
|
|
@@ -2365,6 +2380,7 @@ var createBeacon = (options) => {
|
|
|
2365
2380
|
const loadingFirstSeen = new WeakMap;
|
|
2366
2381
|
const reportedStuckLoading = new WeakSet;
|
|
2367
2382
|
const trackedLoadingIndicators = new Set;
|
|
2383
|
+
let lastLoadingCheckAt;
|
|
2368
2384
|
const loadingIndicatorSelector = `[aria-busy="true"], [role="progressbar"], [${BEACON_ATTRIBUTE.LOADING}]`;
|
|
2369
2385
|
const resetLoadingIndicator = (indicator) => {
|
|
2370
2386
|
loadingFirstSeen.delete(indicator);
|
|
@@ -2410,13 +2426,15 @@ var createBeacon = (options) => {
|
|
|
2410
2426
|
const checkStuckLoading = () => {
|
|
2411
2427
|
if (document.visibilityState === "hidden")
|
|
2412
2428
|
return;
|
|
2429
|
+
const now = Date.now();
|
|
2430
|
+
const missedPollWindow = lastLoadingCheckAt !== undefined && now - lastLoadingCheckAt > STUCK_LOADING_POLL_MS * 3;
|
|
2431
|
+
lastLoadingCheckAt = now;
|
|
2413
2432
|
const indicators = Array.from(document.querySelectorAll(loadingIndicatorSelector));
|
|
2414
2433
|
const activeIndicators = new Set(indicators);
|
|
2415
2434
|
for (const tracked of trackedLoadingIndicators) {
|
|
2416
2435
|
if (!activeIndicators.has(tracked))
|
|
2417
2436
|
resetLoadingIndicator(tracked);
|
|
2418
2437
|
}
|
|
2419
|
-
const now = Date.now();
|
|
2420
2438
|
for (const indicator of indicators) {
|
|
2421
2439
|
if (isPersistentDeterminateProgress(indicator) || isScanExempt(indicator) || hasHiddenAncestor(indicator) || hasTrackedLoadingAncestor(indicator)) {
|
|
2422
2440
|
resetLoadingIndicator(indicator);
|
|
@@ -2427,6 +2445,9 @@ var createBeacon = (options) => {
|
|
|
2427
2445
|
resetLoadingIndicator(indicator);
|
|
2428
2446
|
continue;
|
|
2429
2447
|
}
|
|
2448
|
+
if (missedPollWindow && loadingFirstSeen.has(indicator)) {
|
|
2449
|
+
loadingFirstSeen.set(indicator, now);
|
|
2450
|
+
}
|
|
2430
2451
|
const firstSeen = loadingFirstSeen.get(indicator);
|
|
2431
2452
|
if (firstSeen === undefined) {
|
|
2432
2453
|
loadingFirstSeen.set(indicator, now);
|
|
@@ -2463,16 +2484,26 @@ var createBeacon = (options) => {
|
|
|
2463
2484
|
reportScanIssue(root, BEACON_SIGNAL.BLANK_APP_ROOT, `Blank application root — ${name} rendered no meaningful content`, {});
|
|
2464
2485
|
}
|
|
2465
2486
|
};
|
|
2487
|
+
const documentStylesAreReady = () => {
|
|
2488
|
+
const stylesheets = Array.from(document.querySelectorAll('link[rel~="stylesheet"]')).filter((link) => {
|
|
2489
|
+
if (link.disabled)
|
|
2490
|
+
return false;
|
|
2491
|
+
const media = link.media.trim();
|
|
2492
|
+
return media === "" || typeof window.matchMedia !== "function" || window.matchMedia(media).matches;
|
|
2493
|
+
});
|
|
2494
|
+
return stylesheets.every((link) => link.sheet !== null);
|
|
2495
|
+
};
|
|
2466
2496
|
const runSettledScan = () => {
|
|
2467
|
-
|
|
2497
|
+
const visualStylesReady = documentStylesAreReady();
|
|
2498
|
+
if (detectOverflow && visualStylesReady)
|
|
2468
2499
|
scanForOverflow();
|
|
2469
|
-
if (detectControlCollision)
|
|
2500
|
+
if (detectControlCollision && visualStylesReady)
|
|
2470
2501
|
scanForControlCollisions();
|
|
2471
|
-
if (detectOcclusion)
|
|
2502
|
+
if (detectOcclusion && visualStylesReady)
|
|
2472
2503
|
scanForOcclusion();
|
|
2473
|
-
if (detectInvisibleText)
|
|
2504
|
+
if (detectInvisibleText && visualStylesReady)
|
|
2474
2505
|
scanForInvisibleText();
|
|
2475
|
-
if (detectThemeMismatch)
|
|
2506
|
+
if (detectThemeMismatch && visualStylesReady)
|
|
2476
2507
|
scanForThemeMismatch();
|
|
2477
2508
|
if (detectStuckLoading)
|
|
2478
2509
|
checkStuckLoading();
|
|
@@ -3692,6 +3723,13 @@ var createBeacon = (options) => {
|
|
|
3692
3723
|
const container = navigator.serviceWorker;
|
|
3693
3724
|
const reportedServiceWorkerFailures = new Set;
|
|
3694
3725
|
const serviceWorkerListenerCleanups = [];
|
|
3726
|
+
const pendingRegistrationFailures = new Map;
|
|
3727
|
+
const transientRegistrationErrors = new Set([
|
|
3728
|
+
"AbortError",
|
|
3729
|
+
"NetworkError",
|
|
3730
|
+
"TimeoutError",
|
|
3731
|
+
"TypeError"
|
|
3732
|
+
]);
|
|
3695
3733
|
const reportServiceWorkerFailure = (endpointLabel, failureKind2, error) => {
|
|
3696
3734
|
const key = `${endpointLabel}|${failureKind2}`;
|
|
3697
3735
|
if (reportedServiceWorkerFailures.has(key))
|
|
@@ -3742,9 +3780,32 @@ var createBeacon = (options) => {
|
|
|
3742
3780
|
if (isServiceWorkerRegistration(registration)) {
|
|
3743
3781
|
watchRegistration(registration);
|
|
3744
3782
|
}
|
|
3783
|
+
const pendingFailure = pendingRegistrationFailures.get(endpointLabel);
|
|
3784
|
+
if (pendingFailure !== undefined) {
|
|
3785
|
+
clearTimeout(pendingFailure.timeout);
|
|
3786
|
+
pendingRegistrationFailures.delete(endpointLabel);
|
|
3787
|
+
}
|
|
3745
3788
|
return registration;
|
|
3746
3789
|
} catch (error) {
|
|
3747
|
-
|
|
3790
|
+
const registrationError = toError(error);
|
|
3791
|
+
if (transientRegistrationErrors.has(registrationError.name)) {
|
|
3792
|
+
const existing = pendingRegistrationFailures.get(endpointLabel);
|
|
3793
|
+
if (existing !== undefined) {
|
|
3794
|
+
existing.error = registrationError;
|
|
3795
|
+
} else {
|
|
3796
|
+
const recoveryMs = Math.max(0, signals.serviceWorkerRecoveryMs ?? SERVICE_WORKER_RECOVERY_DEFAULT_MS);
|
|
3797
|
+
const pending = {
|
|
3798
|
+
error: registrationError,
|
|
3799
|
+
timeout: setTimeout(() => {
|
|
3800
|
+
pendingRegistrationFailures.delete(endpointLabel);
|
|
3801
|
+
reportServiceWorkerFailure(endpointLabel, "registration", pending.error);
|
|
3802
|
+
}, recoveryMs)
|
|
3803
|
+
};
|
|
3804
|
+
pendingRegistrationFailures.set(endpointLabel, pending);
|
|
3805
|
+
}
|
|
3806
|
+
} else {
|
|
3807
|
+
reportServiceWorkerFailure(endpointLabel, "registration", registrationError);
|
|
3808
|
+
}
|
|
3748
3809
|
throw error;
|
|
3749
3810
|
}
|
|
3750
3811
|
};
|
|
@@ -3753,6 +3814,10 @@ var createBeacon = (options) => {
|
|
|
3753
3814
|
container.addEventListener("messageerror", onMessageError);
|
|
3754
3815
|
cleanups.push(() => {
|
|
3755
3816
|
container.removeEventListener("messageerror", onMessageError);
|
|
3817
|
+
for (const pending of pendingRegistrationFailures.values()) {
|
|
3818
|
+
clearTimeout(pending.timeout);
|
|
3819
|
+
}
|
|
3820
|
+
pendingRegistrationFailures.clear();
|
|
3756
3821
|
for (const cleanup of serviceWorkerListenerCleanups.splice(0, serviceWorkerListenerCleanups.length)) {
|
|
3757
3822
|
cleanup();
|
|
3758
3823
|
}
|
|
@@ -3772,6 +3837,13 @@ var createBeacon = (options) => {
|
|
|
3772
3837
|
const parsed = raw === null ? [] : JSON.parse(raw);
|
|
3773
3838
|
let history2 = (Array.isArray(parsed) ? parsed : []).filter((entry) => entry !== null && typeof entry === "object" && typeof entry.at === "number" && typeof entry.route === "string" && now - entry.at < RELOAD_LOOP_WINDOW_MS);
|
|
3774
3839
|
let entryKind = "app";
|
|
3840
|
+
const rawNavigationIntent = sessionStorage.getItem(NAVIGATION_INTENT_STORAGE_KEY);
|
|
3841
|
+
sessionStorage.removeItem(NAVIGATION_INTENT_STORAGE_KEY);
|
|
3842
|
+
const navigationIntentAt = Number(rawNavigationIntent);
|
|
3843
|
+
if (rawNavigationIntent !== null && Number.isFinite(navigationIntentAt) && now - navigationIntentAt >= 0 && now - navigationIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
|
|
3844
|
+
history2 = [];
|
|
3845
|
+
entryKind = "intentional-navigation";
|
|
3846
|
+
}
|
|
3775
3847
|
if (document.referrer !== "") {
|
|
3776
3848
|
const referrer = new URL(document.referrer, location.href);
|
|
3777
3849
|
if (referrer.origin !== location.origin) {
|
|
@@ -4109,6 +4181,11 @@ var createBeacon = (options) => {
|
|
|
4109
4181
|
pageLifecycleGeneration += 1;
|
|
4110
4182
|
pageRestoredAt = undefined;
|
|
4111
4183
|
pendingNetworkFailures.delete("transport");
|
|
4184
|
+
if (pendingNavigationIntentAt !== undefined && Date.now() - pendingNavigationIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
|
|
4185
|
+
try {
|
|
4186
|
+
sessionStorage.setItem(NAVIGATION_INTENT_STORAGE_KEY, String(Date.now()));
|
|
4187
|
+
} catch {}
|
|
4188
|
+
}
|
|
4112
4189
|
flush(true);
|
|
4113
4190
|
};
|
|
4114
4191
|
const onPageShow = (event) => {
|
|
@@ -4119,10 +4196,27 @@ var createBeacon = (options) => {
|
|
|
4119
4196
|
if (document.visibilityState === "hidden")
|
|
4120
4197
|
flush(true);
|
|
4121
4198
|
};
|
|
4199
|
+
const onNavigationIntent = (event) => {
|
|
4200
|
+
if (event.type === "submit") {
|
|
4201
|
+
pendingNavigationIntentAt = Date.now();
|
|
4202
|
+
return;
|
|
4203
|
+
}
|
|
4204
|
+
if (!(event instanceof MouseEvent) || event.button !== 0)
|
|
4205
|
+
return;
|
|
4206
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
|
|
4207
|
+
return;
|
|
4208
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
4209
|
+
const anchor = target?.closest("a[href]");
|
|
4210
|
+
if (anchor instanceof HTMLAnchorElement && anchor.target !== "_blank" && !anchor.hasAttribute("download")) {
|
|
4211
|
+
pendingNavigationIntentAt = Date.now();
|
|
4212
|
+
}
|
|
4213
|
+
};
|
|
4122
4214
|
window.addEventListener("pagehide", onPageHide);
|
|
4123
4215
|
window.addEventListener("pageshow", onPageShow);
|
|
4216
|
+
document.addEventListener("click", onNavigationIntent, true);
|
|
4217
|
+
document.addEventListener("submit", onNavigationIntent, true);
|
|
4124
4218
|
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
4125
|
-
cleanups.push(() => window.removeEventListener("pagehide", onPageHide), () => window.removeEventListener("pageshow", onPageShow), () => document.removeEventListener("visibilitychange", onVisibilityChange));
|
|
4219
|
+
cleanups.push(() => window.removeEventListener("pagehide", onPageHide), () => window.removeEventListener("pageshow", onPageShow), () => document.removeEventListener("click", onNavigationIntent, true), () => document.removeEventListener("submit", onNavigationIntent, true), () => document.removeEventListener("visibilitychange", onVisibilityChange));
|
|
4126
4220
|
return {
|
|
4127
4221
|
addBreadcrumb,
|
|
4128
4222
|
captureException,
|
|
@@ -4167,5 +4261,5 @@ export {
|
|
|
4167
4261
|
BEACON_ATTRIBUTE
|
|
4168
4262
|
};
|
|
4169
4263
|
|
|
4170
|
-
//# debugId=
|
|
4264
|
+
//# debugId=B81C5AAC4403BF5B64756E2164756E21
|
|
4171
4265
|
//# sourceMappingURL=index.js.map
|