aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-17 02:10:55 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-17 02:10:55 +0800
commitdb7f74f99f7790297e737165a0fc9742fe3daf06 (patch)
tree534def102e052766c72bfb4d1306a9a261cc57ed
parent45a1899eade34e90801e3fbcba9a6789e43684f4 (diff)
downloaddexon-sol-tools-db7f74f99f7790297e737165a0fc9742fe3daf06.tar.gz
dexon-sol-tools-db7f74f99f7790297e737165a0fc9742fe3daf06.tar.zst
dexon-sol-tools-db7f74f99f7790297e737165a0fc9742fe3daf06.zip
Switch heap id on environment, and make sure app id is what we expect
-rw-r--r--packages/instant/src/constants.ts3
-rw-r--r--packages/instant/src/util/heap.ts16
2 files changed, 16 insertions, 3 deletions
diff --git a/packages/instant/src/constants.ts b/packages/instant/src/constants.ts
index f46b0ca21..80c93c431 100644
--- a/packages/instant/src/constants.ts
+++ b/packages/instant/src/constants.ts
@@ -16,8 +16,9 @@ export const BUY_QUOTE_UPDATE_INTERVAL_TIME_MS = ONE_SECOND_MS * 15;
export const DEFAULT_GAS_PRICE = GWEI_IN_WEI.mul(6);
export const DEFAULT_ESTIMATED_TRANSACTION_TIME_MS = ONE_MINUTE_MS * 2;
export const ETH_GAS_STATION_API_BASE_URL = 'https://ethgasstation.info';
-export const ANALYTICS_ENABLED = true; // TODO: change when we can switch on dev
+export const ANALYTICS_ENABLED = process.env.NODE_ENV === 'production' || process.env.ENABLE_HEAP;
export const HEAP_ANALYTICS_DEVELOPMENT_APP_ID = '507265531';
+export const HEAP_ANALYTICS_PRODUCTION_APP_ID = '2323640988';
export const COINBASE_API_BASE_URL = 'https://api.coinbase.com/v2';
export const PROGRESS_STALL_AT_WIDTH = '95%';
export const PROGRESS_FINISH_ANIMATION_TIME_MS = 200;
diff --git a/packages/instant/src/util/heap.ts b/packages/instant/src/util/heap.ts
index e697562e4..88f65c1ab 100644
--- a/packages/instant/src/util/heap.ts
+++ b/packages/instant/src/util/heap.ts
@@ -1,12 +1,13 @@
import { ObjectMap } from '@0x/types';
import { logUtils } from '@0x/utils';
-import { ANALYTICS_ENABLED, HEAP_ANALYTICS_DEVELOPMENT_APP_ID } from '../constants';
+import { ANALYTICS_ENABLED, HEAP_ANALYTICS_DEVELOPMENT_APP_ID, HEAP_ANALYTICS_PRODUCTION_APP_ID } from '../constants';
import { AnalyticsEventOptions, AnalyticsUserOptions } from './analytics';
export interface HeapAnalytics {
loaded: boolean;
+ appid: string;
identify(id: string, idType: string): void;
track(eventName: string, eventProperties?: ObjectMap<string | number>): void;
resetIdentity(): void;
@@ -23,6 +24,13 @@ const getWindow = (): ModifiedWindow => {
return window as ModifiedWindow;
};
+const getHeapAppId = (): string => {
+ if (process.env.NODE_ENV === 'production') {
+ return HEAP_ANALYTICS_PRODUCTION_APP_ID;
+ }
+ return HEAP_ANALYTICS_DEVELOPMENT_APP_ID;
+};
+
const setupZeroExInstantHeap = () => {
const curWindow = getWindow();
// Set property to specify that this is zeroEx's heap
@@ -64,7 +72,7 @@ const setupZeroExInstantHeap = () => {
(window as any).heap[p[c]] = o(p[c]);
});
// TODO: use production heap id once environment utils merged
- (window as any).heap.load(HEAP_ANALYTICS_DEVELOPMENT_APP_ID);
+ (window as any).heap.load(getHeapAppId());
/* tslint:enable */
return curWindow.heap as HeapAnalytics;
@@ -93,6 +101,10 @@ export const heapUtil = {
const curHeap = heapUtil.getHeap();
if (curHeap) {
try {
+ if (curHeap.appid !== getHeapAppId()) {
+ // Integrator has included heap after us and reset the app id
+ return;
+ }
heapFunctionCall(curHeap);
} catch (e) {
// We never want analytics to crash our React component
4cc5e2bc263609'>Fix math/openblas and bump dependent portsSteve Wills2020-01-301-1/+1 * Mark BROKEN: fails to buildAntoine Brodin2020-01-211-0/+2 * math: Add missing USES={gl,gnome,php,sdl,xorg}Tobias Kortkamp2019-11-081-1/+1 * rename most cases of jakarta- to apache-Pedro F. Giffuni2019-10-071-3/+3 * Chase graphics/batik update to 1.11:Max Brazhnikov2019-08-232-1/+12 * math/scilab: add patch to fix build with updated graphics/xmlgraphics-commonsMax Brazhnikov2019-08-221-0/+82 * math/scilab:Max Brazhnikov2019-08-152-1/+381 * Bump PORTREVISION for ports depending on the canonical version of GCCGerald Pfeifer2019-07-271-1/+1 * Adjust to proposed changes in Java versioningGreg Lewis2019-07-081-1/+1 * Unbreak the build against both current and future versions of OCaml.Alexey Dokuchaev2019-06-221-0/+478 * Related to revision 499061 bump ports with USES=fortran to have themGerald Pfeifer2019-04-221-1/+1 * - bump PORTREVISION after math/matio updateMax Brazhnikov2019-04-071-1/+1 * Make USES=gl conditional on the GUI option to unbreak build when GUI isDon Lewis2019-01-091-5/+6 * Update science/hdf5 to 1.10.4Sunpoet Po-Chuan Hsieh2019-01-061-1/+1 * math/scilab: Small changesYuri Victorovich2018-12-181-2/+7