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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -225,7 +225,10 @@ entry point does not initialize Beacon, send telemetry, or import the main SDK.
225
225
  Instability names shifted elements. When the browser supplies no shifted
226
226
  node, Beacon retains startup/runtime phase plus recent interaction type,
227
227
  target, and age; stable provenance separates issue grouping while volatile
228
- age remains diagnostic-only. Successful HTTP responses can be
228
+ age remains diagnostic-only. Layout shifts during the first two seconds after
229
+ an accepted `pushState`, `replaceState`, or `popstate` route change are treated
230
+ as route settling; later shifts retain navigation type, source, destination,
231
+ and age for diagnosis. Successful HTTP responses can be
229
232
  classified through the host-owned `instrument.classifyResponse` callback for
230
233
  GraphQL-style errors. Selected HTTP 4xx/5xx responses can be promoted through
231
234
  the opt-in `instrument.classifyErrorResponse` callback when application context
package/dist/early.js CHANGED
@@ -86,6 +86,7 @@ var installEarlyLayoutShiftBuffer = () => {
86
86
  "pointerdown",
87
87
  "submit"
88
88
  ];
89
+ observer.observe({ buffered: true, type: "layout-shift" });
89
90
  for (const event of interactionEvents)
90
91
  window.addEventListener(event, recordInteraction, true);
91
92
  window.addEventListener("resize", recordResize);
@@ -105,7 +106,6 @@ var installEarlyLayoutShiftBuffer = () => {
105
106
  recordEntries,
106
107
  resizeTimes
107
108
  };
108
- observer.observe({ buffered: true, type: "layout-shift" });
109
109
  } catch {}
110
110
  };
