Files
klz-cables.com/.pnpm-store/v10/files/b3/d2d2a849b654a9e54873ae12d85f16778fd94bc48c1a223cbb6933b82b5a7cf7025d4b2f0f23ed6b6f408310f1b50123ca1cadb80eef1d2a1bb92725391821
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

96 lines
3.4 KiB
Plaintext

Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const core = require('@sentry/core');
const addHeadersAsAttributes = require('../common/utils/addHeadersAsAttributes.js');
const responseEnd = require('../common/utils/responseEnd.js');
/**
* Wraps a Next.js edge route handler with Sentry error and performance instrumentation.
*/
function wrapApiHandlerWithSentry(
handler,
parameterizedRoute,
) {
return new Proxy(handler, {
apply: async (wrappingTarget, thisArg, args) => {
// TODO: We still should add central isolation scope creation for when our build-time instrumentation does not work anymore with turbopack.
return core.withIsolationScope(isolationScope => {
const req = args[0];
const currentScope = core.getCurrentScope();
let headerAttributes = {};
if (req instanceof Request) {
isolationScope.setSDKProcessingMetadata({
normalizedRequest: core.winterCGRequestToRequestData(req),
});
currentScope.setTransactionName(`${req.method} ${parameterizedRoute}`);
headerAttributes = addHeadersAsAttributes.addHeadersAsAttributes(req.headers);
} else {
currentScope.setTransactionName(`handler (${parameterizedRoute})`);
}
let spanName;
let op = 'http.server';
// If there is an active span, it likely means that the automatic Next.js OTEL instrumentation worked and we can
// rely on that for parameterization.
const activeSpan = core.getActiveSpan();
if (activeSpan) {
spanName = `handler (${parameterizedRoute})`;
op = undefined;
const rootSpan = core.getRootSpan(activeSpan);
if (rootSpan) {
rootSpan.updateName(
req instanceof Request ? `${req.method} ${parameterizedRoute}` : `handler ${parameterizedRoute}`,
);
rootSpan.setAttributes({
[core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server',
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
...headerAttributes,
});
core.setCapturedScopesOnSpan(rootSpan, currentScope, isolationScope);
}
} else if (req instanceof Request) {
spanName = `${req.method} ${parameterizedRoute}`;
} else {
spanName = `handler ${parameterizedRoute}`;
}
return core.startSpan(
{
name: spanName,
op: op,
attributes: {
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs.wrap_api_handler',
...headerAttributes,
},
},
() => {
return core.handleCallbackErrors(
() => wrappingTarget.apply(thisArg, args),
error => {
core.captureException(error, {
mechanism: {
type: 'auto.function.nextjs.wrap_api_handler',
handled: false,
},
});
},
() => {
responseEnd.waitUntil(responseEnd.flushSafelyWithTimeout());
},
);
},
);
});
},
});
}
exports.wrapApiHandlerWithSentry = wrapApiHandlerWithSentry;
//# sourceMappingURL=wrapApiHandlerWithSentry.js.map