@sentry/nextjs
Version:
Official Sentry SDK for Next.js
37 lines (30 loc) • 984 B
JavaScript
import { withScope, headersToDict, captureException, vercelWaitUntil } from '@sentry/core';
import { flushSafelyWithTimeout } from './utils/responseEnd.js';
/**
* Reports errors passed to the the Next.js `onRequestError` instrumentation hook.
*/
function captureRequestError(error, request, errorContext) {
withScope(scope => {
scope.setSDKProcessingMetadata({
normalizedRequest: {
headers: headersToDict(request.headers),
method: request.method,
} ,
});
scope.setContext('nextjs', {
request_path: request.path,
router_kind: errorContext.routerKind,
router_path: errorContext.routePath,
route_type: errorContext.routeType,
});
scope.setTransactionName(errorContext.routePath);
captureException(error, {
mechanism: {
handled: false,
},
});
vercelWaitUntil(flushSafelyWithTimeout());
});
}
export { captureRequestError };
//# sourceMappingURL=captureRequestError.js.map