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
feat: Next.js SDK + Plugin #3301
Conversation
Co-authored-by: Daniel Griesser <daniel.griesser.86@gmail.com>
size-limit report
|
This comment has been minimized.
This comment has been minimized.
Besides, remove unncessary files
Instead of having an empty interface, set the type as the union of the interfaces it's made of.
`toHaveLength` instead of `toEqual({length})` also: `toBeInstanceOf`
if (typeof err.req !== 'undefined') { | ||
scope.addEventProcessor(event => { | ||
return parseRequest(event, err.req, { | ||
// 'cookies' and 'query_string' use `dynamicRequire` which has a bug in SSR envs right now — Kamil |
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.
What are we supposed to do with this comment?
}); | ||
} | ||
|
||
const toCapture = err instanceof Error ? err : err.err; |
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.
Why do we assume that err.err
is a thing if we don't know the type of err
?
captureException(toCapture); | ||
}); | ||
|
||
await flush(sentryTimeout); |
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.
This is probably fine, but has a caveat: it possibly slows down requests on the server when there are errors, even if it is not necessary.
Flushing on every error is most of the time not required. In certain platforms, in particular serverless platforms, we should flush once per request.
Is there an obvious better place we could put it in? Per-request flush?
It provides a better output message, if the test fails
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.
does the next.js supports sentry now? |
Yes, it should be working. |
Getting Started
It's assumed that NextJS is installed. Note that its version can't be
latest
; please replace it with a numeric version instead (it can be the latest version, but use the numeric notation).Install:
Note: It's important to use exactly
@sentry/nextjs@6.3.0-beta.7
to setup the SDK call
follow the steps and finish the setup.
After starting your next app, the Sentry SDK is started on both the frontend and backend.
The next config we provide out of the box comes with automatic source map setup and Vercel deployment support.
Features
✅ Error Monitoring both frontend and backend
✅ Automatic source maps (incl. upload) for both JS and TS
🔜 Performance Monitoring (transactions frontend + backend)
Manual Setup
The config we provide by default is rather lengthy and if you don't start from scratch and have an existing config, you need to merge it manually. Note however that the config files are automatically generated by the wizard.
next.config.js
sentry.client.config.js
sentry.server.config.js
TypeScript Source Maps
If you are using TypeScript, make sure to add
"sourceMap": true
and"noEmit": false
in yourtsconfig.json
in the compiler options:Usage
With the provided configuration you don't have to do anything else, the SDK is already working. If you want to configure it, custom the
Sentry.init
in thesentry.client.config.js
orsentry.server.config.js
.The SDK itself underneath uses either
@sentry/react
or@sentry/node
depending on if it's called on the frontend or backend.