From a5616973dc618f2d9a30224d1651cd80644abede Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 19 Aug 2022 13:32:45 +0000 Subject: [PATCH] Patch up rebase --- .../config/templates/proxyLoaderTemplate.ts | 2 +- packages/nextjs/src/config/wrappers/index.ts | 2 +- .../wrappers/withSentryGetInitialProps.ts | 26 ------------------- .../wrappers/withSentryGetServerSideProps.ts | 1 + packages/nextjs/src/index.server.ts | 6 ++++- 5 files changed, 8 insertions(+), 29 deletions(-) delete mode 100644 packages/nextjs/src/config/wrappers/withSentryGetInitialProps.ts diff --git a/packages/nextjs/src/config/templates/proxyLoaderTemplate.ts b/packages/nextjs/src/config/templates/proxyLoaderTemplate.ts index e303ebc24ea0..43630f52daae 100644 --- a/packages/nextjs/src/config/templates/proxyLoaderTemplate.ts +++ b/packages/nextjs/src/config/templates/proxyLoaderTemplate.ts @@ -27,7 +27,7 @@ const origGetStaticProps = userPageModule.getStaticProps; const origGetServerSideProps = userPageModule.getServerSideProps; if (typeof origGetInitialProps === 'function') { - pageComponent.getInitialProps = Sentry.withSentryGetInitialProps( + pageComponent.getInitialProps = Sentry.withSentryServerSideGetInitialProps( origGetInitialProps, '__ROUTE__', ) as NextPageComponent['getInitialProps']; diff --git a/packages/nextjs/src/config/wrappers/index.ts b/packages/nextjs/src/config/wrappers/index.ts index 347f8c99f875..bd47765ae04f 100644 --- a/packages/nextjs/src/config/wrappers/index.ts +++ b/packages/nextjs/src/config/wrappers/index.ts @@ -1,3 +1,3 @@ export { withSentryGetStaticProps } from './withSentryGetStaticProps'; -export { withSentryGetInitialProps } from './withSentryGetInitialProps'; export { withSentryGetServerSideProps } from './withSentryGetServerSideProps'; +export { withSentryServerSideGetInitialProps } from './withSentryServerSideGetInitialProps'; diff --git a/packages/nextjs/src/config/wrappers/withSentryGetInitialProps.ts b/packages/nextjs/src/config/wrappers/withSentryGetInitialProps.ts deleted file mode 100644 index 9abf2c7a7f0a..000000000000 --- a/packages/nextjs/src/config/wrappers/withSentryGetInitialProps.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { NextPage } from 'next'; - -import { callDataFetcherTraced } from './wrapperUtils'; - -type GetInitialProps = Required>['getInitialProps']; - -/** - * Create a wrapped version of the user's exported `getInitialProps` function - * - * @param origGetInitialProps The user's `getInitialProps` function - * @param parameterizedRoute The page's parameterized route - * @returns A wrapped version of the function - */ -export function withSentryGetInitialProps( - origGetInitialProps: GetInitialProps, - parameterizedRoute: string, -): GetInitialProps { - return async function ( - ...getInitialPropsArguments: Parameters - ): Promise> { - return callDataFetcherTraced(origGetInitialProps, getInitialPropsArguments, { - parameterizedRoute, - dataFetchingMethodName: 'getInitialProps', - }); - }; -} diff --git a/packages/nextjs/src/config/wrappers/withSentryGetServerSideProps.ts b/packages/nextjs/src/config/wrappers/withSentryGetServerSideProps.ts index ca88e8dc3fcc..a9d06f17cf4e 100644 --- a/packages/nextjs/src/config/wrappers/withSentryGetServerSideProps.ts +++ b/packages/nextjs/src/config/wrappers/withSentryGetServerSideProps.ts @@ -1,3 +1,4 @@ +import { hasTracingEnabled } from '@sentry/tracing'; import { GetServerSideProps } from 'next'; import { isBuild } from '../../utils/isBuild'; diff --git a/packages/nextjs/src/index.server.ts b/packages/nextjs/src/index.server.ts index 0c1935b84d83..4fbe95bb8ee6 100644 --- a/packages/nextjs/src/index.server.ts +++ b/packages/nextjs/src/index.server.ts @@ -125,7 +125,11 @@ function addServerIntegrations(options: NextjsOptions): void { export type { SentryWebpackPluginOptions } from './config/types'; export { withSentryConfig } from './config'; export { isBuild } from './utils/isBuild'; -export { withSentryGetServerSideProps, withSentryGetStaticProps, withSentryGetInitialProps } from './config/wrappers'; +export { + withSentryGetServerSideProps, + withSentryGetStaticProps, + withSentryServerSideGetInitialProps, +} from './config/wrappers'; export { withSentry } from './utils/withSentry'; // Wrap various server methods to enable error monitoring and tracing. (Note: This only happens for non-Vercel