1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00

Use environment variable for production Sentry DSN (#9097)

The Sentry DSN is now expected to be provided via environment variable
for production builds. The build script will fail if it is missing, and
an error will be thrown at runtime if it is missing.

The `SENTRY_DSN` environment variable has been set in CI to the old
value for `SENTRY_PROD_DSN`. We can migrate to a new DSN at some point
in the future.
This commit is contained in:
Mark Stacey 2020-07-29 13:14:08 -03:00 committed by GitHub
parent b7715f6e70
commit d7a5319222
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -5,7 +5,6 @@ import extractEthjsErrorMessage from './extractEthjsErrorMessage'
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_PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505'
const SENTRY_DSN_DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496' 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
@ -74,12 +73,15 @@ export default function setupSentry ({ release, getState }) {
if (METAMASK_DEBUG) { if (METAMASK_DEBUG) {
return return
} else if (process.env.IN_TEST) { } else if (METAMASK_ENVIRONMENT === 'production') {
if (!process.env.SENTRY_DSN) {
throw new Error(`Missing SENTRY_DSN environment variable in production environment`)
}
console.log(`Setting up Sentry Remote Error Reporting for '${METAMASK_ENVIRONMENT}': SENTRY_DSN`)
sentryTarget = process.env.SENTRY_DSN
} else {
console.log(`Setting up Sentry Remote Error Reporting for '${METAMASK_ENVIRONMENT}': SENTRY_DSN_DEV`) console.log(`Setting up Sentry Remote Error Reporting for '${METAMASK_ENVIRONMENT}': SENTRY_DSN_DEV`)
sentryTarget = SENTRY_DSN_DEV sentryTarget = SENTRY_DSN_DEV
} else {
console.log(`Setting up Sentry Remote Error Reporting for '${METAMASK_ENVIRONMENT}': SENTRY_DSN_PROD`)
sentryTarget = SENTRY_DSN_PROD
} }
Sentry.init({ Sentry.init({

View File

@ -330,6 +330,10 @@ function createScriptTasks ({ browserPlatforms, livereload }) {
environment = 'other' environment = 'other'
} }
if (environment === 'production' && !process.env.SENTRY_DSN) {
throw new Error('Missing SENTRY_DSN environment variable')
}
// Inject variables into bundle // Inject variables into bundle
bundler.transform(envify({ bundler.transform(envify({
METAMASK_DEBUG: opts.devMode, METAMASK_DEBUG: opts.devMode,
@ -341,6 +345,7 @@ function createScriptTasks ({ browserPlatforms, livereload }) {
PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY || '', PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY || '',
ETH_GAS_STATION_API_KEY: process.env.ETH_GAS_STATION_API_KEY || '', ETH_GAS_STATION_API_KEY: process.env.ETH_GAS_STATION_API_KEY || '',
CONF: opts.devMode ? conf : ({}), CONF: opts.devMode ? conf : ({}),
SENTRY_DSN: process.env.SENTRY_DSN,
}), { }), {
global: true, global: true,
}) })