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

201 lines
7.8 KiB
JavaScript

// Metro module 1118 (f1119).
import { forEachEnvelopeItem } from "./Module817";
import { getDefaultEnvironment } from "./Module1002";
import { getDebugMetadata } from "./Module1119";
const enrichAndroidProfileWithEventContext = function enrichAndroidProfileWithEventContext(a0, a1, a2) {
const r7 = Object;
const r18 = {
...a1
};
const r23 = {
debug_meta: {
images: getDebugMetadata()
},
build_id: a1.build_id || "",
device_cpu_frequencies: [],
device_is_emulator: null,
device_locale: null,
device_manufacturer: null,
device_model: null,
device_os_name: null,
device_os_version: null,
device_physical_memory_bytes: null,
environment: null,
profile_id: null,
timestamp: null,
release: null,
dist: null,
transaction_id: null,
transaction_name: null,
trace_id: null,
version_name: null,
version_code: null
};
const contexts = a2.contexts;
const r28 = contexts !== null ? contexts !== void 0 ? contexts.device : void 0 : void 0;
r23.device_is_emulator = (r28 !== null ? r28 !== void 0 ? r28.simulator : void 0 : void 0) || false;
const contexts2 = a2.contexts;
r23.device_locale = (contexts2 !== null ? contexts2 !== void 0 ? contexts2.device : void 0 : void 0) && a2.contexts.device.locale || "";
const contexts3 = a2.contexts;
const r35 = contexts3 !== null ? contexts3 !== void 0 ? contexts3.device : void 0 : void 0;
r23.device_manufacturer = (r35 !== null ? r35 !== void 0 ? r35.manufacturer : void 0 : void 0) || "";
const contexts4 = a2.contexts;
const r38 = contexts4 !== null ? contexts4 !== void 0 ? contexts4.device : void 0 : void 0;
r23.device_model = (r38 !== null ? r38 !== void 0 ? r38.model : void 0 : void 0) || "";
const contexts5 = a2.contexts;
const r41 = contexts5 !== null ? contexts5 !== void 0 ? contexts5.os : void 0 : void 0;
r23.device_os_name = (r41 !== null ? r41 !== void 0 ? r41.name : void 0 : void 0) || "";
const contexts6 = a2.contexts;
const r44 = contexts6 !== null ? contexts6 !== void 0 ? contexts6.os : void 0 : void 0;
r23.device_os_version = (r44 !== null ? r44 !== void 0 ? r44.version : void 0 : void 0) || "";
const contexts7 = a2.contexts;
const r47 = contexts7 !== null ? contexts7 !== void 0 ? contexts7.device : void 0 : void 0;
r23.device_physical_memory_bytes = (r47 !== null ? r47 !== void 0 ? r47.memory_size : void 0 : void 0) && Number(a2.contexts.device.memory_size).toString(10) || "";
r23.environment = a2.environment || getDefaultEnvironment();
r23.profile_id = a0;
const start_timestamp = a2.start_timestamp;
const r61 = Date;
r23.timestamp = start_timestamp ? new r61(1000 * a2.start_timestamp).toISOString() : new r61().toISOString();
r23.release = a2.release || "";
r23.dist = a2.dist || "";
r23.transaction_id = a2.event_id || "";
r23.transaction_name = a2.transaction || "";
const contexts8 = a2.contexts;
const r79 = contexts8 !== null ? contexts8 !== void 0 ? contexts8.trace : void 0 : void 0;
r23.trace_id = (r79 !== null ? r79 !== void 0 ? r79.trace_id : void 0 : void 0) || "";
r23.version_name = a2.release || "";
r23.version_code = a2.dist || "";
return r7.assign(r18, r23);
};
export function isValidProfile(a0) {
return !(a0.samples.length <= 1);
}
export function findProfiledTransactionsFromEnvelope(a0) {
const r1 = [];
let c12815_0 = r1;
forEachEnvelopeItem(a0, (a0, a1) => {
if (a1 === "transaction") {
const r5 = 1 < a0.length;
let r0 = 1;
if (r5) {
do {
const contexts = a0[r0].contexts;
const r1 = r0;
const r14 = contexts !== null ? contexts !== void 0 ? contexts.trace : void 0 : void 0;
const r15 = r14 !== null ? r14 !== void 0 ? r14.data : void 0 : void 0;
if (r15 !== null ? r15 !== void 0 ? r15.profile_id : void 0 : void 0) {
c12815_0.push(a0[r1]);
}
r0 = r1 + 1;
} while (r0 < a0.length);
}
}
});
return r1;
}
export function enrichCombinedProfileWithEventContext(a0, a1, a2) {
if ("js_profile" in a1) {
return enrichAndroidProfileWithEventContext(a0, a1, a2);
}
if (a1.profile && !(a1.profile.samples.length <= 1)) {
const contexts = a2.contexts;
const r28 = contexts !== null ? contexts !== void 0 ? contexts.trace : void 0 : void 0;
const trace_id = (r28 !== null ? r28 !== void 0 ? r28.trace_id : void 0 : void 0) || "";
if (trace_id != null) {
trace_id.length;
}
const r11 = Object;
const r32 = {
...a1
};
const start_timestamp = a2.start_timestamp;
const r36 = Date;
const timestamp = start_timestamp ? new r36(1000 * a2.start_timestamp).toISOString() : new r36().toISOString();
const release = a2.release || "";
const environment = a2.environment || getDefaultEnvironment();
const contexts2 = a2.contexts;
const r56 = contexts2 !== null ? contexts2 !== void 0 ? contexts2.os : void 0 : void 0;
const name = (r56 !== null ? r56 !== void 0 ? r56.name : void 0 : void 0) || "";
const contexts3 = a2.contexts;
const r60 = contexts3 !== null ? contexts3 !== void 0 ? contexts3.os : void 0 : void 0;
const version = (r60 !== null ? r60 !== void 0 ? r60.version : void 0 : void 0) || "";
const contexts4 = a2.contexts;
const r63 = contexts4 !== null ? contexts4 !== void 0 ? contexts4.os : void 0 : void 0;
const os = {
name,
version,
build_number: (r63 !== null ? r63 !== void 0 ? r63.build : void 0 : void 0) || ""
};
const contexts5 = a2.contexts;
const locale = (contexts5 !== null ? contexts5 !== void 0 ? contexts5.device : void 0 : void 0) && a2.contexts.device.locale || "";
const contexts6 = a2.contexts;
const r71 = contexts6 !== null ? contexts6 !== void 0 ? contexts6.device : void 0 : void 0;
const model = (r71 !== null ? r71 !== void 0 ? r71.model : void 0 : void 0) || "";
const contexts7 = a2.contexts;
const r74 = contexts7 !== null ? contexts7 !== void 0 ? contexts7.device : void 0 : void 0;
const manufacturer = (r74 !== null ? r74 !== void 0 ? r74.manufacturer : void 0 : void 0) || "";
const contexts8 = a2.contexts;
const r77 = contexts8 !== null ? contexts8 !== void 0 ? contexts8.device : void 0 : void 0;
const architecture = (r77 !== null ? r77 !== void 0 ? r77.arch : void 0 : void 0) || "";
const contexts9 = a2.contexts;
const r80 = contexts9 !== null ? contexts9 !== void 0 ? contexts9.device : void 0 : void 0;
const device = {
locale,
model,
manufacturer,
architecture,
is_emulator: (r80 !== null ? r80 !== void 0 ? r80.simulator : void 0 : void 0) || false
};
const name2 = a2.transaction || "";
const id = a2.event_id || "";
const transaction = a1.transaction;
const transaction2 = {
name: name2,
id,
trace_id,
active_thread_id: (transaction !== null ? transaction !== void 0 ? transaction.active_thread_id : void 0 : void 0) || ""
};
const debugMetadata = getDebugMetadata();
const debug_meta = a1.debug_meta;
return r11.assign(r32, {
event_id: a0,
runtime: {
name: "hermes",
version: ""
},
timestamp,
release,
environment,
os,
device,
transaction: transaction2,
debug_meta: {
images: [...debugMetadata, ...(debug_meta !== null ? debug_meta !== void 0 ? debug_meta.images : void 0 : void 0) || []]
}
});
}
return null;
}
export { enrichAndroidProfileWithEventContext };
export function createHermesProfilingEvent(a0) {
return {
platform: "javascript",
version: "1",
profile: a0,
transaction: {
active_thread_id: a0.active_thread_id
}
};
}
export function addProfilesToEnvelope(a0, a1) {
if (!a1.length) {
return a0;
}
for (const item of a1) {
a0[1].push([{
type: "profile"
}, item]);
}
return a0;
}