From d750225554a0c4c317863cf11a7db5b1570e5b41 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 21 Nov 2018 08:20:09 -0800 Subject: Send in explicit props --- .../src/components/zero_ex_instant_provider.tsx | 10 +++++++- packages/instant/src/util/analytics.ts | 30 ++++++++++------------ 2 files changed, 23 insertions(+), 17 deletions(-) (limited to 'packages/instant') diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx index 37ed3dc94..dc6a45a23 100644 --- a/packages/instant/src/components/zero_ex_instant_provider.tsx +++ b/packages/instant/src/components/zero_ex_instant_provider.tsx @@ -126,7 +126,15 @@ export class ZeroExInstantProvider extends React.Component heap.addEventProperties(properties)); }); }, - generateEventProperties: (state: State, window: Window): AnalyticsEventOptions => { - let orderSource = 'unknown'; - const orderProvider = state.providerState.assetBuyer.orderProvider; - if (orderProvider instanceof StandardRelayerAPIOrderProvider) { - orderSource = orderProvider.apiUrl; - } else if (orderProvider instanceof BasicOrderProvider) { - orderSource = 'provided'; - } - - const affiliateAddress = state.affiliateInfo ? state.affiliateInfo.feeRecipient : 'none'; - const affiliateFeePercent = state.affiliateInfo ? parseFloat(state.affiliateInfo.feePercentage.toFixed(4)) : 0; + generateEventProperties: ( + network: Network, + orderSource: OrderSource, + providerState: ProviderState, + window: Window, + affiliateInfo?: AffiliateInfo, + ): AnalyticsEventOptions => { + const affiliateAddress = affiliateInfo ? affiliateInfo.feeRecipient : 'none'; + const affiliateFeePercent = affiliateInfo ? parseFloat(affiliateInfo.feePercentage.toFixed(4)) : 0; + const orderSourceName = typeof orderSource === 'string' ? orderSource : 'provided'; return { embeddedHost: window.location.host, embeddedUrl: window.location.href, - networkId: state.network, - providerName: state.providerState.name, + networkId: network, + providerName: providerState.name, gitSha: process.env.GIT_SHA, npmVersion: process.env.NPM_PACKAGE_VERSION, - orderSource, + orderSource: orderSourceName, affiliateAddress, affiliateFeePercent, }; -- cgit