Skip to content

Commit

Permalink
fix: fusion du authToken (partagé entre le front et le back) & config…
Browse files Browse the repository at this point in the history
…ure le projet sentry front sur le build de vite.js (#4771)
  • Loading branch information
Shamzic authored Dec 31, 2024
1 parent 7b06b1e commit 58ad2d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ VITE_STATS_VERSION=
MONGODB_URL=

SENTRY_BACKEND_DSN=
SENTRY_BACKEND_AUTH_TOKEN=
SENTRY_BACKEND_PROJECT=

SENTRY_FRONTEND_DSN=
SENTRY_FRONTEND_AUTH_TOKEN=
SENTRY_FRONTEND_PROJECT=

SENTRY_AUTH_TOKEN=
SENTRY_CRON_DSN=

SESSION_SECRET=
Expand Down
2 changes: 1 addition & 1 deletion backend/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const config: Configuration = {
process.env.MONGODB_URL || "mongodb://127.0.0.1:27017/dev-aides-jeunes",
sentry: {
dsn: process.env.SENTRY_BACKEND_DSN,
authToken: process.env.SENTRY_BACKEND_AUTH_TOKEN,
authToken: process.env.SENTRY_AUTH_TOKEN,
project: process.env.SENTRY_BACKEND_PROJECT,
environment: process.env.NODE_ENV,
integrations: [nodeProfilingIntegration()],
Expand Down
15 changes: 9 additions & 6 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ const {
smsService,
} = config

function createSentryPlugin() {
if (!sentry.authToken || !sentry.project) {
function createSentryPlugin(authToken, project) {
if (!authToken || !project) {
return null
}
return sentryVitePlugin({
org: "betagouv",
project: sentry.project,
authToken: sentry.authToken,
project,
authToken,
url: "https://sentry.incubateur.net/",
sourcemaps: {
assets: `./dist/assets/${buildId}/js/*.{js,map}`,
Expand All @@ -58,7 +58,7 @@ export default defineConfig(async ({ mode }) => {
VITE_BASE_URL: baseURL,
VITE_CONTEXT: process.env.NODE_ENV,
VITE_SENTRY_FRONTEND_DSN: process.env?.SENTRY_FRONTEND_DSN,
VITE_SENTRY_FRONTEND_AUTH_TOKEN: process.env?.SENTRY_FRONTEND_AUTH_TOKEN,
VITE_SENTRY_FRONTEND_PROJECT: process.env?.SENTRY_FRONTEND_PROJECT,
VITE_PR_URL: `${process.env.REPOSITORY_URL}/pull/${process.env.REVIEW_ID}`,
VITE_REPOSITORY_URL: github.repository_url,
VITE_BENEFIT_URL: `${github.repository_url}/blob/main/data/benefits`,
Expand Down Expand Up @@ -126,7 +126,10 @@ export default defineConfig(async ({ mode }) => {
targets: ["defaults"],
}),
visualizer(),
createSentryPlugin(),
createSentryPlugin(
sentry.authToken,
viteEnvironment.VITE_SENTRY_FRONTEND_PROJECT
),
sitemapGenerator(),
],
resolve: {
Expand Down

0 comments on commit 58ad2d1

Please sign in to comment.