Skip to content

Commit

Permalink
chore: separate SENTRY_ENABLED and SENTRY_SEND_VERSION
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JalilArfaoui committed Nov 12, 2020
1 parent f2be7a8 commit 24bb2ca
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 21 deletions.
6 changes: 5 additions & 1 deletion .env.development.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ [email protected]
[email protected]
SEND_IN_BLUE_TOKEN=token

#SENTRY_ENABLED=true
#CHROME_EXTENSION_ID=

# For tooling and profiles page
Expand All @@ -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://[email protected]/1404847
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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://[email protected]/1404847
9 changes: 8 additions & 1 deletion .env.proding
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
BABEL_ENV=production

BACKEND_ORIGIN=https://notices.bulles.fr/api/v3/

# Refresh intervals in minutes
Expand All @@ -16,7 +18,12 @@ [email protected]

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://[email protected]/1404847
SENTRY_ENABLED=true
8 changes: 8 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
BABEL_ENV=production

BACKEND_ORIGIN=https://notices.bulles.fr/api/v3/

# Refresh intervals in minutes
Expand All @@ -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://[email protected]/1404847
SENTRY_ENABLED=true
9 changes: 8 additions & 1 deletion .env.staging
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
BABEL_ENV=production

BACKEND_ORIGIN=https://staging-notices.bulles.fr/api/v3/

# Refresh intervals in minutes
Expand All @@ -16,7 +18,12 @@ [email protected]

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://[email protected]/1404847
SENTRY_ENABLED=true
14 changes: 6 additions & 8 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const release = Object.freeze({
path: '@semantic-release/exec',
cmd: 'yarn run upload:firefox:proding'
},

{
path: '@semantic-release/github',
assets: [
Expand Down
4 changes: 2 additions & 2 deletions webpack/config.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
{
Expand Down Expand Up @@ -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'),
Expand Down

0 comments on commit 24bb2ca

Please sign in to comment.