diff --git a/frontend/.env.d.ts b/frontend/.env.d.ts new file mode 100644 index 000000000..b52276748 --- /dev/null +++ b/frontend/.env.d.ts @@ -0,0 +1,10 @@ +// https://vitejs.dev/guide/env-and-mode#intellisense-for-typescript +/// + +interface ImportMetaEnv { + readonly FRONTEND_SENTRY_DSN: string +} + +interface ImportMeta { + readonly env: ImportMetaEnv +} diff --git a/frontend/.env.example b/frontend/.env.example new file mode 100644 index 000000000..be9e9cdbf --- /dev/null +++ b/frontend/.env.example @@ -0,0 +1,5 @@ + +################################################################################ +# Sentry + +FRONTEND_SENTRY_DSN=https://something@sentry.incubateur.net/121 diff --git a/frontend/.env.local.defaults b/frontend/.env.local.defaults new file mode 100644 index 000000000..4e2331c97 --- /dev/null +++ b/frontend/.env.local.defaults @@ -0,0 +1,4 @@ +################################################################################ +# Sentry + +FRONTEND_SENTRY_DSN=https://8857258f9f1549968b13e15759bdf2bc@sentry.incubateur.net/121 diff --git a/frontend/.gitignore b/frontend/.gitignore index c5892d753..e389ce6f3 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -1,11 +1,24 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. +# env .env +.env.local +.env.development +.env.development.local +.env.staging +.env.staging.local +.env.production +.env.production.local +.env.test +.env.test.local # dependencies /node_modules /.pnp .pnp.js +npm-debug.log* +yarn-debug.log* +yarn-error.log* # testing /coverage @@ -16,11 +29,3 @@ # misc .DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -npm-debug.log* -yarn-debug.log* -yarn-error.log* diff --git a/frontend/index.html b/frontend/index.html index 8aa9f95ef..4559e5d98 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -9,7 +9,16 @@ +
+ + + + + + diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 69b948a34..f327dc8d4 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -29,6 +29,9 @@ "web-vitals": "^2.1.4" }, "devDependencies": { + "@import-meta-env/cli": "^0.6.8", + "@import-meta-env/prepare": "0.1.13", + "@import-meta-env/unplugin": "^0.5.1", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^14.0.0", "@testing-library/user-event": "^14.4.3", @@ -2267,6 +2270,287 @@ "dev": true, "license": "BSD-3-Clause" }, + "node_modules/@import-meta-env/cli": { + "version": "0.6.8", + "resolved": "https://registry.npmjs.org/@import-meta-env/cli/-/cli-0.6.8.tgz", + "integrity": "sha512-Lunsmlj02yVtI5drlhNwIUFAQ0wsIUYIrz0Nm5jbvmYvyEUsxC8Qotnf3gXTfvM9Yuutvuc2+dx4uXpa3DajTg==", + "dev": true, + "dependencies": { + "commander": "11.1.0", + "glob": "10.3.10", + "picocolors": "1.0.0", + "serialize-javascript": "6.0.1" + }, + "bin": { + "import-meta-env": "bin/import-meta-env.js" + }, + "engines": { + "node": ">= 14" + }, + "peerDependencies": { + "@import-meta-env/babel": "^0.4.3", + "@import-meta-env/swc": "^0.4.5", + "@import-meta-env/unplugin": "^0.4.8 || ^0.5.0", + "dotenv": "^11.0.0 || ^12.0.4 || ^13.0.1 || ^14.3.2 || ^15.0.1 || ^16.0.0" + }, + "peerDependenciesMeta": { + "@import-meta-env/babel": { + "optional": true + }, + "@import-meta-env/swc": { + "optional": true + }, + "@import-meta-env/unplugin": { + "optional": true + } + } + }, + "node_modules/@import-meta-env/cli/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@import-meta-env/cli/node_modules/commander": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", + "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", + "dev": true, + "engines": { + "node": ">=16" + } + }, + "node_modules/@import-meta-env/cli/node_modules/glob": { + "version": "10.3.10", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", + "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", + "dev": true, + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.5", + "minimatch": "^9.0.1", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", + "path-scurry": "^1.10.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@import-meta-env/cli/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@import-meta-env/prepare": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/@import-meta-env/prepare/-/prepare-0.1.13.tgz", + "integrity": "sha512-N/vu1JHcq4NX63/4d2sDWQaZFENtmoVDJNZwMib1MHiZPrkmuyoYj8sVBa/4wgc8f+lFXnliil4DBbI4w2aHzQ==", + "dev": true, + "dependencies": { + "commander": "11.1.0", + "glob": "10.3.10", + "picocolors": "1.0.0", + "serialize-javascript": "6.0.1" + }, + "bin": { + "import-meta-env-prepare": "bin/import-meta-env-prepare.js" + }, + "engines": { + "node": ">= 14" + }, + "peerDependencies": { + "dotenv": "^11.0.0 || ^12.0.4 || ^13.0.1 || ^14.3.2 || ^15.0.1 || ^16.0.0" + } + }, + "node_modules/@import-meta-env/prepare/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@import-meta-env/prepare/node_modules/commander": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", + "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", + "dev": true, + "engines": { + "node": ">=16" + } + }, + "node_modules/@import-meta-env/prepare/node_modules/glob": { + "version": "10.3.10", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", + "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", + "dev": true, + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.5", + "minimatch": "^9.0.1", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", + "path-scurry": "^1.10.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@import-meta-env/prepare/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@import-meta-env/unplugin": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/@import-meta-env/unplugin/-/unplugin-0.5.1.tgz", + "integrity": "sha512-2pn+eYha02TY+iJ8WAlGr9SnOx0o+OvddO6lzU9hBxkogWlU9Q1dI/9thacnjL9alOA3R2qGZPd79kaiYtw81A==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "magic-string": "^0.30.0", + "object-hash": "^3.0.0", + "picocolors": "^1.0.0", + "unplugin": "^1.5.0" + }, + "engines": { + "node": ">= 14" + }, + "peerDependencies": { + "@import-meta-env/cli": "^0.5.1 || ^0.6.0", + "dotenv": "^11.0.0 || ^12.0.4 || ^13.0.1 || ^14.3.2 || ^15.0.1 || ^16.0.0" + }, + "peerDependenciesMeta": { + "@import-meta-env/cli": { + "optional": true + } + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -3289,6 +3573,16 @@ "dev": true, "license": "MIT" }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "optional": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@remix-run/router": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.15.0.tgz", @@ -5792,15 +6086,10 @@ } }, "node_modules/chokidar": { - "version": "3.5.3", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ], - "license": "MIT", "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -5813,6 +6102,9 @@ "engines": { "node": ">= 8.10.0" }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, "optionalDependencies": { "fsevents": "~2.3.2" } @@ -6790,6 +7082,25 @@ "tslib": "^2.0.3" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "dev": true, + "peer": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true + }, "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -8063,6 +8374,34 @@ "is-callable": "^1.1.3" } }, + "node_modules/foreground-child": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", + "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/foreground-child/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -9331,6 +9670,24 @@ "set-function-name": "^2.0.1" } }, + "node_modules/jackspeak": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", + "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", + "dev": true, + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, "node_modules/jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", @@ -12270,6 +12627,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/minipass": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", + "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", + "dev": true, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/mlly": { "version": "1.5.0", "dev": true, @@ -12490,6 +12856,15 @@ "node": ">=0.10.0" } }, + "node_modules/object-hash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", + "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/object-inspect": { "version": "1.13.1", "license": "MIT", @@ -12885,6 +13260,31 @@ "dev": true, "license": "MIT" }, + "node_modules/path-scurry": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.1.tgz", + "integrity": "sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==", + "dev": true, + "dependencies": { + "lru-cache": "^9.1.1 || ^10.0.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-scurry/node_modules/lru-cache": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", + "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", + "dev": true, + "engines": { + "node": "14 || >=16.14" + } + }, "node_modules/path-to-regexp": { "version": "6.2.1", "dev": true, @@ -13229,6 +13629,15 @@ ], "license": "MIT" }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, "node_modules/react": { "version": "18.2.0", "license": "MIT", @@ -13793,6 +14202,15 @@ "semver": "bin/semver.js" } }, + "node_modules/serialize-javascript": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.1.tgz", + "integrity": "sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, "node_modules/set-function-length": { "version": "1.2.0", "license": "MIT", @@ -14118,6 +14536,27 @@ "node": ">=8" } }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, "node_modules/string-width/node_modules/emoji-regex": { "version": "8.0.0", "license": "MIT" @@ -14193,6 +14632,19 @@ "node": ">=8" } }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-bom": { "version": "3.0.0", "dev": true, @@ -14689,6 +15141,21 @@ "node": ">= 4.0.0" } }, + "node_modules/unplugin": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-1.9.0.tgz", + "integrity": "sha512-14PslvMY3gNbXnQtNIRB566Q057L5Fe7f5LDEamxVi0QQVxoz5hrveBwwZLcKyHtZ09ysmipxRRj5Lv+BGz2Iw==", + "dev": true, + "dependencies": { + "acorn": "^8.11.3", + "chokidar": "^3.6.0", + "webpack-sources": "^3.2.3", + "webpack-virtual-modules": "^0.6.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/untildify": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", @@ -15322,6 +15789,21 @@ "node": ">=12" } }, + "node_modules/webpack-sources": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", + "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==", + "dev": true, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/webpack-virtual-modules": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/webpack-virtual-modules/-/webpack-virtual-modules-0.6.1.tgz", + "integrity": "sha512-poXpCylU7ExuvZK8z+On3kX+S8o/2dQ/SVYueKA0D4WEMXROXgY8Ez50/bQEUmvoSMMrWcrJqCHuhAbsiwg7Dg==", + "dev": true + }, "node_modules/whatwg-encoding": { "version": "2.0.0", "dev": true, @@ -15465,6 +15947,57 @@ "node": ">=8" } }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "node_modules/wrap-ansi/node_modules/ansi-styles": { "version": "4.3.0", "license": "MIT", diff --git a/frontend/package.json b/frontend/package.json index db8a5d10d..9a46ee31c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -7,8 +7,8 @@ "node": ">=20.0.0" }, "scripts": { - "dev": "vite", - "build": "vite build", + "dev": "import-meta-env-prepare -x ./.env.local.defaults && vite", + "build": "vite build && import-meta-env -x .env.example -p dist/index.html", "build:with-sourcemaps": "vite build --sourcemap", "tsc": "tsc", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 10000", @@ -39,6 +39,9 @@ "web-vitals": "^2.1.4" }, "devDependencies": { + "@import-meta-env/cli": "^0.6.8", + "@import-meta-env/prepare": "0.1.13", + "@import-meta-env/unplugin": "^0.5.1", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^14.0.0", "@testing-library/user-event": "^14.4.3", diff --git a/frontend/src/apollo-client.ts b/frontend/src/apollo-client.ts index 09bdf00e3..e46db3ea3 100644 --- a/frontend/src/apollo-client.ts +++ b/frontend/src/apollo-client.ts @@ -7,8 +7,7 @@ import { ErrorResponse, onError } from "@apollo/client/link/error"; const authToken = new AuthToken() -if (true) { - // if (__DEV__) { +if (import.meta.env.DEV) { // Adds messages only in a dev environment loadDevMessages() loadErrorMessages() @@ -32,7 +31,7 @@ const authLink = setContext((_, {headers}) => { } }) -const errorLink = onError(({graphQLErrors, networkError, operation, forward}: ErrorResponse) => { +const errorLink = onError(({operation, forward}: ErrorResponse) => { const {response} = operation.getContext() if ([401, 403].indexOf(response.status) !== -1) { diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index c75aa813e..38430a3a3 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -2,45 +2,21 @@ import React from 'react' import ReactDOM from 'react-dom/client' // import reportWebVitals from './report-web-vitals' import App from './app' -import * as Sentry from '@sentry/react' -import { createRoutesFromChildren, matchRoutes, useLocation, useNavigationType } from 'react-router-dom' -import { HttpClient, CaptureConsole, Debug } from "@sentry/integrations"; +import initSentry from "./sentry.ts"; import 'react-toastify/dist/ReactToastify.css' import 'rsuite/dist/rsuite.min.css' import './assets/css/index.css' import '@mtes-mct/monitor-ui/assets/stylesheets/rsuite-override.css' -Sentry.init({ - dsn: 'https://8857258f9f1549968b13e15759bdf2bc@sentry.incubateur.net/121', - integrations: [ - new Sentry.BrowserTracing({ - // See docs for support of different versions of variation of react router - // https://docs.sentry.io/platforms/javascript/guides/react/configuration/integrations/react-router/ - routingInstrumentation: Sentry.reactRouterV6Instrumentation( - React.useEffect, - useLocation, - useNavigationType, - createRoutesFromChildren, - matchRoutes - ) - }), - new Sentry.Replay(), - new HttpClient(), - new Debug(), - new CaptureConsole(), - ], - replaysOnErrorSampleRate: 1.0, - replaysSessionSampleRate: 0.1, - tracesSampleRate: 1.0 -}) +// setup sentry before starting +initSentry() const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement) - root.render( - - - + + + ) // If you want to start measuring performance in your app, pass a function diff --git a/frontend/src/sentry.ts b/frontend/src/sentry.ts new file mode 100644 index 000000000..ee4931839 --- /dev/null +++ b/frontend/src/sentry.ts @@ -0,0 +1,36 @@ +import { useEffect } from "react"; +import { init, reactRouterV6BrowserTracingIntegration, replayIntegration } from "@sentry/react"; +import { createRoutesFromChildren, matchRoutes, useLocation, useNavigationType } from "react-router-dom"; +import { captureConsoleIntegration, debugIntegration, httpClientIntegration } from "@sentry/integrations"; + +const initSentry = () => { + const FRONTEND_SENTRY_DSN = import.meta.env.FRONTEND_SENTRY_DSN + const viteMode = import.meta.env.MODE + const isDev = import.meta.env.DEV + const release = "rapportnav2@" + process.env.npm_package_version + + init({ + dsn: FRONTEND_SENTRY_DSN, + environment: viteMode, + enabled: !isDev, + release: release, + integrations: [ + reactRouterV6BrowserTracingIntegration({ + useEffect: useEffect, + useLocation, + useNavigationType, + createRoutesFromChildren, + matchRoutes, + }), + replayIntegration(), + httpClientIntegration(), + debugIntegration(), + captureConsoleIntegration(), + ], + replaysOnErrorSampleRate: 1.0, + replaysSessionSampleRate: 0.1, + tracesSampleRate: 1.0 + }) +} + +export default initSentry diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 7bc4dfdce..cf67844a3 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,11 +1,7 @@ import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import eslint from 'vite-plugin-eslint'; -import dotenv from 'dotenv'; - -// if (process.env.NODE_ENV === 'development') { -// dotenv.config(); -// } +import importMetaEnv from '@import-meta-env/unplugin' // https://vitejs.dev/config/ export default defineConfig({ @@ -32,6 +28,10 @@ export default defineConfig({ plugins: [ react(), eslint(), + importMetaEnv.vite({ + env: './.env', + example: './.env.example' + }) ], server: { host: true, diff --git a/infra/docker-compose.local.yml b/infra/docker-compose.local.yml index 8740c4190..20379beb9 100644 --- a/infra/docker-compose.local.yml +++ b/infra/docker-compose.local.yml @@ -1,5 +1,5 @@ version: '3.8' - +name: RapportNav2 services: backend: build: diff --git a/infra/docker/app/Dockerfile b/infra/docker/app/Dockerfile index 6bf0e5ac2..51e56020d 100644 --- a/infra/docker/app/Dockerfile +++ b/infra/docker/app/Dockerfile @@ -1,5 +1,5 @@ -FROM azul/zulu-openjdk-alpine:17.0.7-17.42.19 as build-all +FROM azul/zulu-openjdk-alpine:17.0.7-17.42.19 AS build-all WORKDIR /home/rapportnav @@ -31,6 +31,4 @@ RUN mkdir /home/rapportnav/logs # It must point to the front (React) files ENV STATIC_FILES_PATH=/home/rapportnav/public - -# CMD exec java -jar "/home/rapportnav/rapportnav-${VERSION}.jar" -CMD exec java -Dspring.config.additional-location="/home/rapportnav/configurations/" -Dspring.profiles.active=$ENV_PROFILE -jar "/home/rapportnav/rapportnav-${VERSION}.jar" +CMD exec java -Dspring.config.additional-location="/home/rapportnav/configurations/" -Dspring.profiles.active="$ENV_PROFILE" -jar "/home/rapportnav/rapportnav-${VERSION}.jar"