@absolutejs/beacon 0.7.0-beta.0 → 0.7.0-beta.10
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 +19 -0
- package/README.md +22 -1
- package/changelog.json +35 -0
- package/dist/early.d.ts +58 -0
- package/dist/early.js +134 -0
- package/dist/early.js.map +10 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +465 -117
- package/dist/index.js.map +5 -4
- package/package.json +15 -6
package/dist/index.js
CHANGED
|
@@ -77,9 +77,129 @@ var BEACON_ATTRIBUTE = {
|
|
|
77
77
|
THEME: "data-beacon-theme"
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
+
// src/early.ts
|
|
81
|
+
var HISTORY_LIMIT = 16;
|
|
82
|
+
var ENTRY_LIMIT = 50;
|
|
83
|
+
var now = () => typeof performance === "undefined" ? 0 : performance.now();
|
|
84
|
+
var describeNode = (node) => {
|
|
85
|
+
if (!(node instanceof Element))
|
|
86
|
+
return "unknown";
|
|
87
|
+
const id = node.id === "" ? "" : `#${node.id}`;
|
|
88
|
+
const classes = [...node.classList].slice(0, 3).map((name) => `.${name}`).join("");
|
|
89
|
+
return `${node.tagName.toLowerCase()}${id}${classes}`;
|
|
90
|
+
};
|
|
91
|
+
var copyRect = (rect) => rect === undefined ? undefined : {
|
|
92
|
+
bottom: rect.bottom,
|
|
93
|
+
height: rect.height,
|
|
94
|
+
left: rect.left,
|
|
95
|
+
right: rect.right,
|
|
96
|
+
top: rect.top,
|
|
97
|
+
width: rect.width,
|
|
98
|
+
x: rect.x,
|
|
99
|
+
y: rect.y
|
|
100
|
+
};
|
|
101
|
+
var viewportSnapshot = () => {
|
|
102
|
+
const visual = window.visualViewport;
|
|
103
|
+
return {
|
|
104
|
+
documentHeight: document.documentElement.scrollHeight,
|
|
105
|
+
documentWidth: document.documentElement.scrollWidth,
|
|
106
|
+
innerHeight: window.innerHeight,
|
|
107
|
+
innerWidth: window.innerWidth,
|
|
108
|
+
...visual == null ? {} : {
|
|
109
|
+
visualHeight: visual.height,
|
|
110
|
+
visualOffsetLeft: visual.offsetLeft,
|
|
111
|
+
visualOffsetTop: visual.offsetTop,
|
|
112
|
+
visualScale: visual.scale,
|
|
113
|
+
visualWidth: visual.width
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
var appendLimited = (values, value) => {
|
|
118
|
+
values.push(value);
|
|
119
|
+
if (values.length > HISTORY_LIMIT)
|
|
120
|
+
values.splice(0, values.length - HISTORY_LIMIT);
|
|
121
|
+
};
|
|
122
|
+
var installEarlyLayoutShiftBuffer = () => {
|
|
123
|
+
if (typeof window === "undefined" || typeof document === "undefined" || typeof PerformanceObserver === "undefined" || window.__absoluteBeaconEarlyLayoutShift !== undefined)
|
|
124
|
+
return;
|
|
125
|
+
const interactionTimes = [];
|
|
126
|
+
const resizeTimes = [];
|
|
127
|
+
const entries = [];
|
|
128
|
+
const recordInteraction = () => appendLimited(interactionTimes, now());
|
|
129
|
+
const recordResize = () => appendLimited(resizeTimes, now());
|
|
130
|
+
const recordEntries = (rawEntries) => {
|
|
131
|
+
for (const raw of rawEntries) {
|
|
132
|
+
const entry = raw;
|
|
133
|
+
entries.push({
|
|
134
|
+
documentReadyState: document.readyState,
|
|
135
|
+
hadRecentInput: entry.hadRecentInput === true,
|
|
136
|
+
observedAt: now(),
|
|
137
|
+
sources: (entry.sources ?? []).slice(0, 5).map((source) => ({
|
|
138
|
+
...source.currentRect === undefined ? {} : { currentRect: copyRect(source.currentRect) },
|
|
139
|
+
...source.node === undefined || source.node === null ? {} : { node: source.node },
|
|
140
|
+
...source.previousRect === undefined ? {} : { previousRect: copyRect(source.previousRect) },
|
|
141
|
+
target: describeNode(source.node)
|
|
142
|
+
})),
|
|
143
|
+
startTime: entry.startTime,
|
|
144
|
+
value: entry.value ?? 0,
|
|
145
|
+
viewport: viewportSnapshot()
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (entries.length > ENTRY_LIMIT)
|
|
149
|
+
entries.splice(0, entries.length - ENTRY_LIMIT);
|
|
150
|
+
};
|
|
151
|
+
try {
|
|
152
|
+
const observerStartedAt = now();
|
|
153
|
+
const observer = new PerformanceObserver((list) => recordEntries(list.getEntries()));
|
|
154
|
+
const interactionEvents = [
|
|
155
|
+
"click",
|
|
156
|
+
"keydown",
|
|
157
|
+
"pointerdown",
|
|
158
|
+
"submit"
|
|
159
|
+
];
|
|
160
|
+
observer.observe({ buffered: true, type: "layout-shift" });
|
|
161
|
+
for (const event of interactionEvents)
|
|
162
|
+
window.addEventListener(event, recordInteraction, true);
|
|
163
|
+
window.addEventListener("resize", recordResize);
|
|
164
|
+
window.visualViewport?.addEventListener("resize", recordResize);
|
|
165
|
+
const cleanup = () => {
|
|
166
|
+
for (const event of interactionEvents)
|
|
167
|
+
window.removeEventListener(event, recordInteraction, true);
|
|
168
|
+
window.removeEventListener("resize", recordResize);
|
|
169
|
+
window.visualViewport?.removeEventListener("resize", recordResize);
|
|
170
|
+
};
|
|
171
|
+
window.__absoluteBeaconEarlyLayoutShift = {
|
|
172
|
+
cleanup,
|
|
173
|
+
entries,
|
|
174
|
+
interactionTimes,
|
|
175
|
+
observer,
|
|
176
|
+
observerStartedAt,
|
|
177
|
+
recordEntries,
|
|
178
|
+
resizeTimes
|
|
179
|
+
};
|
|
180
|
+
} catch {}
|
|
181
|
+
};
|
|
182
|
+
var consumeEarlyLayoutShiftBuffer = () => {
|
|
183
|
+
if (typeof window === "undefined")
|
|
184
|
+
return;
|
|
185
|
+
const installed = window.__absoluteBeaconEarlyLayoutShift;
|
|
186
|
+
if (installed === undefined)
|
|
187
|
+
return;
|
|
188
|
+
installed.recordEntries(installed.observer.takeRecords());
|
|
189
|
+
installed.observer.disconnect();
|
|
190
|
+
installed.cleanup();
|
|
191
|
+
delete window.__absoluteBeaconEarlyLayoutShift;
|
|
192
|
+
return {
|
|
193
|
+
entries: installed.entries,
|
|
194
|
+
interactionTimes: installed.interactionTimes,
|
|
195
|
+
observerStartedAt: installed.observerStartedAt,
|
|
196
|
+
resizeTimes: installed.resizeTimes
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
|
|
80
200
|
// src/index.ts
|
|
81
201
|
var BEACON_TRACE_HEADER = "x-absolute-trace-id";
|
|
82
|
-
var BEACON_SDK_VERSION = "0.7.0-beta.
|
|
202
|
+
var BEACON_SDK_VERSION = "0.7.0-beta.10";
|
|
83
203
|
var inBrowser = () => typeof window !== "undefined";
|
|
84
204
|
var newId = () => {
|
|
85
205
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
@@ -330,14 +450,14 @@ var FACEBOOK_ANDROID_PERFORMANCE_LOGGER = "iabjs://navigation_performance_logger
|
|
|
330
450
|
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;
|
|
331
451
|
var GOOGLE_WEB_RENDERER_SERVICE_WORKER_WRAPPER = "wrsParams.serviceWorkers.navigator.serviceWorker.register";
|
|
332
452
|
var EXTENSION_STACK_PROTOCOL = /(?:chrome|moz|safari-web)-extension:\/\//u;
|
|
453
|
+
var stackFrames = (stack) => (stack ?? "").split(`
|
|
454
|
+
`).map((line) => line.trim()).filter((line) => line.startsWith("at ") || /@(?:[a-z][a-z\d+.-]*:)?\/\//iu.test(line));
|
|
333
455
|
var isExtensionOnlyStack = (event) => {
|
|
334
|
-
const frames = (event.stack
|
|
335
|
-
`).slice(1).map((line) => line.trim()).filter(Boolean);
|
|
456
|
+
const frames = stackFrames(event.stack);
|
|
336
457
|
return frames.length > 0 && frames.every((frame) => EXTENSION_STACK_PROTOCOL.test(frame));
|
|
337
458
|
};
|
|
338
459
|
var isExtensionInjectedStack = (event) => {
|
|
339
|
-
const firstFrame = (event.stack
|
|
340
|
-
`).slice(1).map((line) => line.trim()).find(Boolean);
|
|
460
|
+
const [firstFrame] = stackFrames(event.stack);
|
|
341
461
|
return firstFrame !== undefined && EXTENSION_STACK_PROTOCOL.test(firstFrame);
|
|
342
462
|
};
|
|
343
463
|
var isStacklessBrowserAbort = (event) => event.name === "AbortError" && event.message === "The user aborted a request." && (event.stack ?? "").trim() === "";
|
|
@@ -485,7 +605,20 @@ var bfcacheLocation = (value) => {
|
|
|
485
605
|
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;
|
|
486
606
|
var LONG_IDENTIFIER_SEGMENT = /\b(?:[0-9a-f]{16,}|\d{8,})\b/giu;
|
|
487
607
|
var VOLATILE_SIGNAL_TAGS = new Set([
|
|
608
|
+
"area",
|
|
609
|
+
"gapPx",
|
|
610
|
+
"overlapPx",
|
|
611
|
+
"surfaceColor",
|
|
612
|
+
"surfaceLuminance",
|
|
613
|
+
"targetBottomPx",
|
|
614
|
+
"targetHeightPx",
|
|
615
|
+
"targetLeftPx",
|
|
616
|
+
"targetRightPx",
|
|
617
|
+
"targetTopPx",
|
|
618
|
+
"targetWidthPx",
|
|
488
619
|
"actionId",
|
|
620
|
+
"actionTrusted",
|
|
621
|
+
"automation",
|
|
489
622
|
"attemptCount",
|
|
490
623
|
"blockingDurationMs",
|
|
491
624
|
"blockingFrameDurationMs",
|
|
@@ -494,13 +627,25 @@ var VOLATILE_SIGNAL_TAGS = new Set([
|
|
|
494
627
|
"closeCount",
|
|
495
628
|
"currentRelease",
|
|
496
629
|
"durationMs",
|
|
630
|
+
"documentReadyState",
|
|
497
631
|
"elapsedMs",
|
|
498
632
|
"errorCount",
|
|
633
|
+
"focusEventTrusted",
|
|
499
634
|
"inputDelayMs",
|
|
500
635
|
"interactionId",
|
|
501
636
|
"interactionAgeMs",
|
|
637
|
+
"lastFocused",
|
|
502
638
|
"loadCount",
|
|
639
|
+
"layoutShiftBuffered",
|
|
640
|
+
"layoutShiftObservedAtMs",
|
|
641
|
+
"layoutShiftObserverStartedAtMs",
|
|
642
|
+
"layoutShiftSources",
|
|
643
|
+
"layoutShiftStartTimeMs",
|
|
503
644
|
"newestRelease",
|
|
645
|
+
"navigationAgeMs",
|
|
646
|
+
"navigationFrom",
|
|
647
|
+
"navigationTo",
|
|
648
|
+
"navigationType",
|
|
504
649
|
"obscuredPx",
|
|
505
650
|
"presentationDelayMs",
|
|
506
651
|
"processingDurationMs",
|
|
@@ -509,17 +654,32 @@ var VOLATILE_SIGNAL_TAGS = new Set([
|
|
|
509
654
|
"responseMs",
|
|
510
655
|
"shiftValue",
|
|
511
656
|
"signal",
|
|
657
|
+
"scriptAttribution",
|
|
512
658
|
"scriptCount",
|
|
513
659
|
"scriptDurationMs",
|
|
660
|
+
"scriptFunction",
|
|
514
661
|
"scriptForcedStyleAndLayoutMs",
|
|
662
|
+
"scriptInvoker",
|
|
663
|
+
"scriptInvokerType",
|
|
515
664
|
"scriptPauseDurationMs",
|
|
665
|
+
"scriptSource",
|
|
516
666
|
"scriptSourceCharPosition",
|
|
667
|
+
"scriptWindowAttribution",
|
|
517
668
|
"spillPx",
|
|
518
669
|
"stallCount",
|
|
519
670
|
"styleAndLayoutDurationMs",
|
|
520
671
|
"thresholdMs",
|
|
521
672
|
"userAgent",
|
|
522
673
|
"viewportHeight",
|
|
674
|
+
"viewportDocumentHeight",
|
|
675
|
+
"viewportDocumentWidth",
|
|
676
|
+
"viewportInnerHeight",
|
|
677
|
+
"viewportInnerWidth",
|
|
678
|
+
"viewportVisualHeight",
|
|
679
|
+
"viewportVisualOffsetLeft",
|
|
680
|
+
"viewportVisualOffsetTop",
|
|
681
|
+
"viewportVisualScale",
|
|
682
|
+
"viewportVisualWidth",
|
|
523
683
|
"viewportWidth",
|
|
524
684
|
"windowMs"
|
|
525
685
|
]);
|
|
@@ -542,6 +702,8 @@ var signalGroupingKey = (signalTags) => {
|
|
|
542
702
|
const hash = stableIdentityHash(identity, 2166136261) + stableIdentityHash(identity, 2654435769);
|
|
543
703
|
return `beacon-signal:${signalTags.signal}:${hash}`;
|
|
544
704
|
};
|
|
705
|
+
var AUTOMATED_BROWSER_USER_AGENT = /(?:\b(?:adsbot|bingbot|crawler|googlebot|headlesschrome|lighthouse|pagespeed|spider)\b|\b(?:bot|crawl|spider)\/)/iu;
|
|
706
|
+
var isAutomatedBrowser = () => typeof navigator !== "undefined" && (navigator.webdriver === true || AUTOMATED_BROWSER_USER_AGENT.test(navigator.userAgent));
|
|
545
707
|
var isInvisibleAnchor = (anchor) => {
|
|
546
708
|
if (anchor.target === "_blank" || anchor.hasAttribute("download"))
|
|
547
709
|
return true;
|
|
@@ -813,6 +975,7 @@ var createBeacon = (options) => {
|
|
|
813
975
|
const FORM_FRUSTRATION_THRESHOLD = 3;
|
|
814
976
|
const FORM_FRUSTRATION_WINDOW_MS = 60000;
|
|
815
977
|
const LAYOUT_SHIFT_RECENT_INTERACTION_MS = 500;
|
|
978
|
+
const LAYOUT_SHIFT_SPA_NAVIGATION_SETTLE_MS = 2000;
|
|
816
979
|
const LAYOUT_SHIFT_INTERACTION_PROVENANCE_MS = 1e4;
|
|
817
980
|
const LAYOUT_SHIFT_VIEWPORT_RESIZE_SETTLE_MS = 500;
|
|
818
981
|
const VIEWPORT_RESIZE_HISTORY_LIMIT = 8;
|
|
@@ -843,6 +1006,7 @@ var createBeacon = (options) => {
|
|
|
843
1006
|
let pageLifecycleGeneration = 0;
|
|
844
1007
|
let pageRestoredAt;
|
|
845
1008
|
let recentInteraction;
|
|
1009
|
+
let recentNavigation;
|
|
846
1010
|
let reportErrorClick = null;
|
|
847
1011
|
const reportCapturedErrorClick = (error, tags2) => {
|
|
848
1012
|
if (filterKnownNoise && isKnownBeaconNoise({
|
|
@@ -925,6 +1089,7 @@ var createBeacon = (options) => {
|
|
|
925
1089
|
rating: metric.rating === "good" || metric.rating === "needs-improvement" || metric.rating === "poor" ? metric.rating : "needs-improvement",
|
|
926
1090
|
...options.release === undefined ? {} : { release: options.release },
|
|
927
1091
|
...replayId === undefined ? {} : { replayId },
|
|
1092
|
+
sessionId,
|
|
928
1093
|
samplingRate: vitalsOptions.samplingRate ?? 1,
|
|
929
1094
|
schemaVersion: vitalsOptions.schemaVersion ?? 1,
|
|
930
1095
|
...vitalsOptions.sdkVersion === undefined ? {} : { sdkVersion: vitalsOptions.sdkVersion },
|
|
@@ -975,12 +1140,13 @@ var createBeacon = (options) => {
|
|
|
975
1140
|
let user;
|
|
976
1141
|
let actionSequence = 0;
|
|
977
1142
|
let activeAction;
|
|
978
|
-
const beginAction = (type, target) => {
|
|
1143
|
+
const beginAction = (type, target, trusted) => {
|
|
979
1144
|
actionSequence += 1;
|
|
980
1145
|
activeAction = {
|
|
981
1146
|
at: Date.now(),
|
|
982
1147
|
id: `${sessionId}:${actionSequence}`,
|
|
983
1148
|
target,
|
|
1149
|
+
trusted,
|
|
984
1150
|
type
|
|
985
1151
|
};
|
|
986
1152
|
};
|
|
@@ -1026,6 +1192,7 @@ var createBeacon = (options) => {
|
|
|
1026
1192
|
...action === undefined ? {} : {
|
|
1027
1193
|
actionId: action.id,
|
|
1028
1194
|
actionTarget: action.target,
|
|
1195
|
+
actionTrusted: String(action.trusted),
|
|
1029
1196
|
actionType: action.type
|
|
1030
1197
|
},
|
|
1031
1198
|
...event.tags
|
|
@@ -1099,6 +1266,8 @@ var createBeacon = (options) => {
|
|
|
1099
1266
|
push(event);
|
|
1100
1267
|
};
|
|
1101
1268
|
const emitSignal = (message, signalTags, traceId, extra, stackBoundary, fallbackFramesToDrop = 1, useDefaultFingerprint = false) => {
|
|
1269
|
+
if (signals?.suppressAutomatedBrowsers === true && isAutomatedBrowser())
|
|
1270
|
+
return;
|
|
1102
1271
|
if (staleClientRelease && signalTags.signal !== BEACON_SIGNAL.STALE_RELEASE && signalTags.signal !== BEACON_SIGNAL.RELOAD_LOOP)
|
|
1103
1272
|
return;
|
|
1104
1273
|
const error = new Error(message);
|
|
@@ -1243,9 +1412,9 @@ var createBeacon = (options) => {
|
|
|
1243
1412
|
if (signals === null || signals.authFailureStorms === false)
|
|
1244
1413
|
return false;
|
|
1245
1414
|
const label = `${method} ${endpoint2}`;
|
|
1246
|
-
const
|
|
1247
|
-
const failures = (authFailuresByEndpoint.get(label) ?? []).filter(({ at }) =>
|
|
1248
|
-
failures.push({ at:
|
|
1415
|
+
const now2 = Date.now();
|
|
1416
|
+
const failures = (authFailuresByEndpoint.get(label) ?? []).filter(({ at }) => now2 - at < authFailureStormWindowMs);
|
|
1417
|
+
failures.push({ at: now2, status });
|
|
1249
1418
|
authFailuresByEndpoint.set(label, failures);
|
|
1250
1419
|
if (failures.length < authFailureStormCount || reportedAuthFailureStorms.has(label)) {
|
|
1251
1420
|
return false;
|
|
@@ -1380,6 +1549,9 @@ var createBeacon = (options) => {
|
|
|
1380
1549
|
method: methods.length === 1 ? methods[0] : "multiple",
|
|
1381
1550
|
online: onlineStates.length === 1 ? onlineStates[0] : "mixed",
|
|
1382
1551
|
reportDelayMs: String(reportDelayMs),
|
|
1552
|
+
requestOrigins: [
|
|
1553
|
+
...new Set(failures.map((failure) => failure.sameOrigin === true ? "same-origin" : failure.origin ?? "unknown"))
|
|
1554
|
+
].sort().join(","),
|
|
1383
1555
|
signal: BEACON_SIGNAL.FETCH_FAILED,
|
|
1384
1556
|
transport: transports.length === 1 ? transports[0] : "multiple",
|
|
1385
1557
|
visibilityState: visibilityStates.length === 1 ? visibilityStates[0] : "mixed",
|
|
@@ -1388,6 +1560,19 @@ var createBeacon = (options) => {
|
|
|
1388
1560
|
}
|
|
1389
1561
|
};
|
|
1390
1562
|
flushPendingNetworkFailures = flushNetworkFailures;
|
|
1563
|
+
const requestOrigin = (url) => {
|
|
1564
|
+
try {
|
|
1565
|
+
const parsed = new URL(url, location.href);
|
|
1566
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
|
|
1567
|
+
return {};
|
|
1568
|
+
return {
|
|
1569
|
+
origin: parsed.origin,
|
|
1570
|
+
sameOrigin: parsed.origin === location.origin
|
|
1571
|
+
};
|
|
1572
|
+
} catch {
|
|
1573
|
+
return {};
|
|
1574
|
+
}
|
|
1575
|
+
};
|
|
1391
1576
|
const reportFailureSignal = (url, method, durationMs, transportKind, errorValue) => {
|
|
1392
1577
|
if (signals === null || signals.failedRequests === false)
|
|
1393
1578
|
return;
|
|
@@ -1400,6 +1585,7 @@ var createBeacon = (options) => {
|
|
|
1400
1585
|
const properties = errorProperties(error);
|
|
1401
1586
|
const state = networkState();
|
|
1402
1587
|
const failure = {
|
|
1588
|
+
...requestOrigin(url),
|
|
1403
1589
|
at: Date.now(),
|
|
1404
1590
|
durationMs,
|
|
1405
1591
|
endpoint: shortUrl(url),
|
|
@@ -1949,7 +2135,7 @@ var createBeacon = (options) => {
|
|
|
1949
2135
|
if (!(target instanceof Element))
|
|
1950
2136
|
return;
|
|
1951
2137
|
const targetName = describeElement(target);
|
|
1952
|
-
beginAction("click", targetName);
|
|
2138
|
+
beginAction("click", targetName, event.isTrusted);
|
|
1953
2139
|
addBreadcrumb({ message: targetName, type: "click" });
|
|
1954
2140
|
if (signals === null)
|
|
1955
2141
|
return;
|
|
@@ -2005,7 +2191,7 @@ var createBeacon = (options) => {
|
|
|
2005
2191
|
if (!(event.target instanceof HTMLFormElement))
|
|
2006
2192
|
return;
|
|
2007
2193
|
const target = describeElement(event.target);
|
|
2008
|
-
beginAction("submit", target);
|
|
2194
|
+
beginAction("submit", target, event.isTrusted);
|
|
2009
2195
|
recentInteraction = {
|
|
2010
2196
|
at: Date.now(),
|
|
2011
2197
|
performanceAt: performance.now(),
|
|
@@ -2020,7 +2206,7 @@ var createBeacon = (options) => {
|
|
|
2020
2206
|
if (!(target instanceof Element))
|
|
2021
2207
|
return;
|
|
2022
2208
|
const targetName = describeElement(target);
|
|
2023
|
-
beginAction("keyboard", targetName);
|
|
2209
|
+
beginAction("keyboard", targetName, event.isTrusted);
|
|
2024
2210
|
recentInteraction = {
|
|
2025
2211
|
at: Date.now(),
|
|
2026
2212
|
performanceAt: performance.now(),
|
|
@@ -2087,7 +2273,7 @@ var createBeacon = (options) => {
|
|
|
2087
2273
|
const seenScanIssues = new Set;
|
|
2088
2274
|
let scanIssueReports = 0;
|
|
2089
2275
|
const SCAN_ISSUE_MAX_REPORTS = 10;
|
|
2090
|
-
const reportScanIssue = (element, signal, detail, extraTags) => {
|
|
2276
|
+
const reportScanIssue = (element, signal, detail, extraTags, extra) => {
|
|
2091
2277
|
const bucket = viewportBucket();
|
|
2092
2278
|
const key = `${signal}:${describeElement(element)}@${bucket}`;
|
|
2093
2279
|
if (seenScanIssues.has(key))
|
|
@@ -2102,7 +2288,7 @@ var createBeacon = (options) => {
|
|
|
2102
2288
|
target: describeElement(element),
|
|
2103
2289
|
viewportBucket: bucket,
|
|
2104
2290
|
viewportWidth: String(document.documentElement.clientWidth)
|
|
2105
|
-
});
|
|
2291
|
+
}, undefined, extra);
|
|
2106
2292
|
};
|
|
2107
2293
|
const reportOverflow = (element, kind, detail, spillPx) => {
|
|
2108
2294
|
const bucket = viewportBucket();
|
|
@@ -2229,6 +2415,8 @@ var createBeacon = (options) => {
|
|
|
2229
2415
|
return visible;
|
|
2230
2416
|
};
|
|
2231
2417
|
const isExtensionOwnedCover = (element) => {
|
|
2418
|
+
if (element.closest("com-1password-notification") !== null)
|
|
2419
|
+
return true;
|
|
2232
2420
|
if (element.tagName !== "IFRAME")
|
|
2233
2421
|
return false;
|
|
2234
2422
|
const source = element.getAttribute("src")?.trim().toLowerCase() ?? "";
|
|
@@ -2243,6 +2431,38 @@ var createBeacon = (options) => {
|
|
|
2243
2431
|
const secondDialog = second.closest('[role="dialog"], dialog');
|
|
2244
2432
|
return firstDialog === null !== (secondDialog === null);
|
|
2245
2433
|
};
|
|
2434
|
+
const scanLayoutContext = (target, other) => {
|
|
2435
|
+
const geometry = (element) => {
|
|
2436
|
+
const rect = element.getBoundingClientRect();
|
|
2437
|
+
let positionedAncestor = element;
|
|
2438
|
+
while (positionedAncestor !== null && !["fixed", "sticky"].includes(window.getComputedStyle(positionedAncestor).position)) {
|
|
2439
|
+
positionedAncestor = positionedAncestor.parentElement;
|
|
2440
|
+
}
|
|
2441
|
+
return {
|
|
2442
|
+
rect: {
|
|
2443
|
+
top: rect.top,
|
|
2444
|
+
right: rect.right,
|
|
2445
|
+
bottom: rect.bottom,
|
|
2446
|
+
left: rect.left,
|
|
2447
|
+
width: rect.width,
|
|
2448
|
+
height: rect.height
|
|
2449
|
+
},
|
|
2450
|
+
position: window.getComputedStyle(element).position,
|
|
2451
|
+
...positionedAncestor ? {
|
|
2452
|
+
positionedAncestor: describeElement(positionedAncestor),
|
|
2453
|
+
ancestorPosition: window.getComputedStyle(positionedAncestor).position
|
|
2454
|
+
} : {}
|
|
2455
|
+
};
|
|
2456
|
+
};
|
|
2457
|
+
return {
|
|
2458
|
+
layout: {
|
|
2459
|
+
target: geometry(target),
|
|
2460
|
+
other: geometry(other),
|
|
2461
|
+
scrollX: window.scrollX,
|
|
2462
|
+
scrollY: window.scrollY
|
|
2463
|
+
}
|
|
2464
|
+
};
|
|
2465
|
+
};
|
|
2246
2466
|
const scanForControlCollisions = () => {
|
|
2247
2467
|
const viewportWidth = document.documentElement.clientWidth;
|
|
2248
2468
|
const viewportHeight = document.documentElement.clientHeight;
|
|
@@ -2289,7 +2509,7 @@ var createBeacon = (options) => {
|
|
|
2289
2509
|
collisionAxis: axis2,
|
|
2290
2510
|
collisionKind: "overlap",
|
|
2291
2511
|
overlapPx: String(Math.round(axis2 === "vertical" ? overlapY : overlapX))
|
|
2292
|
-
});
|
|
2512
|
+
}, scanLayoutContext(first.element, second.element));
|
|
2293
2513
|
continue;
|
|
2294
2514
|
}
|
|
2295
2515
|
if (first.element.parentElement === second.element.parentElement || sharedIntentionalControlGroup(first.element, second.element) || first.positioned || second.positioned) {
|
|
@@ -2313,7 +2533,7 @@ var createBeacon = (options) => {
|
|
|
2313
2533
|
collisionAxis: axis,
|
|
2314
2534
|
collisionKind: "touching",
|
|
2315
2535
|
gapPx: String(Math.round(axis === "vertical" ? verticalGap : horizontalGap))
|
|
2316
|
-
});
|
|
2536
|
+
}, scanLayoutContext(first.element, second.element));
|
|
2317
2537
|
}
|
|
2318
2538
|
}
|
|
2319
2539
|
};
|
|
@@ -2348,7 +2568,7 @@ var createBeacon = (options) => {
|
|
|
2348
2568
|
const coverage = Math.max(overlapX, 0) * Math.max(overlapY, 0) / ((visibleRect.right - visibleRect.left) * (visibleRect.bottom - visibleRect.top));
|
|
2349
2569
|
if (coverage < OCCLUSION_COVERAGE_MIN)
|
|
2350
2570
|
continue;
|
|
2351
|
-
reportScanIssue(control, BEACON_SIGNAL.OCCLUDED_CONTROL, `Occluded control — ${describeElement(control)} is covered by ${describeElement(top)}`, { coveredBy: describeElement(top) });
|
|
2571
|
+
reportScanIssue(control, BEACON_SIGNAL.OCCLUDED_CONTROL, `Occluded control — ${describeElement(control)} is covered by ${describeElement(top)}`, { coveredBy: describeElement(top) }, scanLayoutContext(control, top));
|
|
2352
2572
|
}
|
|
2353
2573
|
};
|
|
2354
2574
|
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
@@ -2633,9 +2853,9 @@ var createBeacon = (options) => {
|
|
|
2633
2853
|
const checkStuckLoading = () => {
|
|
2634
2854
|
if (document.visibilityState === "hidden")
|
|
2635
2855
|
return;
|
|
2636
|
-
const
|
|
2637
|
-
const missedPollWindow = lastLoadingCheckAt !== undefined &&
|
|
2638
|
-
lastLoadingCheckAt =
|
|
2856
|
+
const now2 = Date.now();
|
|
2857
|
+
const missedPollWindow = lastLoadingCheckAt !== undefined && now2 - lastLoadingCheckAt > STUCK_LOADING_POLL_MS * 3;
|
|
2858
|
+
lastLoadingCheckAt = now2;
|
|
2639
2859
|
const indicators = Array.from(document.querySelectorAll(loadingIndicatorSelector));
|
|
2640
2860
|
const activeIndicators = new Set(indicators);
|
|
2641
2861
|
for (const tracked of trackedLoadingIndicators) {
|
|
@@ -2653,22 +2873,22 @@ var createBeacon = (options) => {
|
|
|
2653
2873
|
continue;
|
|
2654
2874
|
}
|
|
2655
2875
|
if (missedPollWindow && loadingFirstSeen.has(indicator)) {
|
|
2656
|
-
loadingFirstSeen.set(indicator,
|
|
2876
|
+
loadingFirstSeen.set(indicator, now2);
|
|
2657
2877
|
}
|
|
2658
2878
|
const firstSeen = loadingFirstSeen.get(indicator);
|
|
2659
2879
|
if (firstSeen === undefined) {
|
|
2660
|
-
loadingFirstSeen.set(indicator,
|
|
2880
|
+
loadingFirstSeen.set(indicator, now2);
|
|
2661
2881
|
trackedLoadingIndicators.add(indicator);
|
|
2662
2882
|
continue;
|
|
2663
2883
|
}
|
|
2664
2884
|
const deadlineMs = loadingDeadlineMs(indicator);
|
|
2665
|
-
if (
|
|
2885
|
+
if (now2 - firstSeen < deadlineMs || reportedStuckLoading.has(indicator)) {
|
|
2666
2886
|
continue;
|
|
2667
2887
|
}
|
|
2668
2888
|
reportedStuckLoading.add(indicator);
|
|
2669
2889
|
reportScanIssue(indicator, BEACON_SIGNAL.STUCK_LOADING, `Stuck loading — ${describeElement(indicator)} never resolved`, {
|
|
2670
2890
|
deadlineMs: String(deadlineMs),
|
|
2671
|
-
visibleMs: String(
|
|
2891
|
+
visibleMs: String(now2 - firstSeen)
|
|
2672
2892
|
});
|
|
2673
2893
|
}
|
|
2674
2894
|
};
|
|
@@ -2771,7 +2991,9 @@ var createBeacon = (options) => {
|
|
|
2771
2991
|
if (signals !== null && signals.disruptiveLayoutShifts !== false && typeof PerformanceObserver !== "undefined") {
|
|
2772
2992
|
const minimum = signals.disruptiveLayoutShiftMin ?? DISRUPTIVE_LAYOUT_SHIFT_DEFAULT_MIN;
|
|
2773
2993
|
const reported = new Set;
|
|
2774
|
-
|
|
2994
|
+
const earlyBuffer = consumeEarlyLayoutShiftBuffer();
|
|
2995
|
+
let viewportResizeTimes = [...earlyBuffer?.resizeTimes ?? []];
|
|
2996
|
+
const earlyInteractionTimes = earlyBuffer?.interactionTimes ?? [];
|
|
2775
2997
|
const recordViewportResize = () => {
|
|
2776
2998
|
viewportResizeTimes.push(performance.now());
|
|
2777
2999
|
if (viewportResizeTimes.length > VIEWPORT_RESIZE_HISTORY_LIMIT) {
|
|
@@ -2781,50 +3003,131 @@ var createBeacon = (options) => {
|
|
|
2781
3003
|
window.addEventListener("resize", recordViewportResize);
|
|
2782
3004
|
window.visualViewport?.addEventListener("resize", recordViewportResize);
|
|
2783
3005
|
try {
|
|
3006
|
+
const currentViewport = () => {
|
|
3007
|
+
const visual = window.visualViewport;
|
|
3008
|
+
return {
|
|
3009
|
+
documentHeight: document.documentElement.scrollHeight,
|
|
3010
|
+
documentWidth: document.documentElement.scrollWidth,
|
|
3011
|
+
innerHeight: window.innerHeight,
|
|
3012
|
+
innerWidth: window.innerWidth,
|
|
3013
|
+
...visual == null ? {} : {
|
|
3014
|
+
visualHeight: visual.height,
|
|
3015
|
+
visualOffsetLeft: visual.offsetLeft,
|
|
3016
|
+
visualOffsetTop: visual.offsetTop,
|
|
3017
|
+
visualScale: visual.scale,
|
|
3018
|
+
visualWidth: visual.width
|
|
3019
|
+
}
|
|
3020
|
+
};
|
|
3021
|
+
};
|
|
3022
|
+
const processLayoutShift = (entry) => {
|
|
3023
|
+
const firstContentfulPaint = performance.getEntriesByName("first-contentful-paint")[0]?.startTime;
|
|
3024
|
+
if (firstContentfulPaint !== undefined && entry.startTime < firstContentfulPaint)
|
|
3025
|
+
return;
|
|
3026
|
+
const interactionTimes = [
|
|
3027
|
+
...earlyInteractionTimes,
|
|
3028
|
+
...recentInteraction === undefined ? [] : [recentInteraction.performanceAt]
|
|
3029
|
+
];
|
|
3030
|
+
const interactionAgeMs = interactionTimes.map((interactionAt) => entry.startTime - interactionAt).filter((age) => age >= 0).sort((left, right) => left - right)[0];
|
|
3031
|
+
const beaconSawRecentInput = interactionAgeMs !== undefined && interactionAgeMs <= LAYOUT_SHIFT_RECENT_INTERACTION_MS;
|
|
3032
|
+
const navigationAgeMs = recentNavigation === undefined ? undefined : entry.startTime - recentNavigation.performanceAt;
|
|
3033
|
+
const navigationSettling = navigationAgeMs !== undefined && navigationAgeMs >= 0 && navigationAgeMs <= LAYOUT_SHIFT_SPA_NAVIGATION_SETTLE_MS;
|
|
3034
|
+
const resizeAdjacent = viewportResizeTimes.some((resizedAt) => {
|
|
3035
|
+
const resizeAgeMs = entry.startTime - resizedAt;
|
|
3036
|
+
return resizeAgeMs >= 0 && resizeAgeMs <= LAYOUT_SHIFT_VIEWPORT_RESIZE_SETTLE_MS;
|
|
3037
|
+
});
|
|
3038
|
+
if (entry.hadRecentInput || beaconSawRecentInput || navigationSettling || resizeAdjacent || mobileKeyboardViewportActive() || entry.value < minimum)
|
|
3039
|
+
return;
|
|
3040
|
+
const sourceElements = entry.sources.map(({ node }) => node instanceof Element ? node : undefined).filter((node) => node !== undefined);
|
|
3041
|
+
if (sourceElements.length > 0 && sourceElements.every((node) => node.closest(`[${BEACON_ATTRIBUTE.LAYOUT_SHIFT}="allow"]`) !== null))
|
|
3042
|
+
return;
|
|
3043
|
+
const targets = entry.sources.map((source) => source.node instanceof Element ? describeElement(source.node) : source.target).filter((target) => target !== "unknown").slice(0, 5);
|
|
3044
|
+
const key = targets.join(",") || "unknown";
|
|
3045
|
+
const framePhase = entry.startTime < MAIN_THREAD_STALL_DEFAULT_WINDOW_MS ? "startup" : "runtime";
|
|
3046
|
+
const interactionProvenance = key === "unknown" && recentInteraction !== undefined && interactionAgeMs !== undefined && interactionAgeMs <= LAYOUT_SHIFT_INTERACTION_PROVENANCE_MS ? recentInteraction : undefined;
|
|
3047
|
+
const reportKey = key === "unknown" ? [
|
|
3048
|
+
key,
|
|
3049
|
+
framePhase,
|
|
3050
|
+
interactionProvenance?.type ?? "no-interaction",
|
|
3051
|
+
interactionProvenance?.target ?? "unknown"
|
|
3052
|
+
].join("|") : key;
|
|
3053
|
+
if (reported.has(reportKey))
|
|
3054
|
+
return;
|
|
3055
|
+
reported.add(reportKey);
|
|
3056
|
+
emitSignal(`Disruptive layout shift — ${key} — ${shortUrl(location.href)}`, {
|
|
3057
|
+
documentReadyState: entry.documentReadyState,
|
|
3058
|
+
...key === "unknown" ? {
|
|
3059
|
+
framePhase,
|
|
3060
|
+
...interactionProvenance === undefined ? {} : {
|
|
3061
|
+
interactionAgeMs: String(Math.round(interactionAgeMs ?? 0)),
|
|
3062
|
+
interactionTarget: interactionProvenance.target,
|
|
3063
|
+
interactionType: interactionProvenance.type
|
|
3064
|
+
}
|
|
3065
|
+
} : {},
|
|
3066
|
+
...recentNavigation === undefined || navigationAgeMs === undefined || navigationAgeMs < 0 || navigationAgeMs > LAYOUT_SHIFT_INTERACTION_PROVENANCE_MS ? {} : {
|
|
3067
|
+
navigationAgeMs: String(Math.round(navigationAgeMs)),
|
|
3068
|
+
navigationFrom: recentNavigation.from,
|
|
3069
|
+
navigationTo: recentNavigation.to,
|
|
3070
|
+
navigationType: recentNavigation.type
|
|
3071
|
+
},
|
|
3072
|
+
layoutShiftBuffered: String(entry.buffered),
|
|
3073
|
+
layoutShiftObservedAtMs: String(Math.round(entry.observedAt)),
|
|
3074
|
+
layoutShiftObserverStartedAtMs: String(Math.round(entry.observerStartedAt)),
|
|
3075
|
+
layoutShiftSources: JSON.stringify(entry.sources.map(({ currentRect, previousRect, target }) => ({
|
|
3076
|
+
currentRect,
|
|
3077
|
+
previousRect,
|
|
3078
|
+
target
|
|
3079
|
+
}))),
|
|
3080
|
+
layoutShiftStartTimeMs: String(Math.round(entry.startTime)),
|
|
3081
|
+
shiftValue: String(entry.value),
|
|
3082
|
+
signal: BEACON_SIGNAL.DISRUPTIVE_LAYOUT_SHIFT,
|
|
3083
|
+
target: key,
|
|
3084
|
+
viewportDocumentHeight: String(entry.viewport.documentHeight),
|
|
3085
|
+
viewportDocumentWidth: String(entry.viewport.documentWidth),
|
|
3086
|
+
viewportInnerHeight: String(entry.viewport.innerHeight),
|
|
3087
|
+
viewportInnerWidth: String(entry.viewport.innerWidth),
|
|
3088
|
+
...entry.viewport.visualHeight === undefined ? {} : {
|
|
3089
|
+
viewportVisualHeight: String(entry.viewport.visualHeight),
|
|
3090
|
+
viewportVisualOffsetLeft: String(entry.viewport.visualOffsetLeft),
|
|
3091
|
+
viewportVisualOffsetTop: String(entry.viewport.visualOffsetTop),
|
|
3092
|
+
viewportVisualScale: String(entry.viewport.visualScale),
|
|
3093
|
+
viewportVisualWidth: String(entry.viewport.visualWidth)
|
|
3094
|
+
}
|
|
3095
|
+
});
|
|
3096
|
+
};
|
|
3097
|
+
for (const entry of earlyBuffer?.entries ?? []) {
|
|
3098
|
+
processLayoutShift({
|
|
3099
|
+
...entry,
|
|
3100
|
+
buffered: true,
|
|
3101
|
+
observerStartedAt: earlyBuffer?.observerStartedAt ?? 0
|
|
3102
|
+
});
|
|
3103
|
+
}
|
|
3104
|
+
const observerStartedAt = performance.now();
|
|
2784
3105
|
const observer = new PerformanceObserver((list) => {
|
|
2785
3106
|
for (const raw of list.getEntries()) {
|
|
2786
3107
|
const entry = raw;
|
|
2787
|
-
const
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
const reportKey = key === "unknown" ? [
|
|
2804
|
-
key,
|
|
2805
|
-
framePhase,
|
|
2806
|
-
interactionProvenance?.type ?? "no-interaction",
|
|
2807
|
-
interactionProvenance?.target ?? "unknown"
|
|
2808
|
-
].join("|") : key;
|
|
2809
|
-
if (reported.has(reportKey))
|
|
2810
|
-
continue;
|
|
2811
|
-
reported.add(reportKey);
|
|
2812
|
-
emitSignal(`Disruptive layout shift — ${key} — ${shortUrl(location.href)}`, {
|
|
2813
|
-
...key === "unknown" ? {
|
|
2814
|
-
framePhase,
|
|
2815
|
-
...interactionProvenance === undefined ? {} : {
|
|
2816
|
-
interactionAgeMs: String(Math.round(interactionAgeMs ?? 0)),
|
|
2817
|
-
interactionTarget: interactionProvenance.target,
|
|
2818
|
-
interactionType: interactionProvenance.type
|
|
2819
|
-
}
|
|
2820
|
-
} : {},
|
|
2821
|
-
shiftValue: String(entry.value ?? 0),
|
|
2822
|
-
signal: BEACON_SIGNAL.DISRUPTIVE_LAYOUT_SHIFT,
|
|
2823
|
-
target: key
|
|
3108
|
+
const viewport = currentViewport();
|
|
3109
|
+
processLayoutShift({
|
|
3110
|
+
buffered: entry.startTime < observerStartedAt,
|
|
3111
|
+
documentReadyState: document.readyState,
|
|
3112
|
+
hadRecentInput: entry.hadRecentInput === true,
|
|
3113
|
+
observedAt: performance.now(),
|
|
3114
|
+
observerStartedAt,
|
|
3115
|
+
sources: (entry.sources ?? []).map((source) => ({
|
|
3116
|
+
currentRect: source.currentRect,
|
|
3117
|
+
...source.node === undefined || source.node === null ? {} : { node: source.node },
|
|
3118
|
+
previousRect: source.previousRect,
|
|
3119
|
+
target: source.node instanceof Element ? describeElement(source.node) : "unknown"
|
|
3120
|
+
})),
|
|
3121
|
+
startTime: entry.startTime,
|
|
3122
|
+
value: entry.value ?? 0,
|
|
3123
|
+
viewport
|
|
2824
3124
|
});
|
|
2825
3125
|
}
|
|
2826
3126
|
});
|
|
2827
|
-
observer.observe({
|
|
3127
|
+
observer.observe({
|
|
3128
|
+
buffered: earlyBuffer === undefined,
|
|
3129
|
+
type: "layout-shift"
|
|
3130
|
+
});
|
|
2828
3131
|
cleanups.push(() => {
|
|
2829
3132
|
observer.disconnect();
|
|
2830
3133
|
window.removeEventListener("resize", recordViewportResize);
|
|
@@ -3346,16 +3649,16 @@ var createBeacon = (options) => {
|
|
|
3346
3649
|
jailBurst = [];
|
|
3347
3650
|
return;
|
|
3348
3651
|
}
|
|
3349
|
-
const
|
|
3652
|
+
const now2 = Date.now();
|
|
3350
3653
|
if (jailScroller !== scroller) {
|
|
3351
3654
|
jailScroller = scroller;
|
|
3352
3655
|
jailBurst = [];
|
|
3353
3656
|
}
|
|
3354
|
-
jailBurst = jailBurst.filter((entry) =>
|
|
3657
|
+
jailBurst = jailBurst.filter((entry) => now2 - entry.at < SCROLL_JAIL_WINDOW_MS && !entry.event.defaultPrevented);
|
|
3355
3658
|
if (jailBurst.length === 0) {
|
|
3356
3659
|
jailStartingScrollGeneration = scrollActivityGeneration;
|
|
3357
3660
|
}
|
|
3358
|
-
jailBurst.push({ at:
|
|
3661
|
+
jailBurst.push({ at: now2, position: scroller.scrollTop, event });
|
|
3359
3662
|
if (jailBurst.length < SCROLL_JAIL_EVENT_COUNT)
|
|
3360
3663
|
return;
|
|
3361
3664
|
const first = jailBurst[0];
|
|
@@ -3367,7 +3670,10 @@ var createBeacon = (options) => {
|
|
|
3367
3670
|
const startingPosition = first.position;
|
|
3368
3671
|
jailSettleTimer = setTimeout(() => {
|
|
3369
3672
|
jailSettleTimer = undefined;
|
|
3673
|
+
const confirmedBurst = jailBurst.filter((entry) => !entry.event.defaultPrevented);
|
|
3370
3674
|
jailBurst = [];
|
|
3675
|
+
if (confirmedBurst.length < SCROLL_JAIL_EVENT_COUNT)
|
|
3676
|
+
return;
|
|
3371
3677
|
if (scrollActivityGeneration !== jailStartingScrollGeneration)
|
|
3372
3678
|
return;
|
|
3373
3679
|
if (!scroller.isConnected || scroller.scrollTop !== startingPosition)
|
|
@@ -3381,7 +3687,29 @@ var createBeacon = (options) => {
|
|
|
3381
3687
|
if (reportedScrollers.has(descriptor))
|
|
3382
3688
|
return;
|
|
3383
3689
|
reportedScrollers.add(descriptor);
|
|
3384
|
-
emitSignal(`Scroll jail — ${descriptor} has scrollable content but never moves — ${shortUrl(location.href)}`, { signal: BEACON_SIGNAL.SCROLL_JAIL, target: descriptor }
|
|
3690
|
+
emitSignal(`Scroll jail — ${descriptor} has scrollable content but never moves — ${shortUrl(location.href)}`, { signal: BEACON_SIGNAL.SCROLL_JAIL, target: descriptor }, undefined, {
|
|
3691
|
+
scroll: {
|
|
3692
|
+
target: target ? describeElement(target) : undefined,
|
|
3693
|
+
scroller: descriptor,
|
|
3694
|
+
direction: scrollingDown ? "down" : "up",
|
|
3695
|
+
wheelCount: confirmedBurst.length,
|
|
3696
|
+
burstDurationMs: now2 - (confirmedBurst[0]?.at ?? now2),
|
|
3697
|
+
scrollTop: scroller.scrollTop,
|
|
3698
|
+
scrollHeight: scroller.scrollHeight,
|
|
3699
|
+
clientHeight: scroller.clientHeight,
|
|
3700
|
+
overflowY: window.getComputedStyle(scroller).overflowY,
|
|
3701
|
+
overscrollBehaviorY: window.getComputedStyle(scroller).overscrollBehaviorY,
|
|
3702
|
+
bodyOverflowY: window.getComputedStyle(document.body).overflowY,
|
|
3703
|
+
rootOverflowY: window.getComputedStyle(document.documentElement).overflowY,
|
|
3704
|
+
modal: modal ? describeElement(modal) : undefined,
|
|
3705
|
+
rect: {
|
|
3706
|
+
top: scroller.getBoundingClientRect().top,
|
|
3707
|
+
left: scroller.getBoundingClientRect().left,
|
|
3708
|
+
width: scroller.getBoundingClientRect().width,
|
|
3709
|
+
height: scroller.getBoundingClientRect().height
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3712
|
+
});
|
|
3385
3713
|
}, SCROLL_JAIL_SETTLE_MS);
|
|
3386
3714
|
};
|
|
3387
3715
|
document.addEventListener("scroll", onDocumentScroll, {
|
|
@@ -3414,9 +3742,9 @@ var createBeacon = (options) => {
|
|
|
3414
3742
|
previous = { x: event.clientX, y: event.clientY };
|
|
3415
3743
|
if (Math.hypot(dx, dy) < 8)
|
|
3416
3744
|
return;
|
|
3417
|
-
const
|
|
3418
|
-
points = points.filter((point) =>
|
|
3419
|
-
points.push({ at:
|
|
3745
|
+
const now2 = Date.now();
|
|
3746
|
+
points = points.filter((point) => now2 - point.at < THRASHED_CURSOR_WINDOW_MS);
|
|
3747
|
+
points.push({ at: now2, dx, dy });
|
|
3420
3748
|
let reversals = 0;
|
|
3421
3749
|
for (let index = 1;index < points.length; index += 1) {
|
|
3422
3750
|
const prior = points[index - 1];
|
|
@@ -3527,19 +3855,29 @@ var createBeacon = (options) => {
|
|
|
3527
3855
|
};
|
|
3528
3856
|
const onFocusOut = (event) => {
|
|
3529
3857
|
const target = event.target;
|
|
3530
|
-
|
|
3531
|
-
|
|
3858
|
+
if (!(target instanceof Element))
|
|
3859
|
+
return;
|
|
3860
|
+
const dialog = target.closest(DIALOG_SELECTOR);
|
|
3861
|
+
if (dialog === null)
|
|
3532
3862
|
return;
|
|
3863
|
+
const dialogDescriptor = describeElement(dialog);
|
|
3864
|
+
const focusEventTrusted = event.isTrusted === true;
|
|
3533
3865
|
setTimeout(() => {
|
|
3534
3866
|
const active = document.activeElement;
|
|
3535
3867
|
const focusDropped = active === null || active === document.body;
|
|
3536
|
-
if (!focusDropped ||
|
|
3868
|
+
if (!focusDropped || target.isConnected)
|
|
3537
3869
|
return;
|
|
3538
|
-
const descriptor = describeElement(
|
|
3870
|
+
const descriptor = describeElement(target);
|
|
3539
3871
|
if (reportedFocusLoss.has(descriptor))
|
|
3540
3872
|
return;
|
|
3541
3873
|
reportedFocusLoss.add(descriptor);
|
|
3542
|
-
emitSignal(`Focus lost — a dialog closed and dropped keyboard focus on body — ${shortUrl(location.href)}`, {
|
|
3874
|
+
emitSignal(`Focus lost — a dialog closed and dropped keyboard focus on body — ${shortUrl(location.href)}`, {
|
|
3875
|
+
dialog: dialogDescriptor,
|
|
3876
|
+
focusEventTrusted: String(focusEventTrusted),
|
|
3877
|
+
lastFocused: descriptor,
|
|
3878
|
+
signal: BEACON_SIGNAL.FOCUS_LOST,
|
|
3879
|
+
...navigator.webdriver === true ? { automation: "webdriver" } : {}
|
|
3880
|
+
});
|
|
3543
3881
|
}, 0);
|
|
3544
3882
|
};
|
|
3545
3883
|
document.addEventListener("focusin", onFocusIn, true);
|
|
@@ -3634,14 +3972,14 @@ var createBeacon = (options) => {
|
|
|
3634
3972
|
if (data === null)
|
|
3635
3973
|
return;
|
|
3636
3974
|
const activity = activityFor(form);
|
|
3637
|
-
const
|
|
3975
|
+
const now2 = Date.now();
|
|
3638
3976
|
if (data !== activity.lastData) {
|
|
3639
3977
|
activity.lastData = data;
|
|
3640
|
-
activity.identicalSubmits = [
|
|
3978
|
+
activity.identicalSubmits = [now2];
|
|
3641
3979
|
return;
|
|
3642
3980
|
}
|
|
3643
|
-
activity.identicalSubmits = activity.identicalSubmits.filter((at) =>
|
|
3644
|
-
activity.identicalSubmits.push(
|
|
3981
|
+
activity.identicalSubmits = activity.identicalSubmits.filter((at) => now2 - at < FORM_FRUSTRATION_WINDOW_MS);
|
|
3982
|
+
activity.identicalSubmits.push(now2);
|
|
3645
3983
|
if (activity.identicalSubmits.length >= FORM_FRUSTRATION_THRESHOLD) {
|
|
3646
3984
|
reportForm(form, "was submitted with identical values repeatedly");
|
|
3647
3985
|
}
|
|
@@ -3652,14 +3990,14 @@ var createBeacon = (options) => {
|
|
|
3652
3990
|
if (form === null)
|
|
3653
3991
|
return;
|
|
3654
3992
|
const activity = activityFor(form);
|
|
3655
|
-
const
|
|
3656
|
-
if (
|
|
3657
|
-
activity.lastInvalidAt =
|
|
3993
|
+
const now2 = Date.now();
|
|
3994
|
+
if (now2 - activity.lastInvalidAt < FORM_INVALID_BURST_GAP_MS) {
|
|
3995
|
+
activity.lastInvalidAt = now2;
|
|
3658
3996
|
return;
|
|
3659
3997
|
}
|
|
3660
|
-
activity.lastInvalidAt =
|
|
3661
|
-
activity.invalidBursts = activity.invalidBursts.filter((at) =>
|
|
3662
|
-
activity.invalidBursts.push(
|
|
3998
|
+
activity.lastInvalidAt = now2;
|
|
3999
|
+
activity.invalidBursts = activity.invalidBursts.filter((at) => now2 - at < FORM_FRUSTRATION_WINDOW_MS);
|
|
4000
|
+
activity.invalidBursts.push(now2);
|
|
3663
4001
|
if (activity.invalidBursts.length >= FORM_FRUSTRATION_THRESHOLD) {
|
|
3664
4002
|
reportForm(form, "keeps failing native validation");
|
|
3665
4003
|
}
|
|
@@ -3758,9 +4096,9 @@ var createBeacon = (options) => {
|
|
|
3758
4096
|
if (signals.sseFlapping === false || pageLifecycleEnding || document.visibilityState === "hidden") {
|
|
3759
4097
|
return;
|
|
3760
4098
|
}
|
|
3761
|
-
const
|
|
3762
|
-
const errors = (errorsByEndpoint.get(endpointLabel) ?? []).filter((at) =>
|
|
3763
|
-
errors.push(
|
|
4099
|
+
const now2 = Date.now();
|
|
4100
|
+
const errors = (errorsByEndpoint.get(endpointLabel) ?? []).filter((at) => now2 - at < sseFlapWindowMs);
|
|
4101
|
+
errors.push(now2);
|
|
3764
4102
|
errorsByEndpoint.set(endpointLabel, errors);
|
|
3765
4103
|
if (errors.length < sseFlapCount || reportedFlappingStreams.has(endpointLabel)) {
|
|
3766
4104
|
return;
|
|
@@ -3836,6 +4174,9 @@ var createBeacon = (options) => {
|
|
|
3836
4174
|
const restoredLifecycleClose = pageRestoredAt !== undefined && socketLifecycleGeneration < pageLifecycleGeneration && Date.now() - pageRestoredAt <= RESTORED_SOCKET_CLOSE_GRACE_MS;
|
|
3837
4175
|
if (pageLifecycleEnding || applicationClose || restoredLifecycleClose)
|
|
3838
4176
|
return;
|
|
4177
|
+
const expectedServerClose = typeof CloseEvent !== "undefined" && event instanceof CloseEvent && (event.wasClean || event.code === 1000 || event.code === 1001 || event.code === 1012);
|
|
4178
|
+
if (expectedServerClose)
|
|
4179
|
+
return;
|
|
3839
4180
|
if (signals.socketAbnormalCloses !== false && typeof CloseEvent !== "undefined" && event instanceof CloseEvent && !event.wasClean && !recoverableSocket(socketUrl)) {
|
|
3840
4181
|
const abnormalKey = `${label}|${event.code}`;
|
|
3841
4182
|
if (!reportedAbnormalCloses.has(abnormalKey)) {
|
|
@@ -3850,10 +4191,10 @@ var createBeacon = (options) => {
|
|
|
3850
4191
|
}
|
|
3851
4192
|
if (signals.socketFlapping === false)
|
|
3852
4193
|
return;
|
|
3853
|
-
const
|
|
3854
|
-
const closes = (closesByUrl.get(label) ?? []).filter((close) =>
|
|
4194
|
+
const now2 = Date.now();
|
|
4195
|
+
const closes = (closesByUrl.get(label) ?? []).filter((close) => now2 - close.at < SOCKET_FLAP_WINDOW_MS);
|
|
3855
4196
|
closes.push({
|
|
3856
|
-
at:
|
|
4197
|
+
at: now2,
|
|
3857
4198
|
code: typeof CloseEvent !== "undefined" && event instanceof CloseEvent ? event.code : null,
|
|
3858
4199
|
wasClean: typeof CloseEvent !== "undefined" && event instanceof CloseEvent ? event.wasClean : null
|
|
3859
4200
|
});
|
|
@@ -3869,7 +4210,7 @@ var createBeacon = (options) => {
|
|
|
3869
4210
|
windowMs: String(SOCKET_FLAP_WINDOW_MS)
|
|
3870
4211
|
}, undefined, {
|
|
3871
4212
|
closeSamples: closes.map((close) => ({
|
|
3872
|
-
ageMs:
|
|
4213
|
+
ageMs: now2 - close.at,
|
|
3873
4214
|
code: close.code,
|
|
3874
4215
|
wasClean: close.wasClean
|
|
3875
4216
|
}))
|
|
@@ -4100,23 +4441,23 @@ var createBeacon = (options) => {
|
|
|
4100
4441
|
try {
|
|
4101
4442
|
const navigation = performance.getEntriesByType("navigation")[0];
|
|
4102
4443
|
if (navigation?.type !== "back_forward") {
|
|
4103
|
-
const
|
|
4444
|
+
const now2 = Date.now();
|
|
4104
4445
|
const route = shortUrl(location.href);
|
|
4105
4446
|
const raw = sessionStorage.getItem(RELOAD_LOOP_STORAGE_KEY);
|
|
4106
4447
|
const parsed = raw === null ? [] : JSON.parse(raw);
|
|
4107
|
-
let history2 = (Array.isArray(parsed) ? parsed : []).filter((entry) => entry !== null && typeof entry === "object" && typeof entry.at === "number" && typeof entry.route === "string" &&
|
|
4448
|
+
let history2 = (Array.isArray(parsed) ? parsed : []).filter((entry) => entry !== null && typeof entry === "object" && typeof entry.at === "number" && typeof entry.route === "string" && now2 - entry.at < RELOAD_LOOP_WINDOW_MS);
|
|
4108
4449
|
let entryKind = "app";
|
|
4109
4450
|
const rawNavigationIntent = sessionStorage.getItem(NAVIGATION_INTENT_STORAGE_KEY);
|
|
4110
4451
|
sessionStorage.removeItem(NAVIGATION_INTENT_STORAGE_KEY);
|
|
4111
4452
|
const navigationIntentAt = Number(rawNavigationIntent);
|
|
4112
|
-
if (rawNavigationIntent !== null && Number.isFinite(navigationIntentAt) &&
|
|
4453
|
+
if (rawNavigationIntent !== null && Number.isFinite(navigationIntentAt) && now2 - navigationIntentAt >= 0 && now2 - navigationIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
|
|
4113
4454
|
history2 = [];
|
|
4114
4455
|
entryKind = "intentional-navigation";
|
|
4115
4456
|
}
|
|
4116
4457
|
const rawServiceWorkerUpdateIntent = sessionStorage.getItem(SERVICE_WORKER_UPDATE_INTENT_STORAGE_KEY);
|
|
4117
4458
|
sessionStorage.removeItem(SERVICE_WORKER_UPDATE_INTENT_STORAGE_KEY);
|
|
4118
4459
|
const serviceWorkerUpdateIntentAt = Number(rawServiceWorkerUpdateIntent);
|
|
4119
|
-
if (rawServiceWorkerUpdateIntent !== null && Number.isFinite(serviceWorkerUpdateIntentAt) &&
|
|
4460
|
+
if (rawServiceWorkerUpdateIntent !== null && Number.isFinite(serviceWorkerUpdateIntentAt) && now2 - serviceWorkerUpdateIntentAt >= 0 && now2 - serviceWorkerUpdateIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
|
|
4120
4461
|
history2 = [];
|
|
4121
4462
|
entryKind = "service-worker-update";
|
|
4122
4463
|
}
|
|
@@ -4127,7 +4468,7 @@ var createBeacon = (options) => {
|
|
|
4127
4468
|
entryKind = "external";
|
|
4128
4469
|
}
|
|
4129
4470
|
}
|
|
4130
|
-
history2.push({ at:
|
|
4471
|
+
history2.push({ at: now2, route });
|
|
4131
4472
|
sessionStorage.setItem(RELOAD_LOOP_STORAGE_KEY, JSON.stringify(history2));
|
|
4132
4473
|
let loadCount = 0;
|
|
4133
4474
|
for (let index = history2.length - 1;index >= 0; index -= 1) {
|
|
@@ -4136,7 +4477,7 @@ var createBeacon = (options) => {
|
|
|
4136
4477
|
loadCount += 1;
|
|
4137
4478
|
}
|
|
4138
4479
|
if (loadCount === RELOAD_LOOP_COUNT) {
|
|
4139
|
-
const firstLoad = history2.at(-loadCount)?.at ??
|
|
4480
|
+
const firstLoad = history2.at(-loadCount)?.at ?? now2;
|
|
4140
4481
|
emitSignal(`Reload loop — repeated page loads within a minute — ${shortUrl(location.href)}`, {
|
|
4141
4482
|
currentRelease: options.release ?? "unknown",
|
|
4142
4483
|
entryKind,
|
|
@@ -4145,7 +4486,7 @@ var createBeacon = (options) => {
|
|
|
4145
4486
|
serviceWorkerControlled: String(navigator.serviceWorker?.controller !== null && navigator.serviceWorker?.controller !== undefined),
|
|
4146
4487
|
serviceWorkerScript: navigator.serviceWorker?.controller?.scriptURL ?? "none",
|
|
4147
4488
|
signal: BEACON_SIGNAL.RELOAD_LOOP,
|
|
4148
|
-
windowMs: String(
|
|
4489
|
+
windowMs: String(now2 - firstLoad)
|
|
4149
4490
|
});
|
|
4150
4491
|
flush(true);
|
|
4151
4492
|
}
|
|
@@ -4155,7 +4496,7 @@ var createBeacon = (options) => {
|
|
|
4155
4496
|
if (signals !== null && signals.staleReleases !== false && typeof localStorage !== "undefined" && typeof options.release === "string" && options.release !== "") {
|
|
4156
4497
|
try {
|
|
4157
4498
|
const currentRelease = options.release;
|
|
4158
|
-
const
|
|
4499
|
+
const now2 = Date.now();
|
|
4159
4500
|
const raw = localStorage.getItem(STALE_RELEASE_STORAGE_KEY);
|
|
4160
4501
|
const parsed = raw === null ? {} : JSON.parse(raw);
|
|
4161
4502
|
const firstSeenByRelease = {};
|
|
@@ -4165,10 +4506,10 @@ var createBeacon = (options) => {
|
|
|
4165
4506
|
firstSeenByRelease[release] = at;
|
|
4166
4507
|
}
|
|
4167
4508
|
}
|
|
4168
|
-
const currentFirstSeen = firstSeenByRelease[currentRelease] ??
|
|
4509
|
+
const currentFirstSeen = firstSeenByRelease[currentRelease] ?? now2;
|
|
4169
4510
|
firstSeenByRelease[currentRelease] = currentFirstSeen;
|
|
4170
4511
|
const newest = Object.entries(firstSeenByRelease).filter(([release, at]) => release !== currentRelease && at > currentFirstSeen).sort((left, right) => right[1] - left[1])[0];
|
|
4171
|
-
if (newest !== undefined &&
|
|
4512
|
+
if (newest !== undefined && now2 - newest[1] > STALE_RELEASE_GRACE_MS) {
|
|
4172
4513
|
emitSignal(`Stale release — this page is running a build older than one this browser already saw — ${shortUrl(location.href)}`, {
|
|
4173
4514
|
currentRelease,
|
|
4174
4515
|
newestRelease: newest[0],
|
|
@@ -4288,9 +4629,9 @@ var createBeacon = (options) => {
|
|
|
4288
4629
|
const reportedStorms = new Set;
|
|
4289
4630
|
recordRequestForStorm = (url, method) => {
|
|
4290
4631
|
const label = `${method.toUpperCase()} ${shortUrl(url)}`;
|
|
4291
|
-
const
|
|
4292
|
-
const hits = (hitsByEndpoint.get(label) ?? []).filter((at) =>
|
|
4293
|
-
hits.push(
|
|
4632
|
+
const now2 = Date.now();
|
|
4633
|
+
const hits = (hitsByEndpoint.get(label) ?? []).filter((at) => now2 - at < stormWindowMs);
|
|
4634
|
+
hits.push(now2);
|
|
4294
4635
|
hitsByEndpoint.set(label, hits);
|
|
4295
4636
|
if (hits.length < stormCount || reportedStorms.has(label))
|
|
4296
4637
|
return;
|
|
@@ -4403,15 +4744,15 @@ var createBeacon = (options) => {
|
|
|
4403
4744
|
type: "xhr"
|
|
4404
4745
|
});
|
|
4405
4746
|
if (!failed) {
|
|
4406
|
-
|
|
4747
|
+
const headers = new Headers;
|
|
4748
|
+
for (const line of this.getAllResponseHeaders().split(/\r?\n/u)) {
|
|
4749
|
+
const separator = line.indexOf(":");
|
|
4750
|
+
if (separator <= 0)
|
|
4751
|
+
continue;
|
|
4752
|
+
headers.append(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
|
|
4753
|
+
}
|
|
4754
|
+
reportResponseSignal(request.url, request.method, this.status, Date.now() - start, responseTraceId(headers.get(BEACON_TRACE_HEADER)));
|
|
4407
4755
|
if ((instrument.classifyResponse !== undefined && this.status >= 200 && this.status < 300 || instrument.classifyErrorResponse !== undefined && this.status >= 400) && (this.responseType === "" || this.responseType === "text")) {
|
|
4408
|
-
const headers = new Headers;
|
|
4409
|
-
for (const line of this.getAllResponseHeaders().split(/\r?\n/u)) {
|
|
4410
|
-
const separator = line.indexOf(":");
|
|
4411
|
-
if (separator <= 0)
|
|
4412
|
-
continue;
|
|
4413
|
-
headers.append(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
|
|
4414
|
-
}
|
|
4415
4756
|
classifyInstrumentedResponse(new Response(this.responseText, {
|
|
4416
4757
|
headers,
|
|
4417
4758
|
status: this.status,
|
|
@@ -4434,11 +4775,17 @@ var createBeacon = (options) => {
|
|
|
4434
4775
|
}
|
|
4435
4776
|
if (instrument.history !== false && typeof history !== "undefined") {
|
|
4436
4777
|
let recordedHistoryUrl = location.href;
|
|
4437
|
-
const record = () => {
|
|
4778
|
+
const record = (from, type) => {
|
|
4438
4779
|
addBreadcrumb({
|
|
4439
4780
|
message: `navigate ${location.pathname}${location.search}`,
|
|
4440
4781
|
type: "navigation"
|
|
4441
4782
|
});
|
|
4783
|
+
recentNavigation = {
|
|
4784
|
+
from: shortUrl(from),
|
|
4785
|
+
performanceAt: performance.now(),
|
|
4786
|
+
to: shortUrl(location.href),
|
|
4787
|
+
type
|
|
4788
|
+
};
|
|
4442
4789
|
recordedHistoryUrl = location.href;
|
|
4443
4790
|
overflowScanOnNavigation?.();
|
|
4444
4791
|
};
|
|
@@ -4460,7 +4807,7 @@ var createBeacon = (options) => {
|
|
|
4460
4807
|
if (!changesUrl)
|
|
4461
4808
|
return result;
|
|
4462
4809
|
reportFormAbandonmentOnNavigation?.(departedUrl);
|
|
4463
|
-
record();
|
|
4810
|
+
record(departedUrl, key);
|
|
4464
4811
|
return result;
|
|
4465
4812
|
};
|
|
4466
4813
|
return () => {
|
|
@@ -4472,7 +4819,7 @@ var createBeacon = (options) => {
|
|
|
4472
4819
|
if (location.href === recordedHistoryUrl)
|
|
4473
4820
|
return;
|
|
4474
4821
|
reportFormAbandonmentOnNavigation?.(recordedHistoryUrl);
|
|
4475
|
-
record();
|
|
4822
|
+
record(recordedHistoryUrl, "popstate");
|
|
4476
4823
|
};
|
|
4477
4824
|
window.addEventListener("popstate", onPopState);
|
|
4478
4825
|
cleanups.push(() => window.removeEventListener("popstate", onPopState));
|
|
@@ -4563,10 +4910,11 @@ export {
|
|
|
4563
4910
|
createBeacon,
|
|
4564
4911
|
getBeacon,
|
|
4565
4912
|
initBeacon,
|
|
4913
|
+
isAutomatedBrowser,
|
|
4566
4914
|
isKnownBeaconNoise,
|
|
4567
4915
|
observeCapability,
|
|
4568
4916
|
redactBeaconEvent
|
|
4569
4917
|
};
|
|
4570
4918
|
|
|
4571
|
-
//# debugId=
|
|
4919
|
+
//# debugId=F6C0F80E961648E164756E2164756E21
|
|
4572
4920
|
//# sourceMappingURL=index.js.map
|