111
111
  var consumeEarlyLayoutShiftBuffer = () => {
@@ -130,5 +130,5 @@ export {
130
130
  installEarlyLayoutShiftBuffer
131
131
  };
132
132
 
133
- //# debugId=197271DDFBB42C0164756E2164756E21
133
+ //# debugId=FBFFEFDD72BD00F564756E2164756E21
134
134
  //# sourceMappingURL=early.js.map
package/dist/early.js.map CHANGED
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/early.ts"],
4
4
  "sourcesContent": [
5
- "/** Lightweight pre-hydration layout-shift recorder. */\n\nexport type EarlyLayoutShiftRect = {\n bottom: number;\n height: number;\n left: number;\n right: number;\n top: number;\n width: number;\n x: number;\n y: number;\n};\n\nexport type EarlyLayoutShiftViewport = {\n documentHeight: number;\n documentWidth: number;\n innerHeight: number;\n innerWidth: number;\n visualHeight?: number;\n visualOffsetLeft?: number;\n visualOffsetTop?: number;\n visualScale?: number;\n visualWidth?: number;\n};\n\nexport type EarlyLayoutShiftSource = {\n currentRect?: EarlyLayoutShiftRect;\n node?: Node;\n previousRect?: EarlyLayoutShiftRect;\n target: string;\n};\n\nexport type EarlyLayoutShiftEntry = {\n documentReadyState: DocumentReadyState;\n hadRecentInput: boolean;\n observedAt: number;\n sources: EarlyLayoutShiftSource[];\n startTime: number;\n value: number;\n viewport: EarlyLayoutShiftViewport;\n};\n\nexport type EarlyLayoutShiftBuffer = {\n entries: EarlyLayoutShiftEntry[];\n interactionTimes: number[];\n observerStartedAt: number;\n resizeTimes: number[];\n};\n\ntype LayoutShiftSourceLike = {\n currentRect?: DOMRectReadOnly;\n node?: Node | null;\n previousRect?: DOMRectReadOnly;\n};\ntype LayoutShiftEntryLike = PerformanceEntry & {\n hadRecentInput?: boolean;\n sources?: LayoutShiftSourceLike[];\n value?: number;\n};\ntype InstalledEarlyLayoutShiftBuffer = EarlyLayoutShiftBuffer & {\n cleanup: () => void;\n observer: PerformanceObserver;\n recordEntries: (entries: PerformanceEntry[]) => void;\n};\n\ndeclare global {\n interface Window {\n __absoluteBeaconEarlyLayoutShift?: InstalledEarlyLayoutShiftBuffer;\n }\n}\n\nconst HISTORY_LIMIT = 16;\nconst ENTRY_LIMIT = 50;\nconst now = (): number =>\n typeof performance === \"undefined\" ? 0 : performance.now();\n\nconst describeNode = (node: Node | null | undefined): string => {\n if (!(node instanceof Element)) return \"unknown\";\n const id = node.id === \"\" ? \"\" : `#${node.id}`;\n const classes = [...node.classList]\n .slice(0, 3)\n .map((name) => `.${name}`)\n .join(\"\");\n return `${node.tagName.toLowerCase()}${id}${classes}`;\n};\n\nconst copyRect = (\n rect: DOMRectReadOnly | undefined,\n): EarlyLayoutShiftRect | undefined =>\n rect === undefined\n ? undefined\n : {\n bottom: rect.bottom,\n height: rect.height,\n left: rect.left,\n right: rect.right,\n top: rect.top,\n width: rect.width,\n x: rect.x,\n y: rect.y,\n };\n\nconst viewportSnapshot = (): EarlyLayoutShiftViewport => {\n const visual = window.visualViewport;\n return {\n documentHeight: document.documentElement.scrollHeight,\n documentWidth: document.documentElement.scrollWidth,\n innerHeight: window.innerHeight,\n innerWidth: window.innerWidth,\n ...(visual == null\n ? {}\n : {\n visualHeight: visual.height,\n visualOffsetLeft: visual.offsetLeft,\n visualOffsetTop: visual.offsetTop,\n visualScale: visual.scale,\n visualWidth: visual.width,\n }),\n };\n};\n\nconst appendLimited = (values: number[], value: number): void => {\n values.push(value);\n if (values.length > HISTORY_LIMIT)\n values.splice(0, values.length - HISTORY_LIMIT);\n};\n\n/** Install once from the application's synchronous entry module. SSR-safe. */\nexport const installEarlyLayoutShiftBuffer = (): void => {\n if (\n typeof window === \"undefined\" ||\n typeof document === \"undefined\" ||\n typeof PerformanceObserver === \"undefined\" ||\n window.__absoluteBeaconEarlyLayoutShift !== undefined\n )\n return;\n\n const interactionTimes: number[] = [];\n const resizeTimes: number[] = [];\n const entries: EarlyLayoutShiftEntry[] = [];\n const recordInteraction = (): void => appendLimited(interactionTimes, now());\n const recordResize = (): void => appendLimited(resizeTimes, now());\n const recordEntries = (rawEntries: PerformanceEntry[]): void => {\n for (const raw of rawEntries) {\n const entry = raw as LayoutShiftEntryLike;\n entries.push({\n documentReadyState: document.readyState,\n hadRecentInput: entry.hadRecentInput === true,\n observedAt: now(),\n sources: (entry.sources ?? []).slice(0, 5).map((source) => ({\n ...(source.currentRect === undefined\n ? {}\n : { currentRect: copyRect(source.currentRect) }),\n ...(source.node === undefined || source.node === null\n ? {}\n : { node: source.node }),\n ...(source.previousRect === undefined\n ? {}\n : { previousRect: copyRect(source.previousRect) }),\n target: describeNode(source.node),\n })),\n startTime: entry.startTime,\n value: entry.value ?? 0,\n viewport: viewportSnapshot(),\n });\n }\n if (entries.length > ENTRY_LIMIT)\n entries.splice(0, entries.length - ENTRY_LIMIT);\n };\n\n try {\n const observerStartedAt = now();\n const observer = new PerformanceObserver((list) =>\n recordEntries(list.getEntries()),\n );\n const interactionEvents = [\n \"click\",\n \"keydown\",\n \"pointerdown\",\n \"submit\",\n ] as const;\n for (const event of interactionEvents)\n window.addEventListener(event, recordInteraction, true);\n window.addEventListener(\"resize\", recordResize);\n window.visualViewport?.addEventListener(\"resize\", recordResize);\n const cleanup = (): void => {\n for (const event of interactionEvents)\n window.removeEventListener(event, recordInteraction, true);\n window.removeEventListener(\"resize\", recordResize);\n window.visualViewport?.removeEventListener(\"resize\", recordResize);\n };\n window.__absoluteBeaconEarlyLayoutShift = {\n cleanup,\n entries,\n interactionTimes,\n observer,\n observerStartedAt,\n recordEntries,\n resizeTimes,\n };\n observer.observe({ buffered: true, type: \"layout-shift\" });\n } catch {\n // Unsupported browsers must not have their startup affected by telemetry.\n }\n};\n\n/** Consume and remove the pre-hydration recorder, if one was installed. */\nexport const consumeEarlyLayoutShiftBuffer = ():\n EarlyLayoutShiftBuffer | undefined => {\n if (typeof window === \"undefined\") return undefined;\n const installed = window.__absoluteBeaconEarlyLayoutShift;\n if (installed === undefined) return undefined;\n installed.recordEntries(installed.observer.takeRecords());\n installed.observer.disconnect();\n installed.cleanup();\n delete window.__absoluteBeaconEarlyLayoutShift;\n return {\n entries: installed.entries,\n interactionTimes: installed.interactionTimes,\n observerStartedAt: installed.observerStartedAt,\n resizeTimes: installed.resizeTimes,\n };\n};\n"
5
+ "/** Lightweight pre-hydration layout-shift recorder. */\n\nexport type EarlyLayoutShiftRect = {\n bottom: number;\n height: number;\n left: number;\n right: number;\n top: number;\n width: number;\n x: number;\n y: number;\n};\n\nexport type EarlyLayoutShiftViewport = {\n documentHeight: number;\n documentWidth: number;\n innerHeight: number;\n innerWidth: number;\n visualHeight?: number;\n visualOffsetLeft?: number;\n visualOffsetTop?: number;\n visualScale?: number;\n visualWidth?: number;\n};\n\nexport type EarlyLayoutShiftSource = {\n currentRect?: EarlyLayoutShiftRect;\n node?: Node;\n previousRect?: EarlyLayoutShiftRect;\n target: string;\n};\n\nexport type EarlyLayoutShiftEntry = {\n documentReadyState: DocumentReadyState;\n hadRecentInput: boolean;\n observedAt: number;\n sources: EarlyLayoutShiftSource[];\n startTime: number;\n value: number;\n viewport: EarlyLayoutShiftViewport;\n};\n\nexport type EarlyLayoutShiftBuffer = {\n entries: EarlyLayoutShiftEntry[];\n interactionTimes: number[];\n observerStartedAt: number;\n resizeTimes: number[];\n};\n\ntype LayoutShiftSourceLike = {\n currentRect?: DOMRectReadOnly;\n node?: Node | null;\n previousRect?: DOMRectReadOnly;\n};\ntype LayoutShiftEntryLike = PerformanceEntry & {\n hadRecentInput?: boolean;\n sources?: LayoutShiftSourceLike[];\n value?: number;\n};\ntype InstalledEarlyLayoutShiftBuffer = EarlyLayoutShiftBuffer & {\n cleanup: () => void;\n observer: PerformanceObserver;\n recordEntries: (entries: PerformanceEntry[]) => void;\n};\n\ndeclare global {\n interface Window {\n __absoluteBeaconEarlyLayoutShift?: InstalledEarlyLayoutShiftBuffer;\n }\n}\n\nconst HISTORY_LIMIT = 16;\nconst ENTRY_LIMIT = 50;\nconst now = (): number =>\n typeof performance === \"undefined\" ? 0 : performance.now();\n\nconst describeNode = (node: Node | null | undefined): string => {\n if (!(node instanceof Element)) return \"unknown\";\n const id = node.id === \"\" ? \"\" : `#${node.id}`;\n const classes = [...node.classList]\n .slice(0, 3)\n .map((name) => `.${name}`)\n .join(\"\");\n return `${node.tagName.toLowerCase()}${id}${classes}`;\n};\n\nconst copyRect = (\n rect: DOMRectReadOnly | undefined,\n): EarlyLayoutShiftRect | undefined =>\n rect === undefined\n ? undefined\n : {\n bottom: rect.bottom,\n height: rect.height,\n left: rect.left,\n right: rect.right,\n top: rect.top,\n width: rect.width,\n x: rect.x,\n y: rect.y,\n };\n\nconst viewportSnapshot = (): EarlyLayoutShiftViewport => {\n const visual = window.visualViewport;\n return {\n documentHeight: document.documentElement.scrollHeight,\n documentWidth: document.documentElement.scrollWidth,\n innerHeight: window.innerHeight,\n innerWidth: window.innerWidth,\n ...(visual == null\n ? {}\n : {\n visualHeight: visual.height,\n visualOffsetLeft: visual.offsetLeft,\n visualOffsetTop: visual.offsetTop,\n visualScale: visual.scale,\n visualWidth: visual.width,\n }),\n };\n};\n\nconst appendLimited = (values: number[], value: number): void => {\n values.push(value);\n if (values.length > HISTORY_LIMIT)\n values.splice(0, values.length - HISTORY_LIMIT);\n};\n\n/** Install once from the application's synchronous entry module. SSR-safe. */\nexport const installEarlyLayoutShiftBuffer = (): void => {\n if (\n typeof window === \"undefined\" ||\n typeof document === \"undefined\" ||\n typeof PerformanceObserver === \"undefined\" ||\n window.__absoluteBeaconEarlyLayoutShift !== undefined\n )\n return;\n\n const interactionTimes: number[] = [];\n const resizeTimes: number[] = [];\n const entries: EarlyLayoutShiftEntry[] = [];\n const recordInteraction = (): void => appendLimited(interactionTimes, now());\n const recordResize = (): void => appendLimited(resizeTimes, now());\n const recordEntries = (rawEntries: PerformanceEntry[]): void => {\n for (const raw of rawEntries) {\n const entry = raw as LayoutShiftEntryLike;\n entries.push({\n documentReadyState: document.readyState,\n hadRecentInput: entry.hadRecentInput === true,\n observedAt: now(),\n sources: (entry.sources ?? []).slice(0, 5).map((source) => ({\n ...(source.currentRect === undefined\n ? {}\n : { currentRect: copyRect(source.currentRect) }),\n ...(source.node === undefined || source.node === null\n ? {}\n : { node: source.node }),\n ...(source.previousRect === undefined\n ? {}\n : { previousRect: copyRect(source.previousRect) }),\n target: describeNode(source.node),\n })),\n startTime: entry.startTime,\n value: entry.value ?? 0,\n viewport: viewportSnapshot(),\n });\n }\n if (entries.length > ENTRY_LIMIT)\n entries.splice(0, entries.length - ENTRY_LIMIT);\n };\n\n try {\n const observerStartedAt = now();\n const observer = new PerformanceObserver((list) =>\n recordEntries(list.getEntries()),\n );\n const interactionEvents = [\n \"click\",\n \"keydown\",\n \"pointerdown\",\n \"submit\",\n ] as const;\n observer.observe({ buffered: true, type: \"layout-shift\" });\n for (const event of interactionEvents)\n window.addEventListener(event, recordInteraction, true);\n window.addEventListener(\"resize\", recordResize);\n window.visualViewport?.addEventListener(\"resize\", recordResize);\n const cleanup = (): void => {\n for (const event of interactionEvents)\n window.removeEventListener(event, recordInteraction, true);\n window.removeEventListener(\"resize\", recordResize);\n window.visualViewport?.removeEventListener(\"resize\", recordResize);\n };\n window.__absoluteBeaconEarlyLayoutShift = {\n cleanup,\n entries,\n interactionTimes,\n observer,\n observerStartedAt,\n recordEntries,\n resizeTimes,\n };\n } catch {\n // Unsupported browsers must not have their startup affected by telemetry.\n }\n};\n\n/** Consume and remove the pre-hydration recorder, if one was installed. */\nexport const consumeEarlyLayoutShiftBuffer = ():\n EarlyLayoutShiftBuffer | undefined => {\n if (typeof window === \"undefined\") return undefined;\n const installed = window.__absoluteBeaconEarlyLayoutShift;\n if (installed === undefined) return undefined;\n installed.recordEntries(installed.observer.takeRecords());\n installed.observer.disconnect();\n installed.cleanup();\n delete window.__absoluteBeaconEarlyLayoutShift;\n return {\n entries: installed.entries,\n interactionTimes: installed.interactionTimes,\n observerStartedAt: installed.observerStartedAt,\n resizeTimes: installed.resizeTimes,\n };\n};\n"
6
6
  ],
7
- "mappings": ";;;;;;;;;AAuEA,IAAM,gBAAgB;AACtB,IAAM,cAAc;AACpB,IAAM,MAAM,MACV,OAAO,gBAAgB,cAAc,IAAI,YAAY,IAAI;AAE3D,IAAM,eAAe,CAAC,SAA0C;AAAA,EAC9D,IAAI,EAAE,gBAAgB;AAAA,IAAU,OAAO;AAAA,EACvC,MAAM,KAAK,KAAK,OAAO,KAAK,KAAK,IAAI,KAAK;AAAA,EAC1C,MAAM,UAAU,CAAC,GAAG,KAAK,SAAS,EAC/B,MAAM,GAAG,CAAC,EACV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AAgB,oBAAoB,UAAU,YAAY;AAAA;AAAA,IAEnE,OAAO,mCAAmC;AAAA,MACxC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,MAAM;AAAA;AAMH,IAAM,gCAAgC,MACL;AAAA,EACtC,IAAI,OAAO,WAAW;AAAA,IAAa;AAAA,EACnC,MAAM,YAAY,OAAO;AAAA,EACzB,IAAI,cAAc;AAAA,IAAW;AAAA,EAC7B,UAAU,cAAc,UAAU,SAAS,YAAY,CAAC;AAAA,EACxD,UAAU,SAAS,WAAW;AAAA,EAC9B,UAAU,QAAQ;AAAA,EAClB,OAAO,OAAO;AAAA,EACd,OAAO;AAAA,IACL,SAAS,UAAU;AAAA,IACnB,kBAAkB,UAAU;AAAA,IAC5B,mBAAmB,UAAU;AAAA,IAC7B,aAAa,UAAU;AAAA,EACzB;AAAA;",
8
+ "debugId": "FBFFEFDD72BD00F564756E2164756E21",
9
9
  "names": []
10
10
  }
