mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +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
440b013d51
commit
5f538f7ab2
@ -505,7 +505,7 @@ jobs:
|
|||||||
at: .
|
at: .
|
||||||
- run:
|
- run:
|
||||||
name: sentry sourcemaps upload
|
name: sentry sourcemaps upload
|
||||||
command: yarn sentry:publish
|
command: SENTRY_ORG=metamask SENTRY_PROJECT=metamask yarn sentry:publish
|
||||||
- run:
|
- run:
|
||||||
name: Create GitHub release
|
name: Create GitHub release
|
||||||
command: |
|
command: |
|
||||||
|
@ -7,9 +7,8 @@ import extractEthjsErrorMessage from './extractEthjsErrorMessage';
|
|||||||
// Destructuring breaks the inlining of the environment variables
|
// Destructuring breaks the inlining of the environment variables
|
||||||
const METAMASK_DEBUG = process.env.METAMASK_DEBUG;
|
const METAMASK_DEBUG = process.env.METAMASK_DEBUG;
|
||||||
const METAMASK_ENVIRONMENT = process.env.METAMASK_ENVIRONMENT;
|
const METAMASK_ENVIRONMENT = process.env.METAMASK_ENVIRONMENT;
|
||||||
|
const SENTRY_DSN_DEV = process.env.SENTRY_DSN_DEV;
|
||||||
/* eslint-enable prefer-destructuring */
|
/* 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
|
// 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
|
// 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_HOST: process.env.SEGMENT_HOST,
|
||||||
SEGMENT_WRITE_KEY: process.env.SEGMENT_WRITE_KEY,
|
SEGMENT_WRITE_KEY: process.env.SEGMENT_WRITE_KEY,
|
||||||
SEGMENT_LEGACY_WRITE_KEY: process.env.SEGMENT_LEGACY_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');
|
const { version } = require('../../package.json');
|
||||||
@ -431,6 +434,7 @@ function getEnvironmentVariables({ devMode, testing }) {
|
|||||||
PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY || '',
|
PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY || '',
|
||||||
CONF: devMode ? metamaskrc : {},
|
CONF: devMode ? metamaskrc : {},
|
||||||
SENTRY_DSN: process.env.SENTRY_DSN,
|
SENTRY_DSN: process.env.SENTRY_DSN,
|
||||||
|
SENTRY_DSN_DEV: metamaskrc.SENTRY_DSN_DEV,
|
||||||
INFURA_PROJECT_ID: testing
|
INFURA_PROJECT_ID: testing
|
||||||
? '00000000000000000000000000000000'
|
? '00000000000000000000000000000000'
|
||||||
: metamaskrc.INFURA_PROJECT_ID,
|
: metamaskrc.INFURA_PROJECT_ID,
|
||||||
|
@ -11,6 +11,12 @@ start().catch((error) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function start() {
|
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();
|
const authWorked = await checkIfAuthWorks();
|
||||||
if (!authWorked) {
|
if (!authWorked) {
|
||||||
throw new Error(`Sentry auth failed`);
|
throw new Error(`Sentry auth failed`);
|
||||||
@ -25,15 +31,11 @@ async function start() {
|
|||||||
} else {
|
} else {
|
||||||
// create sentry release
|
// create sentry release
|
||||||
console.log(`creating Sentry release for "${VERSION}"...`);
|
console.log(`creating Sentry release for "${VERSION}"...`);
|
||||||
await exec(
|
await exec(`sentry-cli releases new ${VERSION}`);
|
||||||
`sentry-cli releases --org 'metamask' --project 'metamask' new ${VERSION}`,
|
|
||||||
);
|
|
||||||
console.log(
|
console.log(
|
||||||
`removing any existing files from Sentry release "${VERSION}"...`,
|
`removing any existing files from Sentry release "${VERSION}"...`,
|
||||||
);
|
);
|
||||||
await exec(
|
await exec(`sentry-cli releases files ${VERSION} delete --all`);
|
||||||
`sentry-cli releases --org 'metamask' --project 'metamask' files ${VERSION} delete --all`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if version has artifacts or not
|
// check if version has artifacts or not
|
||||||
@ -52,26 +54,20 @@ async function start() {
|
|||||||
|
|
||||||
async function checkIfAuthWorks() {
|
async function checkIfAuthWorks() {
|
||||||
const itWorked = await doesNotFail(async () => {
|
const itWorked = await doesNotFail(async () => {
|
||||||
await exec(
|
await exec(`sentry-cli releases list`);
|
||||||
`sentry-cli releases --org 'metamask' --project 'metamask' list`,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
return itWorked;
|
return itWorked;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkIfVersionExists() {
|
async function checkIfVersionExists() {
|
||||||
const versionAlreadyExists = await doesNotFail(async () => {
|
const versionAlreadyExists = await doesNotFail(async () => {
|
||||||
await exec(
|
await exec(`sentry-cli releases info ${VERSION}`);
|
||||||
`sentry-cli releases --org 'metamask' --project 'metamask' info ${VERSION}`,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
return versionAlreadyExists;
|
return versionAlreadyExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkIfVersionHasArtifacts() {
|
async function checkIfVersionHasArtifacts() {
|
||||||
const artifacts = await exec(
|
const artifacts = await exec(`sentry-cli releases files ${VERSION} list`);
|
||||||
`sentry-cli releases --org 'metamask' --project 'metamask' files ${VERSION} list`,
|
|
||||||
);
|
|
||||||
// When there's no artifacts, we get a response from the shell like this ['', '']
|
// When there's no artifacts, we get a response from the shell like this ['', '']
|
||||||
return artifacts[0] && artifacts[0].length > 0;
|
return artifacts[0] && artifacts[0].length > 0;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ EOF
|
|||||||
function upload_sourcemaps {
|
function upload_sourcemaps {
|
||||||
local release="${1}"; shift
|
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 {
|
function main {
|
||||||
@ -62,6 +62,12 @@ function main {
|
|||||||
if [[ -z $release ]]
|
if [[ -z $release ]]
|
||||||
then
|
then
|
||||||
die 'Required parameter "release" missing; either include parameter or set VERSION environment variable'
|
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
|
fi
|
||||||
|
|
||||||
printf 'uploading source files and sourcemaps for Sentry release "%s"...\n' "${release}"
|
printf 'uploading source files and sourcemaps for Sentry release "%s"...\n' "${release}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user