aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-22 00:20:09 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-22 03:10:17 +0800
commitd750225554a0c4c317863cf11a7db5b1570e5b41 (patch)
tree0dfedb44373f9b970ef80d3367419ebe5256be9e
parent1593b94aacd69a9c48c04a13d696c4c0bede4d58 (diff)
downloaddexon-sol-tools-d750225554a0c4c317863cf11a7db5b1570e5b41.tar
dexon-sol-tools-d750225554a0c4c317863cf11a7db5b1570e5b41.tar.gz
dexon-sol-tools-d750225554a0c4c317863cf11a7db5b1570e5b41.tar.bz2
dexon-sol-tools-d750225554a0c4c317863cf11a7db5b1570e5b41.tar.lz
dexon-sol-tools-d750225554a0c4c317863cf11a7db5b1570e5b41.tar.xz
dexon-sol-tools-d750225554a0c4c317863cf11a7db5b1570e5b41.tar.zst
dexon-sol-tools-d750225554a0c4c317863cf11a7db5b1570e5b41.zip
Send in explicit props
-rw-r--r--packages/instant/src/components/zero_ex_instant_provider.tsx10
-rw-r--r--packages/instant/src/util/analytics.ts30
2 files changed, 23 insertions, 17 deletions
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<ZeroExInstantProvider
// Analytics
disableAnalytics(this.props.shouldDisableAnalyticsTracking || false);
- analytics.addEventProperties(analytics.generateEventProperties(state, window));
+ analytics.addEventProperties(
+ analytics.generateEventProperties(
+ state.network,
+ this.props.orderSource,
+ state.providerState,
+ window,
+ this.props.affiliateInfo,
+ ),
+ );
analytics.trackInstantOpened();
}
public componentWillUnmount(): void {
diff --git a/packages/instant/src/util/analytics.ts b/packages/instant/src/util/analytics.ts
index a18532bfa..352ab3b6c 100644
--- a/packages/instant/src/util/analytics.ts
+++ b/packages/instant/src/util/analytics.ts
@@ -1,7 +1,6 @@
-import { BasicOrderProvider, StandardRelayerAPIOrderProvider } from '@0x/asset-buyer';
import { ObjectMap } from '@0x/types';
-import { State } from '../redux/reducer';
+import { AffiliateInfo, Network, OrderSource, ProviderState } from '../types';
import { heapUtil } from './heap';
@@ -65,25 +64,24 @@ export const analytics = {
heapUtil.evaluateHeapCall(heap => 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,
};