Skip to content

Commit

Permalink
update sentry reporting;
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKarow committed Jul 18, 2024
1 parent f6b8f6b commit 42c8127
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions apps/app/src/pages/api/trpc/[trpc].ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,28 @@ const isServer = typeof window === 'undefined'
export default createNextApiHandler({
createContext,
router: appRouter,
onError: ({ path, error, type }) => {
onError: ({ path, error, type, ctx }) => {
Sentry.setUser(ctx?.session?.user ?? null)
if (error.code !== 'NOT_FOUND') {
Sentry.captureException(error, (scope) => {
scope.setTags({
'tRPC.path': path,
'tRPC.operation': type,
})
return scope
})
}
switch (true) {
case isDev: {
if (error.code === 'INTERNAL_SERVER_ERROR') {
Sentry.captureException(error, (scope) => {
scope.setTags({
'tRPC.path': path,
'tRPC.operation': type,
})
return scope
})
}
log.error(`❌ tRPC ${type} failed on ${path}:`, error)
break
}
case isServer: {
if (error.code === 'INTERNAL_SERVER_ERROR') {
Sentry.captureException(error, (scope) => {
scope.setTags({
'tRPC.path': path,
'tRPC.operation': type,
})
return scope
})
}
log.error({ type, path, error })
break
}
default: {
return
break
}
}
},
Expand Down

0 comments on commit 42c8127

Please sign in to comment.