Skip to content

Commit

Permalink
feat: add user id to sentry issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt committed Mar 4, 2024
1 parent a8921e8 commit 1a836ae
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/backend/src/utils/sentry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as Sentry from "@sentry/node"
import { ProfilingIntegration } from "@sentry/profiling-node"
import { stripUrlQueryAndFragment } from "@sentry/utils"
import { Next, Context } from "koa"
import { Next } from "koa"
import Context from "./koa"

export function initSentry() {
Sentry.init({
Expand Down Expand Up @@ -44,6 +45,7 @@ export function sendErrorToSentry(err: unknown, ctx: Context) {
scope.addEventProcessor((event) => {
return Sentry.addRequestDataToEvent(event, ctx.request)
})
scope.setUser({ id: ctx.state.userId })
Sentry.captureException(err)
})
}
Expand Down

0 comments on commit 1a836ae

Please sign in to comment.