@absolutejs/beacon 0.6.56 → 0.6.57
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.d.ts +1 -1
- package/dist/index.js +26 -10
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -107,7 +107,7 @@ export declare const BEACON_ATTRIBUTE: {
|
|
|
107
107
|
/** Response header used to correlate a browser signal with its server request. */
|
|
108
108
|
export declare const BEACON_TRACE_HEADER = "x-absolute-trace-id";
|
|
109
109
|
/** Beacon package version retained with every captured event. */
|
|
110
|
-
export declare const BEACON_SDK_VERSION = "0.6.
|
|
110
|
+
export declare const BEACON_SDK_VERSION = "0.6.57";
|
|
111
111
|
/** Arbitrary event tags, with Beacon's reserved `signal` tag type-checked. */
|
|
112
112
|
export type BeaconTags = Record<string, string> & {
|
|
113
113
|
signal?: BeaconSignal;
|
package/dist/index.js
CHANGED
|
@@ -76,7 +76,7 @@ var BEACON_ATTRIBUTE = {
|
|
|
76
76
|
THEME: "data-beacon-theme"
|
|
77
77
|
};
|
|
78
78
|
var BEACON_TRACE_HEADER = "x-absolute-trace-id";
|
|
79
|
-
var BEACON_SDK_VERSION = "0.6.
|
|
79
|
+
var BEACON_SDK_VERSION = "0.6.57";
|
|
80
80
|
var inBrowser = () => typeof window !== "undefined";
|
|
81
81
|
var newId = () => {
|
|
82
82
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
@@ -793,6 +793,7 @@ var createBeacon = (options) => {
|
|
|
793
793
|
const NAVIGATION_INTENT_MAX_AGE_MS = 30000;
|
|
794
794
|
const RELOAD_LOOP_STORAGE_KEY = "beacon:reload-history-v4";
|
|
795
795
|
const NAVIGATION_INTENT_STORAGE_KEY = "beacon:navigation-intent-v1";
|
|
796
|
+
const SERVICE_WORKER_UPDATE_INTENT_STORAGE_KEY = "beacon:service-worker-update-intent-v1";
|
|
796
797
|
const STALE_RELEASE_STORAGE_KEY = "beacon:release-first-seen";
|
|
797
798
|
const STALE_RELEASE_GRACE_MS = 600000;
|
|
798
799
|
const STALE_RELEASE_HISTORY_LIMIT = 5;
|
|
@@ -1086,7 +1087,7 @@ var createBeacon = (options) => {
|
|
|
1086
1087
|
push(event);
|
|
1087
1088
|
};
|
|
1088
1089
|
const emitSignal = (message, signalTags, traceId, extra, stackBoundary, fallbackFramesToDrop = 1, useDefaultFingerprint = false) => {
|
|
1089
|
-
if (staleClientRelease && signalTags.signal !== BEACON_SIGNAL.STALE_RELEASE)
|
|
1090
|
+
if (staleClientRelease && signalTags.signal !== BEACON_SIGNAL.STALE_RELEASE && signalTags.signal !== BEACON_SIGNAL.RELOAD_LOOP)
|
|
1090
1091
|
return;
|
|
1091
1092
|
const error = new Error(message);
|
|
1092
1093
|
const captureStackTrace = Error.captureStackTrace;
|
|
@@ -1141,7 +1142,8 @@ var createBeacon = (options) => {
|
|
|
1141
1142
|
return;
|
|
1142
1143
|
staleClientRelease = true;
|
|
1143
1144
|
for (let index = buffer.length - 1;index >= 0; index -= 1) {
|
|
1144
|
-
|
|
1145
|
+
const signal = buffer[index]?.tags?.signal;
|
|
1146
|
+
if (signal !== undefined && signal !== BEACON_SIGNAL.RELOAD_LOOP) {
|
|
1145
1147
|
buffer.splice(index, 1);
|
|
1146
1148
|
}
|
|
1147
1149
|
}
|
|
@@ -4055,6 +4057,15 @@ var createBeacon = (options) => {
|
|
|
4055
4057
|
});
|
|
4056
4058
|
} catch {}
|
|
4057
4059
|
}
|
|
4060
|
+
if (typeof navigator.serviceWorker?.addEventListener === "function" && typeof sessionStorage !== "undefined") {
|
|
4061
|
+
const markServiceWorkerUpdate = () => {
|
|
4062
|
+
try {
|
|
4063
|
+
sessionStorage.setItem(SERVICE_WORKER_UPDATE_INTENT_STORAGE_KEY, String(Date.now()));
|
|
4064
|
+
} catch {}
|
|
4065
|
+
};
|
|
4066
|
+
navigator.serviceWorker.addEventListener("controllerchange", markServiceWorkerUpdate);
|
|
4067
|
+
cleanups.push(() => navigator.serviceWorker?.removeEventListener("controllerchange", markServiceWorkerUpdate));
|
|
4068
|
+
}
|
|
4058
4069
|
if (signals !== null && signals.reloadLoops !== false && typeof sessionStorage !== "undefined") {
|
|
4059
4070
|
try {
|
|
4060
4071
|
const navigation = performance.getEntriesByType("navigation")[0];
|
|
@@ -4072,17 +4083,18 @@ var createBeacon = (options) => {
|
|
|
4072
4083
|
history2 = [];
|
|
4073
4084
|
entryKind = "intentional-navigation";
|
|
4074
4085
|
}
|
|
4086
|
+
const rawServiceWorkerUpdateIntent = sessionStorage.getItem(SERVICE_WORKER_UPDATE_INTENT_STORAGE_KEY);
|
|
4087
|
+
sessionStorage.removeItem(SERVICE_WORKER_UPDATE_INTENT_STORAGE_KEY);
|
|
4088
|
+
const serviceWorkerUpdateIntentAt = Number(rawServiceWorkerUpdateIntent);
|
|
4089
|
+
if (rawServiceWorkerUpdateIntent !== null && Number.isFinite(serviceWorkerUpdateIntentAt) && now - serviceWorkerUpdateIntentAt >= 0 && now - serviceWorkerUpdateIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
|
|
4090
|
+
history2 = [];
|
|
4091
|
+
entryKind = "service-worker-update";
|
|
4092
|
+
}
|
|
4075
4093
|
if (document.referrer !== "") {
|
|
4076
4094
|
const referrer = new URL(document.referrer, location.href);
|
|
4077
4095
|
if (referrer.origin !== location.origin) {
|
|
4078
4096
|
history2 = [];
|
|
4079
4097
|
entryKind = "external";
|
|
4080
|
-
} else {
|
|
4081
|
-
const controllerScript = navigator.serviceWorker?.controller?.scriptURL;
|
|
4082
|
-
if (controllerScript !== undefined && new URL(controllerScript, location.href).pathname === referrer.pathname) {
|
|
4083
|
-
history2 = [];
|
|
4084
|
-
entryKind = "service-worker-update";
|
|
4085
|
-
}
|
|
4086
4098
|
}
|
|
4087
4099
|
}
|
|
4088
4100
|
history2.push({ at: now, route });
|
|
@@ -4096,12 +4108,16 @@ var createBeacon = (options) => {
|
|
|
4096
4108
|
if (loadCount === RELOAD_LOOP_COUNT) {
|
|
4097
4109
|
const firstLoad = history2.at(-loadCount)?.at ?? now;
|
|
4098
4110
|
emitSignal(`Reload loop — repeated page loads within a minute — ${shortUrl(location.href)}`, {
|
|
4111
|
+
currentRelease: options.release ?? "unknown",
|
|
4099
4112
|
entryKind,
|
|
4100
4113
|
loadCount: String(loadCount),
|
|
4101
4114
|
navigationType: navigation?.type ?? "unknown",
|
|
4115
|
+
serviceWorkerControlled: String(navigator.serviceWorker?.controller !== null && navigator.serviceWorker?.controller !== undefined),
|
|
4116
|
+
serviceWorkerScript: navigator.serviceWorker?.controller?.scriptURL ?? "none",
|
|
4102
4117
|
signal: BEACON_SIGNAL.RELOAD_LOOP,
|
|
4103
4118
|
windowMs: String(now - firstLoad)
|
|
4104
4119
|
});
|
|
4120
|
+
flush(true);
|
|
4105
4121
|
}
|
|
4106
4122
|
}
|
|
4107
4123
|
} catch {}
|
|
@@ -4522,5 +4538,5 @@ export {
|
|
|
4522
4538
|
BEACON_ATTRIBUTE
|
|
4523
4539
|
};
|
|
4524
4540
|
|
|
4525
|
-
//# debugId=
|
|
4541
|
+
//# debugId=B8C645D9177F5D9E64756E2164756E21
|
|
4526
4542
|
//# sourceMappingURL=index.js.map
|