aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/analytics.ts
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-21 06:59:23 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-21 06:59:23 +0800
commit6124d80c89e7c8e4b1d00a934f2389d2b4461c44 (patch)
treebf52e3b4b13e5f1b9e266e14ae3da8e94bd5d74b /packages/instant/src/util/analytics.ts
parentba41fc9275bebe17577f87d72f54b7e7dc420acc (diff)
downloaddexon-sol-tools-6124d80c89e7c8e4b1d00a934f2389d2b4461c44.tar
dexon-sol-tools-6124d80c89e7c8e4b1d00a934f2389d2b4461c44.tar.gz
dexon-sol-tools-6124d80c89e7c8e4b1d00a934f2389d2b4461c44.tar.bz2
dexon-sol-tools-6124d80c89e7c8e4b1d00a934f2389d2b4461c44.tar.lz
dexon-sol-tools-6124d80c89e7c8e4b1d00a934f2389d2b4461c44.tar.xz
dexon-sol-tools-6124d80c89e7c8e4b1d00a934f2389d2b4461c44.tar.zst
dexon-sol-tools-6124d80c89e7c8e4b1d00a934f2389d2b4461c44.zip
Move out generating of event properties, and send in orderSource
Diffstat (limited to 'packages/instant/src/util/analytics.ts')
-rw-r--r--packages/instant/src/util/analytics.ts23
1 files changed, 23 insertions, 0 deletions
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),
};