Merged in fix/dont-send-expected-error-types-to-sentry (pull request #3358)
fix: don't send expected errors to Sentry * fix: don't send expected errors to Sentry * remove BAD_REQUEST from ignore-list for TRPC errors due to BAD_REQUEST being used improperly Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import * as Sentry from "@sentry/nextjs"
|
import * as Sentry from "@sentry/nextjs"
|
||||||
|
import { TRPCError } from "@trpc/server"
|
||||||
|
|
||||||
import { env } from "./env/server"
|
import { env } from "./env/server"
|
||||||
|
|
||||||
@@ -21,6 +22,20 @@ async function configureSentry() {
|
|||||||
tracesSampleRate: env.SENTRY_SERVER_SAMPLERATE,
|
tracesSampleRate: env.SENTRY_SERVER_SAMPLERATE,
|
||||||
denyUrls: denyUrls,
|
denyUrls: denyUrls,
|
||||||
enableLogs: true,
|
enableLogs: true,
|
||||||
|
enableMetrics: true,
|
||||||
release: env.RELEASE_TAG || undefined,
|
release: env.RELEASE_TAG || undefined,
|
||||||
|
beforeSend(event, hint) {
|
||||||
|
const error = hint.originalException
|
||||||
|
|
||||||
|
// Don't send TRPCErrors with client error codes
|
||||||
|
if (error instanceof TRPCError) {
|
||||||
|
const clientErrorCodes = ["CONFLICT", "NOT_FOUND", "UNAUTHORIZED"]
|
||||||
|
if (clientErrorCodes.includes(error.code)) {
|
||||||
|
return null // Don't send to Sentry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return event
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import * as Sentry from "@sentry/nextjs"
|
import * as Sentry from "@sentry/nextjs"
|
||||||
|
import { TRPCError } from "@trpc/server"
|
||||||
|
|
||||||
import { env } from "./env/server"
|
import { env } from "./env/server"
|
||||||
|
|
||||||
@@ -23,5 +24,18 @@ async function configureSentry() {
|
|||||||
enableLogs: true,
|
enableLogs: true,
|
||||||
enableMetrics: true,
|
enableMetrics: true,
|
||||||
release: env.RELEASE_TAG || undefined,
|
release: env.RELEASE_TAG || undefined,
|
||||||
|
beforeSend(event, hint) {
|
||||||
|
const error = hint.originalException
|
||||||
|
|
||||||
|
// Don't send TRPCErrors with client error codes
|
||||||
|
if (error instanceof TRPCError) {
|
||||||
|
const clientErrorCodes = ["CONFLICT", "NOT_FOUND", "UNAUTHORIZED"]
|
||||||
|
if (clientErrorCodes.includes(error.code)) {
|
||||||
|
return null // Don't send to Sentry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return event
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user