Skip to content

Commit f0018b0

Browse files
committed
feat: enable sentry init only when the enable flag is set
1 parent 8130ffa commit f0018b0

File tree

5 files changed

+30
-25
lines changed

5 files changed

+30
-25
lines changed

.github/workflows/build-and-deploy-test-stack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
cd $DEST_DIR/tests/test-infrastructure
6262
./build-and-deploy.sh update-images
6363
yes | docker system prune -f || echo "Ignoring system prune eror"
64-
envs: GOVTOOL_TAG, GRAFANA_ADMIN_PASSWORD, GRAFANA_SLACK_RECIPIENT, GRAFANA_SLACK_OAUTH_TOKEN, SENTRY_DSN_BACKEND, GTM_ID, NPMRC_TOKEN, SENTRY_DSN_FRONTEND, PIPELINE_URL, USERSNAP_SPACE_API_KEY, APP_ENV, PDF_API_URL, KUBER_API_KEY, IPFS_GATEWAY, IPFS_PROJECT_ID
64+
envs: GOVTOOL_TAG, GRAFANA_ADMIN_PASSWORD, GRAFANA_SLACK_RECIPIENT, GRAFANA_SLACK_OAUTH_TOKEN, SENTRY_DSN_BACKEND, GTM_ID, NPMRC_TOKEN, SENTRY_DSN_FRONTEND, PIPELINE_URL, USERSNAP_SPACE_API_KEY, APP_ENV, PDF_API_URL, KUBER_API_KEY, IPFS_GATEWAY, IPFS_PROJECT_ID, IS_SENTRY_ENABLED
6565
env:
6666
GOVTOOL_TAG: ${{ github.sha }}
6767
GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }}

govtool/frontend/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ VITE_USERSNAP_SPACE_API_KEY=""
99
VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED='true'
1010
VITE_PDF_API_URL=""
1111
VITE_IPFS_GATEWAY=""
12-
VITE_IPFS_PROJECT_ID=""
12+
VITE_IPFS_PROJECT_ID=""
13+
VITE_IS_SENTRY_ENABLED=false

govtool/frontend/Dockerfile.qovery

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM node:20.18.1-alpine as builder
22

33
ARG VITE_APP_ENV='beta'
4+
ARG VITE_IS_SENTRY_ENABLED='false'
45
ARG VITE_BASE_URL
56
ARG VITE_METADATA_API_URL
67
ARG VITE_GTM_ID

govtool/frontend/src/main.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,30 @@ const tagManagerArgs = {
2424

2525
TagManager.initialize(tagManagerArgs);
2626

27-
Sentry.init({
28-
dsn: import.meta.env.VITE_SENTRY_DSN,
29-
environment: import.meta.env.VITE_APP_ENV,
30-
release: version,
31-
integrations: [
32-
Sentry.browserTracingIntegration(),
33-
Sentry.replayIntegration(),
34-
],
35-
tracesSampleRate: 1.0,
36-
replaysSessionSampleRate: 0.1,
37-
replaysOnErrorSampleRate: 1.0,
38-
beforeSend(event) {
39-
window.dataLayer = window.dataLayer || [];
40-
window.dataLayer.push({
41-
event: "sentryEvent",
42-
sentryEventId: event?.event_id || "default_event_id",
43-
sentryErrorMessage:
44-
event?.exception?.values?.[0]?.value || "Unknown Error",
45-
});
46-
return event;
47-
},
48-
});
27+
if (import.meta.env.VITE_IS_SENTRY_ENABLED) {
28+
Sentry.init({
29+
dsn: import.meta.env.VITE_SENTRY_DSN,
30+
environment: import.meta.env.VITE_APP_ENV,
31+
release: version,
32+
integrations: [
33+
Sentry.browserTracingIntegration(),
34+
Sentry.replayIntegration(),
35+
],
36+
tracesSampleRate: 1.0,
37+
replaysSessionSampleRate: 0.1,
38+
replaysOnErrorSampleRate: 1.0,
39+
beforeSend(event) {
40+
window.dataLayer = window.dataLayer || [];
41+
window.dataLayer.push({
42+
event: "sentryEvent",
43+
sentryEventId: event?.event_id || "default_event_id",
44+
sentryErrorMessage:
45+
event?.exception?.values?.[0]?.value || "Unknown Error",
46+
});
47+
return event;
48+
},
49+
});
50+
}
4951

5052
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
5153
<React.StrictMode>

tests/test-infrastructure/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ APP_ENV=test
99
PDF_API_URL=
1010
KUBER_API_KEY=
1111
IPFS_GATEWAY=""
12-
IPFS_PROJECT_ID=""
12+
IPFS_PROJECT_ID=""
13+
IS_SENTRY_ENABLED=false

0 commit comments

Comments
 (0)