Skip to content

Commit

Permalink
fix: write sentry tags to request scope
Browse files Browse the repository at this point in the history
Change-Id: Ic44f907c80e1f2f9f9401fe5a1edff930cac1dcd
GitOrigin-RevId: 3fc1850e769f45ed36cfa92192239a2aff94ad38
  • Loading branch information
jaslong authored and actions-user committed Oct 24, 2024
1 parent 7b1bcf3 commit 1c67f58
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions platform/wab/src/wab/server/AppServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,13 @@ function addSentry(app: express.Application, config: Config) {
return event;
},
});

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

// This anonymous handler uses Sentry.setTag() to modify the current scope.
// To ensure the global scope is not modified, the handler must be after
// Sentry.Handlers.requestHandler(), which creates a new scope per-request.
app.use((req, _res, next) => {
// Some routes get project ID as a path param (e.g.
// /projects/:projectId/code/components) while others get it as query
Expand All @@ -416,8 +423,6 @@ function addSentry(app: express.Application, config: Config) {
}
next();
});
app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler());
}

// Copied from @sentry: https://github.com/getsentry/sentry-javascript/blob/master/packages/node/src/handlers.ts
Expand Down

0 comments on commit 1c67f58

Please sign in to comment.