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

71 lines
2.9 KiB
JavaScript

// Metro module 1064 (f1065).
import { msToSec, getBrowserPerformanceAPI } from "./Module1059";
import { getActiveSpan, getRootSpan, spanToJSON, getCurrentScope, timestampInSeconds, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, startSpan, browserPerformanceTimeOrigin } from "./Module817";
import { addPerformanceInstrumentationHandler } from "./triggerHandlers";
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
const _onElementTiming = ({ entries }) => {
const activeSpan = getActiveSpan();
const r12 = activeSpan ? getRootSpan(activeSpan) : void 0;
const description = r12 ? spanToJSON(r12).description : getCurrentScope().getScopeData().transactionName;
entries.forEach((entry) => {
if (entry.identifier) {
const { name, renderTime, loadTime } = entry;
const r22 = loadTime ? [msToSec(loadTime), "load-time"] : renderTime ? [msToSec(renderTime), "render-time"] : [timestampInSeconds(), "entry-emission"];
const [startTime, r42] = r22;
let c24027_0 = startTime;
let r45 = 0;
if (name === "image-paint") {
const r17 = Math;
let r18 = renderTime;
if (r18 == null) {
r18 = 0;
}
let r50 = loadTime;
if (r50 == null) {
r50 = 0;
}
r45 = msToSec(r17.max(0, r18 - r50));
}
let c24027_1 = r45;
const attributes = {};
attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = "auto.ui.browser.elementtiming";
attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] = "ui.elementtiming";
attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = "component";
attributes["sentry.span_start_time_source"] = r42;
attributes["sentry.transaction_name"] = description;
attributes["element.id"] = entry.id;
const element = entry.element;
const r3 = element == null;
let r77 = void 0;
if (!r3) {
const tagName = element.tagName;
r77 = tagName == null ? void 0 : tagName.toLowerCase();
}
if (!r77) {
r77 = "unknown";
}
attributes["element.type"] = r77;
attributes["element.size"] = entry.naturalWidth ? entry.naturalHeight ? `${entry.naturalWidth}x${entry.naturalHeight}` : void 0 : void 0;
attributes["element.render_time"] = renderTime;
attributes["element.load_time"] = loadTime;
attributes["element.url"] = entry.url || void 0;
attributes["element.identifier"] = entry.identifier;
attributes["element.paint_type"] = name;
startSpan({
name: `element[${entry.identifier}]`,
attributes,
startTime,
onlyIfParent: true
}, (a0) => {
a0.end(c24027_0 + c24027_1);
});
}
});
};
export { _onElementTiming };
export function startTrackingElementTiming() {
return getBrowserPerformanceAPI() && browserPerformanceTimeOrigin() ? addPerformanceInstrumentationHandler("element", _onElementTiming) : () => {};
}