@absolutejs/beacon 0.7.0-beta.2 → 0.7.0-beta.21

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/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.2";
195
+ var BEACON_SDK_VERSION = "0.7.0-beta.21";
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 ?? "").split(`
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 ?? "").split(`
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",
@@ -663,7 +685,7 @@ var VOLATILE_SIGNAL_TAGS = new Set([
663
685
  "windowMs"
664
686
  ]);
665
687
  var BUILT_ASSET_HASH = /([/][A-Za-z0-9_-]+)\.[a-z0-9]{6,16}(\.(?:js|css))\b/giu;
666
- var normalizeSignalIdentityPart = (value) => value.replace(BUILT_ASSET_HASH, "$1.:asset$2").replace(UUID_PATH_SEGMENT, ":id").replace(LONG_IDENTIFIER_SEGMENT, ":id").slice(0, SIGNAL_IDENTITY_PART_MAX);
688
+ var normalizeSignalIdentityPart = (value) => value.replace(BUILT_ASSET_HASH, "$1.:asset$2").replace(/#v-\d+(?:-\d+)*(?![\w-])/gu, "#:vue-id").replace(UUID_PATH_SEGMENT, ":id").replace(LONG_IDENTIFIER_SEGMENT, ":id").slice(0, SIGNAL_IDENTITY_PART_MAX);
667
689
  var SIGNAL_IDENTITY_PART_MAX = 160;
668
690
  var stableIdentityHash = (value, seed) => {
669
691
  let hash = seed;
@@ -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 reported = false;
748
- try {
749
- const observer = new PerformanceObserver((list) => {
750
- const windowStart = performance.getEntriesByName("first-contentful-paint")[0]?.startTime ?? 0;
751
- const windowEnd = windowStart + TBT_WINDOW_MS;
752
- for (const entry of list.getEntries()) {
753
- if (entry.startTime < windowStart || entry.startTime >= windowEnd)
754
- continue;
755
- longTasks.push({
756
- duration: entry.duration,
757
- startTime: entry.startTime
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
- const flush = () => {
763
- if (reported)
764
- return;
765
- const firstContentfulPaint = performance.getEntriesByName("first-contentful-paint")[0]?.startTime;
766
- const windowStart = firstContentfulPaint ?? 0;
767
- const windowEnd = windowStart + TBT_WINDOW_MS;
768
- const tasksInWindow = longTasks.filter(({ startTime }) => startTime >= windowStart && startTime < windowEnd);
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, tags2) => {
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: tags2
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) => observeWebVitals(webVitals, reportVital)).catch(() => {
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 onVisibilityChange2 = () => checkWhenVisible();
1387
+ const onVisibilityChange = () => checkWhenVisible();
1329
1388
  window.addEventListener("focus", checkWhenVisible);
1330
1389
  window.addEventListener("online", checkWhenVisible);
1331
- document.addEventListener("visibilitychange", onVisibilityChange2);
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", onVisibilityChange2);
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 = (endpoint2, method, status) => {
1443
+ const recordAuthFailure = (endpoint, method, status) => {
1385
1444
  if (signals === null || signals.authFailureStorms === false)
1386
1445
  return false;
1387
- const label = `${method} ${endpoint2}`;
1388
- const now2 = Date.now();
1389
- const failures = (authFailuresByEndpoint.get(label) ?? []).filter(({ at }) => now2 - at < authFailureStormWindowMs);
1390
- failures.push({ at: now2, status });
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: endpoint2,
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: endpoint2 }) => endpoint2))
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: transport2 }) => transport2))
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 timer2;
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 (timer2 !== undefined)
1597
- window.clearTimeout(timer2);
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 (timer2 !== undefined)
1608
- window.clearTimeout(timer2);
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
- timer2 = window.setTimeout(() => {
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
- timer2 = window.setTimeout(() => {
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 axis2 = overlapY <= overlapX ? "vertical" : "horizontal";
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: axis2,
2545
+ collisionAxis: axis,
2432
2546
  collisionKind: "overlap",
2433
- overlapPx: String(Math.round(axis2 === "vertical" ? overlapY : overlapX))
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 now2 = Date.now();
2779
- const missedPollWindow = lastLoadingCheckAt !== undefined && now2 - lastLoadingCheckAt > STUCK_LOADING_POLL_MS * 3;
2780
- lastLoadingCheckAt = now2;
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, now2);
2912
+ loadingFirstSeen.set(indicator, now);
2799
2913
  }
2800
2914
  const firstSeen = loadingFirstSeen.get(indicator);
2801
2915
  if (firstSeen === undefined) {
2802
- loadingFirstSeen.set(indicator, now2);
2916
+ loadingFirstSeen.set(indicator, now);
2803
2917
  trackedLoadingIndicators.add(indicator);
2804
2918
  continue;
2805
2919
  }
2806
2920
  const deadlineMs = loadingDeadlineMs(indicator);
2807
- if (now2 - firstSeen < deadlineMs || reportedStuckLoading.has(indicator)) {
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(now2 - firstSeen)
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)),
@@ -3014,9 +3139,9 @@ var createBeacon = (options) => {
3014
3139
  }
3015
3140
  const observerStartedAt = performance.now();
3016
3141
  const observer = new PerformanceObserver((list) => {
3142
+ let viewport;
3017
3143
  for (const raw of list.getEntries()) {
3018
3144
  const entry = raw;
3019
- const viewport = currentViewport();
3020
3145
  processLayoutShift({
3021
3146
  buffered: entry.startTime < observerStartedAt,
3022
3147
  documentReadyState: document.readyState,
@@ -3031,7 +3156,9 @@ var createBeacon = (options) => {
3031
3156
  })),
3032
3157
  startTime: entry.startTime,
3033
3158
  value: entry.value ?? 0,
3034
- viewport
3159
+ get viewport() {
3160
+ return viewport ??= currentViewport();
3161
+ }
3035
3162
  });
3036
3163
  }
3037
3164
  });
@@ -3103,7 +3230,9 @@ var createBeacon = (options) => {
3103
3230
  recordBlockingFrames(blockingObserver.takeRecords());
3104
3231
  }
3105
3232
  const interactionEnd = entry.startTime + entry.duration;
3106
- const overlappingFrame = blockingFrames.filter((frame) => frame.startTime < interactionEnd && frame.startTime + frame.duration > entry.startTime).sort((left, right) => {
3233
+ const overlappingFrames = blockingFrames.filter((frame) => frame.startTime < interactionEnd && frame.startTime + frame.duration > entry.startTime);
3234
+ const onlyIdleFrames = overlappingFrames.length > 0 && overlappingFrames.every((frame) => frame.entryType === "long-animation-frame" && frame.blockingDuration === 0 && Array.isArray(frame.scripts) && frame.scripts.length === 0);
3235
+ const overlappingFrame = overlappingFrames.sort((left, right) => {
3107
3236
  const leftBlocking = left.blockingDuration ?? Math.max(0, left.duration - LONG_TASK_MS);
3108
3237
  const rightBlocking = right.blockingDuration ?? Math.max(0, right.duration - LONG_TASK_MS);
3109
3238
  return rightBlocking - leftBlocking;
@@ -3113,7 +3242,7 @@ var createBeacon = (options) => {
3113
3242
  const processingDurationMs = hasPhaseTiming ? Math.round(Math.max(0, entry.processingEnd - entry.processingStart)) : undefined;
3114
3243
  const presentationDelayMs = hasPhaseTiming ? Math.round(Math.max(0, interactionEnd - entry.processingEnd)) : undefined;
3115
3244
  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)
3245
+ if ((overlappingFrame === undefined || onlyIdleFrames && inputDelayMs !== undefined && inputDelayMs < minimum) && processingDurationMs !== undefined && processingDurationMs <= 16 && presentationDelayMs !== undefined && presentationDelayMs >= minimum)
3117
3246
  continue;
3118
3247
  if (blockingObserver !== undefined && overlappingFrame === undefined && inputDelayMs !== undefined && inputDelayMs >= minimum && processingDurationMs !== undefined && processingDurationMs <= 16 && presentationDelayMs !== undefined && presentationDelayMs < minimum)
3119
3248
  continue;
@@ -3195,7 +3324,7 @@ var createBeacon = (options) => {
3195
3324
  if (name === null)
3196
3325
  return;
3197
3326
  const onLoad = () => stopWatching(frame);
3198
- const timer2 = setTimeout(() => {
3327
+ const timer = setTimeout(() => {
3199
3328
  stopWatching(frame);
3200
3329
  if (pageLifecycleEnding || document.visibilityState === "hidden" || !frame.isConnected) {
3201
3330
  return;
@@ -3212,7 +3341,7 @@ var createBeacon = (options) => {
3212
3341
  target: describeElement(frame)
3213
3342
  });
3214
3343
  }, stallMs);
3215
- watched.set(frame, { onLoad, timer: timer2 });
3344
+ watched.set(frame, { onLoad, timer });
3216
3345
  frame.addEventListener("load", onLoad, { once: true });
3217
3346
  };
3218
3347
  const discoverFrames = (root) => {
@@ -3411,9 +3540,9 @@ var createBeacon = (options) => {
3411
3540
  const pending = new Map;
3412
3541
  const reported = new WeakSet;
3413
3542
  const clearPending = (canvas) => {
3414
- const timer2 = pending.get(canvas);
3415
- if (timer2 !== undefined)
3416
- clearTimeout(timer2);
3543
+ const timer = pending.get(canvas);
3544
+ if (timer !== undefined)
3545
+ clearTimeout(timer);
3417
3546
  pending.delete(canvas);
3418
3547
  };
3419
3548
  const onLost = (event) => {
@@ -3421,7 +3550,7 @@ var createBeacon = (options) => {
3421
3550
  return;
3422
3551
  const canvas = event.target;
3423
3552
  clearPending(canvas);
3424
- const timer2 = setTimeout(() => {
3553
+ const timer = setTimeout(() => {
3425
3554
  pending.delete(canvas);
3426
3555
  if (reported.has(canvas) || pageLifecycleEnding || document.visibilityState === "hidden" || !canvas.isConnected) {
3427
3556
  return;
@@ -3438,7 +3567,7 @@ var createBeacon = (options) => {
3438
3567
  target: describeElement(canvas)
3439
3568
  });
3440
3569
  }, graceMs);
3441
- pending.set(canvas, timer2);
3570
+ pending.set(canvas, timer);
3442
3571
  };
3443
3572
  const onRestored = (event) => {
3444
3573
  if (event.target instanceof HTMLCanvasElement)
@@ -3449,8 +3578,8 @@ var createBeacon = (options) => {
3449
3578
  cleanups.push(() => {
3450
3579
  document.removeEventListener("webglcontextlost", onLost, true);
3451
3580
  document.removeEventListener("webglcontextrestored", onRestored, true);
3452
- for (const timer2 of pending.values())
3453
- clearTimeout(timer2);
3581
+ for (const timer of pending.values())
3582
+ clearTimeout(timer);
3454
3583
  pending.clear();
3455
3584
  });
3456
3585
  }
@@ -3459,9 +3588,9 @@ var createBeacon = (options) => {
3459
3588
  const visualViewport = window.visualViewport;
3460
3589
  const settleMs = signals.focusedControlSettleMs ?? FOCUSED_CONTROL_SETTLE_DEFAULT_MS;
3461
3590
  const reported = new Set;
3462
- let timer2;
3591
+ let timer;
3463
3592
  const checkFocusedControl = () => {
3464
- timer2 = undefined;
3593
+ timer = undefined;
3465
3594
  if (pageLifecycleEnding || document.visibilityState === "hidden" || visualViewport.height >= window.innerHeight * KEYBOARD_VIEWPORT_HEIGHT_RATIO_MAX) {
3466
3595
  return;
3467
3596
  }
@@ -3491,9 +3620,9 @@ var createBeacon = (options) => {
3491
3620
  });
3492
3621
  };
3493
3622
  const scheduleCheck = () => {
3494
- if (timer2 !== undefined)
3495
- clearTimeout(timer2);
3496
- timer2 = setTimeout(checkFocusedControl, settleMs);
3623
+ if (timer !== undefined)
3624
+ clearTimeout(timer);
3625
+ timer = setTimeout(checkFocusedControl, settleMs);
3497
3626
  };
3498
3627
  document.addEventListener("focusin", scheduleCheck, true);
3499
3628
  visualViewport.addEventListener("resize", scheduleCheck);
@@ -3502,8 +3631,8 @@ var createBeacon = (options) => {
3502
3631
  document.removeEventListener("focusin", scheduleCheck, true);
3503
3632
  visualViewport.removeEventListener("resize", scheduleCheck);
3504
3633
  visualViewport.removeEventListener("scroll", scheduleCheck);
3505
- if (timer2 !== undefined)
3506
- clearTimeout(timer2);
3634
+ if (timer !== undefined)
3635
+ clearTimeout(timer);
3507
3636
  });
3508
3637
  }
3509
3638
  if (signals.scrollJail !== false) {
@@ -3543,7 +3672,7 @@ var createBeacon = (options) => {
3543
3672
  };
3544
3673
  const onWheel = (event) => {
3545
3674
  clearJailSettle();
3546
- if (event.ctrlKey || event.defaultPrevented || event.deltaY === 0) {
3675
+ if (event.ctrlKey || event.defaultPrevented || event.deltaY === 0 || Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
3547
3676
  jailBurst = [];
3548
3677
  return;
3549
3678
  }
@@ -3560,16 +3689,16 @@ var createBeacon = (options) => {
3560
3689
  jailBurst = [];
3561
3690
  return;
3562
3691
  }
3563
- const now2 = Date.now();
3692
+ const now = Date.now();
3564
3693
  if (jailScroller !== scroller) {
3565
3694
  jailScroller = scroller;
3566
3695
  jailBurst = [];
3567
3696
  }
3568
- jailBurst = jailBurst.filter((entry) => now2 - entry.at < SCROLL_JAIL_WINDOW_MS);
3697
+ jailBurst = jailBurst.filter((entry) => now - entry.at < SCROLL_JAIL_WINDOW_MS && !entry.event.defaultPrevented);
3569
3698
  if (jailBurst.length === 0) {
3570
3699
  jailStartingScrollGeneration = scrollActivityGeneration;
3571
3700
  }
3572
- jailBurst.push({ at: now2, position: scroller.scrollTop });
3701
+ jailBurst.push({ at: now, position: scroller.scrollTop, event });
3573
3702
  if (jailBurst.length < SCROLL_JAIL_EVENT_COUNT)
3574
3703
  return;
3575
3704
  const first = jailBurst[0];
@@ -3581,7 +3710,10 @@ var createBeacon = (options) => {
3581
3710
  const startingPosition = first.position;
3582
3711
  jailSettleTimer = setTimeout(() => {
3583
3712
  jailSettleTimer = undefined;
3713
+ const confirmedBurst = jailBurst.filter((entry) => !entry.event.defaultPrevented);
3584
3714
  jailBurst = [];
3715
+ if (confirmedBurst.length < SCROLL_JAIL_EVENT_COUNT)
3716
+ return;
3585
3717
  if (scrollActivityGeneration !== jailStartingScrollGeneration)
3586
3718
  return;
3587
3719
  if (!scroller.isConnected || scroller.scrollTop !== startingPosition)
@@ -3595,7 +3727,32 @@ var createBeacon = (options) => {
3595
3727
  if (reportedScrollers.has(descriptor))
3596
3728
  return;
3597
3729
  reportedScrollers.add(descriptor);
3598
- emitSignal(`Scroll jail — ${descriptor} has scrollable content but never moves — ${shortUrl(location.href)}`, { signal: BEACON_SIGNAL.SCROLL_JAIL, target: descriptor });
3730
+ emitSignal(`Scroll jail — ${descriptor} has scrollable content but never moves — ${shortUrl(location.href)}`, { signal: BEACON_SIGNAL.SCROLL_JAIL, target: descriptor }, undefined, {
3731
+ scroll: {
3732
+ target: target ? describeElement(target) : undefined,
3733
+ scroller: descriptor,
3734
+ direction: scrollingDown ? "down" : "up",
3735
+ wheelCount: confirmedBurst.length,
3736
+ deltaX: event.deltaX,
3737
+ deltaY: event.deltaY,
3738
+ deltaMode: event.deltaMode,
3739
+ burstDurationMs: now - (confirmedBurst[0]?.at ?? now),
3740
+ scrollTop: scroller.scrollTop,
3741
+ scrollHeight: scroller.scrollHeight,
3742
+ clientHeight: scroller.clientHeight,
3743
+ overflowY: window.getComputedStyle(scroller).overflowY,
3744
+ overscrollBehaviorY: window.getComputedStyle(scroller).overscrollBehaviorY,
3745
+ bodyOverflowY: window.getComputedStyle(document.body).overflowY,
3746
+ rootOverflowY: window.getComputedStyle(document.documentElement).overflowY,
3747
+ modal: modal ? describeElement(modal) : undefined,
3748
+ rect: {
3749
+ top: scroller.getBoundingClientRect().top,
3750
+ left: scroller.getBoundingClientRect().left,
3751
+ width: scroller.getBoundingClientRect().width,
3752
+ height: scroller.getBoundingClientRect().height
3753
+ }
3754
+ }
3755
+ });
3599
3756
  }, SCROLL_JAIL_SETTLE_MS);
3600
3757
  };
3601
3758
  document.addEventListener("scroll", onDocumentScroll, {
@@ -3628,9 +3785,9 @@ var createBeacon = (options) => {
3628
3785
  previous = { x: event.clientX, y: event.clientY };
3629
3786
  if (Math.hypot(dx, dy) < 8)
3630
3787
  return;
3631
- const now2 = Date.now();
3632
- points = points.filter((point) => now2 - point.at < THRASHED_CURSOR_WINDOW_MS);
3633
- points.push({ at: now2, dx, dy });
3788
+ const now = Date.now();
3789
+ points = points.filter((point) => now - point.at < THRASHED_CURSOR_WINDOW_MS);
3790
+ points.push({ at: now, dx, dy });
3634
3791
  let reversals = 0;
3635
3792
  for (let index = 1;index < points.length; index += 1) {
3636
3793
  const prior = points[index - 1];
@@ -3655,6 +3812,87 @@ var createBeacon = (options) => {
3655
3812
  });
3656
3813
  cleanups.push(() => document.removeEventListener("pointermove", onPointerMove));
3657
3814
  }
3815
+ if (signals.collapsedModals !== false && typeof MutationObserver !== "undefined") {
3816
+ const COLLAPSED_MODAL_SELECTOR = '[aria-modal="true"], dialog[open]';
3817
+ const reportedCollapsedModals = new WeakSet;
3818
+ const pendingCollapsedModals = new WeakSet;
3819
+ const collapsedModalTimers = new Set;
3820
+ const isHiddenOnPurpose = (modal) => {
3821
+ let current = modal;
3822
+ while (current !== null) {
3823
+ if (current.hasAttribute("hidden") || current.getAttribute("aria-hidden")?.toLowerCase() === "true") {
3824
+ return true;
3825
+ }
3826
+ const style = getComputedStyle(current);
3827
+ if (style.display === "none" || style.visibility === "hidden" || style.visibility === "collapse" || style.contentVisibility === "hidden") {
3828
+ return true;
3829
+ }
3830
+ current = current.parentElement;
3831
+ }
3832
+ return false;
3833
+ };
3834
+ const checkCollapsedModal = (modal) => {
3835
+ if (reportedCollapsedModals.has(modal) || pendingCollapsedModals.has(modal)) {
3836
+ return;
3837
+ }
3838
+ pendingCollapsedModals.add(modal);
3839
+ const timer = setTimeout(() => {
3840
+ collapsedModalTimers.delete(timer);
3841
+ pendingCollapsedModals.delete(modal);
3842
+ if (!modal.isConnected || !modal.matches(COLLAPSED_MODAL_SELECTOR) || modal.childElementCount === 0 || document.visibilityState === "hidden" || isHiddenOnPurpose(modal)) {
3843
+ return;
3844
+ }
3845
+ const rect = modal.getBoundingClientRect();
3846
+ if (rect.width >= COLLAPSED_MODAL_MIN_PX && rect.height >= COLLAPSED_MODAL_MIN_PX) {
3847
+ return;
3848
+ }
3849
+ reportedCollapsedModals.add(modal);
3850
+ const modalDescriptor = describeElement(modal);
3851
+ emitSignal(`Collapsed modal — ${modalDescriptor} opened at ${Math.round(rect.width)}×${Math.round(rect.height)}px — ${shortUrl(location.href)}`, {
3852
+ contentHeightPx: String(Math.round(modal.scrollHeight)),
3853
+ contentWidthPx: String(Math.round(modal.scrollWidth)),
3854
+ heightPx: String(Math.round(rect.height)),
3855
+ modal: modalDescriptor,
3856
+ signal: BEACON_SIGNAL.COLLAPSED_MODAL,
3857
+ widthPx: String(Math.round(rect.width))
3858
+ });
3859
+ }, COLLAPSED_MODAL_SETTLE_MS);
3860
+ collapsedModalTimers.add(timer);
3861
+ };
3862
+ const scanForModals = (root) => {
3863
+ if (root.matches(COLLAPSED_MODAL_SELECTOR))
3864
+ checkCollapsedModal(root);
3865
+ for (const modal of Array.from(root.querySelectorAll(COLLAPSED_MODAL_SELECTOR))) {
3866
+ checkCollapsedModal(modal);
3867
+ }
3868
+ };
3869
+ scanForModals(document.documentElement);
3870
+ const collapsedModalObserver = new MutationObserver((records) => {
3871
+ for (const record of records) {
3872
+ if (record.type === "attributes") {
3873
+ if (record.target instanceof Element)
3874
+ scanForModals(record.target);
3875
+ continue;
3876
+ }
3877
+ for (const node of Array.from(record.addedNodes)) {
3878
+ if (node instanceof Element)
3879
+ scanForModals(node);
3880
+ }
3881
+ }
3882
+ });
3883
+ collapsedModalObserver.observe(document.documentElement, {
3884
+ attributeFilter: ["open", "aria-modal"],
3885
+ attributes: true,
3886
+ childList: true,
3887
+ subtree: true
3888
+ });
3889
+ cleanups.push(() => {
3890
+ collapsedModalObserver.disconnect();
3891
+ for (const timer of collapsedModalTimers)
3892
+ clearTimeout(timer);
3893
+ collapsedModalTimers.clear();
3894
+ });
3895
+ }
3658
3896
  if (signals.focusLoss !== false || signals.modalFocusEscape !== false) {
3659
3897
  const DIALOG_SELECTOR = '[role="dialog"], [aria-modal="true"], dialog';
3660
3898
  const MODAL_SELECTOR = '[aria-modal="true"], dialog[open]';
@@ -3694,8 +3932,8 @@ var createBeacon = (options) => {
3694
3932
  };
3695
3933
  const openModals = () => Array.from(document.querySelectorAll(MODAL_SELECTOR)).filter(isRenderedModal);
3696
3934
  const checkInitialModalFocus = (modal) => {
3697
- const timer2 = setTimeout(() => {
3698
- modalTimers.delete(timer2);
3935
+ const timer = setTimeout(() => {
3936
+ modalTimers.delete(timer);
3699
3937
  if (!isRenderedModal(modal))
3700
3938
  return;
3701
3939
  const active = document.activeElement instanceof Element ? document.activeElement : null;
@@ -3703,7 +3941,7 @@ var createBeacon = (options) => {
3703
3941
  return;
3704
3942
  reportModalEscape(modal, active, "initial-focus-missing");
3705
3943
  }, MODAL_FOCUS_SETTLE_MS);
3706
- modalTimers.add(timer2);
3944
+ modalTimers.add(timer);
3707
3945
  };
3708
3946
  const updateModalVisibility = (modal) => {
3709
3947
  knownModals.add(modal);
@@ -3726,8 +3964,8 @@ var createBeacon = (options) => {
3726
3964
  const modals = openModals();
3727
3965
  if (modals.length > 0 && !modals.some((modal) => modal.contains(target))) {
3728
3966
  const modal = modals[modals.length - 1];
3729
- const timer2 = setTimeout(() => {
3730
- modalTimers.delete(timer2);
3967
+ const timer = setTimeout(() => {
3968
+ modalTimers.delete(timer);
3731
3969
  if (!isRenderedModal(modal))
3732
3970
  return;
3733
3971
  const active = document.activeElement instanceof Element ? document.activeElement : null;
@@ -3735,7 +3973,7 @@ var createBeacon = (options) => {
3735
3973
  return;
3736
3974
  reportModalEscape(modal, active, "escaped");
3737
3975
  }, 0);
3738
- modalTimers.add(timer2);
3976
+ modalTimers.add(timer);
3739
3977
  }
3740
3978
  }
3741
3979
  };
@@ -3812,8 +4050,8 @@ var createBeacon = (options) => {
3812
4050
  document.removeEventListener("focusin", onFocusIn, true);
3813
4051
  document.removeEventListener("focusout", onFocusOut, true);
3814
4052
  modalObserver?.disconnect();
3815
- for (const timer2 of modalTimers)
3816
- clearTimeout(timer2);
4053
+ for (const timer of modalTimers)
4054
+ clearTimeout(timer);
3817
4055
  modalTimers.clear();
3818
4056
  knownModals.clear();
3819
4057
  });
@@ -3858,14 +4096,14 @@ var createBeacon = (options) => {
3858
4096
  if (data === null)
3859
4097
  return;
3860
4098
  const activity = activityFor(form);
3861
- const now2 = Date.now();
4099
+ const now = Date.now();
3862
4100
  if (data !== activity.lastData) {
3863
4101
  activity.lastData = data;
3864
- activity.identicalSubmits = [now2];
4102
+ activity.identicalSubmits = [now];
3865
4103
  return;
3866
4104
  }
3867
- activity.identicalSubmits = activity.identicalSubmits.filter((at) => now2 - at < FORM_FRUSTRATION_WINDOW_MS);
3868
- activity.identicalSubmits.push(now2);
4105
+ activity.identicalSubmits = activity.identicalSubmits.filter((at) => now - at < FORM_FRUSTRATION_WINDOW_MS);
4106
+ activity.identicalSubmits.push(now);
3869
4107
  if (activity.identicalSubmits.length >= FORM_FRUSTRATION_THRESHOLD) {
3870
4108
  reportForm(form, "was submitted with identical values repeatedly");
3871
4109
  }
@@ -3876,14 +4114,14 @@ var createBeacon = (options) => {
3876
4114
  if (form === null)
3877
4115
  return;
3878
4116
  const activity = activityFor(form);
3879
- const now2 = Date.now();
3880
- if (now2 - activity.lastInvalidAt < FORM_INVALID_BURST_GAP_MS) {
3881
- activity.lastInvalidAt = now2;
4117
+ const now = Date.now();
4118
+ if (now - activity.lastInvalidAt < FORM_INVALID_BURST_GAP_MS) {
4119
+ activity.lastInvalidAt = now;
3882
4120
  return;
3883
4121
  }
3884
- activity.lastInvalidAt = now2;
3885
- activity.invalidBursts = activity.invalidBursts.filter((at) => now2 - at < FORM_FRUSTRATION_WINDOW_MS);
3886
- activity.invalidBursts.push(now2);
4122
+ activity.lastInvalidAt = now;
4123
+ activity.invalidBursts = activity.invalidBursts.filter((at) => now - at < FORM_FRUSTRATION_WINDOW_MS);
4124
+ activity.invalidBursts.push(now);
3887
4125
  if (activity.invalidBursts.length >= FORM_FRUSTRATION_THRESHOLD) {
3888
4126
  reportForm(form, "keeps failing native validation");
3889
4127
  }
@@ -3982,9 +4220,9 @@ var createBeacon = (options) => {
3982
4220
  if (signals.sseFlapping === false || pageLifecycleEnding || document.visibilityState === "hidden") {
3983
4221
  return;
3984
4222
  }
3985
- const now2 = Date.now();
3986
- const errors = (errorsByEndpoint.get(endpointLabel) ?? []).filter((at) => now2 - at < sseFlapWindowMs);
3987
- errors.push(now2);
4223
+ const now = Date.now();
4224
+ const errors = (errorsByEndpoint.get(endpointLabel) ?? []).filter((at) => now - at < sseFlapWindowMs);
4225
+ errors.push(now);
3988
4226
  errorsByEndpoint.set(endpointLabel, errors);
3989
4227
  if (errors.length < sseFlapCount || reportedFlappingStreams.has(endpointLabel)) {
3990
4228
  return;
@@ -4005,13 +4243,13 @@ var createBeacon = (options) => {
4005
4243
  };
4006
4244
  const originalAddEventListener = source.addEventListener.bind(source);
4007
4245
  const armedTypes = new Set(["error", "message", "open"]);
4008
- source.addEventListener = (type, listener, options2) => {
4246
+ source.addEventListener = (type, listener, options) => {
4009
4247
  if (!armedTypes.has(type)) {
4010
4248
  armedTypes.add(type);
4011
4249
  originalAddEventListener(type, arm);
4012
4250
  }
4013
4251
  if (listener !== null) {
4014
- originalAddEventListener(type, listener, options2);
4252
+ originalAddEventListener(type, listener, options);
4015
4253
  }
4016
4254
  };
4017
4255
  originalAddEventListener("open", arm);
@@ -4060,6 +4298,9 @@ var createBeacon = (options) => {
4060
4298
  const restoredLifecycleClose = pageRestoredAt !== undefined && socketLifecycleGeneration < pageLifecycleGeneration && Date.now() - pageRestoredAt <= RESTORED_SOCKET_CLOSE_GRACE_MS;
4061
4299
  if (pageLifecycleEnding || applicationClose || restoredLifecycleClose)
4062
4300
  return;
4301
+ const expectedServerClose = typeof CloseEvent !== "undefined" && event instanceof CloseEvent && (event.wasClean || event.code === 1000 || event.code === 1001 || event.code === 1012);
4302
+ if (expectedServerClose)
4303
+ return;
4063
4304
  if (signals.socketAbnormalCloses !== false && typeof CloseEvent !== "undefined" && event instanceof CloseEvent && !event.wasClean && !recoverableSocket(socketUrl)) {
4064
4305
  const abnormalKey = `${label}|${event.code}`;
4065
4306
  if (!reportedAbnormalCloses.has(abnormalKey)) {
@@ -4074,10 +4315,10 @@ var createBeacon = (options) => {
4074
4315
  }
4075
4316
  if (signals.socketFlapping === false)
4076
4317
  return;
4077
- const now2 = Date.now();
4078
- const closes = (closesByUrl.get(label) ?? []).filter((close) => now2 - close.at < SOCKET_FLAP_WINDOW_MS);
4318
+ const now = Date.now();
4319
+ const closes = (closesByUrl.get(label) ?? []).filter((close) => now - close.at < SOCKET_FLAP_WINDOW_MS);
4079
4320
  closes.push({
4080
- at: now2,
4321
+ at: now,
4081
4322
  code: typeof CloseEvent !== "undefined" && event instanceof CloseEvent ? event.code : null,
4082
4323
  wasClean: typeof CloseEvent !== "undefined" && event instanceof CloseEvent ? event.wasClean : null
4083
4324
  });
@@ -4093,7 +4334,7 @@ var createBeacon = (options) => {
4093
4334
  windowMs: String(SOCKET_FLAP_WINDOW_MS)
4094
4335
  }, undefined, {
4095
4336
  closeSamples: closes.map((close) => ({
4096
- ageMs: now2 - close.at,
4337
+ ageMs: now - close.at,
4097
4338
  code: close.code,
4098
4339
  wasClean: close.wasClean
4099
4340
  }))
@@ -4117,14 +4358,14 @@ var createBeacon = (options) => {
4117
4358
  cleanup();
4118
4359
  }
4119
4360
  });
4120
- const reportWorkerFailure = (workerType, endpointLabel, failureKind2, error) => {
4121
- const key = `${workerType}|${endpointLabel}|${failureKind2}`;
4361
+ const reportWorkerFailure = (workerType, endpointLabel, failureKind, error) => {
4362
+ const key = `${workerType}|${endpointLabel}|${failureKind}`;
4122
4363
  if (reportedWorkerFailures.has(key))
4123
4364
  return;
4124
4365
  reportedWorkerFailures.add(key);
4125
4366
  emitSignal(`Worker failure — ${workerType} worker ${endpointLabel} failed — ${shortUrl(location.href)}`, {
4126
4367
  endpoint: endpointLabel,
4127
- failureKind: failureKind2,
4368
+ failureKind,
4128
4369
  signal: BEACON_SIGNAL.WORKER_FAILURE,
4129
4370
  workerType
4130
4371
  }, undefined, error === undefined ? undefined : {
@@ -4211,14 +4452,14 @@ var createBeacon = (options) => {
4211
4452
  "TimeoutError",
4212
4453
  "TypeError"
4213
4454
  ]);
4214
- const reportServiceWorkerFailure = (endpointLabel, failureKind2, error) => {
4215
- const key = `${endpointLabel}|${failureKind2}`;
4455
+ const reportServiceWorkerFailure = (endpointLabel, failureKind, error) => {
4456
+ const key = `${endpointLabel}|${failureKind}`;
4216
4457
  if (reportedServiceWorkerFailures.has(key))
4217
4458
  return;
4218
4459
  reportedServiceWorkerFailures.add(key);
4219
- emitSignal(`Service worker failure — ${endpointLabel} failed during ${failureKind2} — ${shortUrl(location.href)}`, {
4460
+ emitSignal(`Service worker failure — ${endpointLabel} failed during ${failureKind} — ${shortUrl(location.href)}`, {
4220
4461
  endpoint: endpointLabel,
4221
- failureKind: failureKind2,
4462
+ failureKind,
4222
4463
  signal: BEACON_SIGNAL.SERVICE_WORKER_FAILURE
4223
4464
  }, undefined, error === undefined ? undefined : {
4224
4465
  serviceWorkerError: {
@@ -4228,12 +4469,15 @@ var createBeacon = (options) => {
4228
4469
  }
4229
4470
  });
4230
4471
  };
4231
- const watchInstallingWorker = (worker) => {
4232
- let activated = worker.state === "activated";
4472
+ const watchInstallingWorker = (worker, registration) => {
4473
+ let settled = worker.state === "installed" || worker.state === "activated";
4233
4474
  const onStateChange = () => {
4234
- if (worker.state === "activated")
4235
- activated = true;
4236
- if (worker.state !== "redundant" || activated)
4475
+ if (worker.state === "installed" || worker.state === "activated")
4476
+ settled = true;
4477
+ if (worker.state !== "redundant" || settled)
4478
+ return;
4479
+ const successor = registration?.installing ?? registration?.waiting;
4480
+ if (successor !== null && successor !== undefined && successor !== worker)
4237
4481
  return;
4238
4482
  reportServiceWorkerFailure(shortUrl(worker.scriptURL), "installation");
4239
4483
  };
@@ -4242,11 +4486,11 @@ var createBeacon = (options) => {
4242
4486
  };
4243
4487
  const watchRegistration = (registration) => {
4244
4488
  if (registration.installing !== null) {
4245
- watchInstallingWorker(registration.installing);
4489
+ watchInstallingWorker(registration.installing, registration);
4246
4490
  }
4247
4491
  const onUpdateFound = () => {
4248
4492
  if (registration.installing !== null) {
4249
- watchInstallingWorker(registration.installing);
4493
+ watchInstallingWorker(registration.installing, registration);
4250
4494
  }
4251
4495
  };
4252
4496
  registration.addEventListener("updatefound", onUpdateFound);
@@ -4324,23 +4568,23 @@ var createBeacon = (options) => {
4324
4568
  try {
4325
4569
  const navigation = performance.getEntriesByType("navigation")[0];
4326
4570
  if (navigation?.type !== "back_forward") {
4327
- const now2 = Date.now();
4571
+ const now = Date.now();
4328
4572
  const route = shortUrl(location.href);
4329
4573
  const raw = sessionStorage.getItem(RELOAD_LOOP_STORAGE_KEY);
4330
4574
  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" && now2 - entry.at < RELOAD_LOOP_WINDOW_MS);
4575
+ 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
4576
  let entryKind = "app";
4333
4577
  const rawNavigationIntent = sessionStorage.getItem(NAVIGATION_INTENT_STORAGE_KEY);
4334
4578
  sessionStorage.removeItem(NAVIGATION_INTENT_STORAGE_KEY);
4335
4579
  const navigationIntentAt = Number(rawNavigationIntent);
4336
- if (rawNavigationIntent !== null && Number.isFinite(navigationIntentAt) && now2 - navigationIntentAt >= 0 && now2 - navigationIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
4580
+ if (rawNavigationIntent !== null && Number.isFinite(navigationIntentAt) && now - navigationIntentAt >= 0 && now - navigationIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
4337
4581
  history2 = [];
4338
4582
  entryKind = "intentional-navigation";
4339
4583
  }
4340
4584
  const rawServiceWorkerUpdateIntent = sessionStorage.getItem(SERVICE_WORKER_UPDATE_INTENT_STORAGE_KEY);
4341
4585
  sessionStorage.removeItem(SERVICE_WORKER_UPDATE_INTENT_STORAGE_KEY);
4342
4586
  const serviceWorkerUpdateIntentAt = Number(rawServiceWorkerUpdateIntent);
4343
- if (rawServiceWorkerUpdateIntent !== null && Number.isFinite(serviceWorkerUpdateIntentAt) && now2 - serviceWorkerUpdateIntentAt >= 0 && now2 - serviceWorkerUpdateIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
4587
+ if (rawServiceWorkerUpdateIntent !== null && Number.isFinite(serviceWorkerUpdateIntentAt) && now - serviceWorkerUpdateIntentAt >= 0 && now - serviceWorkerUpdateIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
4344
4588
  history2 = [];
4345
4589
  entryKind = "service-worker-update";
4346
4590
  }
@@ -4351,7 +4595,7 @@ var createBeacon = (options) => {
4351
4595
  entryKind = "external";
4352
4596
  }
4353
4597
  }
4354
- history2.push({ at: now2, route });
4598
+ history2.push({ at: now, route });
4355
4599
  sessionStorage.setItem(RELOAD_LOOP_STORAGE_KEY, JSON.stringify(history2));
4356
4600
  let loadCount = 0;
4357
4601
  for (let index = history2.length - 1;index >= 0; index -= 1) {
@@ -4360,7 +4604,7 @@ var createBeacon = (options) => {
4360
4604
  loadCount += 1;
4361
4605
  }
4362
4606
  if (loadCount === RELOAD_LOOP_COUNT) {
4363
- const firstLoad = history2.at(-loadCount)?.at ?? now2;
4607
+ const firstLoad = history2.at(-loadCount)?.at ?? now;
4364
4608
  emitSignal(`Reload loop — repeated page loads within a minute — ${shortUrl(location.href)}`, {
4365
4609
  currentRelease: options.release ?? "unknown",
4366
4610
  entryKind,
@@ -4369,7 +4613,7 @@ var createBeacon = (options) => {
4369
4613
  serviceWorkerControlled: String(navigator.serviceWorker?.controller !== null && navigator.serviceWorker?.controller !== undefined),
4370
4614
  serviceWorkerScript: navigator.serviceWorker?.controller?.scriptURL ?? "none",
4371
4615
  signal: BEACON_SIGNAL.RELOAD_LOOP,
4372
- windowMs: String(now2 - firstLoad)
4616
+ windowMs: String(now - firstLoad)
4373
4617
  });
4374
4618
  flush(true);
4375
4619
  }
@@ -4379,7 +4623,7 @@ var createBeacon = (options) => {
4379
4623
  if (signals !== null && signals.staleReleases !== false && typeof localStorage !== "undefined" && typeof options.release === "string" && options.release !== "") {
4380
4624
  try {
4381
4625
  const currentRelease = options.release;
4382
- const now2 = Date.now();
4626
+ const now = Date.now();
4383
4627
  const raw = localStorage.getItem(STALE_RELEASE_STORAGE_KEY);
4384
4628
  const parsed = raw === null ? {} : JSON.parse(raw);
4385
4629
  const firstSeenByRelease = {};
@@ -4389,10 +4633,10 @@ var createBeacon = (options) => {
4389
4633
  firstSeenByRelease[release] = at;
4390
4634
  }
4391
4635
  }
4392
- const currentFirstSeen = firstSeenByRelease[currentRelease] ?? now2;
4636
+ const currentFirstSeen = firstSeenByRelease[currentRelease] ?? now;
4393
4637
  firstSeenByRelease[currentRelease] = currentFirstSeen;
4394
4638
  const newest = Object.entries(firstSeenByRelease).filter(([release, at]) => release !== currentRelease && at > currentFirstSeen).sort((left, right) => right[1] - left[1])[0];
4395
- if (newest !== undefined && now2 - newest[1] > STALE_RELEASE_GRACE_MS) {
4639
+ if (newest !== undefined && now - newest[1] > STALE_RELEASE_GRACE_MS) {
4396
4640
  emitSignal(`Stale release — this page is running a build older than one this browser already saw — ${shortUrl(location.href)}`, {
4397
4641
  currentRelease,
4398
4642
  newestRelease: newest[0],
@@ -4469,8 +4713,8 @@ var createBeacon = (options) => {
4469
4713
  return;
4470
4714
  if (confirmationMs > 0) {
4471
4715
  await new Promise((resolve) => {
4472
- const timer2 = window.setTimeout(resolve, confirmationMs);
4473
- cleanups.push(() => window.clearTimeout(timer2));
4716
+ const timer = window.setTimeout(resolve, confirmationMs);
4717
+ cleanups.push(() => window.clearTimeout(timer));
4474
4718
  });
4475
4719
  if (document.visibilityState === "hidden")
4476
4720
  return;
@@ -4512,9 +4756,9 @@ var createBeacon = (options) => {
4512
4756
  const reportedStorms = new Set;
4513
4757
  recordRequestForStorm = (url, method) => {
4514
4758
  const label = `${method.toUpperCase()} ${shortUrl(url)}`;
4515
- const now2 = Date.now();
4516
- const hits = (hitsByEndpoint.get(label) ?? []).filter((at) => now2 - at < stormWindowMs);
4517
- hits.push(now2);
4759
+ const now = Date.now();
4760
+ const hits = (hitsByEndpoint.get(label) ?? []).filter((at) => now - at < stormWindowMs);
4761
+ hits.push(now);
4518
4762
  hitsByEndpoint.set(label, hits);
4519
4763
  if (hits.length < stormCount || reportedStorms.has(label))
4520
4764
  return;
@@ -4627,15 +4871,15 @@ var createBeacon = (options) => {
4627
4871
  type: "xhr"
4628
4872
  });
4629
4873
  if (!failed) {
4630
- reportResponseSignal(request.url, request.method, this.status, Date.now() - start, responseTraceId(this.getResponseHeader(BEACON_TRACE_HEADER)));
4874
+ const headers = new Headers;
4875
+ for (const line of this.getAllResponseHeaders().split(/\r?\n/u)) {
4876
+ const separator = line.indexOf(":");
4877
+ if (separator <= 0)
4878
+ continue;
4879
+ headers.append(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
4880
+ }
4881
+ reportResponseSignal(request.url, request.method, this.status, Date.now() - start, responseTraceId(headers.get(BEACON_TRACE_HEADER)));
4631
4882
  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
4883
  classifyInstrumentedResponse(new Response(this.responseText, {
4640
4884
  headers,
4641
4885
  status: this.status,
@@ -4658,11 +4902,17 @@ var createBeacon = (options) => {
4658
4902
  }
4659
4903
  if (instrument.history !== false && typeof history !== "undefined") {
4660
4904
  let recordedHistoryUrl = location.href;
4661
- const record = () => {
4905
+ const record = (from, type) => {
4662
4906
  addBreadcrumb({
4663
4907
  message: `navigate ${location.pathname}${location.search}`,
4664
4908
  type: "navigation"
4665
4909
  });
4910
+ recentNavigation = {
4911
+ from: shortUrl(from),
4912
+ performanceAt: performance.now(),
4913
+ to: shortUrl(location.href),
4914
+ type
4915
+ };
4666
4916
  recordedHistoryUrl = location.href;
4667
4917
  overflowScanOnNavigation?.();
4668
4918
  };
@@ -4684,7 +4934,7 @@ var createBeacon = (options) => {
4684
4934
  if (!changesUrl)
4685
4935
  return result;
4686
4936
  reportFormAbandonmentOnNavigation?.(departedUrl);
4687
- record();
4937
+ record(departedUrl, key);
4688
4938
  return result;
4689
4939
  };
4690
4940
  return () => {
@@ -4696,7 +4946,7 @@ var createBeacon = (options) => {
4696
4946
  if (location.href === recordedHistoryUrl)
4697
4947
  return;
4698
4948
  reportFormAbandonmentOnNavigation?.(recordedHistoryUrl);
4699
- record();
4949
+ record(recordedHistoryUrl, "popstate");
4700
4950
  };
4701
4951
  window.addEventListener("popstate", onPopState);
4702
4952
  cleanups.push(() => window.removeEventListener("popstate", onPopState));
@@ -4752,6 +5002,7 @@ var createBeacon = (options) => {
4752
5002
  captureException,
4753
5003
  captureMessage,
4754
5004
  close: async () => {
5005
+ closed = true;
4755
5006
  for (const cleanup of cleanups.splice(0, cleanups.length))
4756
5007
  cleanup();
4757
5008
  await flush(true);
@@ -4787,10 +5038,11 @@ export {
4787
5038
  createBeacon,
4788
5039
  getBeacon,
4789
5040
  initBeacon,
5041
+ isAutomatedBrowser,
4790
5042
  isKnownBeaconNoise,
4791
5043
  observeCapability,
4792
5044
  redactBeaconEvent
4793
5045
  };
4794
5046
 
4795
- //# debugId=777EFA57561DC75664756E2164756E21
5047
+ //# debugId=046F53651A60FDAB64756E2164756E21
4796
5048
  //# sourceMappingURL=index.js.map