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

146 lines
3.8 KiB
JavaScript

// Metro module 1059 (f1060).
import { spanToJSON, withActiveSpan, startInactiveSpan, getClient, getCurrentScope } from "./Module817";
import { WINDOW } from "./Module1039";
import { onHidden } from "./Module1060";
import { HermesBuiltin } from "../_hermes/prelude";
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
export function extractNetworkProtocol(a0) {
let name = "unknown";
let version = "unknown";
let r0 = "";
for (const item of a0) {
if (item !== "/") {
const isNaN2 = isNaN(Number(item));
const r33 = r0;
if (isNaN2) {
r0 = r33 + item;
continue;
}
name = r33 !== "h" ? r0 : "http";
version = a0.split(r0)[1];
break;
}
[name, version] = a0.split("/");
break;
}
if (r0 === a0) {
name = r0;
}
return {
name,
version
};
}
export function getBrowserPerformanceAPI() {
return WINDOW.addEventListener && WINDOW.performance;
}
export function isMeasurementValue(a0) {
return typeof a0 === "number" ? isFinite(a0) : typeof a0 === "number";
}
export function listenForWebVitalReportEvents(a0, c12691_0) {
let spanId, c12691_3, c12691_4;
let c12691_2 = false;
onHidden(() => {
const r0 = c12691_2;
if (r0 ? !r0 : spanId) {
c12691_0("pagehide", spanId);
}
c12691_2 = true;
});
c12691_3 = a0.on("beforeStartNavigationSpan", (a0, a1) => {
if (!a1?.isRedirect) {
const r8 = c12691_2;
if (r8 ? !r8 : spanId) {
c12691_0("navigation", spanId);
}
c12691_2 = true;
c12691_3();
c12691_4();
}
});
c12691_4 = a0.on("afterStartPageLoadSpan", (a0) => {
spanId = a0.spanContext().spanId;
c12691_4();
});
}
export function msToSec(a0) {
return a0 / 1000;
}
export function startAndEndSpan(a0, a1, c12692_1, a3) {
const startTime = a1;
if (a3 == null) {
HermesBuiltin.throwTypeError("Cannot destructure 'undefined' or 'null'.");
throw new Error("unreachable");
}
let c12692_2 = HermesBuiltin.copyDataProperties({}, a3, void 0);
const start_timestamp = spanToJSON(a0).start_timestamp;
if (start_timestamp && start_timestamp > a1 && typeof a0.updateStartTime === "function") {
a0.updateStartTime(a1);
}
return withActiveSpan(a0, () => {
const r13 = startInactiveSpan({
startTime,
...c12692_2
});
if (r13) {
r13.end(c12692_1);
}
return r13;
});
}
export function startStandaloneWebVitalSpan(a0) {
let profile_id;
const client = getClient();
if (client) {
const { name, transaction, attributes, startTime: startTime2 } = a0;
const options = client.getOptions();
const { release, environment, sendDefaultPii } = options;
const integrationByName = client.getIntegrationByName("Replay");
let replay_id = integrationByName == null ? void 0 : integrationByName.getReplayId();
const currentScope = getCurrentScope();
const user = currentScope.getUser();
let user2 = user !== void 0 ? user.email || user.id || user.ip_address : void 0;
try {
profile_id = currentScope.getScopeData().contexts.profile.profile_id;
} catch ($e) {}
if (!user2) {
user2 = void 0;
}
if (!profile_id) {
profile_id = void 0;
}
if (!replay_id) {
replay_id = void 0;
}
return startInactiveSpan({
name,
attributes: {
release,
environment,
user: user2,
profile_id,
replay_id,
transaction,
"user_agent.original": WINDOW.navigator?.userAgent,
"client.address": sendDefaultPii ? "{{auto}}" : void 0,
...attributes
},
startTime: startTime2,
experimental: {
standalone: true
}
});
}
}
export function supportsWebVital(a0) {
let r5;
try {
r5 = PerformanceObserver.supportedEntryTypes.includes(a0);
} catch ($e) {
return false;
}
return r5;
}