@absolutejs/beacon 0.6.50 → 0.6.52
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 +109 -16
- package/dist/index.js.map +3 -3
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -104,7 +104,7 @@ export declare const BEACON_ATTRIBUTE: {
|
|
|
104
104
|
/** Response header used to correlate a browser signal with its server request. */
|
|
105
105
|
export declare const BEACON_TRACE_HEADER = "x-absolute-trace-id";
|
|
106
106
|
/** Beacon package version retained with every captured event. */
|
|
107
|
-
export declare const BEACON_SDK_VERSION = "0.6.
|
|
107
|
+
export declare const BEACON_SDK_VERSION = "0.6.52";
|
|
108
108
|
/** Arbitrary event tags, with Beacon's reserved `signal` tag type-checked. */
|
|
109
109
|
export type BeaconTags = Record<string, string> & {
|
|
110
110
|
signal?: BeaconSignal;
|
package/dist/index.js
CHANGED
|
@@ -75,7 +75,7 @@ var BEACON_ATTRIBUTE = {
|
|
|
75
75
|
THEME: "data-beacon-theme"
|
|
76
76
|
};
|
|
77
77
|
var BEACON_TRACE_HEADER = "x-absolute-trace-id";
|
|
78
|
-
var BEACON_SDK_VERSION = "0.6.
|
|
78
|
+
var BEACON_SDK_VERSION = "0.6.52";
|
|
79
79
|
var inBrowser = () => typeof window !== "undefined";
|
|
80
80
|
var newId = () => {
|
|
81
81
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
@@ -331,6 +331,11 @@ var isExtensionOnlyStack = (event) => {
|
|
|
331
331
|
`).slice(1).map((line) => line.trim()).filter(Boolean);
|
|
332
332
|
return frames.length > 0 && frames.every((frame) => EXTENSION_STACK_PROTOCOL.test(frame));
|
|
333
333
|
};
|
|
334
|
+
var isExtensionInjectedStack = (event) => {
|
|
335
|
+
const firstFrame = (event.stack ?? "").split(`
|
|
336
|
+
`).slice(1).map((line) => line.trim()).find(Boolean);
|
|
337
|
+
return firstFrame !== undefined && EXTENSION_STACK_PROTOCOL.test(firstFrame);
|
|
338
|
+
};
|
|
334
339
|
var isInjectedServiceWorkerRejection = (event) => {
|
|
335
340
|
const stack = event.stack ?? "";
|
|
336
341
|
if (stack.includes(GOOGLE_WEB_RENDERER_SERVICE_WORKER_WRAPPER))
|
|
@@ -823,6 +828,16 @@ var createBeacon = (options) => {
|
|
|
823
828
|
let pageRestoredAt;
|
|
824
829
|
let recentInteraction;
|
|
825
830
|
let reportErrorClick = null;
|
|
831
|
+
const reportCapturedErrorClick = (error, tags2) => {
|
|
832
|
+
if (filterKnownNoise && isKnownBeaconNoise({
|
|
833
|
+
message: error.message,
|
|
834
|
+
name: error.name,
|
|
835
|
+
stack: error.stack,
|
|
836
|
+
tags: tags2
|
|
837
|
+
}))
|
|
838
|
+
return;
|
|
839
|
+
reportErrorClick?.(error.name);
|
|
840
|
+
};
|
|
826
841
|
let reportFormAbandonmentOnNavigation = null;
|
|
827
842
|
const focusedEditable = () => {
|
|
828
843
|
const active = document.activeElement;
|
|
@@ -1352,6 +1367,8 @@ var createBeacon = (options) => {
|
|
|
1352
1367
|
if (signals === null || signals.failedRequests === false)
|
|
1353
1368
|
return;
|
|
1354
1369
|
const error = toError(errorValue);
|
|
1370
|
+
if (filterKnownNoise && isExtensionInjectedStack(error))
|
|
1371
|
+
return;
|
|
1355
1372
|
const kind = failureKind(error);
|
|
1356
1373
|
if (kind === "aborted" || kind === "transport" && pageLifecycleEnding)
|
|
1357
1374
|
return;
|
|
@@ -1558,20 +1575,64 @@ var createBeacon = (options) => {
|
|
|
1558
1575
|
if (stallTimes.length < stallCount)
|
|
1559
1576
|
continue;
|
|
1560
1577
|
reported = true;
|
|
1561
|
-
const
|
|
1578
|
+
const scriptsByDuration = [...animationFrame.scripts ?? []].sort((left, right) => (right.duration ?? 0) - (left.duration ?? 0));
|
|
1579
|
+
const script = scriptsByDuration[0];
|
|
1580
|
+
const frameEnd = entry.startTime + entry.duration;
|
|
1581
|
+
const renderDuration = animationFrame.renderStart === undefined || animationFrame.renderStart <= 0 ? undefined : Math.max(0, frameEnd - animationFrame.renderStart);
|
|
1582
|
+
const styleAndLayoutDuration = animationFrame.styleAndLayoutStart === undefined || animationFrame.styleAndLayoutStart <= 0 ? undefined : Math.max(0, frameEnd - animationFrame.styleAndLayoutStart);
|
|
1583
|
+
const scriptDuration = (animationFrame.scripts ?? []).reduce((total, timing) => total + (timing.duration ?? 0), 0);
|
|
1584
|
+
const scriptTimings = scriptsByDuration.slice(0, 5).map((timing) => ({
|
|
1585
|
+
durationMs: Math.round(timing.duration ?? 0),
|
|
1586
|
+
...timing.forcedStyleAndLayoutDuration === undefined ? {} : {
|
|
1587
|
+
forcedStyleAndLayoutDurationMs: Math.round(timing.forcedStyleAndLayoutDuration)
|
|
1588
|
+
},
|
|
1589
|
+
...timing.invoker === undefined ? {} : { invoker: timing.invoker },
|
|
1590
|
+
...timing.invokerType === undefined ? {} : { invokerType: timing.invokerType },
|
|
1591
|
+
...timing.pauseDuration === undefined ? {} : { pauseDurationMs: Math.round(timing.pauseDuration) },
|
|
1592
|
+
...timing.sourceCharPosition === undefined ? {} : { sourceCharPosition: timing.sourceCharPosition },
|
|
1593
|
+
...timing.sourceFunctionName === undefined && timing.functionName === undefined ? {} : {
|
|
1594
|
+
sourceFunctionName: timing.sourceFunctionName ?? timing.functionName
|
|
1595
|
+
},
|
|
1596
|
+
...timing.sourceURL === undefined ? {} : { sourceURL: shortUrl(timing.sourceURL) },
|
|
1597
|
+
...timing.windowAttribution === undefined ? {} : { windowAttribution: timing.windowAttribution }
|
|
1598
|
+
}));
|
|
1562
1599
|
emitSignal(`Main-thread stall — repeated long frames blocked the page — ${shortUrl(location.href)}`, {
|
|
1563
1600
|
...animationFrame.blockingDuration === undefined ? {} : {
|
|
1564
1601
|
blockingDurationMs: String(Math.round(animationFrame.blockingDuration))
|
|
1565
1602
|
},
|
|
1566
1603
|
durationMs: String(Math.round(entry.duration)),
|
|
1567
1604
|
entryType: entry.entryType,
|
|
1605
|
+
framePhase: entry.startTime < stallWindowMs ? "startup" : "runtime",
|
|
1606
|
+
...animationFrame.firstUIEventTimestamp === undefined || animationFrame.firstUIEventTimestamp <= 0 ? {} : {
|
|
1607
|
+
firstUIEventAtMs: String(Math.round(animationFrame.firstUIEventTimestamp))
|
|
1608
|
+
},
|
|
1609
|
+
...renderDuration === undefined ? {} : { renderDurationMs: String(Math.round(renderDuration)) },
|
|
1568
1610
|
signal: BEACON_SIGNAL.MAIN_THREAD_STALL,
|
|
1569
|
-
|
|
1611
|
+
scriptAttribution: script === undefined ? "unavailable" : "available",
|
|
1612
|
+
scriptCount: String(animationFrame.scripts?.length ?? 0),
|
|
1613
|
+
scriptDurationMs: String(Math.round(scriptDuration)),
|
|
1614
|
+
...script?.forcedStyleAndLayoutDuration === undefined ? {} : {
|
|
1615
|
+
scriptForcedStyleAndLayoutMs: String(Math.round(script.forcedStyleAndLayoutDuration))
|
|
1616
|
+
},
|
|
1617
|
+
...script?.sourceFunctionName === undefined && script?.functionName === undefined ? {} : {
|
|
1618
|
+
scriptFunction: script.sourceFunctionName ?? script.functionName ?? ""
|
|
1619
|
+
},
|
|
1570
1620
|
...script?.invoker === undefined ? {} : { scriptInvoker: script.invoker },
|
|
1621
|
+
...script?.invokerType === undefined ? {} : { scriptInvokerType: script.invokerType },
|
|
1622
|
+
...script?.pauseDuration === undefined ? {} : {
|
|
1623
|
+
scriptPauseDurationMs: String(Math.round(script.pauseDuration))
|
|
1624
|
+
},
|
|
1625
|
+
...script?.sourceCharPosition === undefined ? {} : {
|
|
1626
|
+
scriptSourceCharPosition: String(script.sourceCharPosition)
|
|
1627
|
+
},
|
|
1571
1628
|
...script?.sourceURL === undefined ? {} : { scriptSource: shortUrl(script.sourceURL) },
|
|
1629
|
+
...script?.windowAttribution === undefined ? {} : { scriptWindowAttribution: script.windowAttribution },
|
|
1572
1630
|
stallCount: String(stallTimes.length),
|
|
1631
|
+
...styleAndLayoutDuration === undefined ? {} : {
|
|
1632
|
+
styleAndLayoutDurationMs: String(Math.round(styleAndLayoutDuration))
|
|
1633
|
+
},
|
|
1573
1634
|
windowMs: String(stallWindowMs)
|
|
1574
|
-
});
|
|
1635
|
+
}, undefined, scriptTimings.length === 0 ? undefined : { scriptTimings });
|
|
1575
1636
|
break;
|
|
1576
1637
|
}
|
|
1577
1638
|
});
|
|
@@ -1684,7 +1745,7 @@ var createBeacon = (options) => {
|
|
|
1684
1745
|
level: "error",
|
|
1685
1746
|
tags: errorEventTags(event)
|
|
1686
1747
|
});
|
|
1687
|
-
|
|
1748
|
+
reportCapturedErrorClick(error, errorEventTags(event));
|
|
1688
1749
|
return;
|
|
1689
1750
|
}
|
|
1690
1751
|
const target = event.target;
|
|
@@ -1723,7 +1784,7 @@ var createBeacon = (options) => {
|
|
|
1723
1784
|
const reason = event.reason;
|
|
1724
1785
|
if (reason instanceof Error) {
|
|
1725
1786
|
captureException(reason, { level: "error" });
|
|
1726
|
-
|
|
1787
|
+
reportCapturedErrorClick(reason);
|
|
1727
1788
|
return;
|
|
1728
1789
|
}
|
|
1729
1790
|
if (typeof reason === "object" && reason !== null && typeof reason.stack === "string") {
|
|
@@ -1753,8 +1814,26 @@ var createBeacon = (options) => {
|
|
|
1753
1814
|
if (method === "error" && signals !== null && signals.consoleErrors !== false && !inSignalConsole) {
|
|
1754
1815
|
inSignalConsole = true;
|
|
1755
1816
|
const text = args.map(String).join(" ").trim().slice(0, SIGNAL_TEXT_MAX);
|
|
1756
|
-
|
|
1817
|
+
const loggedError = args.find((argument) => {
|
|
1818
|
+
if (argument instanceof Error)
|
|
1819
|
+
return true;
|
|
1820
|
+
if (typeof argument !== "object" || argument === null)
|
|
1821
|
+
return false;
|
|
1822
|
+
try {
|
|
1823
|
+
return typeof Reflect.get(argument, "stack") === "string";
|
|
1824
|
+
} catch {
|
|
1825
|
+
return false;
|
|
1826
|
+
}
|
|
1827
|
+
});
|
|
1828
|
+
if (text !== "" && loggedError !== undefined) {
|
|
1829
|
+
captureException(loggedError, {
|
|
1830
|
+
extra: { consoleMessage: text },
|
|
1831
|
+
level: "warning",
|
|
1832
|
+
tags: { signal: BEACON_SIGNAL.CONSOLE_ERROR }
|
|
1833
|
+
});
|
|
1834
|
+
} else if (text !== "") {
|
|
1757
1835
|
emitSignal(text, { signal: BEACON_SIGNAL.CONSOLE_ERROR }, undefined, undefined, wrappedConsole, 2, true);
|
|
1836
|
+
}
|
|
1758
1837
|
if (text !== "")
|
|
1759
1838
|
reportErrorClick?.("ConsoleError");
|
|
1760
1839
|
inSignalConsole = false;
|
|
@@ -2587,19 +2666,33 @@ var createBeacon = (options) => {
|
|
|
2587
2666
|
const media = link.media.trim();
|
|
2588
2667
|
return media === "" || typeof window.matchMedia !== "function" || window.matchMedia(media).matches;
|
|
2589
2668
|
});
|
|
2590
|
-
|
|
2669
|
+
if (!stylesheets.every((link) => link.sheet !== null))
|
|
2670
|
+
return false;
|
|
2671
|
+
if (stylesheets.length === 0)
|
|
2672
|
+
return true;
|
|
2673
|
+
const utilityExpectations = [
|
|
2674
|
+
['[class~="absolute"]', "position", "absolute"],
|
|
2675
|
+
['[class~="fixed"]', "position", "fixed"],
|
|
2676
|
+
['[class~="flex"]', "display", "flex"],
|
|
2677
|
+
['[class~="grid"]', "display", "grid"],
|
|
2678
|
+
['[class~="hidden"]', "display", "none"]
|
|
2679
|
+
];
|
|
2680
|
+
return utilityExpectations.every(([selector, property, expected]) => {
|
|
2681
|
+
const sample = document.querySelector(selector);
|
|
2682
|
+
return sample === null || window.getComputedStyle(sample)[property] === expected;
|
|
2683
|
+
});
|
|
2591
2684
|
};
|
|
2592
2685
|
const runSettledScan = () => {
|
|
2593
|
-
const
|
|
2594
|
-
if (detectOverflow &&
|
|
2686
|
+
const geometryReady = documentStylesAreReady() && !mobileKeyboardViewportActive();
|
|
2687
|
+
if (detectOverflow && geometryReady)
|
|
2595
2688
|
scanForOverflow();
|
|
2596
|
-
if (detectControlCollision &&
|
|
2689
|
+
if (detectControlCollision && geometryReady)
|
|
2597
2690
|
scanForControlCollisions();
|
|
2598
|
-
if (detectOcclusion &&
|
|
2691
|
+
if (detectOcclusion && geometryReady)
|
|
2599
2692
|
scanForOcclusion();
|
|
2600
|
-
if (detectInvisibleText &&
|
|
2693
|
+
if (detectInvisibleText && geometryReady)
|
|
2601
2694
|
scanForInvisibleText();
|
|
2602
|
-
if (detectThemeMismatch &&
|
|
2695
|
+
if (detectThemeMismatch && geometryReady)
|
|
2603
2696
|
scanForThemeMismatch();
|
|
2604
2697
|
if (detectStuckLoading)
|
|
2605
2698
|
checkStuckLoading();
|
|
@@ -2754,7 +2847,7 @@ var createBeacon = (options) => {
|
|
|
2754
2847
|
const processingDurationMs = hasPhaseTiming ? Math.round(Math.max(0, entry.processingEnd - entry.processingStart)) : undefined;
|
|
2755
2848
|
const presentationDelayMs = hasPhaseTiming ? Math.round(Math.max(0, interactionEnd - entry.processingEnd)) : undefined;
|
|
2756
2849
|
const inputDelayMs = hasPhaseTiming ? Math.round(Math.max(0, entry.processingStart - entry.startTime)) : undefined;
|
|
2757
|
-
if (
|
|
2850
|
+
if (overlappingFrame === undefined && processingDurationMs !== undefined && processingDurationMs <= 16 && presentationDelayMs !== undefined && presentationDelayMs >= minimum)
|
|
2758
2851
|
continue;
|
|
2759
2852
|
if (blockingObserver !== undefined && overlappingFrame === undefined && inputDelayMs !== undefined && inputDelayMs >= minimum && processingDurationMs !== undefined && processingDurationMs <= 16 && presentationDelayMs !== undefined && presentationDelayMs < minimum)
|
|
2760
2853
|
continue;
|
|
@@ -4395,5 +4488,5 @@ export {
|
|
|
4395
4488
|
BEACON_ATTRIBUTE
|
|
4396
4489
|
};
|
|
4397
4490
|
|
|
4398
|
-
//# debugId=
|
|
4491
|
+
//# debugId=33AAE862F88D371564756E2164756E21
|
|
4399
4492
|
//# sourceMappingURL=index.js.map
|