From f6ff0827f4a2eadb1ed7fee731decfa58416bfba Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Wed, 10 Aug 2022 19:01:12 -0700 Subject: [PATCH] pass parameterized route to wrapper functions --- .../src/config/templates/dataFetchersLoaderTemplate.ts | 5 +++-- .../src/config/wrappers/withSentryGetServerSideProps.ts | 3 ++- .../nextjs/src/config/wrappers/withSentryGetStaticProps.ts | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/nextjs/src/config/templates/dataFetchersLoaderTemplate.ts b/packages/nextjs/src/config/templates/dataFetchersLoaderTemplate.ts index 66a75c599148..4f9984f3f136 100644 --- a/packages/nextjs/src/config/templates/dataFetchersLoaderTemplate.ts +++ b/packages/nextjs/src/config/templates/dataFetchersLoaderTemplate.ts @@ -21,9 +21,10 @@ const PARAMETERIZED_ROUTE = '__FILEPATH__'; export const getServerSideProps = typeof __ORIG_GSSP__ === 'function' - ? ServerSideSentryNextjsSDK.withSentryGetServerSideProps(__ORIG_GSSP__) + ? ServerSideSentryNextjsSDK.withSentryGetServerSideProps(__ORIG_GSSP__, PARAMETERIZED_ROUTE) : __ORIG_GSSP__; + export const getStaticProps = typeof __ORIG_GSPROPS__ === 'function' - ? ServerSideSentryNextjsSDK.withSentryGetStaticProps(__ORIG_GSPROPS__) + ? ServerSideSentryNextjsSDK.withSentryGetStaticProps(__ORIG_GSPROPS__, PARAMETERIZED_ROUTE) : __ORIG_GSPROPS__; diff --git a/packages/nextjs/src/config/wrappers/withSentryGetServerSideProps.ts b/packages/nextjs/src/config/wrappers/withSentryGetServerSideProps.ts index 0293ad999c45..bad402023ab3 100644 --- a/packages/nextjs/src/config/wrappers/withSentryGetServerSideProps.ts +++ b/packages/nextjs/src/config/wrappers/withSentryGetServerSideProps.ts @@ -5,9 +5,10 @@ import { callOriginal } from './wrapperUtils'; * Create a wrapped version of the user's exported `getServerSideProps` function * * @param origGetServerSideProps: The user's `getServerSideProps` function + * @param route: The page's parameterized route * @returns A wrapped version of the function */ -export function withSentryGetServerSideProps(origGetServerSideProps: GSSP['fn']): GSSP['wrappedFn'] { +export function withSentryGetServerSideProps(origGetServerSideProps: GSSP['fn'], route: string): GSSP['wrappedFn'] { return async function (context: GSSP['context']): Promise { return callOriginal(origGetServerSideProps, context); }; diff --git a/packages/nextjs/src/config/wrappers/withSentryGetStaticProps.ts b/packages/nextjs/src/config/wrappers/withSentryGetStaticProps.ts index 23d6023a25bf..88cda4890b86 100644 --- a/packages/nextjs/src/config/wrappers/withSentryGetStaticProps.ts +++ b/packages/nextjs/src/config/wrappers/withSentryGetStaticProps.ts @@ -5,9 +5,10 @@ import { callOriginal } from './wrapperUtils'; * Create a wrapped version of the user's exported `getStaticProps` function * * @param origGetStaticProps: The user's `getStaticProps` function + * @param route: The page's parameterized route * @returns A wrapped version of the function */ -export function withSentryGetStaticProps(origGetStaticProps: GSProps['fn']): GSProps['wrappedFn'] { +export function withSentryGetStaticProps(origGetStaticProps: GSProps['fn'], route: string): GSProps['wrappedFn'] { return async function (context: GSProps['context']): Promise { return callOriginal(origGetStaticProps, context); };