diff --git a/govtool/backend/app/Main.hs b/govtool/backend/app/Main.hs index 6311288f0..68b280164 100644 --- a/govtool/backend/app/Main.hs +++ b/govtool/backend/app/Main.hs @@ -172,7 +172,7 @@ exceptionHandler vvaConfig sentryService mRequest exception = do let env = sentryEnv vvaConfig case mRequest of Nothing -> return () - Just _ -> register + Just _ -> when (env /= "qa") $ register sentryService "vva.be" Error diff --git a/govtool/frontend/Dockerfile b/govtool/frontend/Dockerfile index 7c3eb3740..c8869bd0d 100644 --- a/govtool/frontend/Dockerfile +++ b/govtool/frontend/Dockerfile @@ -22,7 +22,6 @@ RUN \ : "${VITE_METADATA_API_URL:?Build argument VITE_METADATA_API_URL is not set}" && \ : "${VITE_GTM_ID:?Build argument VITE_GTM_ID is not set}" && \ : "${VITE_NETWORK_FLAG:?Build argument VITE_NETWORK_FLAG is not set}" && \ - : "${VITE_SENTRY_DSN:?Build argument VITE_SENTRY_DSN is not set}" && \ : "${NPMRC_TOKEN:?Build argument NPMRC_TOKEN is not set}" && \ : "${VITE_USERSNAP_SPACE_API_KEY:?Build argument VITE_USERSNAP_SPACE_API_KEY is not set}" && \ : "${VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED:?Build argument VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED is not set}" && \ diff --git a/govtool/frontend/src/main.tsx b/govtool/frontend/src/main.tsx index 76f6ff419..0d6e039b0 100644 --- a/govtool/frontend/src/main.tsx +++ b/govtool/frontend/src/main.tsx @@ -24,28 +24,30 @@ const tagManagerArgs = { TagManager.initialize(tagManagerArgs); -Sentry.init({ - dsn: import.meta.env.VITE_SENTRY_DSN, - environment: import.meta.env.VITE_APP_ENV, - release: version, - integrations: [ - Sentry.browserTracingIntegration(), - Sentry.replayIntegration(), - ], - tracesSampleRate: 1.0, - replaysSessionSampleRate: 0.1, - replaysOnErrorSampleRate: 1.0, - beforeSend(event) { - window.dataLayer = window.dataLayer || []; - window.dataLayer.push({ - event: "sentryEvent", - sentryEventId: event?.event_id || "default_event_id", - sentryErrorMessage: - event?.exception?.values?.[0]?.value || "Unknown Error", - }); - return event; - }, -}); +if (import.meta.env.VITE_SENTRY_DSN) { + Sentry.init({ + dsn: import.meta.env.VITE_SENTRY_DSN, + environment: import.meta.env.VITE_APP_ENV, + release: version, + integrations: [ + Sentry.browserTracingIntegration(), + Sentry.replayIntegration(), + ], + tracesSampleRate: 1.0, + replaysSessionSampleRate: 0.1, + replaysOnErrorSampleRate: 1.0, + beforeSend(event) { + window.dataLayer = window.dataLayer || []; + window.dataLayer.push({ + event: "sentryEvent", + sentryEventId: event?.event_id || "default_event_id", + sentryErrorMessage: + event?.exception?.values?.[0]?.value || "Unknown Error", + }); + return event; + }, + }); +} ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(