@absolutejs/beacon 0.7.0-beta.10 → 0.7.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ This file is generated by `absolute-changelog` from the entries in
6
6
  `changelog/`. Edit an entry, not this file — and add new ones under
7
7
  `changelog/unreleased/`.
8
8
 
9
+ ## 0.7.0-beta.12 — 2026-09-27
10
+
11
+ ### Fixed
12
+
13
+ - **Stop TBT observation after its measurement window and clean up on close; ignore late vital delivery.** (`createBeacon`, `BEACON_SDK_VERSION`)
14
+
15
+ ## 0.7.0-beta.11 — 2026-09-27
16
+
17
+ ### Fixed
18
+
19
+ - **Do not promote presentation-only Event Timing waits when every overlapping animation frame explicitly reports zero blocking and no scripts. Preserve incidents with positive blocking, script activity, missing attribution, long handlers or meaningful input delay; Web Vitals collection is unchanged.** (`createBeacon`, `BEACON_SDK_VERSION`)
20
+
9
21
  ## 0.7.0-beta.10 — 2026-09-27
10
22
 
11
23
  ### Fixed
package/changelog.json CHANGED
@@ -1,35 +1,63 @@
1
1
  {
2
- "contract": 1,
3
- "name": "@absolutejs/beacon",
4
- "releases": [
5
- {
6
- "changes": [
7
- {
8
- "kind": "fixed",
9
- "summary": "Ignore wheel events cancelled by later handlers when detecting scroll jail, and capture bounded scroll geometry, overflow policy, direction and modal ownership for genuine immobility without changing issue grouping.",
10
- "symbols": [
11
- "createBeacon",
12
- "BEACON_SDK_VERSION"
13
- ]
14
- }
15
- ],
16
- "date": "2026-09-27",
17
- "version": "0.7.0-beta.10"
18
- },
19
- {
20
- "changes": [
21
- {
22
- "kind": "fixed",
23
- "summary": "Exclude known 1Password notification covers and retain request origins in network-failure diagnostics without credentials or query strings. Same-origin grouping remains stable across environments. Keep layout pixel measurements out of fingerprints and include geometry and sticky/fixed ancestor context in collision and occlusion reports. Read only browser-exposed XHR response headers to avoid unsafe-header console errors while preserving available trace correlation.",
24
- "symbols": [
25
- "createBeacon",
26
- "BeaconNetworkFailure",
27
- "BEACON_SDK_VERSION"
28
- ]
29
- }
30
- ],
31
- "date": "2026-09-27",
32
- "version": "0.7.0-beta.9"
33
- }
34
- ]
2
+ "contract": 1,
3
+ "name": "@absolutejs/beacon",
4
+ "releases": [
5
+ {
6
+ "changes": [
7
+ {
8
+ "kind": "fixed",
9
+ "summary": "Stop TBT observation after its measurement window and clean up on close; ignore late vital delivery.",
10
+ "symbols": [
11
+ "createBeacon",
12
+ "BEACON_SDK_VERSION"
13
+ ]
14
+ }
15
+ ],
16
+ "date": "2026-09-27",
17
+ "version": "0.7.0-beta.12"
18
+ },
19
+ {
20
+ "changes": [
21
+ {
22
+ "kind": "fixed",
23
+ "summary": "Do not promote presentation-only Event Timing waits when every overlapping animation frame explicitly reports zero blocking and no scripts. Preserve incidents with positive blocking, script activity, missing attribution, long handlers or meaningful input delay; Web Vitals collection is unchanged.",
24
+ "symbols": [
25
+ "createBeacon",
26
+ "BEACON_SDK_VERSION"
27
+ ]
28
+ }
29
+ ],
30
+ "date": "2026-09-27",
31
+ "version": "0.7.0-beta.11"
32
+ },
33
+ {
34
+ "changes": [
35
+ {
36
+ "kind": "fixed",
37
+ "summary": "Ignore wheel events cancelled by later handlers when detecting scroll jail, and capture bounded scroll geometry, overflow policy, direction and modal ownership for genuine immobility without changing issue grouping.",
38
+ "symbols": [
39
+ "createBeacon",
40
+ "BEACON_SDK_VERSION"
41
+ ]
42
+ }
43
+ ],
44
+ "date": "2026-09-27",
45
+ "version": "0.7.0-beta.10"
46
+ },
47
+ {
48
+ "changes": [
49
+ {
50
+ "kind": "fixed",
51
+ "summary": "Exclude known 1Password notification covers and retain request origins in network-failure diagnostics without credentials or query strings. Same-origin grouping remains stable across environments. Keep layout pixel measurements out of fingerprints and include geometry and sticky/fixed ancestor context in collision and occlusion reports. Read only browser-exposed XHR response headers to avoid unsafe-header console errors while preserving available trace correlation.",
52
+ "symbols": [
53
+ "createBeacon",
54
+ "BeaconNetworkFailure",
55
+ "BEACON_SDK_VERSION"
56
+ ]
57
+ }
58
+ ],
59
+ "date": "2026-09-27",
60
+ "version": "0.7.0-beta.9"
61
+ }
62
+ ]
35
63
  }
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.10";
28
+ export declare const BEACON_SDK_VERSION = "0.7.0-beta.12";
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
@@ -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.10";
202
+ var BEACON_SDK_VERSION = "0.7.0-beta.12";
203
203
  var inBrowser = () => typeof window !== "undefined";
