Set user for each incoming request on node server #4703
Closed
hannadrehman
started this conversation in
General
Replies: 1 comment 2 replies
-
Didn't try it but I guess instead of polluting the global scope you could try to set this at the time of sending the exception: function authMiddleWare(req, res, next) {
try {
next()
} catch (err) {
const user = extractUserFromReq(req);
Sentry.captureException(err, {
user: user,
});
throw err;
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was following this guide to identify users for sentry.
for any server application any incoming request needs to be authenticated, and post authentication we can identify user and set that scope in the sentry for example
since nodejs is a single threaded runtime. its possible that multiple incoming requests can set user scope. i am not able to understand how will sentry keep this user context for the entire request, and log any issue for that particular user. when in reality its possible that the scope was overridden by some other request/user which can come in parallel.
fyi i am trying to integrate sentry in my remix-run application
Beta Was this translation helpful? Give feedback.
All reactions