From 5f2ea2bd80a4021bbc3cffb2ba7ad13da9bd93ba Mon Sep 17 00:00:00 2001 From: Florian Sommariva <1926041+dtrucs@users.noreply.github.com> Date: Thu, 28 Nov 2024 19:49:15 +0100 Subject: [PATCH] Avoid trying to launch sentry for instances without Sentry DSN key --- frontend/src/{instrumentation.js => instrumentation.ts} | 2 -- .../{sentry.client.config.js => sentry.client.config.ts} | 6 ++++-- .../{sentry.server.config.js => sentry.server.config.ts} | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) rename frontend/src/{instrumentation.js => instrumentation.ts} (75%) rename frontend/src/{sentry.client.config.js => sentry.client.config.ts} (86%) rename frontend/src/{sentry.server.config.js => sentry.server.config.ts} (85%) diff --git a/frontend/src/instrumentation.js b/frontend/src/instrumentation.ts similarity index 75% rename from frontend/src/instrumentation.js rename to frontend/src/instrumentation.ts index 7b819291d..0f89e71e9 100644 --- a/frontend/src/instrumentation.js +++ b/frontend/src/instrumentation.ts @@ -1,5 +1,3 @@ -import * as Sentry from '@sentry/nextjs'; - export async function register() { if (process.env.NEXT_RUNTIME === 'nodejs') { await import('./sentry.server.config'); diff --git a/frontend/src/sentry.client.config.js b/frontend/src/sentry.client.config.ts similarity index 86% rename from frontend/src/sentry.client.config.js rename to frontend/src/sentry.client.config.ts index 2a467c9b8..c27c8deb2 100644 --- a/frontend/src/sentry.client.config.js +++ b/frontend/src/sentry.client.config.ts @@ -9,7 +9,7 @@ const sentryOptions = { maxBreadcrumbs: 50, attachStacktrace: true, integrations: [Sentry.replayIntegration()], -}; +} as Sentry.BrowserOptions; // Development & tests setup if (process.env.NODE_ENV !== 'production') { @@ -17,4 +17,6 @@ if (process.env.NODE_ENV !== 'production') { sentryOptions.beforeSend = () => null; } -Sentry.init(sentryOptions); +if (SENTRY_DSN) { + Sentry.init(sentryOptions); +} diff --git a/frontend/src/sentry.server.config.js b/frontend/src/sentry.server.config.ts similarity index 85% rename from frontend/src/sentry.server.config.js rename to frontend/src/sentry.server.config.ts index 496685cf4..075001de0 100644 --- a/frontend/src/sentry.server.config.js +++ b/frontend/src/sentry.server.config.ts @@ -8,7 +8,7 @@ const sentryOptions = { environment: process.env.ENVIRONMENT, maxBreadcrumbs: 50, attachStacktrace: true, -}; +} as Sentry.NodeOptions; // Development & tests setup if (process.env.NODE_ENV !== 'production') { @@ -16,4 +16,6 @@ if (process.env.NODE_ENV !== 'production') { sentryOptions.beforeSend = () => null; } -Sentry.init(sentryOptions); +if (SENTRY_DSN) { + Sentry.init(sentryOptions); +}