Skip to content

Commit

Permalink
fix: Add missing Error.getInitialProps calls in Next.js error page …
Browse files Browse the repository at this point in the history
…snippets (#632)

Co-authored-by: Luca Forstner <luca.forstner@sentry.io>
  • Loading branch information
Pikachews and lforst authored Aug 1, 2024
1 parent 5febecc commit 3623f08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

- feat(nextjs): Support all `next.config` file types (#630)
- fix(nextjs): Update instrumentation and example creation logic for app or pages usage (#629)
- Improve error logging for package installation (#635)

- fix(nextjs): Add missing Error.getInitialProps calls in Next.js error page snippets (#632)
- fix/feat: Improve error logging for package installation (#635)

## 3.25.2

Expand Down
6 changes: 6 additions & 0 deletions src/nextjs/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ export default CustomErrorComponent;
export function getSimpleUnderscoreErrorCopyPasteSnippet() {
return `
${chalk.green(`import * as Sentry from '@sentry/nextjs';`)}
${chalk.green(`import Error from "next/error";`)}
${chalk.dim(
'// Replace "YourCustomErrorComponent" with your custom error component!',
Expand All @@ -317,6 +318,8 @@ YourCustomErrorComponent.getInitialProps = async (${chalk.green(
${chalk.green('await Sentry.captureUnderscoreErrorException(contextData);')}
${chalk.dim('// ...other getInitialProps code')}
return Error.getInitialProps(contextData);
};
`;
}
Expand All @@ -326,6 +329,7 @@ export function getFullUnderscoreErrorCopyPasteSnippet(isTs: boolean) {
import * as Sentry from '@sentry/nextjs';${
isTs ? '\nimport type { NextPageContext } from "next";' : ''
}
import Error from "next/error";
${chalk.dim(
'// Replace "YourCustomErrorComponent" with your custom error component!',
Expand All @@ -334,6 +338,8 @@ YourCustomErrorComponent.getInitialProps = async (contextData${
isTs ? ': NextPageContext' : ''
}) => {
await Sentry.captureUnderscoreErrorException(contextData);
return Error.getInitialProps(contextData);
};
`;
}
Expand Down

0 comments on commit 3623f08

Please sign in to comment.