{"version":3,"file":"captureRequestError.js","sources":["../../../src/common/captureRequestError.ts"],"sourcesContent":["import type { RequestEventData } from '@sentry/core';\nimport { captureException, headersToDict, withScope } from '@sentry/core';\nimport { flushSafelyWithTimeout, waitUntil } from './utils/responseEnd';\n\ntype RequestInfo = {\n path: string;\n method: string;\n headers: Record;\n};\n\ntype ErrorContext = {\n routerKind: string; // 'Pages Router' | 'App Router'\n routePath: string;\n routeType: string; // 'render' | 'route' | 'middleware'\n};\n\n/**\n * Reports errors passed to the the Next.js `onRequestError` instrumentation hook.\n */\nexport function captureRequestError(error: unknown, request: RequestInfo, errorContext: ErrorContext): void {\n withScope(scope => {\n scope.setSDKProcessingMetadata({\n normalizedRequest: {\n headers: headersToDict(request.headers),\n method: request.method,\n } satisfies RequestEventData,\n });\n\n scope.setContext('nextjs', {\n request_path: request.path,\n router_kind: errorContext.routerKind,\n router_path: errorContext.routePath,\n route_type: errorContext.routeType,\n });\n\n scope.setTransactionName(errorContext.routePath);\n\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.function.nextjs.on_request_error',\n },\n });\n\n waitUntil(flushSafelyWithTimeout());\n });\n}\n"],"names":[],"mappings":";;;AAgBA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,KAAK,EAAW,OAAO,EAAe,YAAY,EAAsB;AAC5G,EAAE,SAAS,CAAC,KAAA,IAAS;AACrB,IAAI,KAAK,CAAC,wBAAwB,CAAC;AACnC,MAAM,iBAAiB,EAAE;AACzB,QAAQ,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC;AAC/C,QAAQ,MAAM,EAAE,OAAO,CAAC,MAAM;AAC9B,OAAM;AACN,KAAK,CAAC;;AAEN,IAAI,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE;AAC/B,MAAM,YAAY,EAAE,OAAO,CAAC,IAAI;AAChC,MAAM,WAAW,EAAE,YAAY,CAAC,UAAU;AAC1C,MAAM,WAAW,EAAE,YAAY,CAAC,SAAS;AACzC,MAAM,UAAU,EAAE,YAAY,CAAC,SAAS;AACxC,KAAK,CAAC;;AAEN,IAAI,KAAK,CAAC,kBAAkB,CAAC,YAAY,CAAC,SAAS,CAAC;;AAEpD,IAAI,gBAAgB,CAAC,KAAK,EAAE;AAC5B,MAAM,SAAS,EAAE;AACjB,QAAQ,OAAO,EAAE,KAAK;AACtB,QAAQ,IAAI,EAAE,uCAAuC;AACrD,OAAO;AACP,KAAK,CAAC;;AAEN,IAAI,SAAS,CAAC,sBAAsB,EAAE,CAAC;AACvC,EAAE,CAAC,CAAC;AACJ;;;;"}