Openstatus www.openstatus.dev

fix: filter expected tRPC errors from Sentry notifications (#1726)

* fix: filter expected tRPC errors from Sentry notifications

Mute UNAUTHORIZED (401), NOT_FOUND (404), and BAD_REQUEST (400) errors
to reduce noise from expected client errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: filter expected tRPC errors from Sentry notifications

Mute UNAUTHORIZED (401), NOT_FOUND (404), and BAD_REQUEST (400) errors
to reduce noise from expected client errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* ci: apply automated fixes

* Fix inconsistent TRPCError filtering in status-page edge Sentry config (#1727)

* Initial plan

* fix: use consistent TRPCError filtering in status-page edge config

Co-authored-by: thibaultleouay <13894054+thibaultleouay@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: thibaultleouay <13894054+thibaultleouay@users.noreply.github.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Thibault Le Ouay <thibaultleouay@gmail.Com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: thibaultleouay <13894054+thibaultleouay@users.noreply.github.com>

+108
+18
apps/dashboard/sentry.edge.config.ts
··· 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/ 5 import * as Sentry from "@sentry/nextjs"; 6 7 Sentry.init({ 8 dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, ··· 13 // Setting this option to true will print useful information to the console while you're setting up Sentry. 14 debug: false, 15 integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })], 16 });
··· 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/ 5 import * as Sentry from "@sentry/nextjs"; 6 + import { TRPCError } from "@trpc/server"; 7 + 8 + // tRPC error codes that should not be reported to Sentry (expected client errors) 9 + const IGNORED_TRPC_CODES: TRPCError["code"][] = [ 10 + "UNAUTHORIZED", 11 + "NOT_FOUND", 12 + "BAD_REQUEST", 13 + ]; 14 15 Sentry.init({ 16 dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, ··· 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 });
+18
apps/dashboard/sentry.server.config.ts
··· 3 // https://docs.sentry.io/platforms/javascript/guides/nextjs/ 4 5 import * as Sentry from "@sentry/nextjs"; 6 7 Sentry.init({ 8 dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, ··· 13 // Setting this option to true will print useful information to the console while you're setting up Sentry. 14 debug: false, 15 integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })], 16 });
··· 3 // https://docs.sentry.io/platforms/javascript/guides/nextjs/ 4 5 import * as Sentry from "@sentry/nextjs"; 6 + import { TRPCError } from "@trpc/server"; 7 + 8 + // tRPC error codes that should not be reported to Sentry (expected client errors) 9 + const IGNORED_TRPC_CODES: TRPCError["code"][] = [ 10 + "UNAUTHORIZED", 11 + "NOT_FOUND", 12 + "BAD_REQUEST", 13 + ]; 14 15 Sentry.init({ 16 dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, ··· 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 });
+18
apps/status-page/sentry.edge.config.ts
··· 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/ 5 import * as Sentry from "@sentry/nextjs"; 6 7 Sentry.init({ 8 dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, ··· 13 // Setting this option to true will print useful information to the console while you're setting up Sentry. 14 debug: false, 15 integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })], 16 });
··· 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/ 5 import * as Sentry from "@sentry/nextjs"; 6 + import { TRPCError } from "@trpc/server"; 7 + 8 + // tRPC error codes that should not be reported to Sentry (expected client errors) 9 + const IGNORED_TRPC_CODES: TRPCError["code"][] = [ 10 + "UNAUTHORIZED", 11 + "NOT_FOUND", 12 + "BAD_REQUEST", 13 + ]; 14 15 Sentry.init({ 16 dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, ··· 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 });
+18
apps/status-page/sentry.server.config.ts
··· 3 // https://docs.sentry.io/platforms/javascript/guides/nextjs/ 4 5 import * as Sentry from "@sentry/nextjs"; 6 7 Sentry.init({ 8 dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, ··· 13 // Setting this option to true will print useful information to the console while you're setting up Sentry. 14 debug: false, 15 integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })], 16 });
··· 3 // https://docs.sentry.io/platforms/javascript/guides/nextjs/ 4 5 import * as Sentry from "@sentry/nextjs"; 6 + import { TRPCError } from "@trpc/server"; 7 + 8 + // tRPC error codes that should not be reported to Sentry (expected client errors) 9 + const IGNORED_TRPC_CODES: TRPCError["code"][] = [ 10 + "UNAUTHORIZED", 11 + "NOT_FOUND", 12 + "BAD_REQUEST", 13 + ]; 14 15 Sentry.init({ 16 dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, ··· 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 });
+18
apps/web/sentry.edge.config.ts
··· 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/ 5 import * as Sentry from "@sentry/nextjs"; 6 7 import { env } from "@/env"; 8 9 Sentry.init({ 10 dsn: env.NEXT_PUBLIC_SENTRY_DSN, 11 ··· 15 // Setting this option to true will print useful information to the console while you're setting up Sentry. 16 debug: false, 17 integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })], 18 });
··· 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/ 5 import * as Sentry from "@sentry/nextjs"; 6 + import { TRPCError } from "@trpc/server"; 7 8 import { env } from "@/env"; 9 10 + // tRPC error codes that should not be reported to Sentry (expected client errors) 11 + const IGNORED_TRPC_CODES: TRPCError["code"][] = [ 12 + "UNAUTHORIZED", 13 + "NOT_FOUND", 14 + "BAD_REQUEST", 15 + ]; 16 + 17 Sentry.init({ 18 dsn: env.NEXT_PUBLIC_SENTRY_DSN, 19 ··· 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 });
+18
apps/web/sentry.server.config.ts
··· 3 // https://docs.sentry.io/platforms/javascript/guides/nextjs/ 4 5 import * as Sentry from "@sentry/nextjs"; 6 7 import { env } from "@/env"; 8 9 Sentry.init({ 10 dsn: env.NEXT_PUBLIC_SENTRY_DSN, 11 ··· 15 // Setting this option to true will print useful information to the console while you're setting up Sentry. 16 debug: false, 17 integrations: [Sentry.captureConsoleIntegration({ levels: ["error"] })], 18 });
··· 3 // https://docs.sentry.io/platforms/javascript/guides/nextjs/ 4 5 import * as Sentry from "@sentry/nextjs"; 6 + import { TRPCError } from "@trpc/server"; 7 8 import { env } from "@/env"; 9 10 + // tRPC error codes that should not be reported to Sentry (expected client errors) 11 + const IGNORED_TRPC_CODES: TRPCError["code"][] = [ 12 + "UNAUTHORIZED", 13 + "NOT_FOUND", 14 + "BAD_REQUEST", 15 + ]; 16 + 17 Sentry.init({ 18 dsn: env.NEXT_PUBLIC_SENTRY_DSN, 19 ··· 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 });