-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(nextjs): Export isomorphic data fetching wrappers from client SDK #6790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
af019fd
Rename a bunch of files
lforst a972cbc
Rename files again
lforst e5db878
Rename and deprecate api route handler wrappers
lforst eb87f3e
Rename middleware wrapper
lforst 4a8fcb1
Update data fetcher exports
lforst 8a2a0b0
Add deprecation note
lforst 1ba4d45
Eslint ignore
lforst f264709
Rerename withSentryConfig
lforst e4c66f4
Update templates
lforst eac2509
Update occurences
lforst 24ca6d1
Rename integration test folder
lforst acfdbde
Replace occurences
lforst 6d947ba
Renam api handler function
lforst f2702af
Fix integration tests
lforst 2c59d79
fix(nextjs): Export isomorphic data fetching wrappers from client SDK
lforst 6868916
Merge remote-tracking branch 'origin/master' into lforst-fix-clientsi…
lforst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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/wrapAppGetInitialPropsWithSentry.ts
This file contains hidden or 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 App from 'next/app'; | ||
|
||
type AppGetInitialProps = typeof App['getInitialProps']; | ||
|
||
/** | ||
* 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 wrapAppGetInitialPropsWithSentry(origAppGetInitialProps: AppGetInitialProps): AppGetInitialProps { | ||
return async function (this: unknown, ...args: Parameters<AppGetInitialProps>): ReturnType<AppGetInitialProps> { | ||
return await origAppGetInitialProps.apply(this, args); | ||
}; | ||
} | ||
|
||
/** | ||
* @deprecated Use `wrapAppGetInitialPropsWithSentry` instead. | ||
*/ | ||
export const withSentryServerSideAppGetInitialProps = wrapAppGetInitialPropsWithSentry; |
23 changes: 23 additions & 0 deletions
23
packages/nextjs/src/client/wrapDocumentGetInitialPropsWithSentry.ts
This file contains hidden or 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,23 @@ | ||
import type Document from 'next/document'; | ||
|
||
type DocumentGetInitialProps = typeof Document.getInitialProps; | ||
|
||
/** | ||
* 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 wrapDocumentGetInitialPropsWithSentry( | ||
origDocumentGetInitialProps: DocumentGetInitialProps, | ||
): DocumentGetInitialProps { | ||
return async function ( | ||
this: unknown, | ||
...args: Parameters<DocumentGetInitialProps> | ||
): ReturnType<DocumentGetInitialProps> { | ||
return await origDocumentGetInitialProps.apply(this, args); | ||
}; | ||
} | ||
|
||
/** | ||
* @deprecated Use `wrapDocumentGetInitialPropsWithSentry` instead. | ||
*/ | ||
export const withSentryServerSideDocumentGetInitialProps = wrapDocumentGetInitialPropsWithSentry; |
21 changes: 21 additions & 0 deletions
21
packages/nextjs/src/client/wrapErrorGetInitialPropsWithSentry.ts
This file contains hidden or 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,21 @@ | ||
import type { NextPageContext } from 'next'; | ||
import type { ErrorProps } from 'next/error'; | ||
|
||
type ErrorGetInitialProps = (context: NextPageContext) => Promise<ErrorProps>; | ||
|
||
/** | ||
* 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 wrapErrorGetInitialPropsWithSentry( | ||
origErrorGetInitialProps: ErrorGetInitialProps, | ||
): ErrorGetInitialProps { | ||
return async function (this: unknown, ...args: Parameters<ErrorGetInitialProps>): ReturnType<ErrorGetInitialProps> { | ||
return await origErrorGetInitialProps.apply(this, args); | ||
}; | ||
} | ||
|
||
/** | ||
* @deprecated Use `wrapErrorGetInitialPropsWithSentry` instead. | ||
*/ | ||
export const withSentryServerSideErrorGetInitialProps = wrapErrorGetInitialPropsWithSentry; |
18 changes: 18 additions & 0 deletions
18
packages/nextjs/src/client/wrapGetInitialPropsWithSentry.ts
This file contains hidden or 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 { NextPage } from 'next'; | ||
|
||
type GetInitialProps = Required<NextPage>['getInitialProps']; | ||
|
||
/** | ||
* 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 wrapGetInitialPropsWithSentry(origGetInitialProps: GetInitialProps): GetInitialProps { | ||
return async function (this: unknown, ...args: Parameters<GetInitialProps>): Promise<ReturnType<GetInitialProps>> { | ||
return origGetInitialProps.apply(this, args); | ||
}; | ||
} | ||
|
||
/** | ||
* @deprecated Use `wrapGetInitialPropsWithSentry` instead. | ||
*/ | ||
export const withSentryServerSideGetInitialProps = wrapGetInitialPropsWithSentry; |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we theoretically create spans instead of transactions here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we definitely could in the future!