From 24bb2caecef88d30184be8a3b8ad970dbc51fcda Mon Sep 17 00:00:00 2001 From: Jalil Arfaoui Date: Thu, 12 Nov 2020 15:34:35 +0100 Subject: [PATCH] chore: separate SENTRY_ENABLED and SENTRY_SEND_VERSION We want to be able to generate a build with Sentry integrated and enabled without uploading the version to the Sentry platform. `SENTRY_ORG`, `SENTRY_PROJECT`, `SENTRY_DSN` and `SENTRY_ENABLED` are now committed in staging and production .env file because they are no secret, and we know the values we want to use depending on the environment. New var `SENTRY_SEND_VERSION` is not defined in any .env file but forced by npm script when using `buildVersion` instead of `build` script, thus triggering the upload of the built version to Sentry service. Such operation does need a .sentryclirc file with the user `token` to complete. --- .env.development.example | 6 +++++- .env.example | 6 +++++- .env.proding | 9 ++++++++- .env.production | 8 ++++++++ .env.staging | 9 ++++++++- docs/CONTRIBUTING.md | 14 ++++++-------- package.json | 12 ++++++------ release.config.js | 1 - webpack/config.plugins.js | 4 ++-- 9 files changed, 48 insertions(+), 21 deletions(-) diff --git a/.env.development.example b/.env.development.example index a704c1df9..a68c64256 100644 --- a/.env.development.example +++ b/.env.development.example @@ -16,7 +16,6 @@ SEND_CONTRIBUTION_FROM=infrastructure@lmem.net SEND_CONTRIBUTION_TO=me@email.com SEND_IN_BLUE_TOKEN=token -#SENTRY_ENABLED=true #CHROME_EXTENSION_ID= # For tooling and profiles page @@ -25,3 +24,8 @@ FIREFOX_EXTENSION_ID= PROFILES_ORIGIN=http://localhost:8080 PROFILES_ASSETS_PATH=/ POPULAR_CONTRIBUTORS_IDS=[1, 2, 3] + +# Sentry +SENTRY_ORG=lmem +SENTRY_PROJECT=web-extension +SENTRY_DSN=https://a22936b545a54f37b153b3f9e2c98790@sentry.io/1404847 diff --git a/.env.example b/.env.example index 0a322214a..55c94dea6 100644 --- a/.env.example +++ b/.env.example @@ -4,7 +4,6 @@ FIREFOX_API_SECRET= CHROME_CLIENT_ID= CHROME_CLIENT_SECRET= CHROME_REFRESH_TOKEN= -SENTRY_DSN= SEND_IN_BLUE_TOKEN= # For tooling and profiles page @@ -13,3 +12,8 @@ FIREFOX_EXTENSION_ID= PROFILES_ORIGIN= PROFILES_ASSETS_PATH= POPULAR_CONTRIBUTORS_IDS=[] + +# Sentry +SENTRY_ORG=lmem +SENTRY_PROJECT=web-extension +SENTRY_DSN=https://a22936b545a54f37b153b3f9e2c98790@sentry.io/1404847 diff --git a/.env.proding b/.env.proding index 4d7c9a8e9..e0ac656e6 100644 --- a/.env.proding +++ b/.env.proding @@ -1,3 +1,5 @@ +BABEL_ENV=production + BACKEND_ORIGIN=https://notices.bulles.fr/api/v3/ # Refresh intervals in minutes @@ -16,7 +18,12 @@ SEND_CONTRIBUTION_TO=contribution+proding@dismoi.io CHROME_EXTENSION_ID=mepoelfgpameiagpkgpjphnbgampgffm FIREFOX_EXTENSION_ID={72aad822-62f5-4663-a8f0-025b2f9a3dd5} -BABEL_ENV=production PROFILES_ORIGIN=https://proding-profiles.dismoi.io PROFILES_ASSETS_PATH=https://proding-profiles.dismoi.io/ POPULAR_CONTRIBUTORS_IDS=[53, 54, 59, 46, 65] + +# Sentry +SENTRY_ORG=lmem +SENTRY_PROJECT=web-extension +SENTRY_DSN=https://a22936b545a54f37b153b3f9e2c98790@sentry.io/1404847 +SENTRY_ENABLED=true diff --git a/.env.production b/.env.production index 16cb613a0..159617ba1 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,5 @@ +BABEL_ENV=production + BACKEND_ORIGIN=https://notices.bulles.fr/api/v3/ # Refresh intervals in minutes @@ -19,3 +21,9 @@ FIREFOX_EXTENSION_ID=@lmem PROFILES_ORIGIN=https://www.dismoi.io PROFILES_ASSETS_PATH=https://profiles.dismoi.io/ POPULAR_CONTRIBUTORS_IDS=[53, 54, 59, 46, 65] + +# Sentry +SENTRY_ORG=lmem +SENTRY_PROJECT=web-extension +SENTRY_DSN=https://a22936b545a54f37b153b3f9e2c98790@sentry.io/1404847 +SENTRY_ENABLED=true diff --git a/.env.staging b/.env.staging index d202489f3..02e7df655 100644 --- a/.env.staging +++ b/.env.staging @@ -1,3 +1,5 @@ +BABEL_ENV=production + BACKEND_ORIGIN=https://staging-notices.bulles.fr/api/v3/ # Refresh intervals in minutes @@ -16,7 +18,12 @@ SEND_CONTRIBUTION_TO=contribution+staging@dismoi.io CHROME_EXTENSION_ID=nfabbfkbbbcebdmnocndhdombaffkaog FIREFOX_EXTENSION_ID={7d0d2553-c311-4acd-a170-f9a4714eb2c0} -BABEL_ENV=production PROFILES_ORIGIN=https://staging-profiles.dismoi.io PROFILES_ASSETS_PATH=https://staging-profiles.dismoi.io/ POPULAR_CONTRIBUTORS_IDS=[53, 54, 59, 46, 65] + +# Sentry +SENTRY_ORG=lmem +SENTRY_PROJECT=web-extension +SENTRY_DSN=https://a22936b545a54f37b153b3f9e2c98790@sentry.io/1404847 +SENTRY_ENABLED=true diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index c64db34d3..ae33500cb 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -119,20 +119,18 @@ we use [Semantic Release](https://github.com/semantic-release/semantic-release) ## Sentry -To configure Sentry error reporting, you should create a `.sentryclirc` file at the root of the project directory: +`SENTRY_ORG`, `SENTRY_PROJECT`, `SENTRY_DSN` and `SENTRY_ENABLED` are committed in staging and production .env file because they are no secret, and we know the values we want to use depending on the environment. -``` -[defaults] -project=web-extension -org=lmem +Env var `SENTRY_SEND_VERSION` is not defined in any .env file but forced by npm script when using `buildVersion` instead of `build` script, thus triggering the upload of the built version to Sentry service. + +Such operation (that you should not have to run on your machine) does need a .sentryclirc file with the user `token` to complete: +``` [auth] token=4d786d88c7d9436282c35b4eb82ae2dfeaff5ee296e3404ba3654ab62c151b73 ``` -> **Note 1:** You'll find your token here https://sentry.io/settings/account/api/auth-tokens/ - -> **Note 2:** You can change the `SENTRY_DSN` from environment files. +> **Note:** You'll find your token here https://sentry.io/settings/account/api/auth-tokens/ ### Redux DevTools diff --git a/package.json b/package.json index 1be5ccc1b..aee78dcad 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,12 @@ "build:staging": "yarn build:chromium:staging && yarn build:firefox:staging", "build:proding": "yarn build:chromium:proding && yarn build:firefox:proding", "build:production": "yarn build:chromium:production && yarn build:firefox:production", - "buildVersion:chromium:staging": "yarn build:chromium:staging --env.SENTRY_ENABLED", - "buildVersion:chromium:proding": "yarn build:chromium:proding --env.SENTRY_ENABLED", - "buildVersion:chromium:production": "yarn build:chromium:production --env.SENTRY_ENABLED", - "buildVersion:firefox:staging": "yarn build:firefox:staging --env.SENTRY_ENABLED", - "buildVersion:firefox:proding": "yarn build:firefox:proding --env.SENTRY_ENABLED", - "buildVersion:firefox:production": "yarn build:firefox:production --env.SENTRY_ENABLED", + "buildVersion:chromium:staging": "yarn build:chromium:staging --env.SENTRY_SEND_VERSION", + "buildVersion:chromium:proding": "yarn build:chromium:proding --env.SENTRY_SEND_VERSION", + "buildVersion:chromium:production": "yarn build:chromium:production --env.SENTRY_SEND_VERSION", + "buildVersion:firefox:staging": "yarn build:firefox:staging --env.SENTRY_SEND_VERSION", + "buildVersion:firefox:proding": "yarn build:firefox:proding --env.SENTRY_SEND_VERSION", + "buildVersion:firefox:production": "yarn build:firefox:production --env.SENTRY_SEND_VERSION", "buildVersion:staging": "yarn buildVersion:chromium:staging && yarn buildVersion:firefox:staging", "buildVersion:proding": "yarn buildVersion:chromium:proding && yarn buildVersion:firefox:proding", "buildVersion:production": "yarn buildVersion:chromium:production && yarn buildVersion:firefox:production", diff --git a/release.config.js b/release.config.js index e5333e2bf..8bf70495c 100644 --- a/release.config.js +++ b/release.config.js @@ -38,7 +38,6 @@ const release = Object.freeze({ path: '@semantic-release/exec', cmd: 'yarn run upload:firefox:proding' }, - { path: '@semantic-release/github', assets: [ diff --git a/webpack/config.plugins.js b/webpack/config.plugins.js index dde64782b..937a2dac0 100644 --- a/webpack/config.plugins.js +++ b/webpack/config.plugins.js @@ -39,7 +39,7 @@ const formatEnvVars = R.map(value => `"${value}"`); const processENVVarsToInject = R.pipe(selectEnvVarsToInject, formatEnvVars); module.exports = (env = {}, argv = {}, buildPath) => { - const { NODE_ENV, SENTRY_ENABLED, PLATFORM, ANALYZE } = env; + const { NODE_ENV, SENTRY_SEND_VERSION, PLATFORM, ANALYZE } = env; const copyConfig = [ { from: 'src/assets', to: buildPath }, { @@ -91,7 +91,7 @@ module.exports = (env = {}, argv = {}, buildPath) => { ); } - if (SENTRY_ENABLED) { + if (SENTRY_SEND_VERSION) { plugins.push( new SentryWebpackPlugin({ include: path.resolve(buildPath, 'js'),