@absolutejs/beacon 0.7.0-beta.24 → 0.7.0-beta.26
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 +12 -0
- package/README.md +12 -0
- package/changelog.json +27 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +85 -7
- 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,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.26 — 2026-11-22
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **Keep rejected background telemetry sends out of application error handlers during normal use and page teardown. Explicit flush and close calls still expose delivery failures to their callers.** (`createBeacon`, `BEACON_SDK_VERSION`)
|
|
14
|
+
|
|
15
|
+
## 0.7.0-beta.25 — 2026-11-21
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **Retain bounded content-free page lifecycle and visibility context on errors and vitals, and guard missing browser policy report types.** (`BEACON_SDK_VERSION`)
|
|
20
|
+
|
|
9
21
|
## 0.7.0-beta.24 — 2026-11-17
|
|
10
22
|
|
|
11
23
|
### 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,33 @@
|
|
|
2
2
|
"contract": 1,
|
|
3
3
|
"name": "@absolutejs/beacon",
|
|
4
4
|
"releases": [
|
|
5
|
+
{
|
|
6
|
+
"changes": [
|
|
7
|
+
{
|
|
8
|
+
"kind": "fixed",
|
|
9
|
+
"summary": "Keep rejected background telemetry sends out of application error handlers during normal use and page teardown. Explicit flush and close calls still expose delivery failures to their callers.",
|
|
10
|
+
"symbols": [
|
|
11
|
+
"createBeacon",
|
|
12
|
+
"BEACON_SDK_VERSION"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"date": "2026-11-22",
|
|
17
|
+
"version": "0.7.0-beta.26"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"changes": [
|
|
21
|
+
{
|
|
22
|
+
"kind": "fixed",
|
|
23
|
+
"summary": "Retain bounded content-free page lifecycle and visibility context on errors and vitals, and guard missing browser policy report types.",
|
|
24
|
+
"symbols": [
|
|
25
|
+
"BEACON_SDK_VERSION"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"date": "2026-11-21",
|
|
30
|
+
"version": "0.7.0-beta.25"
|
|
31
|
+
},
|
|
5
32
|
{
|
|
6
33
|
"changes": [
|
|
7
34
|
{
|
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.26";
|
|
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.26";
|
|
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) {
|
|
@@ -1236,7 +1306,7 @@ var createBeacon = (options) => {
|
|
|
1236
1306
|
type
|
|
1237
1307
|
};
|
|
1238
1308
|
};
|
|
1239
|
-
const
|
|
1309
|
+
const sendBuffered = async (useBeacon) => {
|
|
1240
1310
|
flushPendingNetworkFailures();
|
|
1241
1311
|
if (buffer.length === 0)
|
|
1242
1312
|
return;
|
|
@@ -1255,6 +1325,11 @@ var createBeacon = (options) => {
|
|
|
1255
1325
|
...options.key !== undefined ? { key: options.key } : {}
|
|
1256
1326
|
});
|
|
1257
1327
|
};
|
|
1328
|
+
const flush = (useBeacon = false) => {
|
|
1329
|
+
const delivery = sendBuffered(useBeacon);
|
|
1330
|
+
delivery.catch(() => {});
|
|
1331
|
+
return delivery;
|
|
1332
|
+
};
|
|
1258
1333
|
const addBreadcrumb = (crumb) => {
|
|
1259
1334
|
breadcrumbs.push({
|
|
1260
1335
|
at: Date.now(),
|
|
@@ -1288,6 +1363,7 @@ var createBeacon = (options) => {
|
|
|
1288
1363
|
const extra = {
|
|
1289
1364
|
...event.extra,
|
|
1290
1365
|
pageStartedAt,
|
|
1366
|
+
pageLifecycle: lifecycle.snapshot(),
|
|
1291
1367
|
sdkVersion: BEACON_SDK_VERSION,
|
|
1292
1368
|
sessionId
|
|
1293
1369
|
};
|
|
@@ -1831,6 +1907,8 @@ var createBeacon = (options) => {
|
|
|
1831
1907
|
const reported = new Set;
|
|
1832
1908
|
const observer = new ReportingObserver((reports) => {
|
|
1833
1909
|
for (const report of reports) {
|
|
1910
|
+
if (typeof report.type !== "string" || report.type === "")
|
|
1911
|
+
continue;
|
|
1834
1912
|
const body = report.body;
|
|
1835
1913
|
const id = typeof body.id === "string" && body.id !== "" ? body.id.slice(0, SIGNAL_TEXT_MAX) : report.type;
|
|
1836
1914
|
const key = `${report.type}|${id}|${shortUrl(report.url || location.href)}`;
|
|
@@ -5077,11 +5155,11 @@ var createBeacon = (options) => {
|
|
|
5077
5155
|
addBreadcrumb,
|
|
5078
5156
|
captureException,
|
|
5079
5157
|
captureMessage,
|
|
5080
|
-
close:
|
|
5158
|
+
close: () => {
|
|
5081
5159
|
closed = true;
|
|
5082
5160
|
for (const cleanup of cleanups.splice(0, cleanups.length))
|
|
5083
5161
|
cleanup();
|
|
5084
|
-
|
|
5162
|
+
return flush(true);
|
|
5085
5163
|
},
|
|
5086
5164
|
flush: () => flush(false),
|
|
5087
5165
|
observeCapability,
|
|
@@ -5120,5 +5198,5 @@ export {
|
|
|
5120
5198
|
redactBeaconEvent
|
|
5121
5199
|
};
|
|
5122
5200
|
|
|
5123
|
-
//# debugId=
|
|
5201
|
+
//# debugId=EEBF0BB605B2DB3864756E2164756E21
|
|
5124
5202
|
//# sourceMappingURL=index.js.map
|