chore: Add user and auth context to server side error reports (#1693)

This commit is contained in:
Tom Moor 2020-12-06 17:59:44 -08:00 committed by GitHub
parent 2e798c698d
commit b2bdc7f1d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -119,6 +119,18 @@ app.on("error", (error, ctx) => {
if (requestId) {
scope.setTag("request_id", requestId);
}
const authType = ctx.state ? ctx.state.authType : undefined;
if (authType) {
scope.setTag("auth_type", authType);
}
const userId =
ctx.state && ctx.state.user ? ctx.state.user.id : undefined;
if (userId) {
scope.setUser({ id: userId });
}
scope.addEventProcessor(function (event) {
return Sentry.Handlers.parseRequest(event, ctx.request);
});