Skip to content

Commit

Permalink
Add special getinitialprops to new proxy loader template
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Aug 19, 2022
1 parent 0a4271b commit 00a8058
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/nextjs/src/config/templates/proxyLoaderTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ const origGetInitialProps = pageComponent.getInitialProps;
const origGetStaticProps = userPageModule.getStaticProps;
const origGetServerSideProps = userPageModule.getServerSideProps;

const getInitialPropsWrappers: Record<string, any> = {
'/_app': Sentry.withSentryServerSideAppGetInitialProps,
'/_document': Sentry.withSentryServerSideDocumentGetInitialProps,
'/_error': Sentry.withSentryServerSideErrorGetInitialProps,
};

const getInitialPropsWrapper = getInitialPropsWrappers['__ROUTE__'] || Sentry.withSentryServerSideGetInitialProps;

if (typeof origGetInitialProps === 'function') {
pageComponent.getInitialProps = Sentry.withSentryServerSideGetInitialProps(
origGetInitialProps,
'__ROUTE__',
) as NextPageComponent['getInitialProps'];
pageComponent.getInitialProps = getInitialPropsWrapper(origGetInitialProps) as NextPageComponent['getInitialProps'];
}

export const getStaticProps =
Expand Down

0 comments on commit 00a8058

Please sign in to comment.