package/dist/index.d.ts CHANGED
@@ -25,7 +25,7 @@ export type BeaconLevel = "fatal" | "error" | "warning" | "info";
25
25
  /** Response header used to correlate a browser signal with its server request. */
26
26
  export declare const BEACON_TRACE_HEADER = "x-absolute-trace-id";
27
27
  /** Beacon package version retained with every captured event. */
28
- export declare const BEACON_SDK_VERSION = "0.7.0-beta.2";
28
+ export declare const BEACON_SDK_VERSION = "0.7.0-beta.4";
29
29
  /** Arbitrary event tags, with Beacon's reserved `signal` tag type-checked. */
30
30
  export type BeaconTags = Record<string, string> & {
31
31
  signal?: BeaconSignal;
package/dist/index.js CHANGED
@@ -157,6 +157,7 @@ var installEarlyLayoutShiftBuffer = () => {
157
157
  "pointerdown",
158
158
  "submit"
159
159
  ];
160
+ observer.observe({ buffered: true, type: "layout-shift" });
160
161
  for (const event of interactionEvents)
161
162
  window.addEventListener(event, recordInteraction, true);
162
163
  window.addEventListener("resize", recordResize);
@@ -176,7 +177,6 @@ var installEarlyLayoutShiftBuffer = () => {
176
177
  recordEntries,
177
178
  resizeTimes
178
179
  };
179
- observer.observe({ buffered: true, type: "layout-shift" });
180
180
  } catch {}
