diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index 72b543e25..5ef0e68b4 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -9,7 +9,9 @@ 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; +const SENTRY_DSN_DEV = + process.env.SENTRY_DSN_DEV || + 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496'; const METAMASK_BUILD_TYPE = process.env.METAMASK_BUILD_TYPE; const IN_TEST = process.env.IN_TEST; /* eslint-enable prefer-destructuring */ diff --git a/development/build/config.js b/development/build/config.js index 386bb7554..be3777695 100644 --- a/development/build/config.js +++ b/development/build/config.js @@ -3,6 +3,33 @@ const { readFile } = require('fs/promises'); const ini = require('ini'); const { BuildType } = require('../lib/build-type'); +const commonConfigurationPropertyNames = ['PUBNUB_PUB_KEY', 'PUBNUB_SUB_KEY']; + +const configurationPropertyNames = [ + ...commonConfigurationPropertyNames, + 'COLLECTIBLES_V1', + 'INFURA_PROJECT_ID', + 'ONBOARDING_V2', + 'PHISHING_WARNING_PAGE_URL', + 'PORTFOLIO_URL', + 'SEGMENT_HOST', + 'SEGMENT_WRITE_KEY', + 'SENTRY_DSN_DEV', + 'SIWE_V1', + 'SWAPS_USE_DEV_APIS', +]; + +const productionConfigurationPropertyNames = [ + ...commonConfigurationPropertyNames, + 'INFURA_BETA_PROJECT_ID', + 'INFURA_FLASK_PROJECT_ID', + 'INFURA_PROD_PROJECT_ID', + 'SEGMENT_BETA_WRITE_KEY', + 'SEGMENT_FLASK_WRITE_KEY', + 'SEGMENT_PROD_WRITE_KEY', + 'SENTRY_DSN', +]; + /** * Get configuration for non-production builds. * @@ -20,22 +47,17 @@ async function getConfig() { throw error; } } + + const environmentVariables = {}; + for (const propertyName of configurationPropertyNames) { + if (process.env[propertyName]) { + environmentVariables[propertyName] = process.env[propertyName]; + } + } + return { - COLLECTIBLES_V1: process.env.COLLECTIBLES_V1, - INFURA_PROJECT_ID: process.env.INFURA_PROJECT_ID, - ONBOARDING_V2: process.env.ONBOARDING_V2, - PHISHING_WARNING_PAGE_URL: process.env.PHISHING_WARNING_PAGE_URL, - PORTFOLIO_URL: process.env.PORTFOLIO_URL, - PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY, - PUBNUB_SUB_KEY: process.env.PUBNUB_SUB_KEY, - SEGMENT_HOST: process.env.SEGMENT_HOST, - SEGMENT_WRITE_KEY: process.env.SEGMENT_WRITE_KEY, - SENTRY_DSN_DEV: - process.env.SENTRY_DSN_DEV ?? - 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496', - SIWE_V1: process.env.SIWE_V1, - SWAPS_USE_DEV_APIS: process.env.SWAPS_USE_DEV_APIS, ...ini.parse(configContents), + ...environmentVariables, }; } @@ -61,17 +83,17 @@ async function getProductionConfig(buildType) { throw error; } } + + const environmentVariables = {}; + for (const propertyName of productionConfigurationPropertyNames) { + if (process.env[propertyName]) { + environmentVariables[propertyName] = process.env[propertyName]; + } + } + const prodConfig = { - INFURA_BETA_PROJECT_ID: process.env.INFURA_BETA_PROJECT_ID, - INFURA_FLASK_PROJECT_ID: process.env.INFURA_FLASK_PROJECT_ID, - INFURA_PROD_PROJECT_ID: process.env.INFURA_PROD_PROJECT_ID, - PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY, - PUBNUB_SUB_KEY: process.env.PUBNUB_SUB_KEY, - SEGMENT_BETA_WRITE_KEY: process.env.SEGMENT_BETA_WRITE_KEY, - SEGMENT_FLASK_WRITE_KEY: process.env.SEGMENT_FLASK_WRITE_KEY, - SEGMENT_PROD_WRITE_KEY: process.env.SEGMENT_PROD_WRITE_KEY, - SENTRY_DSN: process.env.SENTRY_DSN, ...ini.parse(prodConfigContents), + ...environmentVariables, }; const requiredEnvironmentVariables = {