diff options
Diffstat (limited to 'packages/instant')
-rw-r--r-- | packages/instant/src/components/zero_ex_instant_provider.tsx | 9 | ||||
-rw-r--r-- | packages/instant/src/util/analytics.ts | 23 |
2 files changed, 24 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 9435d8c7c..37ed3dc94 100644 --- a/packages/instant/src/components/zero_ex_instant_provider.tsx +++ b/packages/instant/src/components/zero_ex_instant_provider.tsx @@ -126,14 +126,7 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider // Analytics disableAnalytics(this.props.shouldDisableAnalyticsTracking || false); - analytics.addEventProperties({ - embeddedHost: window.location.host, - embeddedUrl: window.location.href, - networkId: state.network, - providerName: state.providerState.name, - gitSha: process.env.GIT_SHA, - npmVersion: process.env.NPM_PACKAGE_VERSION, - }); + analytics.addEventProperties(analytics.generateEventProperties(state, window)); analytics.trackInstantOpened(); } public componentWillUnmount(): void { diff --git a/packages/instant/src/util/analytics.ts b/packages/instant/src/util/analytics.ts index 2ffaac1dd..d790ec1e7 100644 --- a/packages/instant/src/util/analytics.ts +++ b/packages/instant/src/util/analytics.ts @@ -1,5 +1,8 @@ +import { BasicOrderProvider, StandardRelayerAPIOrderProvider } from '@0x/asset-buyer'; import { ObjectMap } from '@0x/types'; +import { State } from '../redux/reducer'; + import { heapUtil } from './heap'; let isDisabled = false; @@ -47,6 +50,7 @@ export interface AnalyticsEventOptions { providerName?: string; gitSha?: string; npmVersion?: string; + orderSource?: string; } export const analytics = { addUserProperties: (properties: AnalyticsUserOptions): void => { @@ -59,6 +63,25 @@ 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'; + } + + return { + embeddedHost: window.location.host, + embeddedUrl: window.location.href, + networkId: state.network, + providerName: state.providerState.name, + gitSha: process.env.GIT_SHA, + npmVersion: process.env.NPM_PACKAGE_VERSION, + orderSource, + }; + }, trackWalletReady: trackingEventFnWithoutPayload(EventNames.WALLET_READY), trackInstantOpened: trackingEventFnWithoutPayload(EventNames.INSTANT_OPENED), }; |