Skip to content

Commit

Permalink
pass parameterized route to wrapper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lobsterkatie committed Aug 12, 2022
1 parent 1e93746 commit f6ff082
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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__;
Original file line number Diff line number Diff line change
Expand Up @@ -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<GSSP['result']> {
return callOriginal<GSSP>(origGetServerSideProps, context);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GSProps['result']> {
return callOriginal<GSProps>(origGetStaticProps, context);
};
Expand Down

0 comments on commit f6ff082

Please sign in to comment.