From ab631060a05fc6344ef6e2de7b0e6a0f0096e8ed Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Fri, 30 Nov 2018 12:42:40 -0800 Subject: cdn -> dischargeTarget, and report to heap --- packages/instant/.dogfood.discharge.json | 2 +- packages/instant/.production.discharge.json | 2 +- packages/instant/.staging.discharge.json | 2 +- .../src/components/zero_ex_instant_provider.tsx | 7 +++++- packages/instant/src/constants.ts | 6 +++++- packages/instant/src/util/analytics.ts | 1 + packages/instant/webpack.config.js | 25 ++++++++++++---------- 7 files changed, 29 insertions(+), 16 deletions(-) (limited to 'packages/instant') diff --git a/packages/instant/.dogfood.discharge.json b/packages/instant/.dogfood.discharge.json index f9b96ac95..b0e4edaff 100644 --- a/packages/instant/.dogfood.discharge.json +++ b/packages/instant/.dogfood.discharge.json @@ -1,6 +1,6 @@ { "domain": "0x-instant-dogfood", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:prod --env.cdn=staging", + "build_command": "WEBPACK_OUTPUT_PATH=public yarn build --env.discharge_target=dogfood", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", diff --git a/packages/instant/.production.discharge.json b/packages/instant/.production.discharge.json index 70dd4e04c..4aa5337ba 100644 --- a/packages/instant/.production.discharge.json +++ b/packages/instant/.production.discharge.json @@ -1,6 +1,6 @@ { "domain": "instant.0xproject.com", - "build_command": "yarn build --env.cdn=production", + "build_command": "yarn build --env.discharge_target=production", "upload_directory": "umd", "index_key": "instant.js", "error_key": "404.html", diff --git a/packages/instant/.staging.discharge.json b/packages/instant/.staging.discharge.json index 44fc3abc8..56ffee4e9 100644 --- a/packages/instant/.staging.discharge.json +++ b/packages/instant/.staging.discharge.json @@ -1,6 +1,6 @@ { "domain": "0x-instant-staging", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build --env.cdn=staging", + "build_command": "WEBPACK_OUTPUT_PATH=public yarn build --env.discharge_target=staging", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx index 9814aabf8..dc57513d1 100644 --- a/packages/instant/src/components/zero_ex_instant_provider.tsx +++ b/packages/instant/src/components/zero_ex_instant_provider.tsx @@ -5,7 +5,11 @@ import * as _ from 'lodash'; import * as React from 'react'; import { Provider as ReduxProvider } from 'react-redux'; -import { ACCOUNT_UPDATE_INTERVAL_TIME_MS, BUY_QUOTE_UPDATE_INTERVAL_TIME_MS } from '../constants'; +import { + ACCOUNT_UPDATE_INTERVAL_TIME_MS, + BUY_QUOTE_UPDATE_INTERVAL_TIME_MS, + INSTANT_DISCHARGE_TARGET, +} from '../constants'; import { SelectedAssetThemeProvider } from '../containers/selected_asset_theme_provider'; import { asyncData } from '../redux/async_data'; import { DEFAULT_STATE, DefaultState, State } from '../redux/reducer'; @@ -132,6 +136,7 @@ export class ZeroExInstantProvider extends React.Component { +const DISCHARGE_TARGETS_THAT_REQUIRED_HEAP = ['production', 'staging', 'dogfood']; +const getConfigForDischargeTarget = dischargeTarget => { return { heapAnalyticsIdEnvName: - cdnName === 'production' ? 'INSTANT_HEAP_ANALYTICS_ID_PRODUCTION' : 'INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT', - heapAnalyticsIdRequired: CDNS_THAT_REQUIRE_HEAP.includes(cdnName), + dischargeTarget === 'production' + ? 'INSTANT_HEAP_ANALYTICS_ID_PRODUCTION' + : 'INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT', + heapAnalyticsIdRequired: DISCHARGE_TARGETS_THAT_REQUIRED_HEAP.includes(dischargeTarget), }; }; @@ -19,14 +21,14 @@ const GIT_SHA = childProcess .execSync('git rev-parse HEAD') .toString() .trim(); -const generateConfig = (cdnName, configOptions) => { +const generateConfig = (dischargeTarget, configOptions) => { const outputPath = process.env.WEBPACK_OUTPUT_PATH || 'umd'; const { heapAnalyticsIdEnvName, heapAnalyticsIdRequired } = configOptions; const heapAnalyticsId = process.env[heapAnalyticsIdEnvName]; if (heapAnalyticsIdRequired && !heapAnalyticsId) { throw new Error( - `Must define heap analytics id in ENV var ${heapAnalyticsIdEnvName} when building for ${cdnName}`, + `Must define heap analytics id in ENV var ${heapAnalyticsIdEnvName} when building for ${dischargeTarget}`, ); } @@ -34,12 +36,13 @@ const generateConfig = (cdnName, configOptions) => { GIT_SHA: JSON.stringify(GIT_SHA), NPM_PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version), }; - if (cdnName) { - envVars.INSTANT_CDN = JSON.stringify(cdnName); + if (dischargeTarget) { + envVars.INSTANT_DISCHARGE_TARGET = JSON.stringify(dischargeTarget); } if (heapAnalyticsId) { envVars.HEAP_ANALYTICS_ID = JSON.stringify(heapAnalyticsId); } + console.log(envVars); const config = { entry: { @@ -91,7 +94,7 @@ const generateConfig = (cdnName, configOptions) => { }; module.exports = (env, _argv) => { - const cdnName = env ? env.cdn : undefined; - const configOptions = getConfigForCdn(cdnName); - return generateConfig(cdnName, configOptions); + const dischargeTarget = env ? env.discharge_target : undefined; + const configOptions = getConfigForDischargeTarget(dischargeTarget); + return generateConfig(dischargeTarget, configOptions); }; -- cgit v1.2.3