@absolutejs/beacon 0.7.0-beta.2 → 0.7.0-beta.20
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 +83 -0
- package/README.md +56 -1
- package/changelog.json +187 -0
- package/dist/contracts.d.ts +1 -0
- package/dist/contracts.js +2 -9
- package/dist/contracts.js.map +3 -3
- package/dist/early.js +2 -10
- package/dist/early.js.map +3 -3
- package/dist/index.d.ts +13 -1
- package/dist/index.js +442 -192
- package/dist/index.js.map +5 -5
- package/dist/manifest.js +1 -9
- package/dist/manifest.js.map +2 -2
- package/dist/outbox.d.ts +42 -0
- package/dist/outbox.js +170 -0
- package/dist/outbox.js.map +10 -0
- package/dist/policy.d.ts +9 -0
- package/dist/policy.js +8 -10
- package/dist/policy.js.map +4 -4
- package/package.json +17 -7
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",
|
|
@@ -18,6 +10,7 @@ var BEACON_SIGNAL = {
|
|
|
18
10
|
CONTROL_COLLISION: "control_collision",
|
|
19
11
|
CSP_VIOLATION: "csp_violation",
|
|
20
12
|
CLIPBOARD_FAILURE: "clipboard_failure",
|
|
13
|
+
COLLAPSED_MODAL: "collapsed_modal",
|
|
21
14
|
DEAD_CLICK: "dead_click",
|
|
22
15
|
DISRUPTIVE_LAYOUT_SHIFT: "disruptive_layout_shift",
|
|
23
16
|
DOCUMENT_DISCARDED: "document_discarded",
|
|
@@ -157,6 +150,7 @@ var installEarlyLayoutShiftBuffer = () => {
|
|
|
157
150
|
"pointerdown",
|
|
158
151
|
"submit"
|
|
159
152
|
];
|
|
153
|
+
observer.observe({ buffered: true, type: "layout-shift" });
|
|
160
154
|
for (const event of interactionEvents)
|
|
161
155
|
window.addEventListener(event, recordInteraction, true);
|
|
162
156
|
window.addEventListener("resize", recordResize);
|
|
@@ -176,7 +170,6 @@ var installEarlyLayoutShiftBuffer = () => {
|
|
|
176
170
|
recordEntries,
|
|
177
171
|
resizeTimes
|
|
178
172
|
};
|
|
179
|
-
observer.observe({ buffered: true, type: "layout-shift" });
|
|
180
173
|
} catch {}
|
|
181
174
|
};
|
|
182
175
|
var consumeEarlyLayoutShiftBuffer = () => {
|
|
@@ -199,7 +192,7 @@ var consumeEarlyLayoutShiftBuffer = () => {
|
|
|
199
192
|
|
|
200
193
|
// src/index.ts
|
|
201
194
|
var BEACON_TRACE_HEADER = "x-absolute-trace-id";
|
|
202
|
-
var BEACON_SDK_VERSION = "0.7.0-beta.
|
|
195
|
+
var BEACON_SDK_VERSION = "0.7.0-beta.20";
|
|
203
196
|
var inBrowser = () => typeof window !== "undefined";
|
|
204
197
|
var newId = () => {
|
|
205
198
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
@@ -450,14 +443,14 @@ var FACEBOOK_ANDROID_PERFORMANCE_LOGGER = "iabjs://navigation_performance_logger
|
|
|
450
443
|
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;
|
|
451
444
|
var GOOGLE_WEB_RENDERER_SERVICE_WORKER_WRAPPER = "wrsParams.serviceWorkers.navigator.serviceWorker.register";
|
|
452
445
|
var EXTENSION_STACK_PROTOCOL = /(?:chrome|moz|safari-web)-extension:\/\//u;
|
|
446
|
+
var stackFrames = (stack) => (stack ?? "").split(`
|
|
447
|
+
`).map((line) => line.trim()).filter((line) => line.startsWith("at ") || /@(?:[a-z][a-z\d+.-]*:)?\/\//iu.test(line));
|
|
453
448
|
var isExtensionOnlyStack = (event) => {
|
|
454
|
-
const frames = (event.stack
|
|
455
|
-
`).slice(1).map((line) => line.trim()).filter(Boolean);
|
|
449
|
+
const frames = stackFrames(event.stack);
|
|
456
450
|
return frames.length > 0 && frames.every((frame) => EXTENSION_STACK_PROTOCOL.test(frame));
|
|
457
451
|
};
|
|
458
452
|
var isExtensionInjectedStack = (event) => {
|
|
459
|
-
const firstFrame = (event.stack
|
|
460
|
-
`).slice(1).map((line) => line.trim()).find(Boolean);
|
|
453
|
+
const [firstFrame] = stackFrames(event.stack);
|
|
461
454
|
return firstFrame !== undefined && EXTENSION_STACK_PROTOCOL.test(firstFrame);
|
|
462
455
|
};
|
|
463
456
|
var isStacklessBrowserAbort = (event) => event.name === "AbortError" && event.message === "The user aborted a request." && (event.stack ?? "").trim() === "";
|
|
@@ -605,6 +598,17 @@ var bfcacheLocation = (value) => {
|
|
|
605
598
|
var UUID_PATH_SEGMENT = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/giu;
|
|
606
599
|
var LONG_IDENTIFIER_SEGMENT = /\b(?:[0-9a-f]{16,}|\d{8,})\b/giu;
|
|
607
600
|
var VOLATILE_SIGNAL_TAGS = new Set([
|
|
601
|
+
"area",
|
|
602
|
+
"gapPx",
|
|
603
|
+
"overlapPx",
|
|
604
|
+
"surfaceColor",
|
|
605
|
+
"surfaceLuminance",
|
|
606
|
+
"targetBottomPx",
|
|
607
|
+
"targetHeightPx",
|
|
608
|
+
"targetLeftPx",
|
|
609
|
+
"targetRightPx",
|
|
610
|
+
"targetTopPx",
|
|
611
|
+
"targetWidthPx",
|
|
608
612
|
"actionId",
|
|
609
613
|
"actionTrusted",
|
|
610
614
|
"automation",
|
|
@@ -615,9 +619,17 @@ var VOLATILE_SIGNAL_TAGS = new Set([
|
|
|
615
619
|
"blockerScope",
|
|
616
620
|
"closeCount",
|
|
617
621
|
"currentRelease",
|
|
622
|
+
"currentTime",
|
|
623
|
+
"networkState",
|
|
624
|
+
"readyState",
|
|
618
625
|
"durationMs",
|
|
619
626
|
"documentReadyState",
|
|
620
627
|
"elapsedMs",
|
|
628
|
+
"visibleMs",
|
|
629
|
+
"deadlineMs",
|
|
630
|
+
"layoutViewportHeight",
|
|
631
|
+
"visualViewportHeight",
|
|
632
|
+
"visualViewportOffsetTop",
|
|
621
633
|
"errorCount",
|
|
622
634
|
"focusEventTrusted",
|
|
623
635
|
"inputDelayMs",
|
|
@@ -631,6 +643,10 @@ var VOLATILE_SIGNAL_TAGS = new Set([
|
|
|
631
643
|
"layoutShiftSources",
|
|
632
644
|
"layoutShiftStartTimeMs",
|
|
633
645
|
"newestRelease",
|
|
646
|
+
"navigationAgeMs",
|
|
647
|
+
"navigationFrom",
|
|
648
|
+
"navigationTo",
|
|
649
|
+
"navigationType",
|
|
634
650
|
"obscuredPx",
|
|
635
651
|
"presentationDelayMs",
|
|
636
652
|
"processingDurationMs",
|
|
@@ -639,11 +655,17 @@ var VOLATILE_SIGNAL_TAGS = new Set([
|
|
|
639
655
|
"responseMs",
|
|
640
656
|
"shiftValue",
|
|
641
657
|
"signal",
|
|
658
|
+
"scriptAttribution",
|
|
642
659
|
"scriptCount",
|
|
643
660
|
"scriptDurationMs",
|
|
661
|
+
"scriptFunction",
|
|
644
662
|
"scriptForcedStyleAndLayoutMs",
|
|
663
|
+
"scriptInvoker",
|
|
664
|
+
"scriptInvokerType",
|
|
645
665
|
"scriptPauseDurationMs",
|
|
666
|
+
"scriptSource",
|
|
646
667
|
"scriptSourceCharPosition",
|
|
668
|
+
"scriptWindowAttribution",
|
|
647
669
|
"spillPx",
|
|
648
670
|
"stallCount",
|
|
649
671
|
"styleAndLayoutDurationMs",
|
|
@@ -681,6 +703,8 @@ var signalGroupingKey = (signalTags) => {
|
|
|
681
703
|
const hash = stableIdentityHash(identity, 2166136261) + stableIdentityHash(identity, 2654435769);
|
|
682
704
|
return `beacon-signal:${signalTags.signal}:${hash}`;
|
|
683
705
|
};
|
|
706
|
+
var AUTOMATED_BROWSER_USER_AGENT = /(?:\b(?:adsbot|bingbot|crawler|googlebot|headlesschrome|lighthouse|pagespeed|spider)\b|\b(?:bot|crawl|spider)\/)/iu;
|
|
707
|
+
var isAutomatedBrowser = () => typeof navigator !== "undefined" && (navigator.webdriver === true || AUTOMATED_BROWSER_USER_AGENT.test(navigator.userAgent));
|
|
684
708
|
var isInvisibleAnchor = (anchor) => {
|
|
685
709
|
if (anchor.target === "_blank" || anchor.hasAttribute("download"))
|
|
686
710
|
return true;
|
|
@@ -742,52 +766,77 @@ var TBT_GOOD_MS = 200;
|
|
|
742
766
|
var TBT_POOR_MS = 600;
|
|
743
767
|
var observeLongTasks = (report, navigationType) => {
|
|
744
768
|
if (typeof PerformanceObserver === "undefined")
|
|
745
|
-
return;
|
|
769
|
+
return () => {};
|
|
746
770
|
const longTasks = [];
|
|
747
|
-
let
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
771
|
+
let observer;
|
|
772
|
+
let timer;
|
|
773
|
+
let stopped = false;
|
|
774
|
+
const firstPaint = () => performance.getEntriesByName("first-contentful-paint")[0]?.startTime;
|
|
775
|
+
const collect = (entries) => {
|
|
776
|
+
if (stopped)
|
|
777
|
+
return;
|
|
778
|
+
const windowStart = firstPaint() ?? 0;
|
|
779
|
+
for (const entry of entries) {
|
|
780
|
+
if (entry.startTime < windowStart || entry.startTime >= windowStart + TBT_WINDOW_MS)
|
|
781
|
+
continue;
|
|
782
|
+
longTasks.push({ duration: entry.duration, startTime: entry.startTime });
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
const onVisibilityChange = () => {
|
|
786
|
+
if (document.visibilityState === "hidden")
|
|
787
|
+
flush();
|
|
788
|
+
};
|
|
789
|
+
const stop = () => {
|
|
790
|
+
stopped = true;
|
|
791
|
+
if (timer !== undefined)
|
|
792
|
+
clearTimeout(timer);
|
|
793
|
+
observer?.disconnect();
|
|
794
|
+
window.removeEventListener("visibilitychange", onVisibilityChange);
|
|
795
|
+
window.removeEventListener("pagehide", flush);
|
|
796
|
+
longTasks.length = 0;
|
|
797
|
+
};
|
|
798
|
+
const flush = () => {
|
|
799
|
+
if (stopped)
|
|
800
|
+
return;
|
|
801
|
+
collect(observer?.takeRecords() ?? []);
|
|
802
|
+
const paint = firstPaint();
|
|
803
|
+
const windowStart = paint ?? 0;
|
|
804
|
+
const tasks = longTasks.filter(({ startTime }) => startTime >= windowStart && startTime < windowStart + TBT_WINDOW_MS);
|
|
805
|
+
stop();
|
|
806
|
+
if (tasks.length === 0)
|
|
807
|
+
return;
|
|
808
|
+
const value = Math.round(tasks.reduce((total, { duration }) => total + Math.max(0, duration - LONG_TASK_MS), 0));
|
|
809
|
+
report({
|
|
810
|
+
attribution: {
|
|
811
|
+
measurementWindow: paint === undefined ? "navigation" : "FCP",
|
|
812
|
+
measurementWindowMs: TBT_WINDOW_MS
|
|
813
|
+
},
|
|
814
|
+
id: `tbt-${navigationType}-${TBT_WINDOW_MS}-${value}`,
|
|
815
|
+
name: "TBT",
|
|
816
|
+
navigationType,
|
|
817
|
+
rating: value <= TBT_GOOD_MS ? "good" : value >= TBT_POOR_MS ? "poor" : "needs-improvement",
|
|
818
|
+
value
|
|
760
819
|
});
|
|
820
|
+
};
|
|
821
|
+
const finishWindow = () => {
|
|
822
|
+
if (stopped)
|
|
823
|
+
return;
|
|
824
|
+
const remaining = (firstPaint() ?? 0) + TBT_WINDOW_MS - performance.now();
|
|
825
|
+
if (remaining > 0)
|
|
826
|
+
timer = setTimeout(finishWindow, remaining);
|
|
827
|
+
else
|
|
828
|
+
flush();
|
|
829
|
+
};
|
|
830
|
+
try {
|
|
831
|
+
observer = new PerformanceObserver((list) => collect(list.getEntries()));
|
|
761
832
|
observer.observe({ buffered: true, type: "longtask" });
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
if (tasksInWindow.length === 0)
|
|
770
|
-
return;
|
|
771
|
-
reported = true;
|
|
772
|
-
const value = Math.round(tasksInWindow.reduce((total, { duration }) => total + Math.max(0, duration - LONG_TASK_MS), 0));
|
|
773
|
-
report({
|
|
774
|
-
attribution: {
|
|
775
|
-
measurementWindow: firstContentfulPaint === undefined ? "navigation" : "FCP",
|
|
776
|
-
measurementWindowMs: TBT_WINDOW_MS
|
|
777
|
-
},
|
|
778
|
-
id: `tbt-${navigationType}-${TBT_WINDOW_MS}-${value}`,
|
|
779
|
-
name: "TBT",
|
|
780
|
-
navigationType,
|
|
781
|
-
rating: value <= TBT_GOOD_MS ? "good" : value >= TBT_POOR_MS ? "poor" : "needs-improvement",
|
|
782
|
-
value
|
|
783
|
-
});
|
|
784
|
-
};
|
|
785
|
-
addEventListener("visibilitychange", () => {
|
|
786
|
-
if (document.visibilityState === "hidden")
|
|
787
|
-
flush();
|
|
788
|
-
});
|
|
789
|
-
addEventListener("pagehide", flush);
|
|
790
|
-
} catch {}
|
|
833
|
+
window.addEventListener("visibilitychange", onVisibilityChange);
|
|
834
|
+
window.addEventListener("pagehide", flush);
|
|
835
|
+
timer = setTimeout(finishWindow, Math.max(0, (firstPaint() ?? 0) + TBT_WINDOW_MS - performance.now()));
|
|
836
|
+
} catch {
|
|
837
|
+
stop();
|
|
838
|
+
}
|
|
839
|
+
return stop;
|
|
791
840
|
};
|
|
792
841
|
var isVitalName = (name) => VITAL_NAMES.has(name);
|
|
793
842
|
var vitalAttribution = (value) => {
|
|
@@ -936,6 +985,8 @@ var createBeacon = (options) => {
|
|
|
936
985
|
const STALLED_STREAM_DEFAULT_MS = 60000;
|
|
937
986
|
const SERVICE_WORKER_RECOVERY_DEFAULT_MS = 8000;
|
|
938
987
|
const MODAL_FOCUS_SETTLE_MS = 100;
|
|
988
|
+
const COLLAPSED_MODAL_MIN_PX = 24;
|
|
989
|
+
const COLLAPSED_MODAL_SETTLE_MS = 400;
|
|
939
990
|
const MAIN_THREAD_STALL_DEFAULT_MS = 200;
|
|
940
991
|
const MAIN_THREAD_STALL_DEFAULT_COUNT = 3;
|
|
941
992
|
const MAIN_THREAD_STALL_DEFAULT_WINDOW_MS = 1e4;
|
|
@@ -952,6 +1003,7 @@ var createBeacon = (options) => {
|
|
|
952
1003
|
const FORM_FRUSTRATION_THRESHOLD = 3;
|
|
953
1004
|
const FORM_FRUSTRATION_WINDOW_MS = 60000;
|
|
954
1005
|
const LAYOUT_SHIFT_RECENT_INTERACTION_MS = 500;
|
|
1006
|
+
const LAYOUT_SHIFT_SPA_NAVIGATION_SETTLE_MS = 2000;
|
|
955
1007
|
const LAYOUT_SHIFT_INTERACTION_PROVENANCE_MS = 1e4;
|
|
956
1008
|
const LAYOUT_SHIFT_VIEWPORT_RESIZE_SETTLE_MS = 500;
|
|
957
1009
|
const VIEWPORT_RESIZE_HISTORY_LIMIT = 8;
|
|
@@ -982,13 +1034,14 @@ var createBeacon = (options) => {
|
|
|
982
1034
|
let pageLifecycleGeneration = 0;
|
|
983
1035
|
let pageRestoredAt;
|
|
984
1036
|
let recentInteraction;
|
|
1037
|
+
let recentNavigation;
|
|
985
1038
|
let reportErrorClick = null;
|
|
986
|
-
const reportCapturedErrorClick = (error,
|
|
1039
|
+
const reportCapturedErrorClick = (error, tags) => {
|
|
987
1040
|
if (filterKnownNoise && isKnownBeaconNoise({
|
|
988
1041
|
message: error.message,
|
|
989
1042
|
name: error.name,
|
|
990
1043
|
stack: error.stack,
|
|
991
|
-
tags
|
|
1044
|
+
tags
|
|
992
1045
|
}))
|
|
993
1046
|
return;
|
|
994
1047
|
reportErrorClick?.(error.name);
|
|
@@ -1045,11 +1098,13 @@ var createBeacon = (options) => {
|
|
|
1045
1098
|
}
|
|
1046
1099
|
return false;
|
|
1047
1100
|
};
|
|
1101
|
+
const cleanups = [];
|
|
1102
|
+
let closed = false;
|
|
1048
1103
|
const vitalsOptions = options.vitals === undefined || options.vitals === false ? null : options.vitals === true ? {} : options.vitals;
|
|
1049
1104
|
if (vitalsOptions !== null) {
|
|
1050
1105
|
const vitalsEndpoint = vitalsOptions.endpoint ?? "/ingest/vitals";
|
|
1051
1106
|
const reportVital = (metric) => {
|
|
1052
|
-
if (!isVitalName(metric.name))
|
|
1107
|
+
if (closed || !isVitalName(metric.name))
|
|
1053
1108
|
return;
|
|
1054
1109
|
const replayId = options.getReplayId?.();
|
|
1055
1110
|
const traceId = options.getTraceId?.();
|
|
@@ -1092,17 +1147,19 @@ var createBeacon = (options) => {
|
|
|
1092
1147
|
if (vitalsOptions.webVitals !== undefined) {
|
|
1093
1148
|
observeWebVitals(vitalsOptions.webVitals, reportVital);
|
|
1094
1149
|
} else {
|
|
1095
|
-
loadWebVitals().then((webVitals) =>
|
|
1150
|
+
loadWebVitals().then((webVitals) => {
|
|
1151
|
+
if (!closed)
|
|
1152
|
+
observeWebVitals(webVitals, reportVital);
|
|
1153
|
+
}).catch(() => {
|
|
1096
1154
|
console.warn("[beacon] web-vitals not installed; vitals disabled. `bun add web-vitals`.");
|
|
1097
1155
|
});
|
|
1098
1156
|
}
|
|
1099
1157
|
const navigationEntry = performance.getEntriesByType("navigation")[0];
|
|
1100
1158
|
const navigationType = typeof PerformanceNavigationTiming !== "undefined" && navigationEntry instanceof PerformanceNavigationTiming ? navigationEntry.type : "navigate";
|
|
1101
|
-
observeLongTasks(reportVital, navigationType);
|
|
1159
|
+
cleanups.push(observeLongTasks(reportVital, navigationType));
|
|
1102
1160
|
}
|
|
1103
1161
|
const buffer = [];
|
|
1104
1162
|
const breadcrumbs = [];
|
|
1105
|
-
const cleanups = [];
|
|
1106
1163
|
const pendingClickCleanups = new Set;
|
|
1107
1164
|
cleanups.push(() => {
|
|
1108
1165
|
for (const cleanup of pendingClickCleanups)
|
|
@@ -1241,6 +1298,8 @@ var createBeacon = (options) => {
|
|
|
1241
1298
|
push(event);
|
|
1242
1299
|
};
|
|
1243
1300
|
const emitSignal = (message, signalTags, traceId, extra, stackBoundary, fallbackFramesToDrop = 1, useDefaultFingerprint = false) => {
|
|
1301
|
+
if (signals?.suppressAutomatedBrowsers === true && isAutomatedBrowser())
|
|
1302
|
+
return;
|
|
1244
1303
|
if (staleClientRelease && signalTags.signal !== BEACON_SIGNAL.STALE_RELEASE && signalTags.signal !== BEACON_SIGNAL.RELOAD_LOOP)
|
|
1245
1304
|
return;
|
|
1246
1305
|
const error = new Error(message);
|
|
@@ -1325,15 +1384,15 @@ var createBeacon = (options) => {
|
|
|
1325
1384
|
}
|
|
1326
1385
|
};
|
|
1327
1386
|
const interval = window.setInterval(checkWhenVisible, Math.max(1000, probe.intervalMs ?? 60000));
|
|
1328
|
-
const
|
|
1387
|
+
const onVisibilityChange = () => checkWhenVisible();
|
|
1329
1388
|
window.addEventListener("focus", checkWhenVisible);
|
|
1330
1389
|
window.addEventListener("online", checkWhenVisible);
|
|
1331
|
-
document.addEventListener("visibilitychange",
|
|
1390
|
+
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
1332
1391
|
cleanups.push(() => {
|
|
1333
1392
|
window.clearInterval(interval);
|
|
1334
1393
|
window.removeEventListener("focus", checkWhenVisible);
|
|
1335
1394
|
window.removeEventListener("online", checkWhenVisible);
|
|
1336
|
-
document.removeEventListener("visibilitychange",
|
|
1395
|
+
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
1337
1396
|
});
|
|
1338
1397
|
checkServingRelease();
|
|
1339
1398
|
}
|
|
@@ -1381,13 +1440,13 @@ var createBeacon = (options) => {
|
|
|
1381
1440
|
const authFailureStormWindowMs = signals?.authFailureStormWindowMs ?? AUTH_FAILURE_STORM_DEFAULT_WINDOW_MS;
|
|
1382
1441
|
const authFailuresByEndpoint = new Map;
|
|
1383
1442
|
const reportedAuthFailureStorms = new Set;
|
|
1384
|
-
const recordAuthFailure = (
|
|
1443
|
+
const recordAuthFailure = (endpoint, method, status) => {
|
|
1385
1444
|
if (signals === null || signals.authFailureStorms === false)
|
|
1386
1445
|
return false;
|
|
1387
|
-
const label = `${method} ${
|
|
1388
|
-
const
|
|
1389
|
-
const failures = (authFailuresByEndpoint.get(label) ?? []).filter(({ at }) =>
|
|
1390
|
-
failures.push({ at:
|
|
1446
|
+
const label = `${method} ${endpoint}`;
|
|
1447
|
+
const now = Date.now();
|
|
1448
|
+
const failures = (authFailuresByEndpoint.get(label) ?? []).filter(({ at }) => now - at < authFailureStormWindowMs);
|
|
1449
|
+
failures.push({ at: now, status });
|
|
1391
1450
|
authFailuresByEndpoint.set(label, failures);
|
|
1392
1451
|
if (failures.length < authFailureStormCount || reportedAuthFailureStorms.has(label)) {
|
|
1393
1452
|
return false;
|
|
@@ -1395,7 +1454,7 @@ var createBeacon = (options) => {
|
|
|
1395
1454
|
reportedAuthFailureStorms.add(label);
|
|
1396
1455
|
const statuses = [...new Set(failures.map((failure) => failure.status))];
|
|
1397
1456
|
emitSignal(`Authorization failure storm — ${label} repeatedly rejected requests — ${shortUrl(location.href)}`, {
|
|
1398
|
-
endpoint
|
|
1457
|
+
endpoint,
|
|
1399
1458
|
failureCount: String(failures.length),
|
|
1400
1459
|
method,
|
|
1401
1460
|
signal: BEACON_SIGNAL.AUTH_FAILURE_STORM,
|
|
@@ -1489,14 +1548,14 @@ var createBeacon = (options) => {
|
|
|
1489
1548
|
const newestFailureAt = Math.max(...failures.map(({ at }) => at));
|
|
1490
1549
|
const reportDelayMs = Math.max(0, Date.now() - newestFailureAt);
|
|
1491
1550
|
const endpoints = [
|
|
1492
|
-
...new Set(failures.map(({ endpoint
|
|
1551
|
+
...new Set(failures.map(({ endpoint }) => endpoint))
|
|
1493
1552
|
].sort();
|
|
1494
1553
|
const methods = [...new Set(failures.map(({ method }) => method))].sort();
|
|
1495
1554
|
const onlineStates = [
|
|
1496
1555
|
...new Set(failures.map(({ online }) => String(online)))
|
|
1497
1556
|
].sort();
|
|
1498
1557
|
const transports = [
|
|
1499
|
-
...new Set(failures.map(({ transport
|
|
1558
|
+
...new Set(failures.map(({ transport }) => transport))
|
|
1500
1559
|
].sort();
|
|
1501
1560
|
const visibilityStates = [
|
|
1502
1561
|
...new Set(failures.map(({ visibilityState }) => visibilityState))
|
|
@@ -1522,6 +1581,9 @@ var createBeacon = (options) => {
|
|
|
1522
1581
|
method: methods.length === 1 ? methods[0] : "multiple",
|
|
1523
1582
|
online: onlineStates.length === 1 ? onlineStates[0] : "mixed",
|
|
1524
1583
|
reportDelayMs: String(reportDelayMs),
|
|
1584
|
+
requestOrigins: [
|
|
1585
|
+
...new Set(failures.map((failure) => failure.sameOrigin === true ? "same-origin" : failure.origin ?? "unknown"))
|
|
1586
|
+
].sort().join(","),
|
|
1525
1587
|
signal: BEACON_SIGNAL.FETCH_FAILED,
|
|
1526
1588
|
transport: transports.length === 1 ? transports[0] : "multiple",
|
|
1527
1589
|
visibilityState: visibilityStates.length === 1 ? visibilityStates[0] : "mixed",
|
|
@@ -1530,6 +1592,19 @@ var createBeacon = (options) => {
|
|
|
1530
1592
|
}
|
|
1531
1593
|
};
|
|
1532
1594
|
flushPendingNetworkFailures = flushNetworkFailures;
|
|
1595
|
+
const requestOrigin = (url) => {
|
|
1596
|
+
try {
|
|
1597
|
+
const parsed = new URL(url, location.href);
|
|
1598
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
|
|
1599
|
+
return {};
|
|
1600
|
+
return {
|
|
1601
|
+
origin: parsed.origin,
|
|
1602
|
+
sameOrigin: parsed.origin === location.origin
|
|
1603
|
+
};
|
|
1604
|
+
} catch {
|
|
1605
|
+
return {};
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1533
1608
|
const reportFailureSignal = (url, method, durationMs, transportKind, errorValue) => {
|
|
1534
1609
|
if (signals === null || signals.failedRequests === false)
|
|
1535
1610
|
return;
|
|
@@ -1542,6 +1617,7 @@ var createBeacon = (options) => {
|
|
|
1542
1617
|
const properties = errorProperties(error);
|
|
1543
1618
|
const state = networkState();
|
|
1544
1619
|
const failure = {
|
|
1620
|
+
...requestOrigin(url),
|
|
1545
1621
|
at: Date.now(),
|
|
1546
1622
|
durationMs,
|
|
1547
1623
|
endpoint: shortUrl(url),
|
|
@@ -1580,7 +1656,7 @@ var createBeacon = (options) => {
|
|
|
1580
1656
|
let mutated = false;
|
|
1581
1657
|
let extended = false;
|
|
1582
1658
|
let finished = false;
|
|
1583
|
-
let
|
|
1659
|
+
let timer;
|
|
1584
1660
|
const observeRouterAcceptance = (handledEvent) => {
|
|
1585
1661
|
if (handledEvent !== event)
|
|
1586
1662
|
return;
|
|
@@ -1593,8 +1669,8 @@ var createBeacon = (options) => {
|
|
|
1593
1669
|
finished = true;
|
|
1594
1670
|
observer.disconnect();
|
|
1595
1671
|
control.removeEventListener("click", observeRouterAcceptance);
|
|
1596
|
-
if (
|
|
1597
|
-
window.clearTimeout(
|
|
1672
|
+
if (timer !== undefined)
|
|
1673
|
+
window.clearTimeout(timer);
|
|
1598
1674
|
pendingClickCleanups.delete(cancel);
|
|
1599
1675
|
report(didRespond, navigationStalled);
|
|
1600
1676
|
};
|
|
@@ -1604,8 +1680,8 @@ var createBeacon = (options) => {
|
|
|
1604
1680
|
finished = true;
|
|
1605
1681
|
observer.disconnect();
|
|
1606
1682
|
control.removeEventListener("click", observeRouterAcceptance);
|
|
1607
|
-
if (
|
|
1608
|
-
window.clearTimeout(
|
|
1683
|
+
if (timer !== undefined)
|
|
1684
|
+
window.clearTimeout(timer);
|
|
1609
1685
|
};
|
|
1610
1686
|
const observer = new MutationObserver(() => {
|
|
1611
1687
|
mutated = true;
|
|
@@ -1618,7 +1694,7 @@ var createBeacon = (options) => {
|
|
|
1618
1694
|
});
|
|
1619
1695
|
pendingClickCleanups.add(cancel);
|
|
1620
1696
|
control.addEventListener("click", observeRouterAcceptance, { once: true });
|
|
1621
|
-
|
|
1697
|
+
timer = window.setTimeout(() => {
|
|
1622
1698
|
if (responded()) {
|
|
1623
1699
|
finish(true);
|
|
1624
1700
|
return;
|
|
@@ -1628,7 +1704,7 @@ var createBeacon = (options) => {
|
|
|
1628
1704
|
return;
|
|
1629
1705
|
}
|
|
1630
1706
|
extended = true;
|
|
1631
|
-
|
|
1707
|
+
timer = window.setTimeout(() => {
|
|
1632
1708
|
const didRespond = responded();
|
|
1633
1709
|
finish(didRespond, !didRespond);
|
|
1634
1710
|
}, navigationResponseMs - DEAD_CLICK_WINDOW_MS);
|
|
@@ -2229,7 +2305,7 @@ var createBeacon = (options) => {
|
|
|
2229
2305
|
const seenScanIssues = new Set;
|
|
2230
2306
|
let scanIssueReports = 0;
|
|
2231
2307
|
const SCAN_ISSUE_MAX_REPORTS = 10;
|
|
2232
|
-
const reportScanIssue = (element, signal, detail, extraTags) => {
|
|
2308
|
+
const reportScanIssue = (element, signal, detail, extraTags, extra) => {
|
|
2233
2309
|
const bucket = viewportBucket();
|
|
2234
2310
|
const key = `${signal}:${describeElement(element)}@${bucket}`;
|
|
2235
2311
|
if (seenScanIssues.has(key))
|
|
@@ -2244,7 +2320,7 @@ var createBeacon = (options) => {
|
|
|
2244
2320
|
target: describeElement(element),
|
|
2245
2321
|
viewportBucket: bucket,
|
|
2246
2322
|
viewportWidth: String(document.documentElement.clientWidth)
|
|
2247
|
-
});
|
|
2323
|
+
}, undefined, extra);
|
|
2248
2324
|
};
|
|
2249
2325
|
const reportOverflow = (element, kind, detail, spillPx) => {
|
|
2250
2326
|
const bucket = viewportBucket();
|
|
@@ -2371,6 +2447,8 @@ var createBeacon = (options) => {
|
|
|
2371
2447
|
return visible;
|
|
2372
2448
|
};
|
|
2373
2449
|
const isExtensionOwnedCover = (element) => {
|
|
2450
|
+
if (element.closest("com-1password-notification") !== null)
|
|
2451
|
+
return true;
|
|
2374
2452
|
if (element.tagName !== "IFRAME")
|
|
2375
2453
|
return false;
|
|
2376
2454
|
const source = element.getAttribute("src")?.trim().toLowerCase() ?? "";
|
|
@@ -2380,11 +2458,47 @@ var createBeacon = (options) => {
|
|
|
2380
2458
|
const firstGroup = first.closest(INTENTIONAL_CONTROL_GROUP_SELECTOR);
|
|
2381
2459
|
return firstGroup !== null && firstGroup === second.closest(INTENTIONAL_CONTROL_GROUP_SELECTOR);
|
|
2382
2460
|
};
|
|
2461
|
+
const sharesDrawing = (first, second) => {
|
|
2462
|
+
const drawing = first.closest("svg");
|
|
2463
|
+
return drawing !== null && drawing === second.closest("svg");
|
|
2464
|
+
};
|
|
2383
2465
|
const crossesDialogBoundary = (first, second) => {
|
|
2384
2466
|
const firstDialog = first.closest('[role="dialog"], dialog');
|
|
2385
2467
|
const secondDialog = second.closest('[role="dialog"], dialog');
|
|
2386
2468
|
return firstDialog === null !== (secondDialog === null);
|
|
2387
2469
|
};
|
|
2470
|
+
const scanLayoutContext = (target, other) => {
|
|
2471
|
+
const geometry = (element) => {
|
|
2472
|
+
const rect = element.getBoundingClientRect();
|
|
2473
|
+
let positionedAncestor = element;
|
|
2474
|
+
while (positionedAncestor !== null && !["fixed", "sticky"].includes(window.getComputedStyle(positionedAncestor).position)) {
|
|
2475
|
+
positionedAncestor = positionedAncestor.parentElement;
|
|
2476
|
+
}
|
|
2477
|
+
return {
|
|
2478
|
+
rect: {
|
|
2479
|
+
top: rect.top,
|
|
2480
|
+
right: rect.right,
|
|
2481
|
+
bottom: rect.bottom,
|
|
2482
|
+
left: rect.left,
|
|
2483
|
+
width: rect.width,
|
|
2484
|
+
height: rect.height
|
|
2485
|
+
},
|
|
2486
|
+
position: window.getComputedStyle(element).position,
|
|
2487
|
+
...positionedAncestor ? {
|
|
2488
|
+
positionedAncestor: describeElement(positionedAncestor),
|
|
2489
|
+
ancestorPosition: window.getComputedStyle(positionedAncestor).position
|
|
2490
|
+
} : {}
|
|
2491
|
+
};
|
|
2492
|
+
};
|
|
2493
|
+
return {
|
|
2494
|
+
layout: {
|
|
2495
|
+
target: geometry(target),
|
|
2496
|
+
other: geometry(other),
|
|
2497
|
+
scrollX: window.scrollX,
|
|
2498
|
+
scrollY: window.scrollY
|
|
2499
|
+
}
|
|
2500
|
+
};
|
|
2501
|
+
};
|
|
2388
2502
|
const scanForControlCollisions = () => {
|
|
2389
2503
|
const viewportWidth = document.documentElement.clientWidth;
|
|
2390
2504
|
const viewportHeight = document.documentElement.clientHeight;
|
|
@@ -2415,7 +2529,7 @@ var createBeacon = (options) => {
|
|
|
2415
2529
|
const second = controls[secondIndex];
|
|
2416
2530
|
if (second === undefined)
|
|
2417
2531
|
continue;
|
|
2418
|
-
if (first.element.contains(second.element) || second.element.contains(first.element) || crossesDialogBoundary(first.element, second.element)) {
|
|
2532
|
+
if (first.element.contains(second.element) || second.element.contains(first.element) || crossesDialogBoundary(first.element, second.element) || sharesDrawing(first.element, second.element)) {
|
|
2419
2533
|
continue;
|
|
2420
2534
|
}
|
|
2421
2535
|
const overlapX = Math.min(first.rect.right, second.rect.right) - Math.max(first.rect.left, second.rect.left);
|
|
@@ -2425,13 +2539,13 @@ var createBeacon = (options) => {
|
|
|
2425
2539
|
if (first.element.parentElement === second.element.parentElement && (first.positioned || second.positioned)) {
|
|
2426
2540
|
continue;
|
|
2427
2541
|
}
|
|
2428
|
-
const
|
|
2542
|
+
const axis = overlapY <= overlapX ? "vertical" : "horizontal";
|
|
2429
2543
|
reportScanIssue(first.element, BEACON_SIGNAL.CONTROL_COLLISION, `Control collision — ${describeElement(first.element)} overlaps ${describeElement(second.element)}`, {
|
|
2430
2544
|
collidesWith: describeElement(second.element),
|
|
2431
|
-
collisionAxis:
|
|
2545
|
+
collisionAxis: axis,
|
|
2432
2546
|
collisionKind: "overlap",
|
|
2433
|
-
overlapPx: String(Math.round(
|
|
2434
|
-
});
|
|
2547
|
+
overlapPx: String(Math.round(axis === "vertical" ? overlapY : overlapX))
|
|
2548
|
+
}, scanLayoutContext(first.element, second.element));
|
|
2435
2549
|
continue;
|
|
2436
2550
|
}
|
|
2437
2551
|
if (first.element.parentElement === second.element.parentElement || sharedIntentionalControlGroup(first.element, second.element) || first.positioned || second.positioned) {
|
|
@@ -2455,7 +2569,7 @@ var createBeacon = (options) => {
|
|
|
2455
2569
|
collisionAxis: axis,
|
|
2456
2570
|
collisionKind: "touching",
|
|
2457
2571
|
gapPx: String(Math.round(axis === "vertical" ? verticalGap : horizontalGap))
|
|
2458
|
-
});
|
|
2572
|
+
}, scanLayoutContext(first.element, second.element));
|
|
2459
2573
|
}
|
|
2460
2574
|
}
|
|
2461
2575
|
};
|
|
@@ -2490,7 +2604,7 @@ var createBeacon = (options) => {
|
|
|
2490
2604
|
const coverage = Math.max(overlapX, 0) * Math.max(overlapY, 0) / ((visibleRect.right - visibleRect.left) * (visibleRect.bottom - visibleRect.top));
|
|
2491
2605
|
if (coverage < OCCLUSION_COVERAGE_MIN)
|
|
2492
2606
|
continue;
|
|
2493
|
-
reportScanIssue(control, BEACON_SIGNAL.OCCLUDED_CONTROL, `Occluded control — ${describeElement(control)} is covered by ${describeElement(top)}`, { coveredBy: describeElement(top) });
|
|
2607
|
+
reportScanIssue(control, BEACON_SIGNAL.OCCLUDED_CONTROL, `Occluded control — ${describeElement(control)} is covered by ${describeElement(top)}`, { coveredBy: describeElement(top) }, scanLayoutContext(control, top));
|
|
2494
2608
|
}
|
|
2495
2609
|
};
|
|
2496
2610
|
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
@@ -2775,9 +2889,9 @@ var createBeacon = (options) => {
|
|
|
2775
2889
|
const checkStuckLoading = () => {
|
|
2776
2890
|
if (document.visibilityState === "hidden")
|
|
2777
2891
|
return;
|
|
2778
|
-
const
|
|
2779
|
-
const missedPollWindow = lastLoadingCheckAt !== undefined &&
|
|
2780
|
-
lastLoadingCheckAt =
|
|
2892
|
+
const now = Date.now();
|
|
2893
|
+
const missedPollWindow = lastLoadingCheckAt !== undefined && now - lastLoadingCheckAt > STUCK_LOADING_POLL_MS * 3;
|
|
2894
|
+
lastLoadingCheckAt = now;
|
|
2781
2895
|
const indicators = Array.from(document.querySelectorAll(loadingIndicatorSelector));
|
|
2782
2896
|
const activeIndicators = new Set(indicators);
|
|
2783
2897
|
for (const tracked of trackedLoadingIndicators) {
|
|
@@ -2795,22 +2909,22 @@ var createBeacon = (options) => {
|
|
|
2795
2909
|
continue;
|
|
2796
2910
|
}
|
|
2797
2911
|
if (missedPollWindow && loadingFirstSeen.has(indicator)) {
|
|
2798
|
-
loadingFirstSeen.set(indicator,
|
|
2912
|
+
loadingFirstSeen.set(indicator, now);
|
|
2799
2913
|
}
|
|
2800
2914
|
const firstSeen = loadingFirstSeen.get(indicator);
|
|
2801
2915
|
if (firstSeen === undefined) {
|
|
2802
|
-
loadingFirstSeen.set(indicator,
|
|
2916
|
+
loadingFirstSeen.set(indicator, now);
|
|
2803
2917
|
trackedLoadingIndicators.add(indicator);
|
|
2804
2918
|
continue;
|
|
2805
2919
|
}
|
|
2806
2920
|
const deadlineMs = loadingDeadlineMs(indicator);
|
|
2807
|
-
if (
|
|
2921
|
+
if (now - firstSeen < deadlineMs || reportedStuckLoading.has(indicator)) {
|
|
2808
2922
|
continue;
|
|
2809
2923
|
}
|
|
2810
2924
|
reportedStuckLoading.add(indicator);
|
|
2811
2925
|
reportScanIssue(indicator, BEACON_SIGNAL.STUCK_LOADING, `Stuck loading — ${describeElement(indicator)} never resolved`, {
|
|
2812
2926
|
deadlineMs: String(deadlineMs),
|
|
2813
|
-
visibleMs: String(
|
|
2927
|
+
visibleMs: String(now - firstSeen)
|
|
2814
2928
|
});
|
|
2815
2929
|
}
|
|
2816
2930
|
};
|
|
@@ -2942,17 +3056,22 @@ var createBeacon = (options) => {
|
|
|
2942
3056
|
};
|
|
2943
3057
|
};
|
|
2944
3058
|
const processLayoutShift = (entry) => {
|
|
3059
|
+
const firstContentfulPaint = performance.getEntriesByName("first-contentful-paint")[0]?.startTime;
|
|
3060
|
+
if (firstContentfulPaint !== undefined && entry.startTime < firstContentfulPaint)
|
|
3061
|
+
return;
|
|
2945
3062
|
const interactionTimes = [
|
|
2946
3063
|
...earlyInteractionTimes,
|
|
2947
3064
|
...recentInteraction === undefined ? [] : [recentInteraction.performanceAt]
|
|
2948
3065
|
];
|
|
2949
3066
|
const interactionAgeMs = interactionTimes.map((interactionAt) => entry.startTime - interactionAt).filter((age) => age >= 0).sort((left, right) => left - right)[0];
|
|
2950
3067
|
const beaconSawRecentInput = interactionAgeMs !== undefined && interactionAgeMs <= LAYOUT_SHIFT_RECENT_INTERACTION_MS;
|
|
3068
|
+
const navigationAgeMs = recentNavigation === undefined ? undefined : entry.startTime - recentNavigation.performanceAt;
|
|
3069
|
+
const navigationSettling = navigationAgeMs !== undefined && navigationAgeMs >= 0 && navigationAgeMs <= LAYOUT_SHIFT_SPA_NAVIGATION_SETTLE_MS;
|
|
2951
3070
|
const resizeAdjacent = viewportResizeTimes.some((resizedAt) => {
|
|
2952
3071
|
const resizeAgeMs = entry.startTime - resizedAt;
|
|
2953
3072
|
return resizeAgeMs >= 0 && resizeAgeMs <= LAYOUT_SHIFT_VIEWPORT_RESIZE_SETTLE_MS;
|
|
2954
3073
|
});
|
|
2955
|
-
if (entry.hadRecentInput || beaconSawRecentInput || resizeAdjacent || mobileKeyboardViewportActive() || entry.value < minimum)
|
|
3074
|
+
if (entry.hadRecentInput || beaconSawRecentInput || navigationSettling || resizeAdjacent || mobileKeyboardViewportActive() || entry.value < minimum)
|
|
2956
3075
|
return;
|
|
2957
3076
|
const sourceElements = entry.sources.map(({ node }) => node instanceof Element ? node : undefined).filter((node) => node !== undefined);
|
|
2958
3077
|
if (sourceElements.length > 0 && sourceElements.every((node) => node.closest(`[${BEACON_ATTRIBUTE.LAYOUT_SHIFT}="allow"]`) !== null))
|
|
@@ -2980,6 +3099,12 @@ var createBeacon = (options) => {
|
|
|
2980
3099
|
interactionType: interactionProvenance.type
|
|
2981
3100
|
}
|
|
2982
3101
|
} : {},
|
|
3102
|
+
...recentNavigation === undefined || navigationAgeMs === undefined || navigationAgeMs < 0 || navigationAgeMs > LAYOUT_SHIFT_INTERACTION_PROVENANCE_MS ? {} : {
|
|
3103
|
+
navigationAgeMs: String(Math.round(navigationAgeMs)),
|
|
3104
|
+
navigationFrom: recentNavigation.from,
|
|
3105
|
+
navigationTo: recentNavigation.to,
|
|
3106
|
+
navigationType: recentNavigation.type
|
|
3107
|
+
},
|
|
2983
3108
|
layoutShiftBuffered: String(entry.buffered),
|
|
2984
3109
|
layoutShiftObservedAtMs: String(Math.round(entry.observedAt)),
|
|
2985
3110
|
layoutShiftObserverStartedAtMs: String(Math.round(entry.observerStartedAt)),
|
|
@@ -3103,7 +3228,9 @@ var createBeacon = (options) => {
|
|
|
3103
3228
|
recordBlockingFrames(blockingObserver.takeRecords());
|
|
3104
3229
|
}
|
|
3105
3230
|
const interactionEnd = entry.startTime + entry.duration;
|
|
3106
|
-
const
|
|
3231
|
+
const overlappingFrames = blockingFrames.filter((frame) => frame.startTime < interactionEnd && frame.startTime + frame.duration > entry.startTime);
|
|
3232
|
+
const onlyIdleFrames = overlappingFrames.length > 0 && overlappingFrames.every((frame) => frame.entryType === "long-animation-frame" && frame.blockingDuration === 0 && Array.isArray(frame.scripts) && frame.scripts.length === 0);
|
|
3233
|
+
const overlappingFrame = overlappingFrames.sort((left, right) => {
|
|
3107
3234
|
const leftBlocking = left.blockingDuration ?? Math.max(0, left.duration - LONG_TASK_MS);
|
|
3108
3235
|
const rightBlocking = right.blockingDuration ?? Math.max(0, right.duration - LONG_TASK_MS);
|
|
3109
3236
|
return rightBlocking - leftBlocking;
|
|
@@ -3113,7 +3240,7 @@ var createBeacon = (options) => {
|
|
|
3113
3240
|
const processingDurationMs = hasPhaseTiming ? Math.round(Math.max(0, entry.processingEnd - entry.processingStart)) : undefined;
|
|
3114
3241
|
const presentationDelayMs = hasPhaseTiming ? Math.round(Math.max(0, interactionEnd - entry.processingEnd)) : undefined;
|
|
3115
3242
|
const inputDelayMs = hasPhaseTiming ? Math.round(Math.max(0, entry.processingStart - entry.startTime)) : undefined;
|
|
3116
|
-
if (overlappingFrame === undefined && processingDurationMs !== undefined && processingDurationMs <= 16 && presentationDelayMs !== undefined && presentationDelayMs >= minimum)
|
|
3243
|
+
if ((overlappingFrame === undefined || onlyIdleFrames && inputDelayMs !== undefined && inputDelayMs < minimum) && processingDurationMs !== undefined && processingDurationMs <= 16 && presentationDelayMs !== undefined && presentationDelayMs >= minimum)
|
|
3117
3244
|
continue;
|
|
3118
3245
|
if (blockingObserver !== undefined && overlappingFrame === undefined && inputDelayMs !== undefined && inputDelayMs >= minimum && processingDurationMs !== undefined && processingDurationMs <= 16 && presentationDelayMs !== undefined && presentationDelayMs < minimum)
|
|
3119
3246
|
continue;
|
|
@@ -3195,7 +3322,7 @@ var createBeacon = (options) => {
|
|
|
3195
3322
|
if (name === null)
|
|
3196
3323
|
return;
|
|
3197
3324
|
const onLoad = () => stopWatching(frame);
|
|
3198
|
-
const
|
|
3325
|
+
const timer = setTimeout(() => {
|
|
3199
3326
|
stopWatching(frame);
|
|
3200
3327
|
if (pageLifecycleEnding || document.visibilityState === "hidden" || !frame.isConnected) {
|
|
3201
3328
|
return;
|
|
@@ -3212,7 +3339,7 @@ var createBeacon = (options) => {
|
|
|
3212
3339
|
target: describeElement(frame)
|
|
3213
3340
|
});
|
|
3214
3341
|
}, stallMs);
|
|
3215
|
-
watched.set(frame, { onLoad, timer
|
|
3342
|
+
watched.set(frame, { onLoad, timer });
|
|
3216
3343
|
frame.addEventListener("load", onLoad, { once: true });
|
|
3217
3344
|
};
|
|
3218
3345
|
const discoverFrames = (root) => {
|
|
@@ -3411,9 +3538,9 @@ var createBeacon = (options) => {
|
|
|
3411
3538
|
const pending = new Map;
|
|
3412
3539
|
const reported = new WeakSet;
|
|
3413
3540
|
const clearPending = (canvas) => {
|
|
3414
|
-
const
|
|
3415
|
-
if (
|
|
3416
|
-
clearTimeout(
|
|
3541
|
+
const timer = pending.get(canvas);
|
|
3542
|
+
if (timer !== undefined)
|
|
3543
|
+
clearTimeout(timer);
|
|
3417
3544
|
pending.delete(canvas);
|
|
3418
3545
|
};
|
|
3419
3546
|
const onLost = (event) => {
|
|
@@ -3421,7 +3548,7 @@ var createBeacon = (options) => {
|
|
|
3421
3548
|
return;
|
|
3422
3549
|
const canvas = event.target;
|
|
3423
3550
|
clearPending(canvas);
|
|
3424
|
-
const
|
|
3551
|
+
const timer = setTimeout(() => {
|
|
3425
3552
|
pending.delete(canvas);
|
|
3426
3553
|
if (reported.has(canvas) || pageLifecycleEnding || document.visibilityState === "hidden" || !canvas.isConnected) {
|
|
3427
3554
|
return;
|
|
@@ -3438,7 +3565,7 @@ var createBeacon = (options) => {
|
|
|
3438
3565
|
target: describeElement(canvas)
|
|
3439
3566
|
});
|
|
3440
3567
|
}, graceMs);
|
|
3441
|
-
pending.set(canvas,
|
|
3568
|
+
pending.set(canvas, timer);
|
|
3442
3569
|
};
|
|
3443
3570
|
const onRestored = (event) => {
|
|
3444
3571
|
if (event.target instanceof HTMLCanvasElement)
|
|
@@ -3449,8 +3576,8 @@ var createBeacon = (options) => {
|
|
|
3449
3576
|
cleanups.push(() => {
|
|
3450
3577
|
document.removeEventListener("webglcontextlost", onLost, true);
|
|
3451
3578
|
document.removeEventListener("webglcontextrestored", onRestored, true);
|
|
3452
|
-
for (const
|
|
3453
|
-
clearTimeout(
|
|
3579
|
+
for (const timer of pending.values())
|
|
3580
|
+
clearTimeout(timer);
|
|
3454
3581
|
pending.clear();
|
|
3455
3582
|
});
|
|
3456
3583
|
}
|
|
@@ -3459,9 +3586,9 @@ var createBeacon = (options) => {
|
|
|
3459
3586
|
const visualViewport = window.visualViewport;
|
|
3460
3587
|
const settleMs = signals.focusedControlSettleMs ?? FOCUSED_CONTROL_SETTLE_DEFAULT_MS;
|
|
3461
3588
|
const reported = new Set;
|
|
3462
|
-
let
|
|
3589
|
+
let timer;
|
|
3463
3590
|
const checkFocusedControl = () => {
|
|
3464
|
-
|
|
3591
|
+
timer = undefined;
|
|
3465
3592
|
if (pageLifecycleEnding || document.visibilityState === "hidden" || visualViewport.height >= window.innerHeight * KEYBOARD_VIEWPORT_HEIGHT_RATIO_MAX) {
|
|
3466
3593
|
return;
|
|
3467
3594
|
}
|
|
@@ -3491,9 +3618,9 @@ var createBeacon = (options) => {
|
|
|
3491
3618
|
});
|
|
3492
3619
|
};
|
|
3493
3620
|
const scheduleCheck = () => {
|
|
3494
|
-
if (
|
|
3495
|
-
clearTimeout(
|
|
3496
|
-
|
|
3621
|
+
if (timer !== undefined)
|
|
3622
|
+
clearTimeout(timer);
|
|
3623
|
+
timer = setTimeout(checkFocusedControl, settleMs);
|
|
3497
3624
|
};
|
|
3498
3625
|
document.addEventListener("focusin", scheduleCheck, true);
|
|
3499
3626
|
visualViewport.addEventListener("resize", scheduleCheck);
|
|
@@ -3502,8 +3629,8 @@ var createBeacon = (options) => {
|
|
|
3502
3629
|
document.removeEventListener("focusin", scheduleCheck, true);
|
|
3503
3630
|
visualViewport.removeEventListener("resize", scheduleCheck);
|
|
3504
3631
|
visualViewport.removeEventListener("scroll", scheduleCheck);
|
|
3505
|
-
if (
|
|
3506
|
-
clearTimeout(
|
|
3632
|
+
if (timer !== undefined)
|
|
3633
|
+
clearTimeout(timer);
|
|
3507
3634
|
});
|
|
3508
3635
|
}
|
|
3509
3636
|
if (signals.scrollJail !== false) {
|
|
@@ -3543,7 +3670,7 @@ var createBeacon = (options) => {
|
|
|
3543
3670
|
};
|
|
3544
3671
|
const onWheel = (event) => {
|
|
3545
3672
|
clearJailSettle();
|
|
3546
|
-
if (event.ctrlKey || event.defaultPrevented || event.deltaY === 0) {
|
|
3673
|
+
if (event.ctrlKey || event.defaultPrevented || event.deltaY === 0 || Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
|
|
3547
3674
|
jailBurst = [];
|
|
3548
3675
|
return;
|
|
3549
3676
|
}
|
|
@@ -3560,16 +3687,16 @@ var createBeacon = (options) => {
|
|
|
3560
3687
|
jailBurst = [];
|
|
3561
3688
|
return;
|
|
3562
3689
|
}
|
|
3563
|
-
const
|
|
3690
|
+
const now = Date.now();
|
|
3564
3691
|
if (jailScroller !== scroller) {
|
|
3565
3692
|
jailScroller = scroller;
|
|
3566
3693
|
jailBurst = [];
|
|
3567
3694
|
}
|
|
3568
|
-
jailBurst = jailBurst.filter((entry) =>
|
|
3695
|
+
jailBurst = jailBurst.filter((entry) => now - entry.at < SCROLL_JAIL_WINDOW_MS && !entry.event.defaultPrevented);
|
|
3569
3696
|
if (jailBurst.length === 0) {
|
|
3570
3697
|
jailStartingScrollGeneration = scrollActivityGeneration;
|
|
3571
3698
|
}
|
|
3572
|
-
jailBurst.push({ at:
|
|
3699
|
+
jailBurst.push({ at: now, position: scroller.scrollTop, event });
|
|
3573
3700
|
if (jailBurst.length < SCROLL_JAIL_EVENT_COUNT)
|
|
3574
3701
|
return;
|
|
3575
3702
|
const first = jailBurst[0];
|
|
@@ -3581,7 +3708,10 @@ var createBeacon = (options) => {
|
|
|
3581
3708
|
const startingPosition = first.position;
|
|
3582
3709
|
jailSettleTimer = setTimeout(() => {
|
|
3583
3710
|
jailSettleTimer = undefined;
|
|
3711
|
+
const confirmedBurst = jailBurst.filter((entry) => !entry.event.defaultPrevented);
|
|
3584
3712
|
jailBurst = [];
|
|
3713
|
+
if (confirmedBurst.length < SCROLL_JAIL_EVENT_COUNT)
|
|
3714
|
+
return;
|
|
3585
3715
|
if (scrollActivityGeneration !== jailStartingScrollGeneration)
|
|
3586
3716
|
return;
|
|
3587
3717
|
if (!scroller.isConnected || scroller.scrollTop !== startingPosition)
|
|
@@ -3595,7 +3725,32 @@ var createBeacon = (options) => {
|
|
|
3595
3725
|
if (reportedScrollers.has(descriptor))
|
|
3596
3726
|
return;
|
|
3597
3727
|
reportedScrollers.add(descriptor);
|
|
3598
|
-
emitSignal(`Scroll jail — ${descriptor} has scrollable content but never moves — ${shortUrl(location.href)}`, { signal: BEACON_SIGNAL.SCROLL_JAIL, target: descriptor }
|
|
3728
|
+
emitSignal(`Scroll jail — ${descriptor} has scrollable content but never moves — ${shortUrl(location.href)}`, { signal: BEACON_SIGNAL.SCROLL_JAIL, target: descriptor }, undefined, {
|
|
3729
|
+
scroll: {
|
|
3730
|
+
target: target ? describeElement(target) : undefined,
|
|
3731
|
+
scroller: descriptor,
|
|
3732
|
+
direction: scrollingDown ? "down" : "up",
|
|
3733
|
+
wheelCount: confirmedBurst.length,
|
|
3734
|
+
deltaX: event.deltaX,
|
|
3735
|
+
deltaY: event.deltaY,
|
|
3736
|
+
deltaMode: event.deltaMode,
|
|
3737
|
+
burstDurationMs: now - (confirmedBurst[0]?.at ?? now),
|
|
3738
|
+
scrollTop: scroller.scrollTop,
|
|
3739
|
+
scrollHeight: scroller.scrollHeight,
|
|
3740
|
+
clientHeight: scroller.clientHeight,
|
|
3741
|
+
overflowY: window.getComputedStyle(scroller).overflowY,
|
|
3742
|
+
overscrollBehaviorY: window.getComputedStyle(scroller).overscrollBehaviorY,
|
|
3743
|
+
bodyOverflowY: window.getComputedStyle(document.body).overflowY,
|
|
3744
|
+
rootOverflowY: window.getComputedStyle(document.documentElement).overflowY,
|
|
3745
|
+
modal: modal ? describeElement(modal) : undefined,
|
|
3746
|
+
rect: {
|
|
3747
|
+
top: scroller.getBoundingClientRect().top,
|
|
3748
|
+
left: scroller.getBoundingClientRect().left,
|
|
3749
|
+
width: scroller.getBoundingClientRect().width,
|
|
3750
|
+
height: scroller.getBoundingClientRect().height
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
});
|
|
3599
3754
|
}, SCROLL_JAIL_SETTLE_MS);
|
|
3600
3755
|
};
|
|
3601
3756
|
document.addEventListener("scroll", onDocumentScroll, {
|
|
@@ -3628,9 +3783,9 @@ var createBeacon = (options) => {
|
|
|
3628
3783
|
previous = { x: event.clientX, y: event.clientY };
|
|
3629
3784
|
if (Math.hypot(dx, dy) < 8)
|
|
3630
3785
|
return;
|
|
3631
|
-
const
|
|
3632
|
-
points = points.filter((point) =>
|
|
3633
|
-
points.push({ at:
|
|
3786
|
+
const now = Date.now();
|
|
3787
|
+
points = points.filter((point) => now - point.at < THRASHED_CURSOR_WINDOW_MS);
|
|
3788
|
+
points.push({ at: now, dx, dy });
|
|
3634
3789
|
let reversals = 0;
|
|
3635
3790
|
for (let index = 1;index < points.length; index += 1) {
|
|
3636
3791
|
const prior = points[index - 1];
|
|
@@ -3655,6 +3810,87 @@ var createBeacon = (options) => {
|
|
|
3655
3810
|
});
|
|
3656
3811
|
cleanups.push(() => document.removeEventListener("pointermove", onPointerMove));
|
|
3657
3812
|
}
|
|
3813
|
+
if (signals.collapsedModals !== false && typeof MutationObserver !== "undefined") {
|
|
3814
|
+
const COLLAPSED_MODAL_SELECTOR = '[aria-modal="true"], dialog[open]';
|
|
3815
|
+
const reportedCollapsedModals = new WeakSet;
|
|
3816
|
+
const pendingCollapsedModals = new WeakSet;
|
|
3817
|
+
const collapsedModalTimers = new Set;
|
|
3818
|
+
const isHiddenOnPurpose = (modal) => {
|
|
3819
|
+
let current = modal;
|
|
3820
|
+
while (current !== null) {
|
|
3821
|
+
if (current.hasAttribute("hidden") || current.getAttribute("aria-hidden")?.toLowerCase() === "true") {
|
|
3822
|
+
return true;
|
|
3823
|
+
}
|
|
3824
|
+
const style = getComputedStyle(current);
|
|
3825
|
+
if (style.display === "none" || style.visibility === "hidden" || style.visibility === "collapse" || style.contentVisibility === "hidden") {
|
|
3826
|
+
return true;
|
|
3827
|
+
}
|
|
3828
|
+
current = current.parentElement;
|
|
3829
|
+
}
|
|
3830
|
+
return false;
|
|
3831
|
+
};
|
|
3832
|
+
const checkCollapsedModal = (modal) => {
|
|
3833
|
+
if (reportedCollapsedModals.has(modal) || pendingCollapsedModals.has(modal)) {
|
|
3834
|
+
return;
|
|
3835
|
+
}
|
|
3836
|
+
pendingCollapsedModals.add(modal);
|
|
3837
|
+
const timer = setTimeout(() => {
|
|
3838
|
+
collapsedModalTimers.delete(timer);
|
|
3839
|
+
pendingCollapsedModals.delete(modal);
|
|
3840
|
+
if (!modal.isConnected || !modal.matches(COLLAPSED_MODAL_SELECTOR) || modal.childElementCount === 0 || document.visibilityState === "hidden" || isHiddenOnPurpose(modal)) {
|
|
3841
|
+
return;
|
|
3842
|
+
}
|
|
3843
|
+
const rect = modal.getBoundingClientRect();
|
|
3844
|
+
if (rect.width >= COLLAPSED_MODAL_MIN_PX && rect.height >= COLLAPSED_MODAL_MIN_PX) {
|
|
3845
|
+
return;
|
|
3846
|
+
}
|
|
3847
|
+
reportedCollapsedModals.add(modal);
|
|
3848
|
+
const modalDescriptor = describeElement(modal);
|
|
3849
|
+
emitSignal(`Collapsed modal — ${modalDescriptor} opened at ${Math.round(rect.width)}×${Math.round(rect.height)}px — ${shortUrl(location.href)}`, {
|
|
3850
|
+
contentHeightPx: String(Math.round(modal.scrollHeight)),
|
|
3851
|
+
contentWidthPx: String(Math.round(modal.scrollWidth)),
|
|
3852
|
+
heightPx: String(Math.round(rect.height)),
|
|
3853
|
+
modal: modalDescriptor,
|
|
3854
|
+
signal: BEACON_SIGNAL.COLLAPSED_MODAL,
|
|
3855
|
+
widthPx: String(Math.round(rect.width))
|
|
3856
|
+
});
|
|
3857
|
+
}, COLLAPSED_MODAL_SETTLE_MS);
|
|
3858
|
+
collapsedModalTimers.add(timer);
|
|
3859
|
+
};
|
|
3860
|
+
const scanForModals = (root) => {
|
|
3861
|
+
if (root.matches(COLLAPSED_MODAL_SELECTOR))
|
|
3862
|
+
checkCollapsedModal(root);
|
|
3863
|
+
for (const modal of Array.from(root.querySelectorAll(COLLAPSED_MODAL_SELECTOR))) {
|
|
3864
|
+
checkCollapsedModal(modal);
|
|
3865
|
+
}
|
|
3866
|
+
};
|
|
3867
|
+
scanForModals(document.documentElement);
|
|
3868
|
+
const collapsedModalObserver = new MutationObserver((records) => {
|
|
3869
|
+
for (const record of records) {
|
|
3870
|
+
if (record.type === "attributes") {
|
|
3871
|
+
if (record.target instanceof Element)
|
|
3872
|
+
scanForModals(record.target);
|
|
3873
|
+
continue;
|
|
3874
|
+
}
|
|
3875
|
+
for (const node of Array.from(record.addedNodes)) {
|
|
3876
|
+
if (node instanceof Element)
|
|
3877
|
+
scanForModals(node);
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3880
|
+
});
|
|
3881
|
+
collapsedModalObserver.observe(document.documentElement, {
|
|
3882
|
+
attributeFilter: ["open", "aria-modal"],
|
|
3883
|
+
attributes: true,
|
|
3884
|
+
childList: true,
|
|
3885
|
+
subtree: true
|
|
3886
|
+
});
|
|
3887
|
+
cleanups.push(() => {
|
|
3888
|
+
collapsedModalObserver.disconnect();
|
|
3889
|
+
for (const timer of collapsedModalTimers)
|
|
3890
|
+
clearTimeout(timer);
|
|
3891
|
+
collapsedModalTimers.clear();
|
|
3892
|
+
});
|
|
3893
|
+
}
|
|
3658
3894
|
if (signals.focusLoss !== false || signals.modalFocusEscape !== false) {
|
|
3659
3895
|
const DIALOG_SELECTOR = '[role="dialog"], [aria-modal="true"], dialog';
|
|
3660
3896
|
const MODAL_SELECTOR = '[aria-modal="true"], dialog[open]';
|
|
@@ -3694,8 +3930,8 @@ var createBeacon = (options) => {
|
|
|
3694
3930
|
};
|
|
3695
3931
|
const openModals = () => Array.from(document.querySelectorAll(MODAL_SELECTOR)).filter(isRenderedModal);
|
|
3696
3932
|
const checkInitialModalFocus = (modal) => {
|
|
3697
|
-
const
|
|
3698
|
-
modalTimers.delete(
|
|
3933
|
+
const timer = setTimeout(() => {
|
|
3934
|
+
modalTimers.delete(timer);
|
|
3699
3935
|
if (!isRenderedModal(modal))
|
|
3700
3936
|
return;
|
|
3701
3937
|
const active = document.activeElement instanceof Element ? document.activeElement : null;
|
|
@@ -3703,7 +3939,7 @@ var createBeacon = (options) => {
|
|
|
3703
3939
|
return;
|
|
3704
3940
|
reportModalEscape(modal, active, "initial-focus-missing");
|
|
3705
3941
|
}, MODAL_FOCUS_SETTLE_MS);
|
|
3706
|
-
modalTimers.add(
|
|
3942
|
+
modalTimers.add(timer);
|
|
3707
3943
|
};
|
|
3708
3944
|
const updateModalVisibility = (modal) => {
|
|
3709
3945
|
knownModals.add(modal);
|
|
@@ -3726,8 +3962,8 @@ var createBeacon = (options) => {
|
|
|
3726
3962
|
const modals = openModals();
|
|
3727
3963
|
if (modals.length > 0 && !modals.some((modal) => modal.contains(target))) {
|
|
3728
3964
|
const modal = modals[modals.length - 1];
|
|
3729
|
-
const
|
|
3730
|
-
modalTimers.delete(
|
|
3965
|
+
const timer = setTimeout(() => {
|
|
3966
|
+
modalTimers.delete(timer);
|
|
3731
3967
|
if (!isRenderedModal(modal))
|
|
3732
3968
|
return;
|
|
3733
3969
|
const active = document.activeElement instanceof Element ? document.activeElement : null;
|
|
@@ -3735,7 +3971,7 @@ var createBeacon = (options) => {
|
|
|
3735
3971
|
return;
|
|
3736
3972
|
reportModalEscape(modal, active, "escaped");
|
|
3737
3973
|
}, 0);
|
|
3738
|
-
modalTimers.add(
|
|
3974
|
+
modalTimers.add(timer);
|
|
3739
3975
|
}
|
|
3740
3976
|
}
|
|
3741
3977
|
};
|
|
@@ -3812,8 +4048,8 @@ var createBeacon = (options) => {
|
|
|
3812
4048
|
document.removeEventListener("focusin", onFocusIn, true);
|
|
3813
4049
|
document.removeEventListener("focusout", onFocusOut, true);
|
|
3814
4050
|
modalObserver?.disconnect();
|
|
3815
|
-
for (const
|
|
3816
|
-
clearTimeout(
|
|
4051
|
+
for (const timer of modalTimers)
|
|
4052
|
+
clearTimeout(timer);
|
|
3817
4053
|
modalTimers.clear();
|
|
3818
4054
|
knownModals.clear();
|
|
3819
4055
|
});
|
|
@@ -3858,14 +4094,14 @@ var createBeacon = (options) => {
|
|
|
3858
4094
|
if (data === null)
|
|
3859
4095
|
return;
|
|
3860
4096
|
const activity = activityFor(form);
|
|
3861
|
-
const
|
|
4097
|
+
const now = Date.now();
|
|
3862
4098
|
if (data !== activity.lastData) {
|
|
3863
4099
|
activity.lastData = data;
|
|
3864
|
-
activity.identicalSubmits = [
|
|
4100
|
+
activity.identicalSubmits = [now];
|
|
3865
4101
|
return;
|
|
3866
4102
|
}
|
|
3867
|
-
activity.identicalSubmits = activity.identicalSubmits.filter((at) =>
|
|
3868
|
-
activity.identicalSubmits.push(
|
|
4103
|
+
activity.identicalSubmits = activity.identicalSubmits.filter((at) => now - at < FORM_FRUSTRATION_WINDOW_MS);
|
|
4104
|
+
activity.identicalSubmits.push(now);
|
|
3869
4105
|
if (activity.identicalSubmits.length >= FORM_FRUSTRATION_THRESHOLD) {
|
|
3870
4106
|
reportForm(form, "was submitted with identical values repeatedly");
|
|
3871
4107
|
}
|
|
@@ -3876,14 +4112,14 @@ var createBeacon = (options) => {
|
|
|
3876
4112
|
if (form === null)
|
|
3877
4113
|
return;
|
|
3878
4114
|
const activity = activityFor(form);
|
|
3879
|
-
const
|
|
3880
|
-
if (
|
|
3881
|
-
activity.lastInvalidAt =
|
|
4115
|
+
const now = Date.now();
|
|
4116
|
+
if (now - activity.lastInvalidAt < FORM_INVALID_BURST_GAP_MS) {
|
|
4117
|
+
activity.lastInvalidAt = now;
|
|
3882
4118
|
return;
|
|
3883
4119
|
}
|
|
3884
|
-
activity.lastInvalidAt =
|
|
3885
|
-
activity.invalidBursts = activity.invalidBursts.filter((at) =>
|
|
3886
|
-
activity.invalidBursts.push(
|
|
4120
|
+
activity.lastInvalidAt = now;
|
|
4121
|
+
activity.invalidBursts = activity.invalidBursts.filter((at) => now - at < FORM_FRUSTRATION_WINDOW_MS);
|
|
4122
|
+
activity.invalidBursts.push(now);
|
|
3887
4123
|
if (activity.invalidBursts.length >= FORM_FRUSTRATION_THRESHOLD) {
|
|
3888
4124
|
reportForm(form, "keeps failing native validation");
|
|
3889
4125
|
}
|
|
@@ -3982,9 +4218,9 @@ var createBeacon = (options) => {
|
|
|
3982
4218
|
if (signals.sseFlapping === false || pageLifecycleEnding || document.visibilityState === "hidden") {
|
|
3983
4219
|
return;
|
|
3984
4220
|
}
|
|
3985
|
-
const
|
|
3986
|
-
const errors = (errorsByEndpoint.get(endpointLabel) ?? []).filter((at) =>
|
|
3987
|
-
errors.push(
|
|
4221
|
+
const now = Date.now();
|
|
4222
|
+
const errors = (errorsByEndpoint.get(endpointLabel) ?? []).filter((at) => now - at < sseFlapWindowMs);
|
|
4223
|
+
errors.push(now);
|
|
3988
4224
|
errorsByEndpoint.set(endpointLabel, errors);
|
|
3989
4225
|
if (errors.length < sseFlapCount || reportedFlappingStreams.has(endpointLabel)) {
|
|
3990
4226
|
return;
|
|
@@ -4005,13 +4241,13 @@ var createBeacon = (options) => {
|
|
|
4005
4241
|
};
|
|
4006
4242
|
const originalAddEventListener = source.addEventListener.bind(source);
|
|
4007
4243
|
const armedTypes = new Set(["error", "message", "open"]);
|
|
4008
|
-
source.addEventListener = (type, listener,
|
|
4244
|
+
source.addEventListener = (type, listener, options) => {
|
|
4009
4245
|
if (!armedTypes.has(type)) {
|
|
4010
4246
|
armedTypes.add(type);
|
|
4011
4247
|
originalAddEventListener(type, arm);
|
|
4012
4248
|
}
|
|
4013
4249
|
if (listener !== null) {
|
|
4014
|
-
originalAddEventListener(type, listener,
|
|
4250
|
+
originalAddEventListener(type, listener, options);
|
|
4015
4251
|
}
|
|
4016
4252
|
};
|
|
4017
4253
|
originalAddEventListener("open", arm);
|
|
@@ -4060,6 +4296,9 @@ var createBeacon = (options) => {
|
|
|
4060
4296
|
const restoredLifecycleClose = pageRestoredAt !== undefined && socketLifecycleGeneration < pageLifecycleGeneration && Date.now() - pageRestoredAt <= RESTORED_SOCKET_CLOSE_GRACE_MS;
|
|
4061
4297
|
if (pageLifecycleEnding || applicationClose || restoredLifecycleClose)
|
|
4062
4298
|
return;
|
|
4299
|
+
const expectedServerClose = typeof CloseEvent !== "undefined" && event instanceof CloseEvent && (event.wasClean || event.code === 1000 || event.code === 1001 || event.code === 1012);
|
|
4300
|
+
if (expectedServerClose)
|
|
4301
|
+
return;
|
|
4063
4302
|
if (signals.socketAbnormalCloses !== false && typeof CloseEvent !== "undefined" && event instanceof CloseEvent && !event.wasClean && !recoverableSocket(socketUrl)) {
|
|
4064
4303
|
const abnormalKey = `${label}|${event.code}`;
|
|
4065
4304
|
if (!reportedAbnormalCloses.has(abnormalKey)) {
|
|
@@ -4074,10 +4313,10 @@ var createBeacon = (options) => {
|
|
|
4074
4313
|
}
|
|
4075
4314
|
if (signals.socketFlapping === false)
|
|
4076
4315
|
return;
|
|
4077
|
-
const
|
|
4078
|
-
const closes = (closesByUrl.get(label) ?? []).filter((close) =>
|
|
4316
|
+
const now = Date.now();
|
|
4317
|
+
const closes = (closesByUrl.get(label) ?? []).filter((close) => now - close.at < SOCKET_FLAP_WINDOW_MS);
|
|
4079
4318
|
closes.push({
|
|
4080
|
-
at:
|
|
4319
|
+
at: now,
|
|
4081
4320
|
code: typeof CloseEvent !== "undefined" && event instanceof CloseEvent ? event.code : null,
|
|
4082
4321
|
wasClean: typeof CloseEvent !== "undefined" && event instanceof CloseEvent ? event.wasClean : null
|
|
4083
4322
|
});
|
|
@@ -4093,7 +4332,7 @@ var createBeacon = (options) => {
|
|
|
4093
4332
|
windowMs: String(SOCKET_FLAP_WINDOW_MS)
|
|
4094
4333
|
}, undefined, {
|
|
4095
4334
|
closeSamples: closes.map((close) => ({
|
|
4096
|
-
ageMs:
|
|
4335
|
+
ageMs: now - close.at,
|
|
4097
4336
|
code: close.code,
|
|
4098
4337
|
wasClean: close.wasClean
|
|
4099
4338
|
}))
|
|
@@ -4117,14 +4356,14 @@ var createBeacon = (options) => {
|
|
|
4117
4356
|
cleanup();
|
|
4118
4357
|
}
|
|
4119
4358
|
});
|
|
4120
|
-
const reportWorkerFailure = (workerType, endpointLabel,
|
|
4121
|
-
const key = `${workerType}|${endpointLabel}|${
|
|
4359
|
+
const reportWorkerFailure = (workerType, endpointLabel, failureKind, error) => {
|
|
4360
|
+
const key = `${workerType}|${endpointLabel}|${failureKind}`;
|
|
4122
4361
|
if (reportedWorkerFailures.has(key))
|
|
4123
4362
|
return;
|
|
4124
4363
|
reportedWorkerFailures.add(key);
|
|
4125
4364
|
emitSignal(`Worker failure — ${workerType} worker ${endpointLabel} failed — ${shortUrl(location.href)}`, {
|
|
4126
4365
|
endpoint: endpointLabel,
|
|
4127
|
-
failureKind
|
|
4366
|
+
failureKind,
|
|
4128
4367
|
signal: BEACON_SIGNAL.WORKER_FAILURE,
|
|
4129
4368
|
workerType
|
|
4130
4369
|
}, undefined, error === undefined ? undefined : {
|
|
@@ -4211,14 +4450,14 @@ var createBeacon = (options) => {
|
|
|
4211
4450
|
"TimeoutError",
|
|
4212
4451
|
"TypeError"
|
|
4213
4452
|
]);
|
|
4214
|
-
const reportServiceWorkerFailure = (endpointLabel,
|
|
4215
|
-
const key = `${endpointLabel}|${
|
|
4453
|
+
const reportServiceWorkerFailure = (endpointLabel, failureKind, error) => {
|
|
4454
|
+
const key = `${endpointLabel}|${failureKind}`;
|
|
4216
4455
|
if (reportedServiceWorkerFailures.has(key))
|
|
4217
4456
|
return;
|
|
4218
4457
|
reportedServiceWorkerFailures.add(key);
|
|
4219
|
-
emitSignal(`Service worker failure — ${endpointLabel} failed during ${
|
|
4458
|
+
emitSignal(`Service worker failure — ${endpointLabel} failed during ${failureKind} — ${shortUrl(location.href)}`, {
|
|
4220
4459
|
endpoint: endpointLabel,
|
|
4221
|
-
failureKind
|
|
4460
|
+
failureKind,
|
|
4222
4461
|
signal: BEACON_SIGNAL.SERVICE_WORKER_FAILURE
|
|
4223
4462
|
}, undefined, error === undefined ? undefined : {
|
|
4224
4463
|
serviceWorkerError: {
|
|
@@ -4228,12 +4467,15 @@ var createBeacon = (options) => {
|
|
|
4228
4467
|
}
|
|
4229
4468
|
});
|
|
4230
4469
|
};
|
|
4231
|
-
const watchInstallingWorker = (worker) => {
|
|
4232
|
-
let
|
|
4470
|
+
const watchInstallingWorker = (worker, registration) => {
|
|
4471
|
+
let settled = worker.state === "installed" || worker.state === "activated";
|
|
4233
4472
|
const onStateChange = () => {
|
|
4234
|
-
if (worker.state === "activated")
|
|
4235
|
-
|
|
4236
|
-
if (worker.state !== "redundant" ||
|
|
4473
|
+
if (worker.state === "installed" || worker.state === "activated")
|
|
4474
|
+
settled = true;
|
|
4475
|
+
if (worker.state !== "redundant" || settled)
|
|
4476
|
+
return;
|
|
4477
|
+
const successor = registration?.installing ?? registration?.waiting;
|
|
4478
|
+
if (successor !== null && successor !== undefined && successor !== worker)
|
|
4237
4479
|
return;
|
|
4238
4480
|
reportServiceWorkerFailure(shortUrl(worker.scriptURL), "installation");
|
|
4239
4481
|
};
|
|
@@ -4242,11 +4484,11 @@ var createBeacon = (options) => {
|
|
|
4242
4484
|
};
|
|
4243
4485
|
const watchRegistration = (registration) => {
|
|
4244
4486
|
if (registration.installing !== null) {
|
|
4245
|
-
watchInstallingWorker(registration.installing);
|
|
4487
|
+
watchInstallingWorker(registration.installing, registration);
|
|
4246
4488
|
}
|
|
4247
4489
|
const onUpdateFound = () => {
|
|
4248
4490
|
if (registration.installing !== null) {
|
|
4249
|
-
watchInstallingWorker(registration.installing);
|
|
4491
|
+
watchInstallingWorker(registration.installing, registration);
|
|
4250
4492
|
}
|
|
4251
4493
|
};
|
|
4252
4494
|
registration.addEventListener("updatefound", onUpdateFound);
|
|
@@ -4324,23 +4566,23 @@ var createBeacon = (options) => {
|
|
|
4324
4566
|
try {
|
|
4325
4567
|
const navigation = performance.getEntriesByType("navigation")[0];
|
|
4326
4568
|
if (navigation?.type !== "back_forward") {
|
|
4327
|
-
const
|
|
4569
|
+
const now = Date.now();
|
|
4328
4570
|
const route = shortUrl(location.href);
|
|
4329
4571
|
const raw = sessionStorage.getItem(RELOAD_LOOP_STORAGE_KEY);
|
|
4330
4572
|
const parsed = raw === null ? [] : JSON.parse(raw);
|
|
4331
|
-
let history2 = (Array.isArray(parsed) ? parsed : []).filter((entry) => entry !== null && typeof entry === "object" && typeof entry.at === "number" && typeof entry.route === "string" &&
|
|
4573
|
+
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);
|
|
4332
4574
|
let entryKind = "app";
|
|
4333
4575
|
const rawNavigationIntent = sessionStorage.getItem(NAVIGATION_INTENT_STORAGE_KEY);
|
|
4334
4576
|
sessionStorage.removeItem(NAVIGATION_INTENT_STORAGE_KEY);
|
|
4335
4577
|
const navigationIntentAt = Number(rawNavigationIntent);
|
|
4336
|
-
if (rawNavigationIntent !== null && Number.isFinite(navigationIntentAt) &&
|
|
4578
|
+
if (rawNavigationIntent !== null && Number.isFinite(navigationIntentAt) && now - navigationIntentAt >= 0 && now - navigationIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
|
|
4337
4579
|
history2 = [];
|
|
4338
4580
|
entryKind = "intentional-navigation";
|
|
4339
4581
|
}
|
|
4340
4582
|
const rawServiceWorkerUpdateIntent = sessionStorage.getItem(SERVICE_WORKER_UPDATE_INTENT_STORAGE_KEY);
|
|
4341
4583
|
sessionStorage.removeItem(SERVICE_WORKER_UPDATE_INTENT_STORAGE_KEY);
|
|
4342
4584
|
const serviceWorkerUpdateIntentAt = Number(rawServiceWorkerUpdateIntent);
|
|
4343
|
-
if (rawServiceWorkerUpdateIntent !== null && Number.isFinite(serviceWorkerUpdateIntentAt) &&
|
|
4585
|
+
if (rawServiceWorkerUpdateIntent !== null && Number.isFinite(serviceWorkerUpdateIntentAt) && now - serviceWorkerUpdateIntentAt >= 0 && now - serviceWorkerUpdateIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
|
|
4344
4586
|
history2 = [];
|
|
4345
4587
|
entryKind = "service-worker-update";
|
|
4346
4588
|
}
|
|
@@ -4351,7 +4593,7 @@ var createBeacon = (options) => {
|
|
|
4351
4593
|
entryKind = "external";
|
|
4352
4594
|
}
|
|
4353
4595
|
}
|
|
4354
|
-
history2.push({ at:
|
|
4596
|
+
history2.push({ at: now, route });
|
|
4355
4597
|
sessionStorage.setItem(RELOAD_LOOP_STORAGE_KEY, JSON.stringify(history2));
|
|
4356
4598
|
let loadCount = 0;
|
|
4357
4599
|
for (let index = history2.length - 1;index >= 0; index -= 1) {
|
|
@@ -4360,7 +4602,7 @@ var createBeacon = (options) => {
|
|
|
4360
4602
|
loadCount += 1;
|
|
4361
4603
|
}
|
|
4362
4604
|
if (loadCount === RELOAD_LOOP_COUNT) {
|
|
4363
|
-
const firstLoad = history2.at(-loadCount)?.at ??
|
|
4605
|
+
const firstLoad = history2.at(-loadCount)?.at ?? now;
|
|
4364
4606
|
emitSignal(`Reload loop — repeated page loads within a minute — ${shortUrl(location.href)}`, {
|
|
4365
4607
|
currentRelease: options.release ?? "unknown",
|
|
4366
4608
|
entryKind,
|
|
@@ -4369,7 +4611,7 @@ var createBeacon = (options) => {
|
|
|
4369
4611
|
serviceWorkerControlled: String(navigator.serviceWorker?.controller !== null && navigator.serviceWorker?.controller !== undefined),
|
|
4370
4612
|
serviceWorkerScript: navigator.serviceWorker?.controller?.scriptURL ?? "none",
|
|
4371
4613
|
signal: BEACON_SIGNAL.RELOAD_LOOP,
|
|
4372
|
-
windowMs: String(
|
|
4614
|
+
windowMs: String(now - firstLoad)
|
|
4373
4615
|
});
|
|
4374
4616
|
flush(true);
|
|
4375
4617
|
}
|
|
@@ -4379,7 +4621,7 @@ var createBeacon = (options) => {
|
|
|
4379
4621
|
if (signals !== null && signals.staleReleases !== false && typeof localStorage !== "undefined" && typeof options.release === "string" && options.release !== "") {
|
|
4380
4622
|
try {
|
|
4381
4623
|
const currentRelease = options.release;
|
|
4382
|
-
const
|
|
4624
|
+
const now = Date.now();
|
|
4383
4625
|
const raw = localStorage.getItem(STALE_RELEASE_STORAGE_KEY);
|
|
4384
4626
|
const parsed = raw === null ? {} : JSON.parse(raw);
|
|
4385
4627
|
const firstSeenByRelease = {};
|
|
@@ -4389,10 +4631,10 @@ var createBeacon = (options) => {
|
|
|
4389
4631
|
firstSeenByRelease[release] = at;
|
|
4390
4632
|
}
|
|
4391
4633
|
}
|
|
4392
|
-
const currentFirstSeen = firstSeenByRelease[currentRelease] ??
|
|
4634
|
+
const currentFirstSeen = firstSeenByRelease[currentRelease] ?? now;
|
|
4393
4635
|
firstSeenByRelease[currentRelease] = currentFirstSeen;
|
|
4394
4636
|
const newest = Object.entries(firstSeenByRelease).filter(([release, at]) => release !== currentRelease && at > currentFirstSeen).sort((left, right) => right[1] - left[1])[0];
|
|
4395
|
-
if (newest !== undefined &&
|
|
4637
|
+
if (newest !== undefined && now - newest[1] > STALE_RELEASE_GRACE_MS) {
|
|
4396
4638
|
emitSignal(`Stale release — this page is running a build older than one this browser already saw — ${shortUrl(location.href)}`, {
|
|
4397
4639
|
currentRelease,
|
|
4398
4640
|
newestRelease: newest[0],
|
|
@@ -4469,8 +4711,8 @@ var createBeacon = (options) => {
|
|
|
4469
4711
|
return;
|
|
4470
4712
|
if (confirmationMs > 0) {
|
|
4471
4713
|
await new Promise((resolve) => {
|
|
4472
|
-
const
|
|
4473
|
-
cleanups.push(() => window.clearTimeout(
|
|
4714
|
+
const timer = window.setTimeout(resolve, confirmationMs);
|
|
4715
|
+
cleanups.push(() => window.clearTimeout(timer));
|
|
4474
4716
|
});
|
|
4475
4717
|
if (document.visibilityState === "hidden")
|
|
4476
4718
|
return;
|
|
@@ -4512,9 +4754,9 @@ var createBeacon = (options) => {
|
|
|
4512
4754
|
const reportedStorms = new Set;
|
|
4513
4755
|
recordRequestForStorm = (url, method) => {
|
|
4514
4756
|
const label = `${method.toUpperCase()} ${shortUrl(url)}`;
|
|
4515
|
-
const
|
|
4516
|
-
const hits = (hitsByEndpoint.get(label) ?? []).filter((at) =>
|
|
4517
|
-
hits.push(
|
|
4757
|
+
const now = Date.now();
|
|
4758
|
+
const hits = (hitsByEndpoint.get(label) ?? []).filter((at) => now - at < stormWindowMs);
|
|
4759
|
+
hits.push(now);
|
|
4518
4760
|
hitsByEndpoint.set(label, hits);
|
|
4519
4761
|
if (hits.length < stormCount || reportedStorms.has(label))
|
|
4520
4762
|
return;
|
|
@@ -4627,15 +4869,15 @@ var createBeacon = (options) => {
|
|
|
4627
4869
|
type: "xhr"
|
|
4628
4870
|
});
|
|
4629
4871
|
if (!failed) {
|
|
4630
|
-
|
|
4872
|
+
const headers = new Headers;
|
|
4873
|
+
for (const line of this.getAllResponseHeaders().split(/\r?\n/u)) {
|
|
4874
|
+
const separator = line.indexOf(":");
|
|
4875
|
+
if (separator <= 0)
|
|
4876
|
+
continue;
|
|
4877
|
+
headers.append(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
|
|
4878
|
+
}
|
|
4879
|
+
reportResponseSignal(request.url, request.method, this.status, Date.now() - start, responseTraceId(headers.get(BEACON_TRACE_HEADER)));
|
|
4631
4880
|
if ((instrument.classifyResponse !== undefined && this.status >= 200 && this.status < 300 || instrument.classifyErrorResponse !== undefined && this.status >= 400) && (this.responseType === "" || this.responseType === "text")) {
|
|
4632
|
-
const headers = new Headers;
|
|
4633
|
-
for (const line of this.getAllResponseHeaders().split(/\r?\n/u)) {
|
|
4634
|
-
const separator = line.indexOf(":");
|
|
4635
|
-
if (separator <= 0)
|
|
4636
|
-
continue;
|
|
4637
|
-
headers.append(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
|
|
4638
|
-
}
|
|
4639
4881
|
classifyInstrumentedResponse(new Response(this.responseText, {
|
|
4640
4882
|
headers,
|
|
4641
4883
|
status: this.status,
|
|
@@ -4658,11 +4900,17 @@ var createBeacon = (options) => {
|
|
|
4658
4900
|
}
|
|
4659
4901
|
if (instrument.history !== false && typeof history !== "undefined") {
|
|
4660
4902
|
let recordedHistoryUrl = location.href;
|
|
4661
|
-
const record = () => {
|
|
4903
|
+
const record = (from, type) => {
|
|
4662
4904
|
addBreadcrumb({
|
|
4663
4905
|
message: `navigate ${location.pathname}${location.search}`,
|
|
4664
4906
|
type: "navigation"
|
|
4665
4907
|
});
|
|
4908
|
+
recentNavigation = {
|
|
4909
|
+
from: shortUrl(from),
|
|
4910
|
+
performanceAt: performance.now(),
|
|
4911
|
+
to: shortUrl(location.href),
|
|
4912
|
+
type
|
|
4913
|
+
};
|
|
4666
4914
|
recordedHistoryUrl = location.href;
|
|
4667
4915
|
overflowScanOnNavigation?.();
|
|
4668
4916
|
};
|
|
@@ -4684,7 +4932,7 @@ var createBeacon = (options) => {
|
|
|
4684
4932
|
if (!changesUrl)
|
|
4685
4933
|
return result;
|
|
4686
4934
|
reportFormAbandonmentOnNavigation?.(departedUrl);
|
|
4687
|
-
record();
|
|
4935
|
+
record(departedUrl, key);
|
|
4688
4936
|
return result;
|
|
4689
4937
|
};
|
|
4690
4938
|
return () => {
|
|
@@ -4696,7 +4944,7 @@ var createBeacon = (options) => {
|
|
|
4696
4944
|
if (location.href === recordedHistoryUrl)
|
|
4697
4945
|
return;
|
|
4698
4946
|
reportFormAbandonmentOnNavigation?.(recordedHistoryUrl);
|
|
4699
|
-
record();
|
|
4947
|
+
record(recordedHistoryUrl, "popstate");
|
|
4700
4948
|
};
|
|
4701
4949
|
window.addEventListener("popstate", onPopState);
|
|
4702
4950
|
cleanups.push(() => window.removeEventListener("popstate", onPopState));
|
|
@@ -4752,6 +5000,7 @@ var createBeacon = (options) => {
|
|
|
4752
5000
|
captureException,
|
|
4753
5001
|
captureMessage,
|
|
4754
5002
|
close: async () => {
|
|
5003
|
+
closed = true;
|
|
4755
5004
|
for (const cleanup of cleanups.splice(0, cleanups.length))
|
|
4756
5005
|
cleanup();
|
|
4757
5006
|
await flush(true);
|
|
@@ -4787,10 +5036,11 @@ export {
|
|
|
4787
5036
|
createBeacon,
|
|
4788
5037
|
getBeacon,
|
|
4789
5038
|
initBeacon,
|
|
5039
|
+
isAutomatedBrowser,
|
|
4790
5040
|
isKnownBeaconNoise,
|
|
4791
5041
|
observeCapability,
|
|
4792
5042
|
redactBeaconEvent
|
|
4793
5043
|
};
|
|
4794
5044
|
|
|
4795
|
-
//# debugId=
|
|
5045
|
+
//# debugId=5625CC0D3E0D744164756E2164756E21
|
|
4796
5046
|
//# sourceMappingURL=index.js.map
|