configureScope not working in node

I am using sentry with node and express. I’m unable to get the user to attach to my scope. My code looks like this:

app.use(Sentry.Handlers.requestHandler());
app.use((req, res, next) => {
  console.log('the user',  req.user);
  if (!isEmpty(req.user)) {
    Sentry.configureScope(scope => {
      scope.setUser({ email: req.user.email });
    });
  }
  next();
});
app.use(Sentry.Handlers.errorHandler());

The console log does in fact print out a user but when my exceptions roll in, there is no user attached, just the default ip. Any idea what I’m doing wrong?

Hey :slight_smile:

So I saw your issue you posted on gh and Kamil already replied once, please do not open the same issue in different channels multiple times since it causes us a lot of work to sync between all of them.

ref: https://github.com/getsentry/sentry-javascript/issues/2022

The forum is a very “general” place for sentry questions, very specific questions like these are better suited for GH, so please let’s continue the discussion there.

Also for anyone else finding this, please see GH issue :slight_smile:

I hope that makes sense,
Cheers,
Daniel