1
0
Fork 0
mirror of https://github.com/betagouv/mon-entreprise synced 2025-02-09 22:45:01 +00:00
mon-entreprise/site/source/sentry.ts
Maxime Quandalle 16ba0e5d3e Migration des variables d'environnement
Avec vite, on n'utilise plus `process.env` côté client, mais
`import.meta.env`. Par ailleurs seules les variables d'environnement
préfixées par `VITE_` sont exposées au client, les autres sont
uniquement disponibles côté serveur.
2022-01-31 13:33:07 +01:00

41 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import * as Sentry from '@sentry/react'
import { Integrations } from '@sentry/tracing'
let branch: string | undefined = import.meta.env.VITE_GITHUB_REF?.split(
'/'
)?.slice(-1)?.[0]
if (branch === 'merge') {
branch = import.meta.env.VITE_GITHUB_HEAD_REF
}
const release =
branch && `${branch}-` + import.meta.env.VITE_GITHUB_SHA?.substring(0, 7)
if (branch && branch !== 'master') {
// eslint-disable-next-line no-console
console.info(
` Vous êtes sur la branche : %c${branch}`,
'font-weight: bold; text-decoration: underline;'
)
}
// We use this variable to hide some features in production while keeping them
// in feature-branches. In case we do A/B testing with several branches served
// in production, we should add the public faced branch names in the test below.
// This is different from the import.meta.env.MODE in that a feature branch may
// be build in production mode (with the NODE_ENV) but we may still want to show
// or hide some features.
export const productionMode = ['master', 'next'].includes(branch ?? '')
if (productionMode) {
Sentry.init({
dsn: 'https://92bbc21937b24136a2fe1b1d922b000f@o548798.ingest.sentry.io/5745615',
integrations: [new Integrations.BrowserTracing()],
release,
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 0.5,
})
}