Files
klz-cables.com/.pnpm-store/v10/files/a6/99bbedc114f5183868426a894bda883f4e76f775aa3f93c83ddf05410a054bcf83f2f2b3ebba96dc3ea8545db0d88bda9054d24e83b34bd1fa3d3a77611773
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

95 lines
2.8 KiB
Plaintext

Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const currentScopes = require('../currentScopes.js');
const _exports = require('../exports.js');
const console = require('../instrument/console.js');
const integration = require('../integration.js');
const debugLogger = require('../utils/debug-logger.js');
const misc = require('../utils/misc.js');
const severity = require('../utils/severity.js');
const string = require('../utils/string.js');
const worldwide = require('../utils/worldwide.js');
const INTEGRATION_NAME = 'CaptureConsole';
const _captureConsoleIntegration = ((options = {}) => {
const levels = options.levels || debugLogger.CONSOLE_LEVELS;
const handled = options.handled ?? true;
return {
name: INTEGRATION_NAME,
setup(client) {
if (!('console' in worldwide.GLOBAL_OBJ)) {
return;
}
console.addConsoleInstrumentationHandler(({ args, level }) => {
if (currentScopes.getClient() !== client || !levels.includes(level)) {
return;
}
consoleHandler(args, level, handled);
});
},
};
}) ;
/**
* Send Console API calls as Sentry Events.
*/
const captureConsoleIntegration = integration.defineIntegration(_captureConsoleIntegration);
function consoleHandler(args, level, handled) {
const severityLevel = severity.severityLevelFromString(level);
/*
We create this error here already to attach a stack trace to captured messages,
if users set `attachStackTrace` to `true` in Sentry.init.
We do this here already because we want to minimize the number of Sentry SDK stack frames
within the error. Technically, Client.captureMessage will also do it but this happens several
stack frames deeper.
*/
const syntheticException = new Error();
const captureContext = {
level: severity.severityLevelFromString(level),
extra: {
arguments: args,
},
};
currentScopes.withScope(scope => {
scope.addEventProcessor(event => {
event.logger = 'console';
misc.addExceptionMechanism(event, {
handled,
type: 'auto.core.capture_console',
});
return event;
});
if (level === 'assert') {
if (!args[0]) {
const message = `Assertion failed: ${string.safeJoin(args.slice(1), ' ') || 'console.assert'}`;
scope.setExtra('arguments', args.slice(1));
scope.captureMessage(message, severityLevel, { captureContext, syntheticException });
}
return;
}
const error = args.find(arg => arg instanceof Error);
if (error) {
_exports.captureException(error, captureContext);
return;
}
const message = string.safeJoin(args, ' ');
scope.captureMessage(message, severityLevel, { captureContext, syntheticException });
});
}
exports.captureConsoleIntegration = captureConsoleIntegration;
//# sourceMappingURL=captureconsole.js.map