2021-05-03 11:28:31 +00:00
|
|
|
|
import * as Sentry from '@sentry/react'
|
|
|
|
|
import { Integrations } from '@sentry/tracing'
|
|
|
|
|
|
2022-03-15 19:21:58 +00:00
|
|
|
|
let branch: string | undefined = import.meta.env.VITE_GITHUB_REF?.split(
|
|
|
|
|
'/'
|
|
|
|
|
)?.slice(-1)?.[0]
|
2021-05-03 11:28:31 +00:00
|
|
|
|
|
2022-03-15 19:21:58 +00:00
|
|
|
|
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') {
|
2021-12-27 10:27:57 +00:00
|
|
|
|
// eslint-disable-next-line no-console
|
2021-05-03 11:28:31 +00:00
|
|
|
|
console.info(
|
|
|
|
|
`ℹ Vous êtes sur la branche : %c${branch}`,
|
|
|
|
|
'font-weight: bold; text-decoration: underline;'
|
|
|
|
|
)
|
|
|
|
|
}
|
2021-05-12 14:05:25 +00:00
|
|
|
|
|
2022-03-15 19:21:58 +00:00
|
|
|
|
// 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 ?? '')
|
2021-05-12 14:05:25 +00:00
|
|
|
|
|
2022-03-15 19:21:58 +00:00
|
|
|
|
if (productionMode) {
|
2021-05-12 14:05:25 +00:00
|
|
|
|
Sentry.init({
|
2021-09-01 13:25:33 +00:00
|
|
|
|
dsn: 'https://92bbc21937b24136a2fe1b1d922b000f@o548798.ingest.sentry.io/5745615',
|
2021-05-12 14:05:25 +00:00
|
|
|
|
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,
|
|
|
|
|
})
|
|
|
|
|
}
|