// Metro module 870 (f871). import { uuid4, addExceptionMechanism } from "./Module830"; import { dateTimestampInSeconds } from "./dateTimestampInSeconds"; import { getCombinedScopeData, applyScopeDataToEvent } from "./mergeScopeData"; import { notifyEventProcessors } from "./Module872"; import { DEFAULT_ENVIRONMENT } from "./Module858"; import { truncate } from "./Module832"; import { getFilenameToDebugIdMap } from "./getFilenameToDebugIdMap"; import { normalize } from "./normalize"; import { Scope } from "./Scope"; function $mk67220($env) { return ({ stacktrace }) => { if (stacktrace != null) { const frames = stacktrace.frames; if (frames != null) { frames.forEach($mk101444($env)); } } }; } function $mk67221($env) { return ({ stacktrace }) => { if (stacktrace != null) { const frames = stacktrace.frames; if (frames != null) { frames.forEach($mk101445($env)); } } }; } function $mk67222($env) { return (a0) => { const [code_file, debug_id] = a0; $env[1].push({ type: "sourcemap", code_file, debug_id }); }; } function $mk101444($env) { return (a0) => { if (a0.filename) { a0.debug_id = $env[0][a0.filename]; } }; } function $mk101445($env) { return (a0) => { if (a0.debug_id) { const r6 = $env; if (a0.abs_path) { r6[0][a0.abs_path] = a0.debug_id; } else if (a0.filename) { r6[0][a0.filename] = a0.debug_id; } delete a0["debug_id"]; } }; } let _excluded; const applyClientOptions = function applyClientOptions(a0, { environment, release, dist, maxValueLength }) { a0.environment = a0.environment || environment || DEFAULT_ENVIRONMENT; const release2 = a0.release; if (release2 ? !release2 : release) { a0.release = release; } const dist2 = a0.dist; if (dist2 ? !dist2 : dist) { a0.dist = dist; } const request = a0.request; if (request?.url && maxValueLength) { request.url = truncate(request.url, maxValueLength); } if (maxValueLength) { const exception = a0.exception; if (exception != null) { const values = exception.values; if (values != null) { values.forEach((value) => { if (value.value) { value.value = truncate(value.value, maxValueLength); } }); } } } }; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); _excluded = ["user", "level", "extra", "contexts", "tags", "fingerprint", "propagationContext"]; export { applyClientOptions }; export function applyDebugIds(a0, a1) { let env12529; const r2 = env12529 = {}; env12529[0] = getFilenameToDebugIdMap(a1); const exception = a0.exception; if (exception != null) { const values = exception.values; if (values != null) { values.forEach($mk67220(r2)); } } } export function applyDebugMeta(a0) { let env12530; const r2 = env12530 = {}; const r5 = {}; env12530[0] = r5; const exception = a0.exception; if (exception != null) { const values = exception.values; if (values != null) { values.forEach($mk67221(r2)); } } if (Object.keys(r5).length !== 0) { a0.debug_meta = a0.debug_meta || {}; a0.debug_meta.images = a0.debug_meta.images || []; env12530[1] = a0.debug_meta.images; Object.entries(r5).forEach($mk67222(r2)); } } export function parseEventHintOrCaptureContext(a0) { if (a0) { return a0 instanceof Scope || typeof a0 === "function" ? { captureContext: a0 } : Object.keys(a0).some((item) => _excluded.includes(item)) ? { captureContext: a0 } : a0; } } export function prepareEvent(a0, a1, a2, a3, a4, a5) { const { normalizeDepth = 3, normalizeMaxBreadth = 1000 } = a0; const r8 = { ...a1, event_id: a1.event_id || a2.event_id || uuid4(), timestamp: a1.timestamp || dateTimestampInSeconds() }; const r32 = a2.integrations || a0.integrations.map((integration) => integration.name); applyClientOptions(r8, a0); if (r32.length > 0) { r8.sdk = r8.sdk || {}; r8.sdk.integrations = [...r8.sdk.integrations || [], ...r32]; } if (a4) { a4.emit("applyFrameMetadata", a1); } if (a1.type === void 0) { let env12532; const stackParser = a0.stackParser; const r53 = env12532 = {}; env12532[0] = void 0; env12532[0] = getFilenameToDebugIdMap(stackParser); const exception = r8.exception; if (exception != null) { const values = exception.values; if (values != null) { values.forEach($mk67220(r53)); } } } const captureContext = a2.captureContext; let r68 = a3; if (captureContext) { const r76 = a3 ? a3.clone() : new Scope(); r76.update(captureContext); r68 = r76; } if (a2.mechanism) { addExceptionMechanism(r8, a2.mechanism); } const r88 = a4 ? a4.getEventProcessors() : []; const combinedScopeData = getCombinedScopeData(a5, r68); const attachments = [...a2.attachments || [], ...combinedScopeData.attachments]; if (attachments.length) { a2.attachments = attachments; } applyScopeDataToEvent(r8, combinedScopeData); return notifyEventProcessors([...r88, ...combinedScopeData.eventProcessors], r8, a2).then((result) => { if (result) { let env23868; const r4 = env23868 = {}; const r8 = {}; env23868[0] = r8; const exception = result.exception; if (exception != null) { const values = exception.values; if (values != null) { values.forEach($mk67221(r4)); } } if (Object.keys(r8).length !== 0) { result.debug_meta = result.debug_meta || {}; result.debug_meta.images = result.debug_meta.images || []; env23868[1] = result.debug_meta.images; Object.entries(r8).forEach($mk67222(r4)); } } let r40 = result; if (typeof normalizeDepth === "number") { r40 = result; if (normalizeDepth > 0) { const normalizeDepth2 = normalizeDepth; const normalizeMaxBreadth2 = normalizeMaxBreadth; let r44 = null; if (result) { const r45 = { ...result, ...result.breadcrumbs && { breadcrumbs: result.breadcrumbs.map((breadcrumb) => ({ ...breadcrumb, ...breadcrumb.data && { data: normalize(breadcrumb.data, normalizeDepth2, normalizeMaxBreadth2) } })) }, ...result.user && { user: normalize(result.user, normalizeDepth, normalizeMaxBreadth) }, ...result.contexts && { contexts: normalize(result.contexts, normalizeDepth, normalizeMaxBreadth) }, ...result.extra && { extra: normalize(result.extra, normalizeDepth, normalizeMaxBreadth) } }; if (result.contexts?.trace && r45.contexts) { r45.contexts.trace = result.contexts.trace; if (result.contexts.trace.data) { r45.contexts.trace.data = normalize(result.contexts.trace.data, normalizeDepth, normalizeMaxBreadth); } } if (result.spans) { r45.spans = result.spans.map((span) => ({ ...span, ...span.data && { data: normalize(span.data, normalizeDepth2, normalizeMaxBreadth2) } })); } const r117 = result.contexts?.flags && r45.contexts; r44 = r45; if (r117) { r45.contexts.flags = normalize(result.contexts.flags, 3, normalizeMaxBreadth); r44 = r45; } } r40 = r44; } } return r40; }); }