How to set req (request) in Sentry.captureException?

#1

I’m using the “@sentry/node” (v4.5.3) library in my node project. I don’t see any clear way to pass in my express request object in the same way that it was done with the Raven client. It’s very clearly documented in the Raven docs: https://docs.sentry.io/clients/node/usage/#raven-node-additional-data but if I try the same thing with the @sentry/node client, I don’t get request info in errors.

How are requests properly logged in the Node unified SDK client?

#2

I eventually found the Express integration page: https://docs.sentry.io/platforms/node/express/ and I was able to add the following as the first piece of middleware on my express app:

app.use(Sentry.Handlers.requestHandler());

Also, I’m running on AWS lambda, so I’m using my own error handle to call Sentry.captureException(err) with an additional await Sentry.getCurrentHub().getClient().close(2000); instead of using Sentry.Handlers.errorHandler().

I think it would be helpful if the main “Unified Browser JavaScript SDK” page referenced these integrations (e.g., Express) in some way. I did a cmd+f on that page for “express” and nothing came up.