From 54c4b0b65e78e3193290086a148d1aefa4aa9b54 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Fri, 9 May 2025 11:44:30 -0400 Subject: [PATCH] chore: Remove Sentry replay integration (#21211) --- .env.example | 2 ++ apps/web/instrumentation-client.ts | 16 ++++++++++------ apps/web/sentry.edge.config.ts | 7 +++++++ apps/web/sentry.server.config.ts | 7 +++++++ turbo.json | 2 ++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 37224c869d..ddd0dd9e9b 100644 --- a/.env.example +++ b/.env.example @@ -167,6 +167,8 @@ NEXT_PUBLIC_SENTRY_DSN= SENTRY_DEBUG= SENTRY_MAX_SPANS= SENTRY_TRACES_SAMPLE_RATE= +SENTRY_REPLAYS_SESSION_SAMPLE_RATE= +SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE= # Formbricks Experience Management Integration NEXT_PUBLIC_FORMBRICKS_HOST_URL=https://app.formbricks.com diff --git a/apps/web/instrumentation-client.ts b/apps/web/instrumentation-client.ts index 33e00d43f8..a3fee14ccc 100644 --- a/apps/web/instrumentation-client.ts +++ b/apps/web/instrumentation-client.ts @@ -6,22 +6,26 @@ import * as Sentry from "@sentry/nextjs"; Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, - // Add optional integrations for additional features - integrations: [Sentry.replayIntegration()], - // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control. - tracesSampleRate: 1, + tracesSampleRate: parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE ?? "0.0") || 0.0, // Define how likely Replay events are sampled. // This sets the sample rate to be 10%. You may want this to be 100% while // in development and sample at a lower rate in production - replaysSessionSampleRate: 0.1, + // replaysSessionSampleRate: parseFloat(process.env.SENTRY_REPLAYS_SESSION_SAMPLE_RATE ?? "0.0") || 0.0, // Define how likely Replay events are sampled when an error occurs. - replaysOnErrorSampleRate: 1.0, + // replaysOnErrorSampleRate: parseFloat(process.env.SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE ?? "0.0") || 0.0, // Setting this option to true will print useful information to the console while you're setting up Sentry. debug: false, + beforeSend(event) { + event.tags = { + ...event.tags, + errorSource: "client", + }; + return event; + }, }); export const onRouterTransitionStart = Sentry.captureRouterTransitionStart; diff --git a/apps/web/sentry.edge.config.ts b/apps/web/sentry.edge.config.ts index 842f09fccc..5cf8b25efa 100644 --- a/apps/web/sentry.edge.config.ts +++ b/apps/web/sentry.edge.config.ts @@ -2,4 +2,11 @@ import * as Sentry from "@sentry/nextjs"; Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, + beforeSend(event) { + event.tags = { + ...event.tags, + errorSource: "edge", + }; + return event; + }, }); diff --git a/apps/web/sentry.server.config.ts b/apps/web/sentry.server.config.ts index 576b31d0d4..be7122d37b 100644 --- a/apps/web/sentry.server.config.ts +++ b/apps/web/sentry.server.config.ts @@ -5,4 +5,11 @@ Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, tracesSampleRate: parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE ?? "0.0") || 0.0, integrations: [Sentry.prismaIntegration()], + beforeSend(event) { + event.tags = { + ...event.tags, + errorSource: "server", + }; + return event; + }, }); diff --git a/turbo.json b/turbo.json index 69e8f84241..c090c03dc7 100644 --- a/turbo.json +++ b/turbo.json @@ -41,6 +41,8 @@ "SENTRY_DEBUG", "SENTRY_MAX_SPANS", "SENTRY_TRACES_SAMPLE_RATE", + "SENTRY_REPLAYS_SESSION_SAMPLE_RATE", + "SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE", "STRIPE_PREMIUM_PLAN_PRODUCT_ID", "STRIPE_TEAM_MONTHLY_PRICE_ID", "STRIPE_TEAM_PRODUCT_ID",