@absolutejs/beacon 0.7.0-beta.12 → 0.7.0-beta.14
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/CHANGELOG.md +16 -0
- package/changelog.json +37 -0
- package/dist/contracts.js +1 -9
- package/dist/contracts.js.map +2 -2
- package/dist/early.js +1 -9
- package/dist/early.js.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +119 -120
- package/dist/index.js.map +3 -3
- package/dist/manifest.js +1 -9
- package/dist/manifest.js.map +2 -2
- package/dist/policy.d.ts +9 -0
- package/dist/policy.js +7 -10
- package/dist/policy.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined")
|
|
5
|
-
return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
1
|
// src/contracts.ts
|
|
10
2
|
var BEACON_SIGNAL = {
|
|
11
3
|
AUTH_FAILURE_STORM: "auth_failure_storm",
|
|
@@ -199,7 +191,7 @@ var consumeEarlyLayoutShiftBuffer = () => {
|
|
|
199
191
|
|
|
200
192
|
// src/index.ts
|
|
201
193
|
var BEACON_TRACE_HEADER = "x-absolute-trace-id";
|
|
202
|
-
var BEACON_SDK_VERSION = "0.7.0-beta.
|
|
194
|
+
var BEACON_SDK_VERSION = "0.7.0-beta.14";
|
|
203
195
|
var inBrowser = () => typeof window !== "undefined";
|
|
204
196
|
var newId = () => {
|
|
205
197
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
@@ -1033,12 +1025,12 @@ var createBeacon = (options) => {
|
|
|
1033
1025
|
let recentInteraction;
|
|
1034
1026
|
let recentNavigation;
|
|
1035
1027
|
let reportErrorClick = null;
|
|
1036
|
-
const reportCapturedErrorClick = (error,
|
|
1028
|
+
const reportCapturedErrorClick = (error, tags) => {
|
|
1037
1029
|
if (filterKnownNoise && isKnownBeaconNoise({
|
|
1038
1030
|
message: error.message,
|
|
1039
1031
|
name: error.name,
|
|
1040
1032
|
stack: error.stack,
|
|
1041
|
-
tags
|
|
1033
|
+
tags
|
|
1042
1034
|
}))
|
|
1043
1035
|
return;
|
|
1044
1036
|
reportErrorClick?.(error.name);
|
|
@@ -1381,15 +1373,15 @@ var createBeacon = (options) => {
|
|
|
1381
1373
|
}
|
|
1382
1374
|
};
|
|
1383
1375
|
const interval = window.setInterval(checkWhenVisible, Math.max(1000, probe.intervalMs ?? 60000));
|
|
1384
|
-
const
|
|
1376
|
+
const onVisibilityChange = () => checkWhenVisible();
|
|
1385
1377
|
window.addEventListener("focus", checkWhenVisible);
|
|
1386
1378
|
window.addEventListener("online", checkWhenVisible);
|
|
1387
|
-
document.addEventListener("visibilitychange",
|
|
1379
|
+
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
1388
1380
|
cleanups.push(() => {
|
|
1389
1381
|
window.clearInterval(interval);
|
|
1390
1382
|
window.removeEventListener("focus", checkWhenVisible);
|
|
1391
1383
|
window.removeEventListener("online", checkWhenVisible);
|
|
1392
|
-
document.removeEventListener("visibilitychange",
|
|
1384
|
+
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
1393
1385
|
});
|
|
1394
1386
|
checkServingRelease();
|
|
1395
1387
|
}
|
|
@@ -1437,13 +1429,13 @@ var createBeacon = (options) => {
|
|
|
1437
1429
|
const authFailureStormWindowMs = signals?.authFailureStormWindowMs ?? AUTH_FAILURE_STORM_DEFAULT_WINDOW_MS;
|
|
1438
1430
|
const authFailuresByEndpoint = new Map;
|
|
1439
1431
|
const reportedAuthFailureStorms = new Set;
|
|
1440
|
-
const recordAuthFailure = (
|
|
1432
|
+
const recordAuthFailure = (endpoint, method, status) => {
|
|
1441
1433
|
if (signals === null || signals.authFailureStorms === false)
|
|
1442
1434
|
return false;
|
|
1443
|
-
const label = `${method} ${
|
|
1444
|
-
const
|
|
1445
|
-
const failures = (authFailuresByEndpoint.get(label) ?? []).filter(({ at }) =>
|
|
1446
|
-
failures.push({ at:
|
|
1435
|
+
const label = `${method} ${endpoint}`;
|
|
1436
|
+
const now = Date.now();
|
|
1437
|
+
const failures = (authFailuresByEndpoint.get(label) ?? []).filter(({ at }) => now - at < authFailureStormWindowMs);
|
|
1438
|
+
failures.push({ at: now, status });
|
|
1447
1439
|
authFailuresByEndpoint.set(label, failures);
|
|
1448
1440
|
if (failures.length < authFailureStormCount || reportedAuthFailureStorms.has(label)) {
|
|
1449
1441
|
return false;
|
|
@@ -1451,7 +1443,7 @@ var createBeacon = (options) => {
|
|
|
1451
1443
|
reportedAuthFailureStorms.add(label);
|
|
1452
1444
|
const statuses = [...new Set(failures.map((failure) => failure.status))];
|
|
1453
1445
|
emitSignal(`Authorization failure storm — ${label} repeatedly rejected requests — ${shortUrl(location.href)}`, {
|
|
1454
|
-
endpoint
|
|
1446
|
+
endpoint,
|
|
1455
1447
|
failureCount: String(failures.length),
|
|
1456
1448
|
method,
|
|
1457
1449
|
signal: BEACON_SIGNAL.AUTH_FAILURE_STORM,
|
|
@@ -1545,14 +1537,14 @@ var createBeacon = (options) => {
|
|
|
1545
1537
|
const newestFailureAt = Math.max(...failures.map(({ at }) => at));
|
|
1546
1538
|
const reportDelayMs = Math.max(0, Date.now() - newestFailureAt);
|
|
1547
1539
|
const endpoints = [
|
|
1548
|
-
...new Set(failures.map(({ endpoint
|
|
1540
|
+
...new Set(failures.map(({ endpoint }) => endpoint))
|
|
1549
1541
|
].sort();
|
|
1550
1542
|
const methods = [...new Set(failures.map(({ method }) => method))].sort();
|
|
1551
1543
|
const onlineStates = [
|
|
1552
1544
|
...new Set(failures.map(({ online }) => String(online)))
|
|
1553
1545
|
].sort();
|
|
1554
1546
|
const transports = [
|
|
1555
|
-
...new Set(failures.map(({ transport
|
|
1547
|
+
...new Set(failures.map(({ transport }) => transport))
|
|
1556
1548
|
].sort();
|
|
1557
1549
|
const visibilityStates = [
|
|
1558
1550
|
...new Set(failures.map(({ visibilityState }) => visibilityState))
|
|
@@ -1653,7 +1645,7 @@ var createBeacon = (options) => {
|
|
|
1653
1645
|
let mutated = false;
|
|
1654
1646
|
let extended = false;
|
|
1655
1647
|
let finished = false;
|
|
1656
|
-
let
|
|
1648
|
+
let timer;
|
|
1657
1649
|
const observeRouterAcceptance = (handledEvent) => {
|
|
1658
1650
|
if (handledEvent !== event)
|
|
1659
1651
|
return;
|
|
@@ -1666,8 +1658,8 @@ var createBeacon = (options) => {
|
|
|
1666
1658
|
finished = true;
|
|
1667
1659
|
observer.disconnect();
|
|
1668
1660
|
control.removeEventListener("click", observeRouterAcceptance);
|
|
1669
|
-
if (
|
|
1670
|
-
window.clearTimeout(
|
|
1661
|
+
if (timer !== undefined)
|
|
1662
|
+
window.clearTimeout(timer);
|
|
1671
1663
|
pendingClickCleanups.delete(cancel);
|
|
1672
1664
|
report(didRespond, navigationStalled);
|
|
1673
1665
|
};
|
|
@@ -1677,8 +1669,8 @@ var createBeacon = (options) => {
|
|
|
1677
1669
|
finished = true;
|
|
1678
1670
|
observer.disconnect();
|
|
1679
1671
|
control.removeEventListener("click", observeRouterAcceptance);
|
|
1680
|
-
if (
|
|
1681
|
-
window.clearTimeout(
|
|
1672
|
+
if (timer !== undefined)
|
|
1673
|
+
window.clearTimeout(timer);
|
|
1682
1674
|
};
|
|
1683
1675
|
const observer = new MutationObserver(() => {
|
|
1684
1676
|
mutated = true;
|
|
@@ -1691,7 +1683,7 @@ var createBeacon = (options) => {
|
|
|
1691
1683
|
});
|
|
1692
1684
|
pendingClickCleanups.add(cancel);
|
|
1693
1685
|
control.addEventListener("click", observeRouterAcceptance, { once: true });
|
|
1694
|
-
|
|
1686
|
+
timer = window.setTimeout(() => {
|
|
1695
1687
|
if (responded()) {
|
|
1696
1688
|
finish(true);
|
|
1697
1689
|
return;
|
|
@@ -1701,7 +1693,7 @@ var createBeacon = (options) => {
|
|
|
1701
1693
|
return;
|
|
1702
1694
|
}
|
|
1703
1695
|
extended = true;
|
|
1704
|
-
|
|
1696
|
+
timer = window.setTimeout(() => {
|
|
1705
1697
|
const didRespond = responded();
|
|
1706
1698
|
finish(didRespond, !didRespond);
|
|
1707
1699
|
}, navigationResponseMs - DEAD_CLICK_WINDOW_MS);
|
|
@@ -2455,6 +2447,10 @@ var createBeacon = (options) => {
|
|
|
2455
2447
|
const firstGroup = first.closest(INTENTIONAL_CONTROL_GROUP_SELECTOR);
|
|
2456
2448
|
return firstGroup !== null && firstGroup === second.closest(INTENTIONAL_CONTROL_GROUP_SELECTOR);
|
|
2457
2449
|
};
|
|
2450
|
+
const sharesDrawing = (first, second) => {
|
|
2451
|
+
const drawing = first.closest("svg");
|
|
2452
|
+
return drawing !== null && drawing === second.closest("svg");
|
|
2453
|
+
};
|
|
2458
2454
|
const crossesDialogBoundary = (first, second) => {
|
|
2459
2455
|
const firstDialog = first.closest('[role="dialog"], dialog');
|
|
2460
2456
|
const secondDialog = second.closest('[role="dialog"], dialog');
|
|
@@ -2522,7 +2518,7 @@ var createBeacon = (options) => {
|
|
|
2522
2518
|
const second = controls[secondIndex];
|
|
2523
2519
|
if (second === undefined)
|
|
2524
2520
|
continue;
|
|
2525
|
-
if (first.element.contains(second.element) || second.element.contains(first.element) || crossesDialogBoundary(first.element, second.element)) {
|
|
2521
|
+
if (first.element.contains(second.element) || second.element.contains(first.element) || crossesDialogBoundary(first.element, second.element) || sharesDrawing(first.element, second.element)) {
|
|
2526
2522
|
continue;
|
|
2527
2523
|
}
|
|
2528
2524
|
const overlapX = Math.min(first.rect.right, second.rect.right) - Math.max(first.rect.left, second.rect.left);
|
|
@@ -2532,12 +2528,12 @@ var createBeacon = (options) => {
|
|
|
2532
2528
|
if (first.element.parentElement === second.element.parentElement && (first.positioned || second.positioned)) {
|
|
2533
2529
|
continue;
|
|
2534
2530
|
}
|
|
2535
|
-
const
|
|
2531
|
+
const axis = overlapY <= overlapX ? "vertical" : "horizontal";
|
|
2536
2532
|
reportScanIssue(first.element, BEACON_SIGNAL.CONTROL_COLLISION, `Control collision — ${describeElement(first.element)} overlaps ${describeElement(second.element)}`, {
|
|
2537
2533
|
collidesWith: describeElement(second.element),
|
|
2538
|
-
collisionAxis:
|
|
2534
|
+
collisionAxis: axis,
|
|
2539
2535
|
collisionKind: "overlap",
|
|
2540
|
-
overlapPx: String(Math.round(
|
|
2536
|
+
overlapPx: String(Math.round(axis === "vertical" ? overlapY : overlapX))
|
|
2541
2537
|
}, scanLayoutContext(first.element, second.element));
|
|
2542
2538
|
continue;
|
|
2543
2539
|
}
|
|
@@ -2882,9 +2878,9 @@ var createBeacon = (options) => {
|
|
|
2882
2878
|
const checkStuckLoading = () => {
|
|
2883
2879
|
if (document.visibilityState === "hidden")
|
|
2884
2880
|
return;
|
|
2885
|
-
const
|
|
2886
|
-
const missedPollWindow = lastLoadingCheckAt !== undefined &&
|
|
2887
|
-
lastLoadingCheckAt =
|
|
2881
|
+
const now = Date.now();
|
|
2882
|
+
const missedPollWindow = lastLoadingCheckAt !== undefined && now - lastLoadingCheckAt > STUCK_LOADING_POLL_MS * 3;
|
|
2883
|
+
lastLoadingCheckAt = now;
|
|
2888
2884
|
const indicators = Array.from(document.querySelectorAll(loadingIndicatorSelector));
|
|
2889
2885
|
const activeIndicators = new Set(indicators);
|
|
2890
2886
|
for (const tracked of trackedLoadingIndicators) {
|
|
@@ -2902,22 +2898,22 @@ var createBeacon = (options) => {
|
|
|
2902
2898
|
continue;
|
|
2903
2899
|
}
|
|
2904
2900
|
if (missedPollWindow && loadingFirstSeen.has(indicator)) {
|
|
2905
|
-
loadingFirstSeen.set(indicator,
|
|
2901
|
+
loadingFirstSeen.set(indicator, now);
|
|
2906
2902
|
}
|
|
2907
2903
|
const firstSeen = loadingFirstSeen.get(indicator);
|
|
2908
2904
|
if (firstSeen === undefined) {
|
|
2909
|
-
loadingFirstSeen.set(indicator,
|
|
2905
|
+
loadingFirstSeen.set(indicator, now);
|
|
2910
2906
|
trackedLoadingIndicators.add(indicator);
|
|
2911
2907
|
continue;
|
|
2912
2908
|
}
|
|
2913
2909
|
const deadlineMs = loadingDeadlineMs(indicator);
|
|
2914
|
-
if (
|
|
2910
|
+
if (now - firstSeen < deadlineMs || reportedStuckLoading.has(indicator)) {
|
|
2915
2911
|
continue;
|
|
2916
2912
|
}
|
|
2917
2913
|
reportedStuckLoading.add(indicator);
|
|
2918
2914
|
reportScanIssue(indicator, BEACON_SIGNAL.STUCK_LOADING, `Stuck loading — ${describeElement(indicator)} never resolved`, {
|
|
2919
2915
|
deadlineMs: String(deadlineMs),
|
|
2920
|
-
visibleMs: String(
|
|
2916
|
+
visibleMs: String(now - firstSeen)
|
|
2921
2917
|
});
|
|
2922
2918
|
}
|
|
2923
2919
|
};
|
|
@@ -3315,7 +3311,7 @@ var createBeacon = (options) => {
|
|
|
3315
3311
|
if (name === null)
|
|
3316
3312
|
return;
|
|
3317
3313
|
const onLoad = () => stopWatching(frame);
|
|
3318
|
-
const
|
|
3314
|
+
const timer = setTimeout(() => {
|
|
3319
3315
|
stopWatching(frame);
|
|
3320
3316
|
if (pageLifecycleEnding || document.visibilityState === "hidden" || !frame.isConnected) {
|
|
3321
3317
|
return;
|
|
@@ -3332,7 +3328,7 @@ var createBeacon = (options) => {
|
|
|
3332
3328
|
target: describeElement(frame)
|
|
3333
3329
|
});
|
|
3334
3330
|
}, stallMs);
|
|
3335
|
-
watched.set(frame, { onLoad, timer
|
|
3331
|
+
watched.set(frame, { onLoad, timer });
|
|
3336
3332
|
frame.addEventListener("load", onLoad, { once: true });
|
|
3337
3333
|
};
|
|
3338
3334
|
const discoverFrames = (root) => {
|
|
@@ -3531,9 +3527,9 @@ var createBeacon = (options) => {
|
|
|
3531
3527
|
const pending = new Map;
|
|
3532
3528
|
const reported = new WeakSet;
|
|
3533
3529
|
const clearPending = (canvas) => {
|
|
3534
|
-
const
|
|
3535
|
-
if (
|
|
3536
|
-
clearTimeout(
|
|
3530
|
+
const timer = pending.get(canvas);
|
|
3531
|
+
if (timer !== undefined)
|
|
3532
|
+
clearTimeout(timer);
|
|
3537
3533
|
pending.delete(canvas);
|
|
3538
3534
|
};
|
|
3539
3535
|
const onLost = (event) => {
|
|
@@ -3541,7 +3537,7 @@ var createBeacon = (options) => {
|
|
|
3541
3537
|
return;
|
|
3542
3538
|
const canvas = event.target;
|
|
3543
3539
|
clearPending(canvas);
|
|
3544
|
-
const
|
|
3540
|
+
const timer = setTimeout(() => {
|
|
3545
3541
|
pending.delete(canvas);
|
|
3546
3542
|
if (reported.has(canvas) || pageLifecycleEnding || document.visibilityState === "hidden" || !canvas.isConnected) {
|
|
3547
3543
|
return;
|
|
@@ -3558,7 +3554,7 @@ var createBeacon = (options) => {
|
|
|
3558
3554
|
target: describeElement(canvas)
|
|
3559
3555
|
});
|
|
3560
3556
|
}, graceMs);
|
|
3561
|
-
pending.set(canvas,
|
|
3557
|
+
pending.set(canvas, timer);
|
|
3562
3558
|
};
|
|
3563
3559
|
const onRestored = (event) => {
|
|
3564
3560
|
if (event.target instanceof HTMLCanvasElement)
|
|
@@ -3569,8 +3565,8 @@ var createBeacon = (options) => {
|
|
|
3569
3565
|
cleanups.push(() => {
|
|
3570
3566
|
document.removeEventListener("webglcontextlost", onLost, true);
|
|
3571
3567
|
document.removeEventListener("webglcontextrestored", onRestored, true);
|
|
3572
|
-
for (const
|
|
3573
|
-
clearTimeout(
|
|
3568
|
+
for (const timer of pending.values())
|
|
3569
|
+
clearTimeout(timer);
|
|
3574
3570
|
pending.clear();
|
|
3575
3571
|
});
|
|
3576
3572
|
}
|
|
@@ -3579,9 +3575,9 @@ var createBeacon = (options) => {
|
|
|
3579
3575
|
const visualViewport = window.visualViewport;
|
|
3580
3576
|
const settleMs = signals.focusedControlSettleMs ?? FOCUSED_CONTROL_SETTLE_DEFAULT_MS;
|
|
3581
3577
|
const reported = new Set;
|
|
3582
|
-
let
|
|
3578
|
+
let timer;
|
|
3583
3579
|
const checkFocusedControl = () => {
|
|
3584
|
-
|
|
3580
|
+
timer = undefined;
|
|
3585
3581
|
if (pageLifecycleEnding || document.visibilityState === "hidden" || visualViewport.height >= window.innerHeight * KEYBOARD_VIEWPORT_HEIGHT_RATIO_MAX) {
|
|
3586
3582
|
return;
|
|
3587
3583
|
}
|
|
@@ -3611,9 +3607,9 @@ var createBeacon = (options) => {
|
|
|
3611
3607
|
});
|
|
3612
3608
|
};
|
|
3613
3609
|
const scheduleCheck = () => {
|
|
3614
|
-
if (
|
|
3615
|
-
clearTimeout(
|
|
3616
|
-
|
|
3610
|
+
if (timer !== undefined)
|
|
3611
|
+
clearTimeout(timer);
|
|
3612
|
+
timer = setTimeout(checkFocusedControl, settleMs);
|
|
3617
3613
|
};
|
|
3618
3614
|
document.addEventListener("focusin", scheduleCheck, true);
|
|
3619
3615
|
visualViewport.addEventListener("resize", scheduleCheck);
|
|
@@ -3622,8 +3618,8 @@ var createBeacon = (options) => {
|
|
|
3622
3618
|
document.removeEventListener("focusin", scheduleCheck, true);
|
|
3623
3619
|
visualViewport.removeEventListener("resize", scheduleCheck);
|
|
3624
3620
|
visualViewport.removeEventListener("scroll", scheduleCheck);
|
|
3625
|
-
if (
|
|
3626
|
-
clearTimeout(
|
|
3621
|
+
if (timer !== undefined)
|
|
3622
|
+
clearTimeout(timer);
|
|
3627
3623
|
});
|
|
3628
3624
|
}
|
|
3629
3625
|
if (signals.scrollJail !== false) {
|
|
@@ -3680,16 +3676,16 @@ var createBeacon = (options) => {
|
|
|
3680
3676
|
jailBurst = [];
|
|
3681
3677
|
return;
|
|
3682
3678
|
}
|
|
3683
|
-
const
|
|
3679
|
+
const now = Date.now();
|
|
3684
3680
|
if (jailScroller !== scroller) {
|
|
3685
3681
|
jailScroller = scroller;
|
|
3686
3682
|
jailBurst = [];
|
|
3687
3683
|
}
|
|
3688
|
-
jailBurst = jailBurst.filter((entry) =>
|
|
3684
|
+
jailBurst = jailBurst.filter((entry) => now - entry.at < SCROLL_JAIL_WINDOW_MS && !entry.event.defaultPrevented);
|
|
3689
3685
|
if (jailBurst.length === 0) {
|
|
3690
3686
|
jailStartingScrollGeneration = scrollActivityGeneration;
|
|
3691
3687
|
}
|
|
3692
|
-
jailBurst.push({ at:
|
|
3688
|
+
jailBurst.push({ at: now, position: scroller.scrollTop, event });
|
|
3693
3689
|
if (jailBurst.length < SCROLL_JAIL_EVENT_COUNT)
|
|
3694
3690
|
return;
|
|
3695
3691
|
const first = jailBurst[0];
|
|
@@ -3724,7 +3720,7 @@ var createBeacon = (options) => {
|
|
|
3724
3720
|
scroller: descriptor,
|
|
3725
3721
|
direction: scrollingDown ? "down" : "up",
|
|
3726
3722
|
wheelCount: confirmedBurst.length,
|
|
3727
|
-
burstDurationMs:
|
|
3723
|
+
burstDurationMs: now - (confirmedBurst[0]?.at ?? now),
|
|
3728
3724
|
scrollTop: scroller.scrollTop,
|
|
3729
3725
|
scrollHeight: scroller.scrollHeight,
|
|
3730
3726
|
clientHeight: scroller.clientHeight,
|
|
@@ -3773,9 +3769,9 @@ var createBeacon = (options) => {
|
|
|
3773
3769
|
previous = { x: event.clientX, y: event.clientY };
|
|
3774
3770
|
if (Math.hypot(dx, dy) < 8)
|
|
3775
3771
|
return;
|
|
3776
|
-
const
|
|
3777
|
-
points = points.filter((point) =>
|
|
3778
|
-
points.push({ at:
|
|
3772
|
+
const now = Date.now();
|
|
3773
|
+
points = points.filter((point) => now - point.at < THRASHED_CURSOR_WINDOW_MS);
|
|
3774
|
+
points.push({ at: now, dx, dy });
|
|
3779
3775
|
let reversals = 0;
|
|
3780
3776
|
for (let index = 1;index < points.length; index += 1) {
|
|
3781
3777
|
const prior = points[index - 1];
|
|
@@ -3839,8 +3835,8 @@ var createBeacon = (options) => {
|
|
|
3839
3835
|
};
|
|
3840
3836
|
const openModals = () => Array.from(document.querySelectorAll(MODAL_SELECTOR)).filter(isRenderedModal);
|
|
3841
3837
|
const checkInitialModalFocus = (modal) => {
|
|
3842
|
-
const
|
|
3843
|
-
modalTimers.delete(
|
|
3838
|
+
const timer = setTimeout(() => {
|
|
3839
|
+
modalTimers.delete(timer);
|
|
3844
3840
|
if (!isRenderedModal(modal))
|
|
3845
3841
|
return;
|
|
3846
3842
|
const active = document.activeElement instanceof Element ? document.activeElement : null;
|
|
@@ -3848,7 +3844,7 @@ var createBeacon = (options) => {
|
|
|
3848
3844
|
return;
|
|
3849
3845
|
reportModalEscape(modal, active, "initial-focus-missing");
|
|
3850
3846
|
}, MODAL_FOCUS_SETTLE_MS);
|
|
3851
|
-
modalTimers.add(
|
|
3847
|
+
modalTimers.add(timer);
|
|
3852
3848
|
};
|
|
3853
3849
|
const updateModalVisibility = (modal) => {
|
|
3854
3850
|
knownModals.add(modal);
|
|
@@ -3871,8 +3867,8 @@ var createBeacon = (options) => {
|
|
|
3871
3867
|
const modals = openModals();
|
|
3872
3868
|
if (modals.length > 0 && !modals.some((modal) => modal.contains(target))) {
|
|
3873
3869
|
const modal = modals[modals.length - 1];
|
|
3874
|
-
const
|
|
3875
|
-
modalTimers.delete(
|
|
3870
|
+
const timer = setTimeout(() => {
|
|
3871
|
+
modalTimers.delete(timer);
|
|
3876
3872
|
if (!isRenderedModal(modal))
|
|
3877
3873
|
return;
|
|
3878
3874
|
const active = document.activeElement instanceof Element ? document.activeElement : null;
|
|
@@ -3880,7 +3876,7 @@ var createBeacon = (options) => {
|
|
|
3880
3876
|
return;
|
|
3881
3877
|
reportModalEscape(modal, active, "escaped");
|
|
3882
3878
|
}, 0);
|
|
3883
|
-
modalTimers.add(
|
|
3879
|
+
modalTimers.add(timer);
|
|
3884
3880
|
}
|
|
3885
3881
|
}
|
|
3886
3882
|
};
|
|
@@ -3957,8 +3953,8 @@ var createBeacon = (options) => {
|
|
|
3957
3953
|
document.removeEventListener("focusin", onFocusIn, true);
|
|
3958
3954
|
document.removeEventListener("focusout", onFocusOut, true);
|
|
3959
3955
|
modalObserver?.disconnect();
|
|
3960
|
-
for (const
|
|
3961
|
-
clearTimeout(
|
|
3956
|
+
for (const timer of modalTimers)
|
|
3957
|
+
clearTimeout(timer);
|
|
3962
3958
|
modalTimers.clear();
|
|
3963
3959
|
knownModals.clear();
|
|
3964
3960
|
});
|
|
@@ -4003,14 +3999,14 @@ var createBeacon = (options) => {
|
|
|
4003
3999
|
if (data === null)
|
|
4004
4000
|
return;
|
|
4005
4001
|
const activity = activityFor(form);
|
|
4006
|
-
const
|
|
4002
|
+
const now = Date.now();
|
|
4007
4003
|
if (data !== activity.lastData) {
|
|
4008
4004
|
activity.lastData = data;
|
|
4009
|
-
activity.identicalSubmits = [
|
|
4005
|
+
activity.identicalSubmits = [now];
|
|
4010
4006
|
return;
|
|
4011
4007
|
}
|
|
4012
|
-
activity.identicalSubmits = activity.identicalSubmits.filter((at) =>
|
|
4013
|
-
activity.identicalSubmits.push(
|
|
4008
|
+
activity.identicalSubmits = activity.identicalSubmits.filter((at) => now - at < FORM_FRUSTRATION_WINDOW_MS);
|
|
4009
|
+
activity.identicalSubmits.push(now);
|
|
4014
4010
|
if (activity.identicalSubmits.length >= FORM_FRUSTRATION_THRESHOLD) {
|
|
4015
4011
|
reportForm(form, "was submitted with identical values repeatedly");
|
|
4016
4012
|
}
|
|
@@ -4021,14 +4017,14 @@ var createBeacon = (options) => {
|
|
|
4021
4017
|
if (form === null)
|
|
4022
4018
|
return;
|
|
4023
4019
|
const activity = activityFor(form);
|
|
4024
|
-
const
|
|
4025
|
-
if (
|
|
4026
|
-
activity.lastInvalidAt =
|
|
4020
|
+
const now = Date.now();
|
|
4021
|
+
if (now - activity.lastInvalidAt < FORM_INVALID_BURST_GAP_MS) {
|
|
4022
|
+
activity.lastInvalidAt = now;
|
|
4027
4023
|
return;
|
|
4028
4024
|
}
|
|
4029
|
-
activity.lastInvalidAt =
|
|
4030
|
-
activity.invalidBursts = activity.invalidBursts.filter((at) =>
|
|
4031
|
-
activity.invalidBursts.push(
|
|
4025
|
+
activity.lastInvalidAt = now;
|
|
4026
|
+
activity.invalidBursts = activity.invalidBursts.filter((at) => now - at < FORM_FRUSTRATION_WINDOW_MS);
|
|
4027
|
+
activity.invalidBursts.push(now);
|
|
4032
4028
|
if (activity.invalidBursts.length >= FORM_FRUSTRATION_THRESHOLD) {
|
|
4033
4029
|
reportForm(form, "keeps failing native validation");
|
|
4034
4030
|
}
|
|
@@ -4127,9 +4123,9 @@ var createBeacon = (options) => {
|
|
|
4127
4123
|
if (signals.sseFlapping === false || pageLifecycleEnding || document.visibilityState === "hidden") {
|
|
4128
4124
|
return;
|
|
4129
4125
|
}
|
|
4130
|
-
const
|
|
4131
|
-
const errors = (errorsByEndpoint.get(endpointLabel) ?? []).filter((at) =>
|
|
4132
|
-
errors.push(
|
|
4126
|
+
const now = Date.now();
|
|
4127
|
+
const errors = (errorsByEndpoint.get(endpointLabel) ?? []).filter((at) => now - at < sseFlapWindowMs);
|
|
4128
|
+
errors.push(now);
|
|
4133
4129
|
errorsByEndpoint.set(endpointLabel, errors);
|
|
4134
4130
|
if (errors.length < sseFlapCount || reportedFlappingStreams.has(endpointLabel)) {
|
|
4135
4131
|
return;
|
|
@@ -4150,13 +4146,13 @@ var createBeacon = (options) => {
|
|
|
4150
4146
|
};
|
|
4151
4147
|
const originalAddEventListener = source.addEventListener.bind(source);
|
|
4152
4148
|
const armedTypes = new Set(["error", "message", "open"]);
|
|
4153
|
-
source.addEventListener = (type, listener,
|
|
4149
|
+
source.addEventListener = (type, listener, options) => {
|
|
4154
4150
|
if (!armedTypes.has(type)) {
|
|
4155
4151
|
armedTypes.add(type);
|
|
4156
4152
|
originalAddEventListener(type, arm);
|
|
4157
4153
|
}
|
|
4158
4154
|
if (listener !== null) {
|
|
4159
|
-
originalAddEventListener(type, listener,
|
|
4155
|
+
originalAddEventListener(type, listener, options);
|
|
4160
4156
|
}
|
|
4161
4157
|
};
|
|
4162
4158
|
originalAddEventListener("open", arm);
|
|
@@ -4222,10 +4218,10 @@ var createBeacon = (options) => {
|
|
|
4222
4218
|
}
|
|
4223
4219
|
if (signals.socketFlapping === false)
|
|
4224
4220
|
return;
|
|
4225
|
-
const
|
|
4226
|
-
const closes = (closesByUrl.get(label) ?? []).filter((close) =>
|
|
4221
|
+
const now = Date.now();
|
|
4222
|
+
const closes = (closesByUrl.get(label) ?? []).filter((close) => now - close.at < SOCKET_FLAP_WINDOW_MS);
|
|
4227
4223
|
closes.push({
|
|
4228
|
-
at:
|
|
4224
|
+
at: now,
|
|
4229
4225
|
code: typeof CloseEvent !== "undefined" && event instanceof CloseEvent ? event.code : null,
|
|
4230
4226
|
wasClean: typeof CloseEvent !== "undefined" && event instanceof CloseEvent ? event.wasClean : null
|
|
4231
4227
|
});
|
|
@@ -4241,7 +4237,7 @@ var createBeacon = (options) => {
|
|
|
4241
4237
|
windowMs: String(SOCKET_FLAP_WINDOW_MS)
|
|
4242
4238
|
}, undefined, {
|
|
4243
4239
|
closeSamples: closes.map((close) => ({
|
|
4244
|
-
ageMs:
|
|
4240
|
+
ageMs: now - close.at,
|
|
4245
4241
|
code: close.code,
|
|
4246
4242
|
wasClean: close.wasClean
|
|
4247
4243
|
}))
|
|
@@ -4265,14 +4261,14 @@ var createBeacon = (options) => {
|
|
|
4265
4261
|
cleanup();
|
|
4266
4262
|
}
|
|
4267
4263
|
});
|
|
4268
|
-
const reportWorkerFailure = (workerType, endpointLabel,
|
|
4269
|
-
const key = `${workerType}|${endpointLabel}|${
|
|
4264
|
+
const reportWorkerFailure = (workerType, endpointLabel, failureKind, error) => {
|
|
4265
|
+
const key = `${workerType}|${endpointLabel}|${failureKind}`;
|
|
4270
4266
|
if (reportedWorkerFailures.has(key))
|
|
4271
4267
|
return;
|
|
4272
4268
|
reportedWorkerFailures.add(key);
|
|
4273
4269
|
emitSignal(`Worker failure — ${workerType} worker ${endpointLabel} failed — ${shortUrl(location.href)}`, {
|
|
4274
4270
|
endpoint: endpointLabel,
|
|
4275
|
-
failureKind
|
|
4271
|
+
failureKind,
|
|
4276
4272
|
signal: BEACON_SIGNAL.WORKER_FAILURE,
|
|
4277
4273
|
workerType
|
|
4278
4274
|
}, undefined, error === undefined ? undefined : {
|
|
@@ -4359,14 +4355,14 @@ var createBeacon = (options) => {
|
|
|
4359
4355
|
"TimeoutError",
|
|
4360
4356
|
"TypeError"
|
|
4361
4357
|
]);
|
|
4362
|
-
const reportServiceWorkerFailure = (endpointLabel,
|
|
4363
|
-
const key = `${endpointLabel}|${
|
|
4358
|
+
const reportServiceWorkerFailure = (endpointLabel, failureKind, error) => {
|
|
4359
|
+
const key = `${endpointLabel}|${failureKind}`;
|
|
4364
4360
|
if (reportedServiceWorkerFailures.has(key))
|
|
4365
4361
|
return;
|
|
4366
4362
|
reportedServiceWorkerFailures.add(key);
|
|
4367
|
-
emitSignal(`Service worker failure — ${endpointLabel} failed during ${
|
|
4363
|
+
emitSignal(`Service worker failure — ${endpointLabel} failed during ${failureKind} — ${shortUrl(location.href)}`, {
|
|
4368
4364
|
endpoint: endpointLabel,
|
|
4369
|
-
failureKind
|
|
4365
|
+
failureKind,
|
|
4370
4366
|
signal: BEACON_SIGNAL.SERVICE_WORKER_FAILURE
|
|
4371
4367
|
}, undefined, error === undefined ? undefined : {
|
|
4372
4368
|
serviceWorkerError: {
|
|
@@ -4376,12 +4372,15 @@ var createBeacon = (options) => {
|
|
|
4376
4372
|
}
|
|
4377
4373
|
});
|
|
4378
4374
|
};
|
|
4379
|
-
const watchInstallingWorker = (worker) => {
|
|
4380
|
-
let
|
|
4375
|
+
const watchInstallingWorker = (worker, registration) => {
|
|
4376
|
+
let settled = worker.state === "installed" || worker.state === "activated";
|
|
4381
4377
|
const onStateChange = () => {
|
|
4382
|
-
if (worker.state === "activated")
|
|
4383
|
-
|
|
4384
|
-
if (worker.state !== "redundant" ||
|
|
4378
|
+
if (worker.state === "installed" || worker.state === "activated")
|
|
4379
|
+
settled = true;
|
|
4380
|
+
if (worker.state !== "redundant" || settled)
|
|
4381
|
+
return;
|
|
4382
|
+
const successor = registration?.installing ?? registration?.waiting;
|
|
4383
|
+
if (successor !== null && successor !== undefined && successor !== worker)
|
|
4385
4384
|
return;
|
|
4386
4385
|
reportServiceWorkerFailure(shortUrl(worker.scriptURL), "installation");
|
|
4387
4386
|
};
|
|
@@ -4390,11 +4389,11 @@ var createBeacon = (options) => {
|
|
|
4390
4389
|
};
|
|
4391
4390
|
const watchRegistration = (registration) => {
|
|
4392
4391
|
if (registration.installing !== null) {
|
|
4393
|
-
watchInstallingWorker(registration.installing);
|
|
4392
|
+
watchInstallingWorker(registration.installing, registration);
|
|
4394
4393
|
}
|
|
4395
4394
|
const onUpdateFound = () => {
|
|
4396
4395
|
if (registration.installing !== null) {
|
|
4397
|
-
watchInstallingWorker(registration.installing);
|
|
4396
|
+
watchInstallingWorker(registration.installing, registration);
|
|
4398
4397
|
}
|
|
4399
4398
|
};
|
|
4400
4399
|
registration.addEventListener("updatefound", onUpdateFound);
|
|
@@ -4472,23 +4471,23 @@ var createBeacon = (options) => {
|
|
|
4472
4471
|
try {
|
|
4473
4472
|
const navigation = performance.getEntriesByType("navigation")[0];
|
|
4474
4473
|
if (navigation?.type !== "back_forward") {
|
|
4475
|
-
const
|
|
4474
|
+
const now = Date.now();
|
|
4476
4475
|
const route = shortUrl(location.href);
|
|
4477
4476
|
const raw = sessionStorage.getItem(RELOAD_LOOP_STORAGE_KEY);
|
|
4478
4477
|
const parsed = raw === null ? [] : JSON.parse(raw);
|
|
4479
|
-
let history2 = (Array.isArray(parsed) ? parsed : []).filter((entry) => entry !== null && typeof entry === "object" && typeof entry.at === "number" && typeof entry.route === "string" &&
|
|
4478
|
+
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);
|
|
4480
4479
|
let entryKind = "app";
|
|
4481
4480
|
const rawNavigationIntent = sessionStorage.getItem(NAVIGATION_INTENT_STORAGE_KEY);
|
|
4482
4481
|
sessionStorage.removeItem(NAVIGATION_INTENT_STORAGE_KEY);
|
|
4483
4482
|
const navigationIntentAt = Number(rawNavigationIntent);
|
|
4484
|
-
if (rawNavigationIntent !== null && Number.isFinite(navigationIntentAt) &&
|
|
4483
|
+
if (rawNavigationIntent !== null && Number.isFinite(navigationIntentAt) && now - navigationIntentAt >= 0 && now - navigationIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
|
|
4485
4484
|
history2 = [];
|
|
4486
4485
|
entryKind = "intentional-navigation";
|
|
4487
4486
|
}
|
|
4488
4487
|
const rawServiceWorkerUpdateIntent = sessionStorage.getItem(SERVICE_WORKER_UPDATE_INTENT_STORAGE_KEY);
|
|
4489
4488
|
sessionStorage.removeItem(SERVICE_WORKER_UPDATE_INTENT_STORAGE_KEY);
|
|
4490
4489
|
const serviceWorkerUpdateIntentAt = Number(rawServiceWorkerUpdateIntent);
|
|
4491
|
-
if (rawServiceWorkerUpdateIntent !== null && Number.isFinite(serviceWorkerUpdateIntentAt) &&
|
|
4490
|
+
if (rawServiceWorkerUpdateIntent !== null && Number.isFinite(serviceWorkerUpdateIntentAt) && now - serviceWorkerUpdateIntentAt >= 0 && now - serviceWorkerUpdateIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
|
|
4492
4491
|
history2 = [];
|
|
4493
4492
|
entryKind = "service-worker-update";
|
|
4494
4493
|
}
|
|
@@ -4499,7 +4498,7 @@ var createBeacon = (options) => {
|
|
|
4499
4498
|
entryKind = "external";
|
|
4500
4499
|
}
|
|
4501
4500
|
}
|
|
4502
|
-
history2.push({ at:
|
|
4501
|
+
history2.push({ at: now, route });
|
|
4503
4502
|
sessionStorage.setItem(RELOAD_LOOP_STORAGE_KEY, JSON.stringify(history2));
|
|
4504
4503
|
let loadCount = 0;
|
|
4505
4504
|
for (let index = history2.length - 1;index >= 0; index -= 1) {
|
|
@@ -4508,7 +4507,7 @@ var createBeacon = (options) => {
|
|
|
4508
4507
|
loadCount += 1;
|
|
4509
4508
|
}
|
|
4510
4509
|
if (loadCount === RELOAD_LOOP_COUNT) {
|
|
4511
|
-
const firstLoad = history2.at(-loadCount)?.at ??
|
|
4510
|
+
const firstLoad = history2.at(-loadCount)?.at ?? now;
|
|
4512
4511
|
emitSignal(`Reload loop — repeated page loads within a minute — ${shortUrl(location.href)}`, {
|
|
4513
4512
|
currentRelease: options.release ?? "unknown",
|
|
4514
4513
|
entryKind,
|
|
@@ -4517,7 +4516,7 @@ var createBeacon = (options) => {
|
|
|
4517
4516
|
serviceWorkerControlled: String(navigator.serviceWorker?.controller !== null && navigator.serviceWorker?.controller !== undefined),
|
|
4518
4517
|
serviceWorkerScript: navigator.serviceWorker?.controller?.scriptURL ?? "none",
|
|
4519
4518
|
signal: BEACON_SIGNAL.RELOAD_LOOP,
|
|
4520
|
-
windowMs: String(
|
|
4519
|
+
windowMs: String(now - firstLoad)
|
|
4521
4520
|
});
|
|
4522
4521
|
flush(true);
|
|
4523
4522
|
}
|
|
@@ -4527,7 +4526,7 @@ var createBeacon = (options) => {
|
|
|
4527
4526
|
if (signals !== null && signals.staleReleases !== false && typeof localStorage !== "undefined" && typeof options.release === "string" && options.release !== "") {
|
|
4528
4527
|
try {
|
|
4529
4528
|
const currentRelease = options.release;
|
|
4530
|
-
const
|
|
4529
|
+
const now = Date.now();
|
|
4531
4530
|
const raw = localStorage.getItem(STALE_RELEASE_STORAGE_KEY);
|
|
4532
4531
|
const parsed = raw === null ? {} : JSON.parse(raw);
|
|
4533
4532
|
const firstSeenByRelease = {};
|
|
@@ -4537,10 +4536,10 @@ var createBeacon = (options) => {
|
|
|
4537
4536
|
firstSeenByRelease[release] = at;
|
|
4538
4537
|
}
|
|
4539
4538
|
}
|
|
4540
|
-
const currentFirstSeen = firstSeenByRelease[currentRelease] ??
|
|
4539
|
+
const currentFirstSeen = firstSeenByRelease[currentRelease] ?? now;
|
|
4541
4540
|
firstSeenByRelease[currentRelease] = currentFirstSeen;
|
|
4542
4541
|
const newest = Object.entries(firstSeenByRelease).filter(([release, at]) => release !== currentRelease && at > currentFirstSeen).sort((left, right) => right[1] - left[1])[0];
|
|
4543
|
-
if (newest !== undefined &&
|
|
4542
|
+
if (newest !== undefined && now - newest[1] > STALE_RELEASE_GRACE_MS) {
|
|
4544
4543
|
emitSignal(`Stale release — this page is running a build older than one this browser already saw — ${shortUrl(location.href)}`, {
|
|
4545
4544
|
currentRelease,
|
|
4546
4545
|
newestRelease: newest[0],
|
|
@@ -4617,8 +4616,8 @@ var createBeacon = (options) => {
|
|
|
4617
4616
|
return;
|
|
4618
4617
|
if (confirmationMs > 0) {
|
|
4619
4618
|
await new Promise((resolve) => {
|
|
4620
|
-
const
|
|
4621
|
-
cleanups.push(() => window.clearTimeout(
|
|
4619
|
+
const timer = window.setTimeout(resolve, confirmationMs);
|
|
4620
|
+
cleanups.push(() => window.clearTimeout(timer));
|
|
4622
4621
|
});
|
|
4623
4622
|
if (document.visibilityState === "hidden")
|
|
4624
4623
|
return;
|
|
@@ -4660,9 +4659,9 @@ var createBeacon = (options) => {
|
|
|
4660
4659
|
const reportedStorms = new Set;
|
|
4661
4660
|
recordRequestForStorm = (url, method) => {
|
|
4662
4661
|
const label = `${method.toUpperCase()} ${shortUrl(url)}`;
|
|
4663
|
-
const
|
|
4664
|
-
const hits = (hitsByEndpoint.get(label) ?? []).filter((at) =>
|
|
4665
|
-
hits.push(
|
|
4662
|
+
const now = Date.now();
|
|
4663
|
+
const hits = (hitsByEndpoint.get(label) ?? []).filter((at) => now - at < stormWindowMs);
|
|
4664
|
+
hits.push(now);
|
|
4666
4665
|
hitsByEndpoint.set(label, hits);
|
|
4667
4666
|
if (hits.length < stormCount || reportedStorms.has(label))
|
|
4668
4667
|
return;
|
|
@@ -4948,5 +4947,5 @@ export {
|
|
|
4948
4947
|
redactBeaconEvent
|
|
4949
4948
|
};
|
|
4950
4949
|
|
|
4951
|
-
//# debugId=
|
|
4950
|
+
//# debugId=04264040FE86397764756E2164756E21
|
|
4952
4951
|
//# sourceMappingURL=index.js.map
|