Openstatus www.openstatus.dev
at main 34 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 8// tRPC error codes that should not be reported to Sentry (expected client errors) 9const IGNORED_TRPC_CODES: TRPCError["code"][] = [ 10 "UNAUTHORIZED", 11 "NOT_FOUND", 12 "BAD_REQUEST", 13]; 14 15Sentry.init({ 16 dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, 17 18 // Adjust this value in production, or use tracesSampler for greater control 19 tracesSampleRate: 0.2, 20 21 // Setting this option to true will print useful information to the console while you're setting up Sentry. 22 debug: false, 23 integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })], 24 25 beforeSend(event, hint) { 26 if ( 27 hint.originalException instanceof TRPCError && 28 IGNORED_TRPC_CODES.includes(hint.originalException.code) 29 ) { 30 return null; 31 } 32 return event; 33 }, 34});