@absolutejs/beacon 0.6.51 → 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 +68 -6
- 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") {
|
|
@@ -1575,20 +1575,64 @@ var createBeacon = (options) => {
|
|
|
1575
1575
|
if (stallTimes.length < stallCount)
|
|
1576
1576
|
continue;
|
|
1577
1577
|
reported = true;
|
|
1578
|
-
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
|
+
}));
|
|
1579
1599
|
emitSignal(`Main-thread stall — repeated long frames blocked the page — ${shortUrl(location.href)}`, {
|
|
1580
1600
|
...animationFrame.blockingDuration === undefined ? {} : {
|
|
1581
1601
|
blockingDurationMs: String(Math.round(animationFrame.blockingDuration))
|
|
1582
1602
|
},
|
|
1583
1603
|
durationMs: String(Math.round(entry.duration)),
|
|
1584
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)) },
|
|
1585
1610
|
signal: BEACON_SIGNAL.MAIN_THREAD_STALL,
|
|
1586
|
-
|
|
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
|
+
},
|
|
1587
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
|
+
},
|
|
1588
1628
|
...script?.sourceURL === undefined ? {} : { scriptSource: shortUrl(script.sourceURL) },
|
|
1629
|
+
...script?.windowAttribution === undefined ? {} : { scriptWindowAttribution: script.windowAttribution },
|
|
1589
1630
|
stallCount: String(stallTimes.length),
|
|
1631
|
+
...styleAndLayoutDuration === undefined ? {} : {
|
|
1632
|
+
styleAndLayoutDurationMs: String(Math.round(styleAndLayoutDuration))
|
|
1633
|
+
},
|
|
1590
1634
|
windowMs: String(stallWindowMs)
|
|
1591
|
-
});
|
|
1635
|
+
}, undefined, scriptTimings.length === 0 ? undefined : { scriptTimings });
|
|
1592
1636
|
break;
|
|
1593
1637
|
}
|
|
1594
1638
|
});
|
|
@@ -1770,8 +1814,26 @@ var createBeacon = (options) => {
|
|
|
1770
1814
|
if (method === "error" && signals !== null && signals.consoleErrors !== false && !inSignalConsole) {
|
|
1771
1815
|
inSignalConsole = true;
|
|
1772
1816
|
const text = args.map(String).join(" ").trim().slice(0, SIGNAL_TEXT_MAX);
|
|
1773
|
-
|
|
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 !== "") {
|
|
1774
1835
|
emitSignal(text, { signal: BEACON_SIGNAL.CONSOLE_ERROR }, undefined, undefined, wrappedConsole, 2, true);
|
|
1836
|
+
}
|
|
1775
1837
|
if (text !== "")
|
|
1776
1838
|
reportErrorClick?.("ConsoleError");
|
|
1777
1839
|
inSignalConsole = false;
|
|
@@ -4426,5 +4488,5 @@ export {
|
|
|
4426
4488
|
BEACON_ATTRIBUTE
|
|
4427
4489
|
};
|
|
4428
4490
|
|
|
4429
|
-
//# debugId=
|
|
4491
|
+
//# debugId=33AAE862F88D371564756E2164756E21
|
|
4430
4492
|
//# sourceMappingURL=index.js.map
|