import * as Sentry from '@sentry/nextjs'; import * as serverComponentModule from '__SENTRY_WRAPPING_TARGET_FILE__'; export * from '__SENTRY_WRAPPING_TARGET_FILE__'; /* * This file is a template for the code which will be substituted when our webpack loader handles non-API files in the * `pages/` directory. * * We use `__SENTRY_WRAPPING_TARGET_FILE__` as a placeholder for the path to the file being wrapped. Because it's not a real package, * this causes both TS and ESLint to complain, hence the pragma comments below. */ const userPageModule = serverComponentModule ; const pageComponent = userPageModule ? userPageModule.default : undefined; const origGetInitialProps = pageComponent ? pageComponent.getInitialProps : undefined; const origGetStaticProps = userPageModule ? userPageModule.getStaticProps : undefined; const origGetServerSideProps = userPageModule ? userPageModule.getServerSideProps : undefined; // eslint-disable-next-line @typescript-eslint/no-explicit-any const getInitialPropsWrappers = { '/_app': Sentry.wrapAppGetInitialPropsWithSentry, '/_document': Sentry.wrapDocumentGetInitialPropsWithSentry, '/_error': Sentry.wrapErrorGetInitialPropsWithSentry, }; const getInitialPropsWrapper = getInitialPropsWrappers['__ROUTE__'] || Sentry.wrapGetInitialPropsWithSentry; if (pageComponent && typeof origGetInitialProps === 'function') { pageComponent.getInitialProps = getInitialPropsWrapper(origGetInitialProps) ; } const getStaticProps = typeof origGetStaticProps === 'function' ? Sentry.wrapGetStaticPropsWithSentry(origGetStaticProps, '__ROUTE__') : undefined; const getServerSideProps = typeof origGetServerSideProps === 'function' ? Sentry.wrapGetServerSidePropsWithSentry(origGetServerSideProps, '__ROUTE__') : undefined; const pageWrapperTemplate = pageComponent ? Sentry.wrapPageComponentWithSentry(pageComponent ) : pageComponent; export { pageWrapperTemplate as default, getServerSideProps, getStaticProps };