Skip to content

Commit

Permalink
feat: enable sentry init only when the enable flag is set
Browse files Browse the repository at this point in the history
  • Loading branch information
kneerose committed Dec 2, 2024
1 parent 5d433b7 commit 6dcda0d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
1 change: 1 addition & 0 deletions govtool/frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ VITE_IS_DEV=true
VITE_USERSNAP_SPACE_API_KEY=""
VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED='true'
VITE_PDF_API_URL=""
VITE_SENTRY_ENABLED=false
1 change: 1 addition & 0 deletions govtool/frontend/Dockerfile.qovery
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM node:20.18.1-alpine as builder

ARG VITE_APP_ENV='beta'
ARG VITE_SENTRY_ENABLED='false'
ARG VITE_BASE_URL
ARG VITE_METADATA_API_URL
ARG VITE_GTM_ID
Expand Down
46 changes: 24 additions & 22 deletions govtool/frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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_ENABLED) {
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(
<React.StrictMode>
Expand Down

0 comments on commit 6dcda0d

Please sign in to comment.