204
204
  var newId = () => {
205
205
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
@@ -765,52 +765,77 @@ var TBT_GOOD_MS = 200;
765
765
  var TBT_POOR_MS = 600;
766
766
  var observeLongTasks = (report, navigationType) => {
767
767
  if (typeof PerformanceObserver === "undefined")
768
- return;
768
+ return () => {};
769
769
  const longTasks = [];
770
- let reported = false;
771
- try {
772
- const observer = new PerformanceObserver((list) => {
773
- const windowStart = performance.getEntriesByName("first-contentful-paint")[0]?.startTime ?? 0;
774
- const windowEnd = windowStart + TBT_WINDOW_MS;
775
- for (const entry of list.getEntries()) {
776
- if (entry.startTime < windowStart || entry.startTime >= windowEnd)
777
- continue;
778
- longTasks.push({
779
- duration: entry.duration,
780
- startTime: entry.startTime
781
- });
782
- }
770
+ let observer;
771
+ let timer;
772
+ let stopped = false;
773
+ const firstPaint = () => performance.getEntriesByName("first-contentful-paint")[0]?.startTime;
774
+ const collect = (entries) => {
775
+ if (stopped)
776
+ return;
777
+ const windowStart = firstPaint() ?? 0;
778
+ for (const entry of entries) {
779
+ if (entry.startTime < windowStart || entry.startTime >= windowStart + TBT_WINDOW_MS)
780
+ continue;
781
+ longTasks.push({ duration: entry.duration, startTime: entry.startTime });
782
+ }
783
+ };
784
+ const onVisibilityChange = () => {
785
+ if (document.visibilityState === "hidden")
786
+ flush();
787
+ };
788
+ const stop = () => {
789
+ stopped = true;
790
+ if (timer !== undefined)
791
+ clearTimeout(timer);
792
+ observer?.disconnect();
793
+ window.removeEventListener("visibilitychange", onVisibilityChange);
794
+ window.removeEventListener("pagehide", flush);
795
+ longTasks.length = 0;
796
+ };
797
+ const flush = () => {
798
+ if (stopped)
799
+ return;
800
+ collect(observer?.takeRecords() ?? []);
801
+ const paint = firstPaint();
802
+ const windowStart = paint ?? 0;
803
+ const tasks = longTasks.filter(({ startTime }) => startTime >= windowStart && startTime < windowStart + TBT_WINDOW_MS);
804
+ stop();
805
+ if (tasks.length === 0)
806
+ return;
807
+ const value = Math.round(tasks.reduce((total, { duration }) => total + Math.max(0, duration - LONG_TASK_MS), 0));
808
+ report({
809
+ attribution: {
810
+ measurementWindow: paint === undefined ? "navigation" : "FCP",
811
+ measurementWindowMs: TBT_WINDOW_MS
812
+ },
813
+ id: `tbt-${navigationType}-${TBT_WINDOW_MS}-${value}`,
814
+ name: "TBT",
815
+ navigationType,
816
+ rating: value <= TBT_GOOD_MS ? "good" : value >= TBT_POOR_MS ? "poor" : "needs-improvement",
817
+ value
783
818
  });
819
+ };
820
+ const finishWindow = () => {
821
+ if (stopped)
822
+ return;
823
+ const remaining = (firstPaint() ?? 0) + TBT_WINDOW_MS - performance.now();
824
+ if (remaining > 0)
825
+ timer = setTimeout(finishWindow, remaining);
826
+ else
827
+ flush();
828
+ };
829
+ try {
830
+ observer = new PerformanceObserver((list) => collect(list.getEntries()));
784
831
  observer.observe({ buffered: true, type: "longtask" });
785
- const flush = () => {
786
- if (reported)
787
- return;
788
- const firstContentfulPaint = performance.getEntriesByName("first-contentful-paint")[0]?.startTime;
789
- const windowStart = firstContentfulPaint ?? 0;
790
- const windowEnd = windowStart + TBT_WINDOW_MS;
791
- const tasksInWindow = longTasks.filter(({ startTime }) => startTime >= windowStart && startTime < windowEnd);
792
- if (tasksInWindow.length === 0)
793
- return;
794
- reported = true;
795
- const value = Math.round(tasksInWindow.reduce((total, { duration }) => total + Math.max(0, duration - LONG_TASK_MS), 0));
796
- report({
797
- attribution: {
798
- measurementWindow: firstContentfulPaint === undefined ? "navigation" : "FCP",
799
- measurementWindowMs: TBT_WINDOW_MS
800
- },
801
- id: `tbt-${navigationType}-${TBT_WINDOW_MS}-${value}`,
802
- name: "TBT",
803
- navigationType,
804
- rating: value <= TBT_GOOD_MS ? "good" : value >= TBT_POOR_MS ? "poor" : "needs-improvement",
805
- value
806
- });
807
- };
808
- addEventListener("visibilitychange", () => {
809
- if (document.visibilityState === "hidden")
810
- flush();
811
- });
812
- addEventListener("pagehide", flush);
813
- } catch {}
832
+ window.addEventListener("visibilitychange", onVisibilityChange);
833
+ window.addEventListener("pagehide", flush);
834
+ timer = setTimeout(finishWindow, Math.max(0, (firstPaint() ?? 0) + TBT_WINDOW_MS - performance.now()));
835
+ } catch {
836
+ stop();
837
+ }
838
+ return stop;
814
839
  };
815
840
  var isVitalName = (name) => VITAL_NAMES.has(name);
816
841
  var vitalAttribution = (value) => {
@@ -1070,11 +1095,13 @@ var createBeacon = (options) => {
1070
1095
  }
1071
1096
  return false;
1072
1097
  };
1098
+ const cleanups = [];
1099
+ let closed = false;
1073
1100
  const vitalsOptions = options.vitals === undefined || options.vitals === false ? null : options.vitals === true ? {} : options.vitals;
1074
1101
  if (vitalsOptions !== null) {
1075
1102
  const vitalsEndpoint = vitalsOptions.endpoint ?? "/ingest/vitals";
1076
1103
  const reportVital = (metric) => {
1077
- if (!isVitalName(metric.name))
1104
+ if (closed || !isVitalName(metric.name))
1078
1105
  return;
1079
1106
  const replayId = options.getReplayId?.();
1080
1107
  const traceId = options.getTraceId?.();
@@ -1117,17 +1144,19 @@ var createBeacon = (options) => {
1117
1144
  if (vitalsOptions.webVitals !== undefined) {
1118
1145
  observeWebVitals(vitalsOptions.webVitals, reportVital);
1119
1146
  } else {
1120
- loadWebVitals().then((webVitals) => observeWebVitals(webVitals, reportVital)).catch(() => {
1147
+ loadWebVitals().then((webVitals) => {
1148
+ if (!closed)
1149
+ observeWebVitals(webVitals, reportVital);
1150
+ }).catch(() => {
1121
1151
  console.warn("[beacon] web-vitals not installed; vitals disabled. `bun add web-vitals`.");
1122
1152
  });
1123
1153
  }
1124
1154
  const navigationEntry = performance.getEntriesByType("navigation")[0];
1125
1155
  const navigationType = typeof PerformanceNavigationTiming !== "undefined" && navigationEntry instanceof PerformanceNavigationTiming ? navigationEntry.type : "navigate";
1126
- observeLongTasks(reportVital, navigationType);
1156
+ cleanups.push(observeLongTasks(reportVital, navigationType));
1127
1157
  }
1128
1158
  const buffer = [];
1129
1159
  const breadcrumbs = [];
1130
- const cleanups = [];
1131
1160
  const pendingClickCleanups = new Set;
1132
1161
  cleanups.push(() => {
1133
1162
  for (const cleanup of pendingClickCleanups)
@@ -3192,7 +3221,9 @@ var createBeacon = (options) => {
3192
3221
  recordBlockingFrames(blockingObserver.takeRecords());
3193
3222
  }
3194
3223
  const interactionEnd = entry.startTime + entry.duration;
3195
- const overlappingFrame = blockingFrames.filter((frame) => frame.startTime < interactionEnd && frame.startTime + frame.duration > entry.startTime).sort((left, right) => {
3224
+ const overlappingFrames = blockingFrames.filter((frame) => frame.startTime < interactionEnd && frame.startTime + frame.duration > entry.startTime);
3225
+ const onlyIdleFrames = overlappingFrames.length > 0 && overlappingFrames.every((frame) => frame.entryType === "long-animation-frame" && frame.blockingDuration === 0 && Array.isArray(frame.scripts) && frame.scripts.length === 0);
3226
+ const overlappingFrame = overlappingFrames.sort((left, right) => {
3196
3227
  const leftBlocking = left.blockingDuration ?? Math.max(0, left.duration - LONG_TASK_MS);
3197
3228
  const rightBlocking = right.blockingDuration ?? Math.max(0, right.duration - LONG_TASK_MS);
3198
3229
  return rightBlocking - leftBlocking;
@@ -3202,7 +3233,7 @@ var createBeacon = (options) => {
3202
3233
  const processingDurationMs = hasPhaseTiming ? Math.round(Math.max(0, entry.processingEnd - entry.processingStart)) : undefined;
3203
3234
  const presentationDelayMs = hasPhaseTiming ? Math.round(Math.max(0, interactionEnd - entry.processingEnd)) : undefined;
3204
3235
  const inputDelayMs = hasPhaseTiming ? Math.round(Math.max(0, entry.processingStart - entry.startTime)) : undefined;
3205
- if (overlappingFrame === undefined && processingDurationMs !== undefined && processingDurationMs <= 16 && presentationDelayMs !== undefined && presentationDelayMs >= minimum)
3236
+ if ((overlappingFrame === undefined || onlyIdleFrames && inputDelayMs !== undefined && inputDelayMs < minimum) && processingDurationMs !== undefined && processingDurationMs <= 16 && presentationDelayMs !== undefined && presentationDelayMs >= minimum)
3206
3237
  continue;
3207
3238
  if (blockingObserver !== undefined && overlappingFrame === undefined && inputDelayMs !== undefined && inputDelayMs >= minimum && processingDurationMs !== undefined && processingDurationMs <= 16 && presentationDelayMs !== undefined && presentationDelayMs < minimum)
3208
3239
  continue;
@@ -4875,6 +4906,7 @@ var createBeacon = (options) => {
4875
4906
  captureException,
4876
4907
  captureMessage,
4877
4908
  close: async () => {
4909
+ closed = true;
4878
4910
  for (const cleanup of cleanups.splice(0, cleanups.length))
4879
4911
  cleanup();
4880
4912
  await flush(true);
@@ -4916,5 +4948,5 @@ export {
4916
4948
  redactBeaconEvent
4917
4949
  };
4918
4950
 
4919
- //# debugId=F6C0F80E961648E164756E2164756E21
4951
+ //# debugId=508A7FF4EEF1B17D64756E2164756E21
4920
4952
  //# sourceMappingURL=index.js.map