-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nextjs): Export serverside data-fetcher wrappers from client (#7256)
- Loading branch information
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/nextjs/src/client/wrapGetServerSidePropsWithSentry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { GetServerSideProps } from 'next'; | ||
|
||
/** | ||
* A passthrough function in case this function is used on the clientside. We need to make the returned function async | ||
* so we are consistent with the serverside implementation. | ||
*/ | ||
export function wrapGetServerSidePropsWithSentry(origGetServerSideProps: GetServerSideProps): GetServerSideProps { | ||
return new Proxy(origGetServerSideProps, { | ||
apply: async (wrappingTarget, thisArg, args: Parameters<GetServerSideProps>) => { | ||
return await wrappingTarget.apply(thisArg, args); | ||
}, | ||
}); | ||
} | ||
|
||
/** | ||
* @deprecated Use `withSentryGetServerSideProps` instead. | ||
*/ | ||
export const withSentryGetServerSideProps = wrapGetServerSidePropsWithSentry; |
20 changes: 20 additions & 0 deletions
20
packages/nextjs/src/client/wrapGetStaticPropsWithSentry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { GetStaticProps } from 'next'; | ||
|
||
type Props = { [key: string]: unknown }; | ||
|
||
/** | ||
* A passthrough function in case this function is used on the clientside. We need to make the returned function async | ||
* so we are consistent with the serverside implementation. | ||
*/ | ||
export function wrapGetStaticPropsWithSentry(origGetStaticProps: GetStaticProps<Props>): GetStaticProps<Props> { | ||
return new Proxy(origGetStaticProps, { | ||
apply: async (wrappingTarget, thisArg, args: Parameters<GetStaticProps<Props>>) => { | ||
return await wrappingTarget.apply(thisArg, args); | ||
}, | ||
}); | ||
} | ||
|
||
/** | ||
* @deprecated Use `wrapGetStaticPropsWithSentry` instead. | ||
*/ | ||
export const withSentryGetStaticProps = wrapGetStaticPropsWithSentry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters