Skip to content

Commit

Permalink
Remove one more occurence of withSentry
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Sep 22, 2022
1 parent 69bdf90 commit 86ea721
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions src/wizard/javascript/nextjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,19 @@ npx @sentry/wizard -i nextjs
```

Sentry wizard will automatically patch your application:

- create `sentry.client.config.js` and `sentry.server.config.js` with the default `Sentry.init`.
- create `next.config.js` with the default configuration.
- create `sentry.properties` with configuration for sentry-cli (which is used when automatically uploading source maps).


You can also [configure it manually](https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/).


## Nextjs API routes
While `@sentry/nextjs` will enable Sentry for your nextjs application, files under the `pages/api` require one additional installing step.

Wrap your API handlers with a `withSentry` function to capture [Next.js API route errors](https://nextjs.org/docs/api-routes/introduction):

```javascript
import { withSentry } from '@sentry/nextjs';

const handler = async (req, res) => {
// ...
}

export default withSentry(handler);
```

Configure the Sentry initialization:

```javascript
Sentry.init({
dsn: "___PUBLIC_DSN___",

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
Expand All @@ -62,10 +46,13 @@ The above configuration has automatic error tracking with source maps for both J
Then create an intentional error, so you can test that everything is working from your development environment. For example, a button whose `onClick` handler throws an error:

```javascript
<button type="button" onClick={() => {
<button
type="button"
onClick={() => {
throw new Error("Sentry Frontend Error");
}}>
Throw error
}}
>
Throw error
</button>
```

Expand Down

0 comments on commit 86ea721

Please sign in to comment.