@absolutejs/beacon 0.6.34 → 0.6.36
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 +5 -0
- package/dist/index.js +11 -5
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -351,6 +351,11 @@ export type BeaconSignals = {
|
|
|
351
351
|
/** Abnormal WebSocket closes (`wasClean: false` or non-normal codes).
|
|
352
352
|
* Default true. */
|
|
353
353
|
socketAbnormalCloses?: boolean;
|
|
354
|
+
/** Endpoints whose client explicitly owns reconnect/resume. An isolated
|
|
355
|
+
* abnormal close is suppressed for matching URLs, while every close still
|
|
356
|
+
* counts toward socket-flapping detection. String patterns are URL/path
|
|
357
|
+
* prefixes; RegExp patterns match the full URL. */
|
|
358
|
+
recoverableSockets?: Array<RegExp | string>;
|
|
354
359
|
/** WebSocket connect/close cycles to one URL tripping a flap report.
|
|
355
360
|
* Default true. */
|
|
356
361
|
socketFlapping?: boolean;
|
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;
|
|
@@ -3504,10 +3508,12 @@ var createBeacon = (options) => {
|
|
|
3504
3508
|
const closesByUrl = new Map;
|
|
3505
3509
|
const reportedSockets = new Set;
|
|
3506
3510
|
const reportedAbnormalCloses = new Set;
|
|
3511
|
+
const recoverableSocket = (url) => (signals.recoverableSockets ?? []).some((pattern) => typeof pattern === "string" ? url.startsWith(pattern) || shortUrl(url).startsWith(pattern) : pattern.test(url));
|
|
3507
3512
|
const wrappedWebSocket = new Proxy(OriginalWebSocket, {
|
|
3508
3513
|
construct(target, args) {
|
|
3509
3514
|
const socket = Reflect.construct(target, args);
|
|
3510
|
-
const
|
|
3515
|
+
const socketUrl = String(args[0]);
|
|
3516
|
+
const label = shortUrl(socketUrl);
|
|
3511
3517
|
const socketLifecycleGeneration = pageLifecycleGeneration;
|
|
3512
3518
|
let applicationClose = false;
|
|
3513
3519
|
const originalClose = socket.close.bind(socket);
|
|
@@ -3519,7 +3525,7 @@ var createBeacon = (options) => {
|
|
|
3519
3525
|
const restoredLifecycleClose = pageRestoredAt !== undefined && socketLifecycleGeneration < pageLifecycleGeneration && Date.now() - pageRestoredAt <= RESTORED_SOCKET_CLOSE_GRACE_MS;
|
|
3520
3526
|
if (pageLifecycleEnding || applicationClose || restoredLifecycleClose)
|
|
3521
3527
|
return;
|
|
3522
|
-
if (signals.socketAbnormalCloses !== false && typeof CloseEvent !== "undefined" && event instanceof CloseEvent && !event.wasClean) {
|
|
3528
|
+
if (signals.socketAbnormalCloses !== false && typeof CloseEvent !== "undefined" && event instanceof CloseEvent && !event.wasClean && !recoverableSocket(socketUrl)) {
|
|
3523
3529
|
const abnormalKey = `${label}|${event.code}`;
|
|
3524
3530
|
if (!reportedAbnormalCloses.has(abnormalKey)) {
|
|
3525
3531
|
reportedAbnormalCloses.add(abnormalKey);
|
|
@@ -4075,5 +4081,5 @@ export {
|
|
|
4075
4081
|
BEACON_ATTRIBUTE
|
|
4076
4082
|
};
|
|
4077
4083
|
|
|
4078
|
-
//# debugId=
|
|
4084
|
+
//# debugId=76AB7EECBF8D441B64756E2164756E21
|
|
4079
4085
|
//# sourceMappingURL=index.js.map
|