UNPKG

@sentry/nextjs

Version:
45 lines (41 loc) • 1.66 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const core = require('@sentry/core'); const isBuild = require('../utils/isBuild.js'); const wrapperUtils = require('../utils/wrapperUtils.js'); function wrapErrorGetInitialPropsWithSentry(origErrorGetInitialProps) { return new Proxy(origErrorGetInitialProps, { apply: async (wrappingTarget, thisArg, args) => { if (isBuild.isBuild()) { return wrappingTarget.apply(thisArg, args); } const [context] = args; const { req, res } = context; const errorWrappedGetInitialProps = wrapperUtils.withErrorInstrumentation(wrappingTarget); if (req && res) { const tracedGetInitialProps = wrapperUtils.withTracedServerSideDataFetcher(errorWrappedGetInitialProps, req, res, { dataFetcherRouteName: "/_error", requestedRouteName: context.pathname, dataFetchingMethodName: "getInitialProps" }); const { data: errorGetInitialProps, baggage, sentryTrace } = await tracedGetInitialProps.apply(thisArg, args); if (core.isObjectLike(errorGetInitialProps)) { if (sentryTrace) { errorGetInitialProps._sentryTraceData = sentryTrace; } if (baggage) { errorGetInitialProps._sentryBaggage = baggage; } } return errorGetInitialProps; } else { return errorWrappedGetInitialProps.apply(thisArg, args); } } }); } exports.wrapErrorGetInitialPropsWithSentry = wrapErrorGetInitialPropsWithSentry; //# sourceMappingURL=wrapErrorGetInitialPropsWithSentry.js.map