Openstatus
www.openstatus.dev
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
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,
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});