import { getActiveSpan } from '@sentry/core'; import { withEdgeWrapping } from '../common/utils/edgeWrapperUtils.js'; /** * Wraps a Next.js edge route handler with Sentry error and performance instrumentation. */ function wrapApiHandlerWithSentry( handler, parameterizedRoute, ) { return new Proxy(handler, { apply: (wrappingTarget, thisArg, args) => { const req = args[0]; const activeSpan = getActiveSpan(); const wrappedHandler = withEdgeWrapping(wrappingTarget, { spanDescription: activeSpan || !(req instanceof Request) ? `handler (${parameterizedRoute})` : `${req.method} ${parameterizedRoute}`, spanOp: activeSpan ? 'function' : 'http.server', mechanismFunctionName: 'wrapApiHandlerWithSentry', }); return wrappedHandler.apply(thisArg, args); }, }); } /** * @deprecated Use `wrapApiHandlerWithSentry` instead. */ const withSentryAPI = wrapApiHandlerWithSentry; export { withSentryAPI, wrapApiHandlerWithSentry }; //# sourceMappingURL=wrapApiHandlerWithSentry.js.map