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

72 lines
2.5 KiB
JavaScript

// Metro module 918 (f919).
import * as _consoleSandbox from "./consoleSandbox";
import { GLOBAL_OBJ } from "./Module821";
import { addConsoleInstrumentationHandler } from "./instrumentConsole";
import { getClient, withScope } from "./Module848";
import { defineIntegration } from "./setupIntegration";
import { severityLevelFromString } from "./Module920";
import { addExceptionMechanism } from "./Module830";
import { safeJoin } from "./Module832";
import { captureException } from "./captureCheckIn";
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
export const captureConsoleIntegration = defineIntegration(function(r1 = {}) {
const CONSOLE_LEVELS = r1.levels || _consoleSandbox.CONSOLE_LEVELS;
let handled2 = r1.handled;
if (handled2 == null) {
handled2 = true;
}
let c12563_1 = handled2;
return {
name: "CaptureConsole",
setup: (c23903_0) => {
if ("console" in GLOBAL_OBJ) {
addConsoleInstrumentationHandler(({ args: args2, level: level2 }) => {
if (getClient() === c23903_0 && CONSOLE_LEVELS.includes(level2)) {
const args = args2;
const level = level2;
const handled = c12563_1;
let c28687_3 = severityLevelFromString(level);
const syntheticException = new Error();
const captureContext = {
level: severityLevelFromString(level),
extra: {
arguments: args
}
};
withScope((a0) => {
a0.addEventProcessor((a0) => {
a0.logger = "console";
addExceptionMechanism(a0, {
handled,
type: "auto.core.capture_console"
});
return a0;
});
if (level !== "assert") {
const r43 = args.find((arg) => arg instanceof Error);
if (r43) {
captureException(r43, captureContext);
} else {
a0.captureMessage(safeJoin(args, " "), c28687_3, {
captureContext,
syntheticException
});
}
} else if (!args[0]) {
const r28 = `Assertion failed: ${safeJoin(args.slice(1), " ") || "console.assert"}`;
a0.setExtra("arguments", args.slice(1));
a0.captureMessage(r28, c28687_3, {
captureContext,
syntheticException
});
}
});
}
});
}
}
};
});