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.1 KiB
Plaintext
1 line
4.1 KiB
Plaintext
{"version":3,"file":"wrapGetInitialPropsWithSentry.js","sources":["../../../../src/common/pages-router-instrumentation/wrapGetInitialPropsWithSentry.ts"],"sourcesContent":["import type { NextPage } from 'next';\nimport { isBuild } from '../utils/isBuild';\nimport { withErrorInstrumentation, withTracedServerSideDataFetcher } from '../utils/wrapperUtils';\n\ntype GetInitialProps = Required<NextPage>['getInitialProps'];\n\n/**\n * Create a wrapped version of the user's exported `getInitialProps` function\n *\n * @param origGetInitialProps The user's `getInitialProps` function\n * @param parameterizedRoute The page's parameterized route\n * @returns A wrapped version of the function\n */\nexport function wrapGetInitialPropsWithSentry(origGetInitialProps: GetInitialProps): GetInitialProps {\n return new Proxy(origGetInitialProps, {\n apply: async (wrappingTarget, thisArg, args: Parameters<GetInitialProps>) => {\n if (isBuild()) {\n return wrappingTarget.apply(thisArg, args);\n }\n\n const [context] = args;\n const { req, res } = context;\n\n const errorWrappedGetInitialProps = withErrorInstrumentation(wrappingTarget);\n // Generally we can assume that `req` and `res` are always defined on the server:\n // https://nextjs.org/docs/api-reference/data-fetching/get-initial-props#context-object\n // This does not seem to be the case in dev mode. Because we have no clean way of associating the the data fetcher\n // span with each other when there are no req or res objects, we simply do not trace them at all here.\n if (req && res) {\n const tracedGetInitialProps = withTracedServerSideDataFetcher(errorWrappedGetInitialProps, req, res, {\n dataFetcherRouteName: context.pathname,\n requestedRouteName: context.pathname,\n dataFetchingMethodName: 'getInitialProps',\n });\n\n const {\n data: initialProps,\n baggage,\n sentryTrace,\n }: {\n data?: unknown;\n baggage?: string;\n sentryTrace?: string;\n } = (await tracedGetInitialProps.apply(thisArg, args)) ?? {}; // Next.js allows undefined to be returned from a getInitialPropsFunction.\n\n if (typeof initialProps === 'object' && initialProps !== null) {\n // The Next.js serializer throws on undefined values so we need to guard for it (#12102)\n if (sentryTrace) {\n (initialProps as Record<string, unknown>)._sentryTraceData = sentryTrace;\n }\n\n // The Next.js serializer throws on undefined values so we need to guard for it (#12102)\n if (baggage) {\n (initialProps as Record<string, unknown>)._sentryBaggage = baggage;\n }\n }\n\n return initialProps;\n } else {\n return errorWrappedGetInitialProps.apply(thisArg, args);\n }\n },\n });\n}\n"],"names":["isBuild","withErrorInstrumentation","withTracedServerSideDataFetcher"],"mappings":";;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,6BAA6B,CAAC,mBAAmB,EAAoC;AACrG,EAAE,OAAO,IAAI,KAAK,CAAC,mBAAmB,EAAE;AACxC,IAAI,KAAK,EAAE,OAAO,cAAc,EAAE,OAAO,EAAE,IAAI,KAAkC;AACjF,MAAM,IAAIA,eAAO,EAAE,EAAE;AACrB,QAAQ,OAAO,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;AAClD,MAAM;;AAEN,MAAM,MAAM,CAAC,OAAO,CAAA,GAAI,IAAI;AAC5B,MAAM,MAAM,EAAE,GAAG,EAAE,GAAA,EAAI,GAAI,OAAO;;AAElC,MAAM,MAAM,2BAAA,GAA8BC,qCAAwB,CAAC,cAAc,CAAC;AAClF;AACA;AACA;AACA;AACA,MAAM,IAAI,GAAA,IAAO,GAAG,EAAE;AACtB,QAAQ,MAAM,qBAAA,GAAwBC,4CAA+B,CAAC,2BAA2B,EAAE,GAAG,EAAE,GAAG,EAAE;AAC7G,UAAU,oBAAoB,EAAE,OAAO,CAAC,QAAQ;AAChD,UAAU,kBAAkB,EAAE,OAAO,CAAC,QAAQ;AAC9C,UAAU,sBAAsB,EAAE,iBAAiB;AACnD,SAAS,CAAC;;AAEV,QAAQ,MA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