Files
klz-cables.com/.pnpm-store/v10/files/12/063b5d0d75e90b962e7c69f8d9ca83fe544ed75c454fbe00f6668f1350aa82bf4e7fb3e06ab97bd00e8ed05e483eca37703729239f1ba203b079b5f7d21c43
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

69 lines
2.5 KiB
Plaintext

import { getIsolationScope, winterCGHeadersToDict, handleCallbackErrors, getActiveSpan, SPAN_STATUS_ERROR, SPAN_STATUS_OK, captureException } from '@sentry/core';
import { isNotFoundNavigationError, isRedirectNavigationError } from './nextNavigationErrorUtils.js';
import { waitUntil, flushSafelyWithTimeout } from './utils/responseEnd.js';
/**
* Wraps an `app` directory server component with Sentry error instrumentation.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function wrapServerComponentWithSentry(
appDirComponent,
context,
) {
// Even though users may define server components as async functions, for the client bundles
// Next.js will turn them into synchronous functions and it will transform any `await`s into instances of the `use`
// hook. 🤯
return new Proxy(appDirComponent, {
apply: (originalFunction, thisArg, args) => {
const isolationScope = getIsolationScope();
const headersDict = context.headers ? winterCGHeadersToDict(context.headers) : undefined;
isolationScope.setSDKProcessingMetadata({
normalizedRequest: {
headers: headersDict,
} ,
});
return handleCallbackErrors(
() => originalFunction.apply(thisArg, args),
error => {
const span = getActiveSpan();
const { componentRoute, componentType } = context;
let shouldCapture = true;
isolationScope.setTransactionName(`${componentType} Server Component (${componentRoute})`);
if (span) {
if (isNotFoundNavigationError(error)) {
// We don't want to report "not-found"s
shouldCapture = false;
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'not_found' });
} else if (isRedirectNavigationError(error)) {
// We don't want to report redirects
shouldCapture = false;
span.setStatus({ code: SPAN_STATUS_OK });
} else {
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });
}
}
if (shouldCapture) {
captureException(error, {
mechanism: {
handled: false,
type: 'auto.function.nextjs.server_component',
},
});
}
},
() => {
waitUntil(flushSafelyWithTimeout());
},
);
},
});
}
export { wrapServerComponentWithSentry };
//# sourceMappingURL=wrapServerComponentWithSentry.js.map