Move out generating of event properties, and send in orderSource
This commit is contained in:
parent
ba41fc9275
commit
6124d80c89
@ -126,14 +126,7 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
|
|||||||
|
|
||||||
// Analytics
|
// Analytics
|
||||||
disableAnalytics(this.props.shouldDisableAnalyticsTracking || false);
|
disableAnalytics(this.props.shouldDisableAnalyticsTracking || false);
|
||||||
analytics.addEventProperties({
|
analytics.addEventProperties(analytics.generateEventProperties(state, window));
|
||||||
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.trackInstantOpened();
|
analytics.trackInstantOpened();
|
||||||
}
|
}
|
||||||
public componentWillUnmount(): void {
|
public componentWillUnmount(): void {
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
|
import { BasicOrderProvider, StandardRelayerAPIOrderProvider } from '@0x/asset-buyer';
|
||||||
import { ObjectMap } from '@0x/types';
|
import { ObjectMap } from '@0x/types';
|
||||||
|
|
||||||
|
import { State } from '../redux/reducer';
|
||||||
|
|
||||||
import { heapUtil } from './heap';
|
import { heapUtil } from './heap';
|
||||||
|
|
||||||
let isDisabled = false;
|
let isDisabled = false;
|
||||||
@ -47,6 +50,7 @@ export interface AnalyticsEventOptions {
|
|||||||
providerName?: string;
|
providerName?: string;
|
||||||
gitSha?: string;
|
gitSha?: string;
|
||||||
npmVersion?: string;
|
npmVersion?: string;
|
||||||
|
orderSource?: string;
|
||||||
}
|
}
|
||||||
export const analytics = {
|
export const analytics = {
|
||||||
addUserProperties: (properties: AnalyticsUserOptions): void => {
|
addUserProperties: (properties: AnalyticsUserOptions): void => {
|
||||||
@ -59,6 +63,25 @@ export const analytics = {
|
|||||||
heapUtil.evaluateHeapCall(heap => heap.addEventProperties(properties));
|
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),
|
trackWalletReady: trackingEventFnWithoutPayload(EventNames.WALLET_READY),
|
||||||
trackInstantOpened: trackingEventFnWithoutPayload(EventNames.INSTANT_OPENED),
|
trackInstantOpened: trackingEventFnWithoutPayload(EventNames.INSTANT_OPENED),
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user