Openstatus www.openstatus.dev
at 4c0f4c00a38753a5d0dfd7e7b7b7706dec6f1503 36 lines 1.1 kB view raw
1// This file configures the initialization of Sentry on the server. 2// The config you add here will be used whenever the server handles a request. 3// https://docs.sentry.io/platforms/javascript/guides/nextjs/ 4 5import * as Sentry from "@sentry/nextjs"; 6import { TRPCError } from "@trpc/server"; 7 8import { env } from "@/env"; 9 10// tRPC error codes that should not be reported to Sentry (expected client errors) 11const IGNORED_TRPC_CODES: TRPCError["code"][] = [ 12 "UNAUTHORIZED", 13 "NOT_FOUND", 14 "BAD_REQUEST", 15]; 16 17Sentry.init({ 18 dsn: env.NEXT_PUBLIC_SENTRY_DSN, 19 20 // Adjust this value in production, or use tracesSampler for greater control 21 tracesSampleRate: 0.2, 22 23 // Setting this option to true will print useful information to the console while you're setting up Sentry. 24 debug: false, 25 integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })], 26 27 beforeSend(event, hint) { 28 if ( 29 hint.originalException instanceof TRPCError && 30 IGNORED_TRPC_CODES.includes(hint.originalException.code) 31 ) { 32 return null; 33 } 34 return event; 35 }, 36});