Skip to content
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

fix(nextjs): Export serverside data-fetcher wrappers from client #7256

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/nextjs/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,29 @@ export {
withSentryServerSideAppGetInitialProps,
wrapAppGetInitialPropsWithSentry,
} from './wrapAppGetInitialPropsWithSentry';

export {
// eslint-disable-next-line deprecation/deprecation
withSentryServerSideDocumentGetInitialProps,
wrapDocumentGetInitialPropsWithSentry,
} from './wrapDocumentGetInitialPropsWithSentry';

export {
// eslint-disable-next-line deprecation/deprecation
withSentryServerSideErrorGetInitialProps,
wrapErrorGetInitialPropsWithSentry,
} from './wrapErrorGetInitialPropsWithSentry';

export {
// eslint-disable-next-line deprecation/deprecation
withSentryGetServerSideProps,
wrapGetServerSidePropsWithSentry,
} from './wrapGetServerSidePropsWithSentry';

export {
// eslint-disable-next-line deprecation/deprecation
withSentryGetStaticProps,
wrapGetStaticPropsWithSentry,
} from './wrapGetStaticPropsWithSentry';

export { wrapAppDirComponentWithSentry } from './wrapAppDirComponentWithSentry';
11 changes: 3 additions & 8 deletions packages/nextjs/src/client/wrapAppGetInitialPropsWithSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ 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.
* A passthrough function in case this function is used on the clientside.
*/
export function wrapAppGetInitialPropsWithSentry(origAppGetInitialProps: AppGetInitialProps): AppGetInitialProps {
return new Proxy(origAppGetInitialProps, {
apply: async (wrappingTarget, thisArg, args: Parameters<AppGetInitialProps>) => {
return await wrappingTarget.apply(thisArg, args);
},
});
export function wrapAppGetInitialPropsWithSentry(appGetInitialProps: AppGetInitialProps): AppGetInitialProps {
return appGetInitialProps;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@ 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.
* A passthrough function in case this function is used on the clientside.
*/
export function wrapDocumentGetInitialPropsWithSentry(
origDocumentGetInitialProps: DocumentGetInitialProps,
documentGetInitialProps: DocumentGetInitialProps,
): DocumentGetInitialProps {
return new Proxy(origDocumentGetInitialProps, {
apply: async (wrappingTarget, thisArg, args: Parameters<DocumentGetInitialProps>) => {
return await wrappingTarget.apply(thisArg, args);
},
});
return documentGetInitialProps;
}

/**
Expand Down
13 changes: 3 additions & 10 deletions packages/nextjs/src/client/wrapErrorGetInitialPropsWithSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@ 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.
* A passthrough function in case this function is used on the clientside.
*/
export function wrapErrorGetInitialPropsWithSentry(
origErrorGetInitialProps: ErrorGetInitialProps,
): ErrorGetInitialProps {
return new Proxy(origErrorGetInitialProps, {
apply: async (wrappingTarget, thisArg, args: Parameters<ErrorGetInitialProps>) => {
return await wrappingTarget.apply(thisArg, args);
},
});
export function wrapErrorGetInitialPropsWithSentry(errorGetInitialProps: ErrorGetInitialProps): ErrorGetInitialProps {
return errorGetInitialProps;
}

/**
Expand Down
11 changes: 3 additions & 8 deletions packages/nextjs/src/client/wrapGetInitialPropsWithSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ 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.
* A passthrough function in case this function is used on the clientside.
*/
export function wrapGetInitialPropsWithSentry(origGetInitialProps: GetInitialProps): GetInitialProps {
return new Proxy(origGetInitialProps, {
apply: async (wrappingTarget, thisArg, args: Parameters<GetInitialProps>) => {
return await wrappingTarget.apply(thisArg, args);
},
});
export function wrapGetInitialPropsWithSentry(getInitialProps: GetInitialProps): GetInitialProps {
return getInitialProps;
}

/**
Expand Down
13 changes: 13 additions & 0 deletions packages/nextjs/src/client/wrapGetServerSidePropsWithSentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { GetServerSideProps } from 'next';

/**
* A passthrough function in case this function is used on the clientside.
*/
export function wrapGetServerSidePropsWithSentry(getServerSideProps: GetServerSideProps): GetServerSideProps {
return getServerSideProps;
}

/**
* @deprecated Use `withSentryGetServerSideProps` instead.
*/
export const withSentryGetServerSideProps = wrapGetServerSidePropsWithSentry;
15 changes: 15 additions & 0 deletions packages/nextjs/src/client/wrapGetStaticPropsWithSentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { GetStaticProps } from 'next';

type Props = { [key: string]: unknown };

/**
* A passthrough function in case this function is used on the clientside.
*/
export function wrapGetStaticPropsWithSentry(getStaticProps: GetStaticProps<Props>): GetStaticProps<Props> {
return getStaticProps;
}

/**
* @deprecated Use `wrapGetStaticPropsWithSentry` instead.
*/
export const withSentryGetStaticProps = wrapGetStaticPropsWithSentry;