181
181
  };
182
182
  var consumeEarlyLayoutShiftBuffer = () => {
@@ -199,7 +199,7 @@ var consumeEarlyLayoutShiftBuffer = () => {
199
199
 
200
200
  // src/index.ts
201
201
  var BEACON_TRACE_HEADER = "x-absolute-trace-id";
202
- var BEACON_SDK_VERSION = "0.7.0-beta.2";
202
+ var BEACON_SDK_VERSION = "0.7.0-beta.4";
203
203
  var inBrowser = () => typeof window !== "undefined";
204
204
  var newId = () => {
205
205
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
@@ -631,6 +631,10 @@ var VOLATILE_SIGNAL_TAGS = new Set([
631
631
  "layoutShiftSources",
632
632
  "layoutShiftStartTimeMs",
633
633
  "newestRelease",
634
+ "navigationAgeMs",
635
+ "navigationFrom",
636
+ "navigationTo",
637
+ "navigationType",
634
638
  "obscuredPx",
635
639
  "presentationDelayMs",
636
640
  "processingDurationMs",
@@ -952,6 +956,7 @@ var createBeacon = (options) => {
952
956
  const FORM_FRUSTRATION_THRESHOLD = 3;
953
957
  const FORM_FRUSTRATION_WINDOW_MS = 60000;
954
958
  const LAYOUT_SHIFT_RECENT_INTERACTION_MS = 500;
959
+ const LAYOUT_SHIFT_SPA_NAVIGATION_SETTLE_MS = 2000;
955
960
  const LAYOUT_SHIFT_INTERACTION_PROVENANCE_MS = 1e4;
956
961
  const LAYOUT_SHIFT_VIEWPORT_RESIZE_SETTLE_MS = 500;
957
962
  const VIEWPORT_RESIZE_HISTORY_LIMIT = 8;
@@ -982,6 +987,7 @@ var createBeacon = (options) => {
982
987
  let pageLifecycleGeneration = 0;
983
988
  let pageRestoredAt;
984
989
  let recentInteraction;
990
+ let recentNavigation;
985
991
  let reportErrorClick = null;
986
992
  const reportCapturedErrorClick = (error, tags2) => {
987
993
  if (filterKnownNoise && isKnownBeaconNoise({
@@ -2948,11 +2954,13 @@ var createBeacon = (options) => {
2948
2954
  ];
2949
2955
  const interactionAgeMs = interactionTimes.map((interactionAt) => entry.startTime - interactionAt).filter((age) => age >= 0).sort((left, right) => left - right)[0];
2950
2956
  const beaconSawRecentInput = interactionAgeMs !== undefined && interactionAgeMs <= LAYOUT_SHIFT_RECENT_INTERACTION_MS;
2957
+ const navigationAgeMs = recentNavigation === undefined ? undefined : entry.startTime - recentNavigation.performanceAt;
2958
+ const navigationSettling = navigationAgeMs !== undefined && navigationAgeMs >= 0 && navigationAgeMs <= LAYOUT_SHIFT_SPA_NAVIGATION_SETTLE_MS;
2951
2959
  const resizeAdjacent = viewportResizeTimes.some((resizedAt) => {
2952
2960
  const resizeAgeMs = entry.startTime - resizedAt;
2953
2961
  return resizeAgeMs >= 0 && resizeAgeMs <= LAYOUT_SHIFT_VIEWPORT_RESIZE_SETTLE_MS;
2954
2962
  });
2955
- if (entry.hadRecentInput || beaconSawRecentInput || resizeAdjacent || mobileKeyboardViewportActive() || entry.value < minimum)
2963
+ if (entry.hadRecentInput || beaconSawRecentInput || navigationSettling || resizeAdjacent || mobileKeyboardViewportActive() || entry.value < minimum)
2956
2964
  return;
2957
2965
  const sourceElements = entry.sources.map(({ node }) => node instanceof Element ? node : undefined).filter((node) => node !== undefined);
2958
2966
  if (sourceElements.length > 0 && sourceElements.every((node) => node.closest(`[${BEACON_ATTRIBUTE.LAYOUT_SHIFT}="allow"]`) !== null))
@@ -2980,6 +2988,12 @@ var createBeacon = (options) => {
2980
2988
  interactionType: interactionProvenance.type
2981
2989
  }
2982
2990
  } : {},
2991
+ ...recentNavigation === undefined || navigationAgeMs === undefined || navigationAgeMs < 0 || navigationAgeMs > LAYOUT_SHIFT_INTERACTION_PROVENANCE_MS ? {} : {
2992
+ navigationAgeMs: String(Math.round(navigationAgeMs)),
2993
+ navigationFrom: recentNavigation.from,
2994
+ navigationTo: recentNavigation.to,
2995
+ navigationType: recentNavigation.type
2996
+ },
2983
2997
  layoutShiftBuffered: String(entry.buffered),
2984
2998
  layoutShiftObservedAtMs: String(Math.round(entry.observedAt)),
2985
2999
  layoutShiftObserverStartedAtMs: String(Math.round(entry.observerStartedAt)),
@@ -4658,11 +4672,17 @@ var createBeacon = (options) => {
4658
4672
  }
4659
4673
  if (instrument.history !== false && typeof history !== "undefined") {
4660
4674
  let recordedHistoryUrl = location.href;
4661
- const record = () => {
4675
+ const record = (from, type) => {
4662
4676
  addBreadcrumb({
4663
4677
  message: `navigate ${location.pathname}${location.search}`,
4664
4678
  type: "navigation"
4665
4679
  });
4680
+ recentNavigation = {
4681
+ from: shortUrl(from),
4682
+ performanceAt: performance.now(),
4683
+ to: shortUrl(location.href),
4684
+ type
4685
+ };
4666
4686
  recordedHistoryUrl = location.href;
4667
4687
  overflowScanOnNavigation?.();
4668
4688
  };
@@ -4684,7 +4704,7 @@ var createBeacon = (options) => {
4684
4704
  if (!changesUrl)
4685
4705
  return result;
4686
4706
  reportFormAbandonmentOnNavigation?.(departedUrl);
4687
- record();
4707
+ record(departedUrl, key);
4688
4708
  return result;
4689
4709
  };
4690
4710
  return () => {
@@ -4696,7 +4716,7 @@ var createBeacon = (options) => {
4696
4716
  if (location.href === recordedHistoryUrl)
4697
4717
  return;
4698
4718
  reportFormAbandonmentOnNavigation?.(recordedHistoryUrl);
4699
- record();
4719
+ record(recordedHistoryUrl, "popstate");
4700
4720
  };
4701
4721
  window.addEventListener("popstate", onPopState);
4702
4722
  cleanups.push(() => window.removeEventListener("popstate", onPopState));
@@ -4792,5 +4812,5 @@ export {
4792
4812
  redactBeaconEvent
4793
4813
  };
4794
4814
 
4795
- //# debugId=777EFA57561DC75664756E2164756E21
4815
+ //# debugId=A0B643E313B5380864756E2164756E21
4796
4816
  //# sourceMappingURL=index.js.map