Files
discord-decomp/_bundle/Module1062.js
T
2026-11-01 12:12:55 +02:00

60 lines
2.3 KiB
JavaScript

// Metro module 1062 (f1063).
import { msToSec, startStandaloneWebVitalSpan, supportsWebVital, listenForWebVitalReportEvents } from "./Module1059";
import { addClsInstrumentationHandler } from "./triggerHandlers";
import { DEBUG_BUILD } from "./Module1035";
import { debug, browserPerformanceTimeOrigin, timestampInSeconds, getCurrentScope, htmlTreeAsString, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE } from "./Module817";
const _sendStandaloneClsSpan = function _sendStandaloneClsSpan(value, a1, a2, a3) {
if (DEBUG_BUILD) {
debug.log(`Sending CLS span (${value})`);
}
const startTime = a1 ? msToSec((browserPerformanceTimeOrigin() || 0) + a1.startTime) : timestampInSeconds();
const transactionName = getCurrentScope().getScopeData().transactionName;
const name = a1 ? htmlTreeAsString(a1.sources[0]?.node) : "Layout shift";
const attributes = {};
attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = "auto.http.browser.cls";
attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] = "ui.webvital.cls";
attributes[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME] = 0;
attributes["sentry.pageload.span_id"] = a2;
attributes["sentry.report_event"] = a3;
let c12695_0 = attributes;
if (a1?.sources) {
a1.sources.forEach((source, index) => {
c12695_0[`cls.source.${index + 1}`] = htmlTreeAsString(source.node);
});
}
const r76 = startStandaloneWebVitalSpan({
name,
transaction: transactionName,
attributes,
startTime
});
if (r76) {
const r78 = {};
r78[SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT] = "";
r78[SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE] = value;
r76.addEvent("cls", r78);
r76.end(startTime);
}
};
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
export { _sendStandaloneClsSpan };
export function trackClsAsStandaloneSpan(a0) {
let c12696_0, c12696_2;
const value = 0;
if (supportsWebVital("layout-shift")) {
c12696_2 = addClsInstrumentationHandler(({ metric }) => {
const r8 = metric.entries[metric.entries.length - 1];
if (r8) {
value = metric.value;
c12696_0 = r8;
}
}, true);
listenForWebVitalReportEvents(a0, (a0, a1) => {
_sendStandaloneClsSpan(value, c12696_0, a1, a0);
c12696_2();
});
}
}