@absolutejs/beacon 0.7.0-beta.24 → 0.7.0-beta.25
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 +6 -0
- package/README.md +12 -0
- package/changelog.json +13 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +77 -4
- package/dist/index.js.map +5 -4
- package/dist/pageLifecycle.d.ts +21 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,12 @@ 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.25 — 2026-11-21
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **Retain bounded content-free page lifecycle and visibility context on errors and vitals, and guard missing browser policy report types.** (`BEACON_SDK_VERSION`)
|
|
14
|
+
|
|
9
15
|
## 0.7.0-beta.24 — 2026-11-17
|
|
10
16
|
|
|
11
17
|
### Fixed
|
package/README.md
CHANGED
|
@@ -398,3 +398,15 @@ Validation: `bun test tests/outbox.test.ts` covers restart recovery, unchanged
|
|
|
398
398
|
retry IDs, acknowledgement mismatch, overlapping flushes, capacity/age limits,
|
|
399
399
|
timeouts and quota failure. Exercised by Hello World's real browser offline /
|
|
400
400
|
reload / retry workflow.
|
|
401
|
+
|
|
402
|
+
### Page lifecycle diagnostics
|
|
403
|
+
|
|
404
|
+
Errors include `extra.pageLifecycle`; vital samples include
|
|
405
|
+
`attribution.pageLifecycle`. These content-free snapshots record initial/current
|
|
406
|
+
visibility, readiness, observed hidden duration, visibility changes, back/forward
|
|
407
|
+
cache restores, pagehide state, and at most eight recent transitions. Times are
|
|
408
|
+
monotonic milliseconds since observation began. They do not reconstruct history
|
|
409
|
+
before Beacon initialized or prove that a high paint value meant a blank page.
|
|
410
|
+
No page content, user identifiers, extra request, or polling timer is added.
|
|
411
|
+
Hosts using strict attribution schemas must allow the optional `pageLifecycle`
|
|
412
|
+
object to retain this context. `close()` removes its listeners.
|
package/changelog.json
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
"contract": 1,
|
|
3
3
|
"name": "@absolutejs/beacon",
|
|
4
4
|
"releases": [
|
|
5
|
+
{
|
|
6
|
+
"changes": [
|
|
7
|
+
{
|
|
8
|
+
"kind": "fixed",
|
|
9
|
+
"summary": "Retain bounded content-free page lifecycle and visibility context on errors and vitals, and guard missing browser policy report types.",
|
|
10
|
+
"symbols": [
|
|
11
|
+
"BEACON_SDK_VERSION"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"date": "2026-11-21",
|
|
16
|
+
"version": "0.7.0-beta.25"
|
|
17
|
+
},
|
|
5
18
|
{
|
|
6
19
|
"changes": [
|
|
7
20
|
{
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type BeaconLevel = "fatal" | "error" | "warning" | "info";
|
|
|
5
5
|
/** Response header used to correlate a browser signal with its server request. */
|
|
6
6
|
export declare const BEACON_TRACE_HEADER = "x-absolute-trace-id";
|
|
7
7
|
/** Beacon package version retained with every captured event. */
|
|
8
|
-
export declare const BEACON_SDK_VERSION = "0.7.0-beta.
|
|
8
|
+
export declare const BEACON_SDK_VERSION = "0.7.0-beta.25";
|
|
9
9
|
/** Arbitrary event tags, with Beacon's reserved `signal` tag type-checked. */
|
|
10
10
|
export type BeaconTags = Record<string, string> & {
|
|
11
11
|
signal?: BeaconSignal;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,69 @@
|
|
|
1
|
+
// src/pageLifecycle.ts
|
|
2
|
+
var observePageLifecycle = () => {
|
|
3
|
+
const started = performance.now();
|
|
4
|
+
const elapsed = () => Math.max(0, Math.round(performance.now() - started));
|
|
5
|
+
const visibility = () => document.visibilityState === "visible" ? "visible" : document.visibilityState === "hidden" ? "hidden" : "unknown";
|
|
6
|
+
const initialVisibility = visibility();
|
|
7
|
+
let state = initialVisibility;
|
|
8
|
+
let hiddenAt = state === "hidden" ? 0 : undefined;
|
|
9
|
+
let hiddenDurationMs = 0;
|
|
10
|
+
let visibilityChanges = 0;
|
|
11
|
+
let bfcacheRestores = 0;
|
|
12
|
+
let pageHidden = false;
|
|
13
|
+
const recentTransitions = [];
|
|
14
|
+
const record = (kind, persisted) => {
|
|
15
|
+
const atMs = elapsed();
|
|
16
|
+
const next = visibility();
|
|
17
|
+
if (next !== state) {
|
|
18
|
+
visibilityChanges = Math.min(visibilityChanges + 1, 1e6);
|
|
19
|
+
if (hiddenAt !== undefined)
|
|
20
|
+
hiddenDurationMs += Math.max(0, atMs - hiddenAt);
|
|
21
|
+
hiddenAt = next === "hidden" ? atMs : undefined;
|
|
22
|
+
state = next;
|
|
23
|
+
}
|
|
24
|
+
recentTransitions.push({
|
|
25
|
+
kind,
|
|
26
|
+
atMs,
|
|
27
|
+
visibility: state,
|
|
28
|
+
...persisted === undefined ? {} : { persisted }
|
|
29
|
+
});
|
|
30
|
+
if (recentTransitions.length > 8)
|
|
31
|
+
recentTransitions.shift();
|
|
32
|
+
};
|
|
33
|
+
const onVisibility = () => record("visibilitychange");
|
|
34
|
+
const onHide = (event) => {
|
|
35
|
+
pageHidden = true;
|
|
36
|
+
record("pagehide", event.persisted === true);
|
|
37
|
+
};
|
|
38
|
+
const onShow = (event) => {
|
|
39
|
+
pageHidden = false;
|
|
40
|
+
if (event.persisted)
|
|
41
|
+
bfcacheRestores = Math.min(bfcacheRestores + 1, 1e6);
|
|
42
|
+
record("pageshow", event.persisted === true);
|
|
43
|
+
};
|
|
44
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
45
|
+
window.addEventListener("pagehide", onHide);
|
|
46
|
+
window.addEventListener("pageshow", onShow);
|
|
47
|
+
return {
|
|
48
|
+
snapshot: () => ({
|
|
49
|
+
observationAgeMs: elapsed(),
|
|
50
|
+
initialVisibility,
|
|
51
|
+
visibilityState: visibility(),
|
|
52
|
+
readyState: document.readyState,
|
|
53
|
+
observedHiddenDurationMs: hiddenDurationMs + (hiddenAt === undefined ? 0 : Math.max(0, elapsed() - hiddenAt)),
|
|
54
|
+
visibilityChanges,
|
|
55
|
+
bfcacheRestores,
|
|
56
|
+
pageHidden,
|
|
57
|
+
recentTransitions: recentTransitions.map((item) => ({ ...item }))
|
|
58
|
+
}),
|
|
59
|
+
close: () => {
|
|
60
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
61
|
+
window.removeEventListener("pagehide", onHide);
|
|
62
|
+
window.removeEventListener("pageshow", onShow);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
1
67
|
// src/rejection.ts
|
|
2
68
|
var read = (value, key) => {
|
|
3
69
|
try {
|
|
@@ -245,7 +311,7 @@ var consumeEarlyLayoutShiftBuffer = () => {
|
|
|
245
311
|
|
|
246
312
|
// src/index.ts
|
|
247
313
|
var BEACON_TRACE_HEADER = "x-absolute-trace-id";
|
|
248
|
-
var BEACON_SDK_VERSION = "0.7.0-beta.
|
|
314
|
+
var BEACON_SDK_VERSION = "0.7.0-beta.25";
|
|
249
315
|
var inBrowser = () => typeof window !== "undefined";
|
|
250
316
|
var newId = () => {
|
|
251
317
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
@@ -1152,7 +1218,8 @@ var createBeacon = (options) => {
|
|
|
1152
1218
|
}
|
|
1153
1219
|
return false;
|
|
1154
1220
|
};
|
|
1155
|
-
const
|
|
1221
|
+
const lifecycle = observePageLifecycle();
|
|
1222
|
+
const cleanups = [lifecycle.close];
|
|
1156
1223
|
let closed = false;
|
|
1157
1224
|
const vitalsOptions = options.vitals === undefined || options.vitals === false ? null : options.vitals === true ? {} : options.vitals;
|
|
1158
1225
|
if (vitalsOptions !== null) {
|
|
@@ -1179,7 +1246,10 @@ var createBeacon = (options) => {
|
|
|
1179
1246
|
...vitalsOptions.sdkVersion === undefined ? {} : { sdkVersion: vitalsOptions.sdkVersion },
|
|
1180
1247
|
...traceId === undefined ? {} : { traceId },
|
|
1181
1248
|
value: metric.value,
|
|
1182
|
-
|
|
1249
|
+
attribution: {
|
|
1250
|
+
...vitalAttribution(metric.attribution),
|
|
1251
|
+
pageLifecycle: lifecycle.snapshot()
|
|
1252
|
+
}
|
|
1183
1253
|
};
|
|
1184
1254
|
vitalsOptions.onVital?.(vital);
|
|
1185
1255
|
if (vitalsOptions.transport !== undefined) {
|
|
@@ -1288,6 +1358,7 @@ var createBeacon = (options) => {
|
|
|
1288
1358
|
const extra = {
|
|
1289
1359
|
...event.extra,
|
|
1290
1360
|
pageStartedAt,
|
|
1361
|
+
pageLifecycle: lifecycle.snapshot(),
|
|
1291
1362
|
sdkVersion: BEACON_SDK_VERSION,
|
|
1292
1363
|
sessionId
|
|
1293
1364
|
};
|
|
@@ -1831,6 +1902,8 @@ var createBeacon = (options) => {
|
|
|
1831
1902
|
const reported = new Set;
|
|
1832
1903
|
const observer = new ReportingObserver((reports) => {
|
|
1833
1904
|
for (const report of reports) {
|
|
1905
|
+
if (typeof report.type !== "string" || report.type === "")
|
|
1906
|
+
continue;
|
|
1834
1907
|
const body = report.body;
|
|
1835
1908
|
const id = typeof body.id === "string" && body.id !== "" ? body.id.slice(0, SIGNAL_TEXT_MAX) : report.type;
|
|
1836
1909
|
const key = `${report.type}|${id}|${shortUrl(report.url || location.href)}`;
|
|
@@ -5120,5 +5193,5 @@ export {
|
|
|
5120
5193
|
redactBeaconEvent
|
|
5121
5194
|
};
|
|
5122
5195
|
|
|
5123
|
-
//# debugId=
|
|
5196
|
+
//# debugId=E26A5543E609C9A364756E2164756E21
|
|
5124
5197
|
//# sourceMappingURL=index.js.map
|