Openstatus www.openstatus.dev
at main 34 lines 1.2 kB view raw
1// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on). 2// The config you add here will be used whenever one of the edge features is loaded. 3// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally. 4// https://docs.sentry.io/platforms/javascript/guides/nextjs/ 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, 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});