mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
Migrate Sentry settings to environment variables (#11085)
Sentry is now configured with environment variables, rather than with hard-coded values. This makes it easier to test Sentry functionality using a different Sentry account, as we did recently during QA of v9.5.1. The only change for the normal build process is the introduction of the `SENTRY_DSN_DEV` variable, which can be set via `.metamaskrc` or via an environment variable. This determines where error reports are sent. It still defaults to our team Sentry account's `metamask-testing` project. The `sentry:publish` script now requires SENTRY_ORG and SENTRY_PROJECT to be set in order to publish release artifacts. The CircleCI configuration has been updated with these values, so it should act the same as it did before. Previously we had used a CLI flag to specify the organization and project, but Sentry already natively supports these environment variables [1]. [1]: https://docs.sentry.io/product/cli/configuration/#configuration-values
This commit is contained in:
parent
da2e662675
commit
37dc19a352
@ -505,7 +505,7 @@ jobs:
|
||||
at: .
|
||||
- run:
|
||||
name: sentry sourcemaps upload
|
||||
command: yarn sentry:publish
|
||||
command: SENTRY_ORG=metamask SENTRY_PROJECT=metamask yarn sentry:publish
|
||||
- run:
|
||||
name: Create GitHub release
|
||||
command: |
|
||||
|
@ -7,9 +7,8 @@ import extractEthjsErrorMessage from './extractEthjsErrorMessage';
|
||||
// Destructuring breaks the inlining of the environment variables
|
||||
const METAMASK_DEBUG = process.env.METAMASK_DEBUG;
|
||||
const METAMASK_ENVIRONMENT = process.env.METAMASK_ENVIRONMENT;
|
||||
const SENTRY_DSN_DEV = process.env.SENTRY_DSN_DEV;
|
||||
/* eslint-enable prefer-destructuring */
|
||||
const SENTRY_DSN_DEV =
|
||||
'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496';
|
||||
|
||||
// This describes the subset of Redux state attached to errors sent to Sentry
|
||||
// These properties have some potential to be useful for debugging, and they do
|
||||
|
@ -20,6 +20,9 @@ const metamaskrc = require('rc')('metamask', {
|
||||
SEGMENT_HOST: process.env.SEGMENT_HOST,
|
||||
SEGMENT_WRITE_KEY: process.env.SEGMENT_WRITE_KEY,
|
||||
SEGMENT_LEGACY_WRITE_KEY: process.env.SEGMENT_LEGACY_WRITE_KEY,
|
||||
SENTRY_DSN_DEV:
|
||||
process.env.SENTRY_DSN_DEV ||
|
||||
'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496',
|
||||
});
|
||||
|
||||
const { version } = require('../../package.json');
|
||||
@ -431,6 +434,7 @@ function getEnvironmentVariables({ devMode, testing }) {
|
||||
PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY || '',
|
||||
CONF: devMode ? metamaskrc : {},
|
||||
SENTRY_DSN: process.env.SENTRY_DSN,
|
||||
SENTRY_DSN_DEV: metamaskrc.SENTRY_DSN_DEV,
|
||||
INFURA_PROJECT_ID: testing
|
||||
? '00000000000000000000000000000000'
|
||||
: metamaskrc.INFURA_PROJECT_ID,
|
||||
|
@ -11,6 +11,12 @@ start().catch((error) => {
|
||||
});
|
||||
|
||||
async function start() {
|
||||
if (!process.env.SENTRY_ORG) {
|
||||
throw new Error('Missing required "SENTRY_ORG" environment variable');
|
||||
} else if (!process.env.SENTRY_PROJECT) {
|
||||
throw new Error('Missing required "SENTRY_PROJECT" environment variable');
|
||||
}
|
||||
|
||||
const authWorked = await checkIfAuthWorks();
|
||||
if (!authWorked) {
|
||||
throw new Error(`Sentry auth failed`);
|
||||
@ -25,15 +31,11 @@ async function start() {
|
||||
} else {
|
||||
// create sentry release
|
||||
console.log(`creating Sentry release for "${VERSION}"...`);
|
||||
await exec(
|
||||
`sentry-cli releases --org 'metamask' --project 'metamask' new ${VERSION}`,
|
||||
);
|
||||
await exec(`sentry-cli releases new ${VERSION}`);
|
||||
console.log(
|
||||
`removing any existing files from Sentry release "${VERSION}"...`,
|
||||
);
|
||||
await exec(
|
||||
`sentry-cli releases --org 'metamask' --project 'metamask' files ${VERSION} delete --all`,
|
||||
);
|
||||
await exec(`sentry-cli releases files ${VERSION} delete --all`);
|
||||
}
|
||||
|
||||
// check if version has artifacts or not
|
||||
@ -52,26 +54,20 @@ async function start() {
|
||||
|
||||
async function checkIfAuthWorks() {
|
||||
const itWorked = await doesNotFail(async () => {
|
||||
await exec(
|
||||
`sentry-cli releases --org 'metamask' --project 'metamask' list`,
|
||||
);
|
||||
await exec(`sentry-cli releases list`);
|
||||
});
|
||||
return itWorked;
|
||||
}
|
||||
|
||||
async function checkIfVersionExists() {
|
||||
const versionAlreadyExists = await doesNotFail(async () => {
|
||||
await exec(
|
||||
`sentry-cli releases --org 'metamask' --project 'metamask' info ${VERSION}`,
|
||||
);
|
||||
await exec(`sentry-cli releases info ${VERSION}`);
|
||||
});
|
||||
return versionAlreadyExists;
|
||||
}
|
||||
|
||||
async function checkIfVersionHasArtifacts() {
|
||||
const artifacts = await exec(
|
||||
`sentry-cli releases --org 'metamask' --project 'metamask' files ${VERSION} list`,
|
||||
);
|
||||
const artifacts = await exec(`sentry-cli releases files ${VERSION} list`);
|
||||
// When there's no artifacts, we get a response from the shell like this ['', '']
|
||||
return artifacts[0] && artifacts[0].length > 0;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ EOF
|
||||
function upload_sourcemaps {
|
||||
local release="${1}"; shift
|
||||
|
||||
sentry-cli releases --org 'metamask' --project 'metamask' files "${release}" upload-sourcemaps ./dist/chrome/*.js ./dist/sourcemaps/ --rewrite --url-prefix 'metamask'
|
||||
sentry-cli releases files "${release}" upload-sourcemaps ./dist/chrome/*.js ./dist/sourcemaps/ --rewrite --url-prefix 'metamask'
|
||||
}
|
||||
|
||||
function main {
|
||||
@ -62,6 +62,12 @@ function main {
|
||||
if [[ -z $release ]]
|
||||
then
|
||||
die 'Required parameter "release" missing; either include parameter or set VERSION environment variable'
|
||||
elif [[ -z $SENTRY_ORG ]]
|
||||
then
|
||||
die 'Required environment variable "SENTRY_ORG" missing'
|
||||
elif [[ -z $SENTRY_PROJECT ]]
|
||||
then
|
||||
die 'Required environment variable "SENTRY_PROJECT" missing'
|
||||
fi
|
||||
|
||||
printf 'uploading source files and sourcemaps for Sentry release "%s"...\n' "${release}"
|
||||
|
Loading…
Reference in New Issue
Block a user