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
1 line
4.5 KiB
Plaintext
1 line
4.5 KiB
Plaintext
{"version":3,"file":"wrapServerComponentWithSentry.js","sources":["../../../src/common/wrapServerComponentWithSentry.ts"],"sourcesContent":["import type { RequestEventData } from '@sentry/core';\nimport {\n captureException,\n getActiveSpan,\n getIsolationScope,\n handleCallbackErrors,\n SPAN_STATUS_ERROR,\n SPAN_STATUS_OK,\n winterCGHeadersToDict,\n} from '@sentry/core';\nimport { isNotFoundNavigationError, isRedirectNavigationError } from '../common/nextNavigationErrorUtils';\nimport type { ServerComponentContext } from '../common/types';\nimport { flushSafelyWithTimeout, waitUntil } from '../common/utils/responseEnd';\n\n/**\n * Wraps an `app` directory server component with Sentry error instrumentation.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapServerComponentWithSentry<F extends (...args: any[]) => any>(\n appDirComponent: F,\n context: ServerComponentContext,\n): F {\n // Even though users may define server components as async functions, for the client bundles\n // Next.js will turn them into synchronous functions and it will transform any `await`s into instances of the `use`\n // hook. 🤯\n return new Proxy(appDirComponent, {\n apply: (originalFunction, thisArg, args) => {\n const isolationScope = getIsolationScope();\n\n const headersDict = context.headers ? winterCGHeadersToDict(context.headers) : undefined;\n\n isolationScope.setSDKProcessingMetadata({\n normalizedRequest: {\n headers: headersDict,\n } satisfies RequestEventData,\n });\n\n return handleCallbackErrors(\n () => originalFunction.apply(thisArg, args),\n error => {\n const span = getActiveSpan();\n const { componentRoute, componentType } = context;\n let shouldCapture = true;\n isolationScope.setTransactionName(`${componentType} Server Component (${componentRoute})`);\n\n if (span) {\n if (isNotFoundNavigationError(error)) {\n // We don't want to report \"not-found\"s\n shouldCapture = false;\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'not_found' });\n } else if (isRedirectNavigationError(error)) {\n // We don't want to report redirects\n shouldCapture = false;\n span.setStatus({ code: SPAN_STATUS_OK });\n } else {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n }\n\n if (shouldCapture) {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.function.nextjs.server_component',\n },\n });\n }\n },\n () => {\n waitUntil(flushSafelyWithTimeout());\n },\n );\n },\n });\n}\n"],"names":["getIsolationScope","winterCGHeadersToDict","handleCallbackErrors","getActiveSpan","isNotFoundNavigationError","SPAN_STATUS_ERROR","isRedirectNavigationError","SPAN_STATUS_OK","captureException","waitUntil","flushSafelyWithTimeout"],"mappings":";;;;;;AAcA;AACA;AACA;AACA;AACO,SAAS,6BAA6B;AAC7C,EAAE,eAAe;AACjB,EAAE,OAAO;AACT,EAAK;AACL;AACA;AACA;AACA,EAAE,OAAO,IAAI,KAAK,CAAC,eAAe,EAAE;AACpC,IAAI,KAAK,EAAE,CAAC,gBAAgB,EAAE,OAAO,EAAE,IAAI,KAAK;AAChD,MAAM,MAAM,cAAA,GAAiBA,sBAAiB,EAAE;;AAEhD,MAAM,MAAM,WAAA,GAAc,OAAO,CAAC,OAAA,GAAUC,0BAAqB,CAAC,OAAO,CAAC,OAAO,CAAA,GAAI,SAAS;;AAE9F,MAAM,cAAc,CAAC,wBAAwB,CAAC;AAC9C,QAAQ,iBAAiB,EAAE;AAC3B,UAAU,OAAO,EAAE,WAAW;AAC9B,SAAQ;AACR,OAAO,CAAC;;AAER,MAAM,OAAOC,yBAAoB;AACjC,QAAQ,MAAM,gBAAgB,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;AACnD,QAAQ,SAAS;AACjB,UAAU,MAAM,IAAA,GAAOC,kBAAa,EAAE;AACtC,UAAU,MAAM,EAAE,cAAc,EAAE,aAAA,EAAc,GAAI,OAA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