Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
fix: filter expected tRPC errors from Sentry notifications (#1726)
Maximilian Kaskecc233520dfac
diff --git a/apps/dashboard/sentry.edge.config.ts b/apps/dashboard/sentry.edge.config.tsindex 0d4fd1acb..baae24f36 100644--- a/apps/dashboard/sentry.edge.config.ts+++ b/apps/dashboard/sentry.edge.config.ts@@ -3,6 +3,14 @@// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.// https://docs.sentry.io/platforms/javascript/guides/nextjs/import * as Sentry from "@sentry/nextjs";+import { TRPCError } from "@trpc/server";++// tRPC error codes that should not be reported to Sentry (expected client errors)+const IGNORED_TRPC_CODES: TRPCError["code"][] = [+ "UNAUTHORIZED",+ "NOT_FOUND",+ "BAD_REQUEST",+];Sentry.init({dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,@@ -13,4 +21,14 @@ Sentry.init({// Setting this option to true will print useful information to the console while you're setting up Sentry.debug: false,integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })],++ beforeSend(event, hint) {+ if (+ hint.originalException instanceof TRPCError &&+ IGNORED_TRPC_CODES.includes(hint.originalException.code)+ ) {+ return null;+ }+ return event;+ },});diff --git a/apps/dashboard/sentry.server.config.ts b/apps/dashboard/sentry.server.config.tsindex b0e1adde7..4dbeb370a 100644--- a/apps/dashboard/sentry.server.config.ts+++ b/apps/dashboard/sentry.server.config.ts@@ -3,6 +3,14 @@// https://docs.sentry.io/platforms/javascript/guides/nextjs/import * as Sentry from "@sentry/nextjs";+import { TRPCError } from "@trpc/server";++// tRPC error codes that should not be reported to Sentry (expected client errors)+const IGNORED_TRPC_CODES: TRPCError["code"][] = [+ "UNAUTHORIZED",+ "NOT_FOUND",+ "BAD_REQUEST",+];Sentry.init({dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,@@ -13,4 +21,14 @@ Sentry.init({// Setting this option to true will print useful information to the console while you're setting up Sentry.debug: false,integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })],++ beforeSend(event, hint) {+ if (+ hint.originalException instanceof TRPCError &&+ IGNORED_TRPC_CODES.includes(hint.originalException.code)+ ) {+ return null;+ }+ return event;+ },});diff --git a/apps/status-page/sentry.edge.config.ts b/apps/status-page/sentry.edge.config.tsindex 0d4fd1acb..baae24f36 100644--- a/apps/status-page/sentry.edge.config.ts+++ b/apps/status-page/sentry.edge.config.ts@@ -3,6 +3,14 @@// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.// https://docs.sentry.io/platforms/javascript/guides/nextjs/import * as Sentry from "@sentry/nextjs";+import { TRPCError } from "@trpc/server";++// tRPC error codes that should not be reported to Sentry (expected client errors)+const IGNORED_TRPC_CODES: TRPCError["code"][] = [+ "UNAUTHORIZED",+ "NOT_FOUND",+ "BAD_REQUEST",+];Sentry.init({dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,@@ -13,4 +21,14 @@ Sentry.init({// Setting this option to true will print useful information to the console while you're setting up Sentry.debug: false,integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })],++ beforeSend(event, hint) {+ if (+ hint.originalException instanceof TRPCError &&+ IGNORED_TRPC_CODES.includes(hint.originalException.code)+ ) {+ return null;+ }+ return event;+ },});diff --git a/apps/status-page/sentry.server.config.ts b/apps/status-page/sentry.server.config.tsindex b0e1adde7..4dbeb370a 100644--- a/apps/status-page/sentry.server.config.ts+++ b/apps/status-page/sentry.server.config.ts@@ -3,6 +3,14 @@// https://docs.sentry.io/platforms/javascript/guides/nextjs/import * as Sentry from "@sentry/nextjs";+import { TRPCError } from "@trpc/server";++// tRPC error codes that should not be reported to Sentry (expected client errors)+const IGNORED_TRPC_CODES: TRPCError["code"][] = [+ "UNAUTHORIZED",+ "NOT_FOUND",+ "BAD_REQUEST",+];Sentry.init({dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,@@ -13,4 +21,14 @@ Sentry.init({// Setting this option to true will print useful information to the console while you're setting up Sentry.debug: false,integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })],++ beforeSend(event, hint) {+ if (+ hint.originalException instanceof TRPCError &&+ IGNORED_TRPC_CODES.includes(hint.originalException.code)+ ) {+ return null;+ }+ return event;+ },});diff --git a/apps/web/sentry.edge.config.ts b/apps/web/sentry.edge.config.tsindex fe2e14cd8..1d534fe9d 100644--- a/apps/web/sentry.edge.config.ts+++ b/apps/web/sentry.edge.config.ts@@ -3,9 +3,17 @@// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.// https://docs.sentry.io/platforms/javascript/guides/nextjs/import * as Sentry from "@sentry/nextjs";+import { TRPCError } from "@trpc/server";import { env } from "@/env";+// tRPC error codes that should not be reported to Sentry (expected client errors)+const IGNORED_TRPC_CODES: TRPCError["code"][] = [+ "UNAUTHORIZED",+ "NOT_FOUND",+ "BAD_REQUEST",+];+Sentry.init({dsn: env.NEXT_PUBLIC_SENTRY_DSN,@@ -15,4 +23,14 @@ Sentry.init({// Setting this option to true will print useful information to the console while you're setting up Sentry.debug: false,integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })],++ beforeSend(event, hint) {+ if (+ hint.originalException instanceof TRPCError &&+ IGNORED_TRPC_CODES.includes(hint.originalException.code)+ ) {+ return null;+ }+ return event;+ },});diff --git a/apps/web/sentry.server.config.ts b/apps/web/sentry.server.config.tsindex c6bab57e5..275869259 100644--- a/apps/web/sentry.server.config.ts+++ b/apps/web/sentry.server.config.ts@@ -3,9 +3,17 @@// https://docs.sentry.io/platforms/javascript/guides/nextjs/import * as Sentry from "@sentry/nextjs";+import { TRPCError } from "@trpc/server";import { env } from "@/env";+// tRPC error codes that should not be reported to Sentry (expected client errors)+const IGNORED_TRPC_CODES: TRPCError["code"][] = [+ "UNAUTHORIZED",+ "NOT_FOUND",+ "BAD_REQUEST",+];+Sentry.init({dsn: env.NEXT_PUBLIC_SENTRY_DSN,@@ -15,4 +23,14 @@ Sentry.init({// Setting this option to true will print useful information to the console while you're setting up Sentry.debug: false,integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })],++ beforeSend(event, hint) {+ if (+ hint.originalException instanceof TRPCError &&+ IGNORED_TRPC_CODES.includes(hint.originalException.code)+ ) {+ return null;+ }+ return event;+ },});