diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-20 01:54:59 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-20 01:54:59 +0800 |
commit | 2bfd03e64f20905b0526d65813f78eff3e924727 (patch) | |
tree | 78887ca52a5ff1a4e7872c3a2f08b870c55ef1a0 | |
parent | e23f90b82cc1346bea66e91858bc7fdc874542dd (diff) | |
download | dexon-sol-tools-2bfd03e64f20905b0526d65813f78eff3e924727.tar dexon-sol-tools-2bfd03e64f20905b0526d65813f78eff3e924727.tar.gz dexon-sol-tools-2bfd03e64f20905b0526d65813f78eff3e924727.tar.bz2 dexon-sol-tools-2bfd03e64f20905b0526d65813f78eff3e924727.tar.lz dexon-sol-tools-2bfd03e64f20905b0526d65813f78eff3e924727.tar.xz dexon-sol-tools-2bfd03e64f20905b0526d65813f78eff3e924727.tar.zst dexon-sol-tools-2bfd03e64f20905b0526d65813f78eff3e924727.zip |
Change disabled analytics name, add assertion, and always set
-rw-r--r-- | packages/instant/src/components/zero_ex_instant_provider.tsx | 6 | ||||
-rw-r--r-- | packages/instant/src/index.umd.ts | 3 | ||||
-rw-r--r-- | packages/instant/src/util/analytics.ts | 8 |
3 files changed, 9 insertions, 8 deletions
diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx index 52454148f..9435d8c7c 100644 --- a/packages/instant/src/components/zero_ex_instant_provider.tsx +++ b/packages/instant/src/components/zero_ex_instant_provider.tsx @@ -37,7 +37,7 @@ export interface ZeroExInstantProviderOptionalProps { additionalAssetMetaDataMap: ObjectMap<AssetMetaData>; networkId: Network; affiliateInfo: AffiliateInfo; - disableAnalyticsTracking: boolean; + shouldDisableAnalyticsTracking: boolean; } export class ZeroExInstantProvider extends React.Component<ZeroExInstantProviderProps> { @@ -125,9 +125,7 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider this._flashErrorIfWrongNetwork(); // Analytics - if (this.props.disableAnalyticsTracking) { - disableAnalytics(); - } + disableAnalytics(this.props.shouldDisableAnalyticsTracking || false); analytics.addEventProperties({ embeddedHost: window.location.host, embeddedUrl: window.location.href, diff --git a/packages/instant/src/index.umd.ts b/packages/instant/src/index.umd.ts index 0274db30c..5010347b3 100644 --- a/packages/instant/src/index.umd.ts +++ b/packages/instant/src/index.umd.ts @@ -35,6 +35,9 @@ export const render = (props: ZeroExInstantOverlayProps, selector: string = DEFA if (!_.isUndefined(props.provider)) { assert.isWeb3Provider('props.provider', props.provider); } + if (!_.isUndefined(props.shouldDisableAnalyticsTracking)) { + assert.isBoolean('props.shouldDisableAnalyticsTracking', props.shouldDisableAnalyticsTracking); + } assert.isString('selector', selector); const appendToIfExists = document.querySelector(selector); assert.assert(!_.isNull(appendToIfExists), `Could not find div with selector: ${selector}`); diff --git a/packages/instant/src/util/analytics.ts b/packages/instant/src/util/analytics.ts index ce40d08e7..2ffaac1dd 100644 --- a/packages/instant/src/util/analytics.ts +++ b/packages/instant/src/util/analytics.ts @@ -2,12 +2,12 @@ import { ObjectMap } from '@0x/types'; import { heapUtil } from './heap'; -let disabled = false; -export const disableAnalytics = () => { - disabled = true; +let isDisabled = false; +export const disableAnalytics = (shouldDisableAnalytics: boolean) => { + isDisabled = shouldDisableAnalytics; }; export const evaluateIfEnabled = (fnCall: () => void) => { - if (disabled) { + if (isDisabled) { return; } fnCall(); |