|
| 1 | +import type { |
| 2 | + GetServerSideProps as GetServerSidePropsFunction, |
| 3 | + GetStaticPaths as GetStaticPathsFunction, |
| 4 | + GetStaticProps as GetStaticPropsFunction, |
| 5 | +} from 'next'; |
| 6 | + |
| 7 | +declare const __ORIG_GSSP__: GetServerSidePropsFunction; |
| 8 | +declare const __ORIG_GSPROPS__: GetStaticPropsFunction; |
| 9 | +declare const __ORIG_GSPATHS__: GetStaticPathsFunction; |
| 10 | + |
| 11 | +// We import the SDK under a purposefully clunky name, to lessen to near zero the chances of a name collision in case |
| 12 | +// the user has also imported Sentry for some reason. (In the future, we could check for such a collision using the AST, |
| 13 | +// but this is a lot simpler.) |
| 14 | +// |
| 15 | +// TODO: This import line is here because it needs to be in the injected code, but it also would (ideally) |
| 16 | +// let us take advantage of typechecking, via the linter (both eslint and the TS linter), using intellisense, and when |
| 17 | +// building. Solving for all five simultaneously seems to be tricky, however, because of the circular dependency. This |
| 18 | +// is one of a number of possible compromise options, which seems to hit everything except eslint linting and |
| 19 | +// typechecking via `tsc`. (TS linting and intellisense both work, though, so we do get at least some type safety.) See |
| 20 | +// https://github.com/getsentry/sentry-javascript/pull/5503#discussion_r936827996 for more details. |
| 21 | +// |
| 22 | +// eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved |
| 23 | +import * as ServerSideSentryNextjsSDK from '@sentry/nextjs'; |
| 24 | + |
| 25 | +export const getServerSideProps = ServerSideSentryNextjsSDK.withSentryGSSP(__ORIG_GSSP__); |
| 26 | +export const getStaticProps = ServerSideSentryNextjsSDK.withSentryGSProps(__ORIG_GSPROPS__); |
| 27 | +export const getStaticPaths = ServerSideSentryNextjsSDK.withSentryGSPaths(__ORIG_GSPATHS__); |
0 commit comments