Skip to content

Commit 00a8058

Browse files
committed
Add special getinitialprops to new proxy loader template
1 parent 0a4271b commit 00a8058

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/nextjs/src/config/templates/proxyLoaderTemplate.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ const origGetInitialProps = pageComponent.getInitialProps;
2626
const origGetStaticProps = userPageModule.getStaticProps;
2727
const origGetServerSideProps = userPageModule.getServerSideProps;
2828

29+
const getInitialPropsWrappers: Record<string, any> = {
30+
'/_app': Sentry.withSentryServerSideAppGetInitialProps,
31+
'/_document': Sentry.withSentryServerSideDocumentGetInitialProps,
32+
'/_error': Sentry.withSentryServerSideErrorGetInitialProps,
33+
};
34+
35+
const getInitialPropsWrapper = getInitialPropsWrappers['__ROUTE__'] || Sentry.withSentryServerSideGetInitialProps;
36+
2937
if (typeof origGetInitialProps === 'function') {
30-
pageComponent.getInitialProps = Sentry.withSentryServerSideGetInitialProps(
31-
origGetInitialProps,
32-
'__ROUTE__',
33-
) as NextPageComponent['getInitialProps'];
38+
pageComponent.getInitialProps = getInitialPropsWrapper(origGetInitialProps) as NextPageComponent['getInitialProps'];
3439
}
3540

3641
export const getStaticProps =

0 commit comments

Comments
 (0)