@absolutejs/beacon 0.6.33 → 0.6.35
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.js +36 -9
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -314,7 +314,11 @@ var FACEBOOK_IOS_HOST_INJECTION = new Set([
|
|
|
314
314
|
"TypeError: undefined is not an object (evaluating 'window.webkit.messageHandlers')"
|
|
315
315
|
]);
|
|
316
316
|
var META_IOS_WEBKIT_BRIDGE_FAILURE = "TypeError: undefined is not an object (evaluating 'window.webkit.messageHandlers')";
|
|
317
|
-
var
|
|
317
|
+
var META_IOS_WEBKIT_BRIDGE_FAILURES = new Set([
|
|
318
|
+
META_IOS_WEBKIT_BRIDGE_FAILURE
|
|
319
|
+
]);
|
|
320
|
+
var matchesErrorMessage = (event, expected) => expected.has(event.message) || expected.has(`${event.name}: ${event.message}`);
|
|
321
|
+
var isInstagramIosBridgeInjection = (event, userAgent) => INSTAGRAM_IOS_IN_APP_BROWSER.test(userAgent) && matchesErrorMessage(event, META_IOS_WEBKIT_BRIDGE_FAILURES) && event.stack?.includes("sendDataToNative") === true && event.stack.includes("sendPageHideMessage");
|
|
318
322
|
var FACEBOOK_ANDROID_DETACHED_BRIDGE_MESSAGE = "Error invoking postMessage: Java object is gone";
|
|
319
323
|
var FACEBOOK_ANDROID_PERFORMANCE_LOGGER = "iabjs://navigation_performance_logger_android";
|
|
320
324
|
var KNOWN_CRAWLER_USER_AGENT = /(?:AdsBot-Google|Googlebot|bingbot|Baiduspider|YandexBot|DuckDuckBot|Applebot|Bytespider|PetalBot|SemrushBot|AhrefsBot|DotBot|MJ12bot|GPTBot|ClaudeBot|PerplexityBot|Google-NotebookLM|BitSightBot|Dataprovider\.com|meta-external(?:agent|ads))/i;
|
|
@@ -326,7 +330,7 @@ var isInjectedServiceWorkerRejection = (event) => {
|
|
|
326
330
|
return event.message === "Rejected" && stack.includes("ServiceWorkerContainer.<anonymous> (<anonymous>:") && stack.includes("ServiceWorkerContainer.register (<anonymous>:");
|
|
327
331
|
};
|
|
328
332
|
var browserUserAgent = () => typeof navigator === "undefined" ? "" : navigator.userAgent;
|
|
329
|
-
var isKnownBeaconNoise = (event, userAgent = browserUserAgent()) => KNOWN_CRAWLER_USER_AGENT.test(userAgent) || event.name === "UnhandledRejection" && CEF_SHARP_REJECTION.test(event.message) || FACEBOOK_IOS_IN_APP_BROWSER.test(userAgent) &&
|
|
333
|
+
var isKnownBeaconNoise = (event, userAgent = browserUserAgent()) => KNOWN_CRAWLER_USER_AGENT.test(userAgent) || event.name === "UnhandledRejection" && CEF_SHARP_REJECTION.test(event.message) || FACEBOOK_IOS_IN_APP_BROWSER.test(userAgent) && matchesErrorMessage(event, FACEBOOK_IOS_HOST_INJECTION) || isInstagramIosBridgeInjection(event, userAgent) || isInjectedServiceWorkerRejection(event) || event.name === "Error" && event.message === FACEBOOK_ANDROID_DETACHED_BRIDGE_MESSAGE && event.tags?.errorFilename === FACEBOOK_ANDROID_PERFORMANCE_LOGGER && event.stack?.includes(FACEBOOK_ANDROID_PERFORMANCE_LOGGER) === true;
|
|
330
334
|
var errorWithStack = (name, message, location2) => {
|
|
331
335
|
const error = new Error(message);
|
|
332
336
|
error.name = name;
|
|
@@ -760,7 +764,7 @@ var createBeacon = (options) => {
|
|
|
760
764
|
const MAIN_THREAD_STALL_DEFAULT_WINDOW_MS = 1e4;
|
|
761
765
|
const RELOAD_LOOP_COUNT = 4;
|
|
762
766
|
const RELOAD_LOOP_WINDOW_MS = 60000;
|
|
763
|
-
const RELOAD_LOOP_STORAGE_KEY = "beacon:reload-history-
|
|
767
|
+
const RELOAD_LOOP_STORAGE_KEY = "beacon:reload-history-v3";
|
|
764
768
|
const STALE_RELEASE_STORAGE_KEY = "beacon:release-first-seen";
|
|
765
769
|
const STALE_RELEASE_GRACE_MS = 600000;
|
|
766
770
|
const STALE_RELEASE_HISTORY_LIMIT = 5;
|
|
@@ -3731,14 +3735,37 @@ var createBeacon = (options) => {
|
|
|
3731
3735
|
const route = shortUrl(location.href);
|
|
3732
3736
|
const raw = sessionStorage.getItem(RELOAD_LOOP_STORAGE_KEY);
|
|
3733
3737
|
const parsed = raw === null ? [] : JSON.parse(raw);
|
|
3734
|
-
|
|
3738
|
+
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);
|
|
3739
|
+
let entryKind = "app";
|
|
3740
|
+
if (document.referrer !== "") {
|
|
3741
|
+
const referrer = new URL(document.referrer, location.href);
|
|
3742
|
+
if (referrer.origin !== location.origin) {
|
|
3743
|
+
history2 = [];
|
|
3744
|
+
entryKind = "external";
|
|
3745
|
+
} else {
|
|
3746
|
+
const controllerScript = navigator.serviceWorker?.controller?.scriptURL;
|
|
3747
|
+
if (controllerScript !== undefined && new URL(controllerScript, location.href).pathname === referrer.pathname) {
|
|
3748
|
+
history2 = [];
|
|
3749
|
+
entryKind = "service-worker-update";
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3735
3753
|
history2.push({ at: now, route });
|
|
3736
3754
|
sessionStorage.setItem(RELOAD_LOOP_STORAGE_KEY, JSON.stringify(history2));
|
|
3737
|
-
|
|
3738
|
-
|
|
3755
|
+
let loadCount = 0;
|
|
3756
|
+
for (let index = history2.length - 1;index >= 0; index -= 1) {
|
|
3757
|
+
if (history2[index]?.route !== route)
|
|
3758
|
+
break;
|
|
3759
|
+
loadCount += 1;
|
|
3760
|
+
}
|
|
3761
|
+
if (loadCount === RELOAD_LOOP_COUNT) {
|
|
3762
|
+
const firstLoad = history2.at(-loadCount)?.at ?? now;
|
|
3739
3763
|
emitSignal(`Reload loop — repeated page loads within a minute — ${shortUrl(location.href)}`, {
|
|
3740
|
-
|
|
3741
|
-
|
|
3764
|
+
entryKind,
|
|
3765
|
+
loadCount: String(loadCount),
|
|
3766
|
+
navigationType: navigation?.type ?? "unknown",
|
|
3767
|
+
signal: BEACON_SIGNAL.RELOAD_LOOP,
|
|
3768
|
+
windowMs: String(now - firstLoad)
|
|
3742
3769
|
});
|
|
3743
3770
|
}
|
|
3744
3771
|
}
|
|
@@ -4052,5 +4079,5 @@ export {
|
|
|
4052
4079
|
BEACON_ATTRIBUTE
|
|
4053
4080
|
};
|
|
4054
4081
|
|
|
4055
|
-
//# debugId=
|
|
4082
|
+
//# debugId=C8724C190000F91564756E2164756E21
|
|
4056
4083
|
//# sourceMappingURL=index.js.map
|