import * as Sentry from "@sentry/nextjs" import { TRPCError } from "@trpc/server" import { env } from "./env/server" export const denyUrls: (string | RegExp)[] = [ // Ignore preview urls /\/.{2}\/preview\//, ] export async function register() { await configureSentry() } export const onRequestError = Sentry.captureRequestError async function configureSentry() { Sentry.init({ dsn: "https://130a3188ceac7bbf7b628ab511024956@o4508102497206272.ingest.de.sentry.io/4509587678167121", environment: env.SENTRY_ENVIRONMENT, enabled: env.SENTRY_ENVIRONMENT !== "development", tracesSampleRate: env.SENTRY_SERVER_SAMPLERATE, denyUrls: denyUrls, enableLogs: true, enableMetrics: true, 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 }, }) }