Merge pull request #1370 from 0xProject/feature/instant/explicitly-enable-heap-dev

[instant] Must explicitly specify when want to send to heap when developing
This commit is contained in:
Steve Klebanoff 2018-12-03 16:52:06 -08:00 committed by GitHub
commit 703cea6173
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 6 deletions

View File

@ -1,4 +1,7 @@
INSTANT_ROLLBAR_PUBLISH_TOKEN= INSTANT_ROLLBAR_PUBLISH_TOKEN=
INSTANT_ROLLBAR_CLIENT_TOKEN= INSTANT_ROLLBAR_CLIENT_TOKEN=
INSTANT_HEAP_ANALYTICS_ID_PRODUCTION= INSTANT_HEAP_ANALYTICS_ID_PRODUCTION=
INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT= INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT=
# if you want to report to heap or rollbar when building in development mode, you can use the following:
# INSTANT_HEAP_FORCE_DEVELOPMENT=true
# INSTANT_ROLLBAR_FORCE_DEVELOPMENT=true

View File

@ -19,6 +19,7 @@ export const DEFAULT_GAS_PRICE = GWEI_IN_WEI.mul(6);
export const DEFAULT_ESTIMATED_TRANSACTION_TIME_MS = ONE_MINUTE_MS * 2; export const DEFAULT_ESTIMATED_TRANSACTION_TIME_MS = ONE_MINUTE_MS * 2;
export const ETH_GAS_STATION_API_BASE_URL = 'https://ethgasstation.info'; export const ETH_GAS_STATION_API_BASE_URL = 'https://ethgasstation.info';
export const HEAP_ANALYTICS_ID = process.env.HEAP_ANALYTICS_ID; export const HEAP_ANALYTICS_ID = process.env.HEAP_ANALYTICS_ID;
export const HEAP_ENABLED = process.env.HEAP_ENABLED;
export const COINBASE_API_BASE_URL = 'https://api.coinbase.com/v2'; export const COINBASE_API_BASE_URL = 'https://api.coinbase.com/v2';
export const PROGRESS_STALL_AT_WIDTH = '95%'; export const PROGRESS_STALL_AT_WIDTH = '95%';
export const PROGRESS_FINISH_ANIMATION_TIME_MS = 200; export const PROGRESS_FINISH_ANIMATION_TIME_MS = 200;

View File

@ -2,7 +2,7 @@ import { BuyQuote } from '@0x/asset-buyer';
import { BigNumber } from '@0x/utils'; import { BigNumber } from '@0x/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { INSTANT_DISCHARGE_TARGET } from '../constants'; import { HEAP_ENABLED, INSTANT_DISCHARGE_TARGET } from '../constants';
import { import {
AffiliateInfo, AffiliateInfo,
Asset, Asset,
@ -16,15 +16,17 @@ import {
import { EventProperties, heapUtil } from './heap'; import { EventProperties, heapUtil } from './heap';
let isDisabled = false; let isDisabledViaConfig = false;
export const disableAnalytics = (shouldDisableAnalytics: boolean) => { export const disableAnalytics = (shouldDisableAnalytics: boolean) => {
isDisabled = shouldDisableAnalytics; isDisabledViaConfig = shouldDisableAnalytics;
}; };
export const evaluateIfEnabled = (fnCall: () => void) => { export const evaluateIfEnabled = (fnCall: () => void) => {
if (isDisabled) { if (isDisabledViaConfig) {
return; return;
} }
fnCall(); if (HEAP_ENABLED) {
fnCall();
}
}; };
enum EventNames { enum EventNames {

View File

@ -71,6 +71,7 @@ const generateConfig = (dischargeTarget, heapConfigOptions, rollbarConfigOptions
`Must define heap analytics id in ENV var ${heapAnalyticsIdEnvName} when building for ${dischargeTarget}`, `Must define heap analytics id in ENV var ${heapAnalyticsIdEnvName} when building for ${dischargeTarget}`,
); );
} }
const heapEnabled = heapAnalyticsId && (nodeEnv !== 'development' || process.env.INSTANT_HEAP_FORCE_DEVELOPMENT);
const rollbarTokens = getRollbarTokens(dischargeTarget, rollbarConfigOptions.rollbarRequired); const rollbarTokens = getRollbarTokens(dischargeTarget, rollbarConfigOptions.rollbarRequired);
const rollbarEnabled = const rollbarEnabled =
@ -92,6 +93,7 @@ const generateConfig = (dischargeTarget, heapConfigOptions, rollbarConfigOptions
GIT_SHA: JSON.stringify(GIT_SHA), GIT_SHA: JSON.stringify(GIT_SHA),
NPM_PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version), NPM_PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version),
ROLLBAR_ENABLED: rollbarEnabled, ROLLBAR_ENABLED: rollbarEnabled,
HEAP_ENABLED: heapEnabled
}; };
if (dischargeTarget) { if (dischargeTarget) {
envVars.INSTANT_DISCHARGE_TARGET = JSON.stringify(dischargeTarget); envVars.INSTANT_DISCHARGE_TARGET = JSON.stringify(dischargeTarget);