@absolutejs/beacon 0.6.39 → 0.6.40
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 +3 -0
- package/dist/index.js +43 -7
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -214,6 +214,9 @@ export type BeaconResourceFailure = {
|
|
|
214
214
|
export type BeaconSignals = {
|
|
215
215
|
/** Back/forward navigations the browser could not restore from bfcache. */
|
|
216
216
|
bfcacheBlocks?: boolean;
|
|
217
|
+
/** Browser-specific bfcache reason strings that are inherent to an
|
|
218
|
+
* application's required capabilities and therefore not actionable. */
|
|
219
|
+
ignoredBfcacheReasons?: string[];
|
|
217
220
|
/** Marked application roots that settle without meaningful visible content. */
|
|
218
221
|
blankAppRoots?: boolean;
|
|
219
222
|
/** Delay before an application root is evaluated. Default 3000ms. */
|
package/dist/index.js
CHANGED
|
@@ -764,7 +764,9 @@ var createBeacon = (options) => {
|
|
|
764
764
|
const MAIN_THREAD_STALL_DEFAULT_WINDOW_MS = 1e4;
|
|
765
765
|
const RELOAD_LOOP_COUNT = 4;
|
|
766
766
|
const RELOAD_LOOP_WINDOW_MS = 60000;
|
|
767
|
-
const
|
|
767
|
+
const NAVIGATION_INTENT_MAX_AGE_MS = 30000;
|
|
768
|
+
const RELOAD_LOOP_STORAGE_KEY = "beacon:reload-history-v4";
|
|
769
|
+
const NAVIGATION_INTENT_STORAGE_KEY = "beacon:navigation-intent-v1";
|
|
768
770
|
const STALE_RELEASE_STORAGE_KEY = "beacon:release-first-seen";
|
|
769
771
|
const STALE_RELEASE_GRACE_MS = 600000;
|
|
770
772
|
const STALE_RELEASE_HISTORY_LIMIT = 5;
|
|
@@ -910,6 +912,7 @@ var createBeacon = (options) => {
|
|
|
910
912
|
pendingClickCleanups.clear();
|
|
911
913
|
});
|
|
912
914
|
let flushPendingNetworkFailures = () => {};
|
|
915
|
+
let pendingNavigationIntentAt;
|
|
913
916
|
let tags = {};
|
|
914
917
|
let user;
|
|
915
918
|
let actionSequence = 0;
|
|
@@ -1451,9 +1454,9 @@ var createBeacon = (options) => {
|
|
|
1451
1454
|
const blockingDuration = entry.entryType === "long-animation-frame" && animationFrame.blockingDuration !== undefined ? animationFrame.blockingDuration : entry.duration;
|
|
1452
1455
|
if (blockingDuration < stallMs)
|
|
1453
1456
|
continue;
|
|
1454
|
-
const
|
|
1455
|
-
stallTimes = stallTimes.filter((at) =>
|
|
1456
|
-
stallTimes.push(
|
|
1457
|
+
const entryAt = entry.startTime;
|
|
1458
|
+
stallTimes = stallTimes.filter((at) => entryAt >= at && entryAt - at < stallWindowMs);
|
|
1459
|
+
stallTimes.push(entryAt);
|
|
1457
1460
|
if (stallTimes.length < stallCount)
|
|
1458
1461
|
continue;
|
|
1459
1462
|
reported = true;
|
|
@@ -1498,6 +1501,7 @@ var createBeacon = (options) => {
|
|
|
1498
1501
|
emitSignal(`Document discarded — the browser reloaded a discarded tab — ${shortUrl(location.href)}`, { signal: BEACON_SIGNAL.DOCUMENT_DISCARDED });
|
|
1499
1502
|
}
|
|
1500
1503
|
if (signals.bfcacheBlocks !== false && typeof performance !== "undefined") {
|
|
1504
|
+
const ignoredBfcacheReasons = new Set(signals.ignoredBfcacheReasons ?? []);
|
|
1501
1505
|
const navigation = performance.getEntriesByType("navigation")[0];
|
|
1502
1506
|
if (navigation?.type === "back_forward" && navigation.notRestoredReasons != null) {
|
|
1503
1507
|
const reasons = new Set;
|
|
@@ -1506,7 +1510,7 @@ var createBeacon = (options) => {
|
|
|
1506
1510
|
if (node === null || typeof node !== "object")
|
|
1507
1511
|
return;
|
|
1508
1512
|
const detail = node;
|
|
1509
|
-
const nodeReasons = (detail.reasons ?? []).map((reason) => reason.reason).filter((reason) => typeof reason === "string" && reason !== "masked").slice(0, 10);
|
|
1513
|
+
const nodeReasons = (detail.reasons ?? []).map((reason) => reason.reason).filter((reason) => typeof reason === "string" && reason !== "masked" && !ignoredBfcacheReasons.has(reason)).slice(0, 10);
|
|
1510
1514
|
for (const reason of nodeReasons)
|
|
1511
1515
|
reasons.add(reason);
|
|
1512
1516
|
if (nodeReasons.length > 0 && blockers.length < 10) {
|
|
@@ -1943,6 +1947,9 @@ var createBeacon = (options) => {
|
|
|
1943
1947
|
const rect = element.getBoundingClientRect();
|
|
1944
1948
|
if (rect.width === 0 && rect.height === 0)
|
|
1945
1949
|
return;
|
|
1950
|
+
if (rect.width <= 2 && rect.height <= 2 && (style.overflowX === "hidden" || style.overflowX === "clip" || style.overflowY === "hidden" || style.overflowY === "clip")) {
|
|
1951
|
+
return;
|
|
1952
|
+
}
|
|
1946
1953
|
if ((style.position === "absolute" || style.position === "fixed") && (rect.right <= 0 || rect.left >= viewportRight || rect.bottom <= 0 || rect.top >= document.documentElement.clientHeight)) {
|
|
1947
1954
|
return;
|
|
1948
1955
|
}
|
|
@@ -3772,6 +3779,13 @@ var createBeacon = (options) => {
|
|
|
3772
3779
|
const parsed = raw === null ? [] : JSON.parse(raw);
|
|
3773
3780
|
let history2 = (Array.isArray(parsed) ? parsed : []).filter((entry) => entry !== null && typeof entry === "object" && typeof entry.at === "number" && typeof entry.route === "string" && now - entry.at < RELOAD_LOOP_WINDOW_MS);
|
|
3774
3781
|
let entryKind = "app";
|
|
3782
|
+
const rawNavigationIntent = sessionStorage.getItem(NAVIGATION_INTENT_STORAGE_KEY);
|
|
3783
|
+
sessionStorage.removeItem(NAVIGATION_INTENT_STORAGE_KEY);
|
|
3784
|
+
const navigationIntentAt = Number(rawNavigationIntent);
|
|
3785
|
+
if (rawNavigationIntent !== null && Number.isFinite(navigationIntentAt) && now - navigationIntentAt >= 0 && now - navigationIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
|
|
3786
|
+
history2 = [];
|
|
3787
|
+
entryKind = "intentional-navigation";
|
|
3788
|
+
}
|
|
3775
3789
|
if (document.referrer !== "") {
|
|
3776
3790
|
const referrer = new URL(document.referrer, location.href);
|
|
3777
3791
|
if (referrer.origin !== location.origin) {
|
|
@@ -4109,6 +4123,11 @@ var createBeacon = (options) => {
|
|
|
4109
4123
|
pageLifecycleGeneration += 1;
|
|
4110
4124
|
pageRestoredAt = undefined;
|
|
4111
4125
|
pendingNetworkFailures.delete("transport");
|
|
4126
|
+
if (pendingNavigationIntentAt !== undefined && Date.now() - pendingNavigationIntentAt <= NAVIGATION_INTENT_MAX_AGE_MS) {
|
|
4127
|
+
try {
|
|
4128
|
+
sessionStorage.setItem(NAVIGATION_INTENT_STORAGE_KEY, String(Date.now()));
|
|
4129
|
+
} catch {}
|
|
4130
|
+
}
|
|
4112
4131
|
flush(true);
|
|
4113
4132
|
};
|
|
4114
4133
|
const onPageShow = (event) => {
|
|
@@ -4119,10 +4138,27 @@ var createBeacon = (options) => {
|
|
|
4119
4138
|
if (document.visibilityState === "hidden")
|
|
4120
4139
|
flush(true);
|
|
4121
4140
|
};
|
|
4141
|
+
const onNavigationIntent = (event) => {
|
|
4142
|
+
if (event.type === "submit") {
|
|
4143
|
+
pendingNavigationIntentAt = Date.now();
|
|
4144
|
+
return;
|
|
4145
|
+
}
|
|
4146
|
+
if (!(event instanceof MouseEvent) || event.button !== 0)
|
|
4147
|
+
return;
|
|
4148
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
|
|
4149
|
+
return;
|
|
4150
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
4151
|
+
const anchor = target?.closest("a[href]");
|
|
4152
|
+
if (anchor instanceof HTMLAnchorElement && anchor.target !== "_blank" && !anchor.hasAttribute("download")) {
|
|
4153
|
+
pendingNavigationIntentAt = Date.now();
|
|
4154
|
+
}
|
|
4155
|
+
};
|
|
4122
4156
|
window.addEventListener("pagehide", onPageHide);
|
|
4123
4157
|
window.addEventListener("pageshow", onPageShow);
|
|
4158
|
+
document.addEventListener("click", onNavigationIntent, true);
|
|
4159
|
+
document.addEventListener("submit", onNavigationIntent, true);
|
|
4124
4160
|
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
4125
|
-
cleanups.push(() => window.removeEventListener("pagehide", onPageHide), () => window.removeEventListener("pageshow", onPageShow), () => document.removeEventListener("visibilitychange", onVisibilityChange));
|
|
4161
|
+
cleanups.push(() => window.removeEventListener("pagehide", onPageHide), () => window.removeEventListener("pageshow", onPageShow), () => document.removeEventListener("click", onNavigationIntent, true), () => document.removeEventListener("submit", onNavigationIntent, true), () => document.removeEventListener("visibilitychange", onVisibilityChange));
|
|
4126
4162
|
return {
|
|
4127
4163
|
addBreadcrumb,
|
|
4128
4164
|
captureException,
|
|
@@ -4167,5 +4203,5 @@ export {
|
|
|
4167
4203
|
BEACON_ATTRIBUTE
|
|
4168
4204
|
};
|
|
4169
4205
|
|
|
4170
|
-
//# debugId=
|
|
4206
|
+
//# debugId=F92DB6A4B074BFF064756E2164756E21
|
|
4171
4207
|
//# sourceMappingURL=index.js.map
|