sentry-javascript: Pass req in Sentry.captureException
It looks like Raven was able to take context information including a req parameter, but Sentry isn’t allowing me to to do this. So something like this:
Sentry.captureException(Error("An error"), {
user: { id: 123 },
req: req, // Request object from HTTP web server
tags: { component: 'main', method: 'doSomething' },
extra: { catType: cat.type },
level: 'error'
})
Is this still possible with Sentry? If not, how can I achieve the same thing (especially sending the req)?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (9 by maintainers)
@HazAT Thanks, it’s works.
My solutions for Restify 4.x:
@vhu I guess our docs can be improved here: https://docs.sentry.io/platforms/node/koa/
But you would do something in the lines of in your custom
scope.addEventProcessordo:If that solves it we can add it to the docs.
I can absolutely second that updating the Koa documentation with that snippet would be a huge help. Took me quite a bit of time to figure out why my captured exceptions were missing the request meta data.
Right now it only advocates:
but changing that to:
would be a huge improvement and ensure people get all the request info attached to their requests.
We dropped the second “magic” arbitrary object in
captureExceptionthe new official way of doing this is setting stuff on the scope like:Sending the req or something else, either requires to add it in the
beforeSendoption. Or add a customeventProcessorto the scope:Hope this helps.