@absolutejs/beacon 0.6.22 → 0.6.24
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 +52 -10
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -317,8 +317,15 @@ var isInstagramIosBridgeInjection = (event, userAgent) => INSTAGRAM_IOS_IN_APP_B
|
|
|
317
317
|
var FACEBOOK_ANDROID_DETACHED_BRIDGE_MESSAGE = "Error invoking postMessage: Java object is gone";
|
|
318
318
|
var FACEBOOK_ANDROID_PERFORMANCE_LOGGER = "iabjs://navigation_performance_logger_android";
|
|
319
319
|
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;
|
|
320
|
+
var GOOGLE_WEB_RENDERER_SERVICE_WORKER_WRAPPER = "wrsParams.serviceWorkers.navigator.serviceWorker.register";
|
|
321
|
+
var isInjectedServiceWorkerRejection = (event) => {
|
|
322
|
+
const stack = event.stack ?? "";
|
|
323
|
+
if (stack.includes(GOOGLE_WEB_RENDERER_SERVICE_WORKER_WRAPPER))
|
|
324
|
+
return true;
|
|
325
|
+
return event.message === "Rejected" && stack.includes("ServiceWorkerContainer.<anonymous> (<anonymous>:") && stack.includes("ServiceWorkerContainer.register (<anonymous>:");
|
|
326
|
+
};
|
|
320
327
|
var browserUserAgent = () => typeof navigator === "undefined" ? "" : navigator.userAgent;
|
|
321
|
-
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) && FACEBOOK_IOS_HOST_INJECTION.has(event.message) || isInstagramIosBridgeInjection(event, userAgent) || 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;
|
|
328
|
+
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) && FACEBOOK_IOS_HOST_INJECTION.has(event.message) || 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;
|
|
322
329
|
var errorWithStack = (name, message, location2) => {
|
|
323
330
|
const error = new Error(message);
|
|
324
331
|
error.name = name;
|
|
@@ -755,6 +762,7 @@ var createBeacon = (options) => {
|
|
|
755
762
|
const rageCount = signals?.rageClickCount ?? RAGE_COUNT_DEFAULT;
|
|
756
763
|
let networkRequestCount = 0;
|
|
757
764
|
let externalNavigationCount = 0;
|
|
765
|
+
let externalShareCount = 0;
|
|
758
766
|
let clipboardWriteCount = 0;
|
|
759
767
|
let inSignalConsole = false;
|
|
760
768
|
let pageLifecycleEnding = false;
|
|
@@ -1248,6 +1256,7 @@ var createBeacon = (options) => {
|
|
|
1248
1256
|
const formBefore = snapshotRelevantFormControls(control);
|
|
1249
1257
|
const networkRequestsBefore = networkRequestCount;
|
|
1250
1258
|
const externalNavigationsBefore = externalNavigationCount;
|
|
1259
|
+
const externalSharesBefore = externalShareCount;
|
|
1251
1260
|
const clipboardWritesBefore = clipboardWriteCount;
|
|
1252
1261
|
let routerAcceptedNavigation = false;
|
|
1253
1262
|
let mutated = false;
|
|
@@ -1259,7 +1268,7 @@ var createBeacon = (options) => {
|
|
|
1259
1268
|
return;
|
|
1260
1269
|
routerAcceptedNavigation = control instanceof HTMLAnchorElement && handledEvent.defaultPrevented;
|
|
1261
1270
|
};
|
|
1262
|
-
const responded = () => mutated || formStateChanged(formBefore) || location.href !== urlBefore || window.scrollY !== scrollBefore || document.activeElement !== activeBefore || networkRequestCount !== networkRequestsBefore || externalNavigationCount !== externalNavigationsBefore || clipboardWriteCount !== clipboardWritesBefore;
|
|
1271
|
+
const responded = () => mutated || formStateChanged(formBefore) || location.href !== urlBefore || window.scrollY !== scrollBefore || document.activeElement !== activeBefore || networkRequestCount !== networkRequestsBefore || externalNavigationCount !== externalNavigationsBefore || externalShareCount !== externalSharesBefore || clipboardWriteCount !== clipboardWritesBefore;
|
|
1263
1272
|
const finish = (didRespond, navigationStalled = false) => {
|
|
1264
1273
|
if (finished)
|
|
1265
1274
|
return;
|
|
@@ -1666,6 +1675,20 @@ var createBeacon = (options) => {
|
|
|
1666
1675
|
if (window.open === wrappedWindowOpen)
|
|
1667
1676
|
window.open = originalWindowOpen;
|
|
1668
1677
|
});
|
|
1678
|
+
if (typeof navigator !== "undefined" && typeof navigator.share === "function") {
|
|
1679
|
+
const originalShare = navigator.share;
|
|
1680
|
+
const wrappedShare = (...args) => {
|
|
1681
|
+
externalShareCount += 1;
|
|
1682
|
+
return originalShare.apply(navigator, args);
|
|
1683
|
+
};
|
|
1684
|
+
try {
|
|
1685
|
+
navigator.share = wrappedShare;
|
|
1686
|
+
cleanups.push(() => {
|
|
1687
|
+
if (navigator.share === wrappedShare)
|
|
1688
|
+
navigator.share = originalShare;
|
|
1689
|
+
});
|
|
1690
|
+
} catch {}
|
|
1691
|
+
}
|
|
1669
1692
|
}
|
|
1670
1693
|
let unresponsiveClicks = [];
|
|
1671
1694
|
const onClick = (event) => {
|
|
@@ -3175,15 +3198,16 @@ var createBeacon = (options) => {
|
|
|
3175
3198
|
submittedForms.add(event.target);
|
|
3176
3199
|
dirtyForms.delete(event.target);
|
|
3177
3200
|
};
|
|
3178
|
-
const report = () => {
|
|
3201
|
+
const report = (departedUrl = location.href) => {
|
|
3179
3202
|
for (const form of dirtyForms) {
|
|
3180
3203
|
if (!form.isConnected || submittedForms.has(form))
|
|
3181
3204
|
continue;
|
|
3182
3205
|
const name = form.getAttribute(BEACON_ATTRIBUTE.FORM)?.trim() || describeElement(form);
|
|
3183
|
-
emitSignal(`Form abandonment — ${name} left dirty — ${shortUrl(
|
|
3206
|
+
emitSignal(`Form abandonment — ${name} left dirty — ${shortUrl(departedUrl)}`, {
|
|
3184
3207
|
fieldCount: String(form.elements.length),
|
|
3185
3208
|
signal: BEACON_SIGNAL.FORM_ABANDONMENT,
|
|
3186
|
-
target: name
|
|
3209
|
+
target: name,
|
|
3210
|
+
url: shortUrl(departedUrl)
|
|
3187
3211
|
});
|
|
3188
3212
|
dirtyForms.delete(form);
|
|
3189
3213
|
}
|
|
@@ -3191,12 +3215,13 @@ var createBeacon = (options) => {
|
|
|
3191
3215
|
reportFormAbandonmentOnNavigation = report;
|
|
3192
3216
|
document.addEventListener("input", onInput, true);
|
|
3193
3217
|
document.addEventListener("submit", onSubmit, true);
|
|
3194
|
-
|
|
3218
|
+
const reportOnPageHide = () => report();
|
|
3219
|
+
window.addEventListener("pagehide", reportOnPageHide);
|
|
3195
3220
|
cleanups.push(() => {
|
|
3196
3221
|
reportFormAbandonmentOnNavigation = null;
|
|
3197
3222
|
document.removeEventListener("input", onInput, true);
|
|
3198
3223
|
document.removeEventListener("submit", onSubmit, true);
|
|
3199
|
-
window.removeEventListener("pagehide",
|
|
3224
|
+
window.removeEventListener("pagehide", reportOnPageHide);
|
|
3200
3225
|
});
|
|
3201
3226
|
}
|
|
3202
3227
|
}
|
|
@@ -3734,18 +3759,33 @@ var createBeacon = (options) => {
|
|
|
3734
3759
|
});
|
|
3735
3760
|
}
|
|
3736
3761
|
if (instrument.history !== false && typeof history !== "undefined") {
|
|
3762
|
+
let recordedHistoryUrl = location.href;
|
|
3737
3763
|
const record = () => {
|
|
3738
3764
|
addBreadcrumb({
|
|
3739
3765
|
message: `navigate ${location.pathname}${location.search}`,
|
|
3740
3766
|
type: "navigation"
|
|
3741
3767
|
});
|
|
3768
|
+
recordedHistoryUrl = location.href;
|
|
3742
3769
|
overflowScanOnNavigation?.();
|
|
3743
3770
|
};
|
|
3744
3771
|
const patch = (key) => {
|
|
3745
3772
|
const original = history[key].bind(history);
|
|
3746
3773
|
history[key] = (...args) => {
|
|
3747
|
-
|
|
3774
|
+
const departedUrl = location.href;
|
|
3775
|
+
const destination = args[2];
|
|
3776
|
+
let changesUrl = false;
|
|
3777
|
+
if (destination !== undefined && destination !== null) {
|
|
3778
|
+
try {
|
|
3779
|
+
changesUrl = new URL(String(destination), departedUrl).href !== departedUrl;
|
|
3780
|
+
} catch {
|
|
3781
|
+
const rawDestination = String(destination);
|
|
3782
|
+
changesUrl = rawDestination !== departedUrl && rawDestination !== `${location.pathname}${location.search}${location.hash}`;
|
|
3783
|
+
}
|
|
3784
|
+
}
|
|
3748
3785
|
const result = original(...args);
|
|
3786
|
+
if (!changesUrl)
|
|
3787
|
+
return result;
|
|
3788
|
+
reportFormAbandonmentOnNavigation?.(departedUrl);
|
|
3749
3789
|
record();
|
|
3750
3790
|
return result;
|
|
3751
3791
|
};
|
|
@@ -3755,7 +3795,9 @@ var createBeacon = (options) => {
|
|
|
3755
3795
|
};
|
|
3756
3796
|
cleanups.push(patch("pushState"), patch("replaceState"));
|
|
3757
3797
|
const onPopState = () => {
|
|
3758
|
-
|
|
3798
|
+
if (location.href === recordedHistoryUrl)
|
|
3799
|
+
return;
|
|
3800
|
+
reportFormAbandonmentOnNavigation?.(recordedHistoryUrl);
|
|
3759
3801
|
record();
|
|
3760
3802
|
};
|
|
3761
3803
|
window.addEventListener("popstate", onPopState);
|
|
@@ -3829,5 +3871,5 @@ export {
|
|
|
3829
3871
|
BEACON_ATTRIBUTE
|
|
3830
3872
|
};
|
|
3831
3873
|
|
|
3832
|
-
//# debugId=
|
|
3874
|
+
//# debugId=F390493D9649926964756E2164756E21
|
|
3833
3875
|
//# sourceMappingURL=index.js.map
|