Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize sentry integration #2449

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy-test-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
cd $DEST_DIR/tests/test-infrastructure
./build-and-deploy.sh update-images
yes | docker system prune -f || echo "Ignoring system prune eror"
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
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
env:
GOVTOOL_TAG: ${{ github.sha }}
GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }}
Expand Down
3 changes: 2 additions & 1 deletion govtool/frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ VITE_USERSNAP_SPACE_API_KEY=""
VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED='true'
VITE_PDF_API_URL=""
VITE_IPFS_GATEWAY=""
VITE_IPFS_PROJECT_ID=""
VITE_IPFS_PROJECT_ID=""
VITE_IS_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_IS_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_IS_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
3 changes: 2 additions & 1 deletion tests/test-infrastructure/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ APP_ENV=test
PDF_API_URL=
KUBER_API_KEY=
IPFS_GATEWAY=""
IPFS_PROJECT_ID=""
IPFS_PROJECT_ID=""
IS_SENTRY_ENABLED=false
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"port" : 8080,
"host" : "0.0.0.0",
"cachedurationseconds": 20,
"sentrydsn": "${SENTRY_DSN_BACKEND:-https://username:[email protected]/id}"
"sentrydsn": "${SENTRY_DSN_BACKEND:-https://username:[email protected]/id}",
"sentryenv": "test"
}
Loading