aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util
diff options
context:
space:
mode:
authorSteve Klebanoff <steve@0xproject.com>2018-11-28 02:23:28 +0800
committerGitHub <noreply@github.com>2018-11-28 02:23:28 +0800
commitd23fd23e912ef2ca646048e2df70e2c016ce9986 (patch)
treec98ae62402344a4fca2dae6b8389e0fedbbf8151 /packages/instant/src/util
parentfdc4a4e5fa31d8797abf6313f4488147853ed77e (diff)
parent23274f9b487ef30f971a06445830aef5dced4cf6 (diff)
downloaddexon-sol-tools-d23fd23e912ef2ca646048e2df70e2c016ce9986.tar
dexon-sol-tools-d23fd23e912ef2ca646048e2df70e2c016ce9986.tar.gz
dexon-sol-tools-d23fd23e912ef2ca646048e2df70e2c016ce9986.tar.bz2
dexon-sol-tools-d23fd23e912ef2ca646048e2df70e2c016ce9986.tar.lz
dexon-sol-tools-d23fd23e912ef2ca646048e2df70e2c016ce9986.tar.xz
dexon-sol-tools-d23fd23e912ef2ca646048e2df70e2c016ce9986.tar.zst
dexon-sol-tools-d23fd23e912ef2ca646048e2df70e2c016ce9986.zip
Merge pull request #1329 from 0xProject/feature/instant/token-picker-events
[instant] Token Selector events
Diffstat (limited to 'packages/instant/src/util')
-rw-r--r--packages/instant/src/util/analytics.ts28
1 files changed, 25 insertions, 3 deletions
diff --git a/packages/instant/src/util/analytics.ts b/packages/instant/src/util/analytics.ts
index cec99dd1b..aa0f37194 100644
--- a/packages/instant/src/util/analytics.ts
+++ b/packages/instant/src/util/analytics.ts
@@ -1,4 +1,4 @@
-import { AffiliateInfo, Network, OrderSource, ProviderState } from '../types';
+import { AffiliateInfo, Asset, Network, OrderSource, ProviderState } from '../types';
import { EventProperties, heapUtil } from './heap';
@@ -20,7 +20,12 @@ enum EventNames {
ACCOUNT_UNLOCK_REQUESTED = 'Account - Unlock Requested',
ACCOUNT_UNLOCK_DENIED = 'Account - Unlock Denied',
ACCOUNT_ADDRESS_CHANGED = 'Account - Address Changed',
+ TOKEN_SELECTOR_OPENED = 'Token Selector - Opened',
+ TOKEN_SELECTOR_CLOSED = 'Token Selector - Closed',
+ TOKEN_SELECTOR_CHOSE = 'Token Selector - Chose',
+ TOKEN_SELECTOR_SEARCHED = 'Token Selector - Searched',
}
+
const track = (eventName: EventNames, eventProperties: EventProperties = {}): void => {
evaluateIfEnabled(() => {
heapUtil.evaluateHeapCall(heap => heap.track(eventName, eventProperties));
@@ -52,8 +57,14 @@ export interface AnalyticsEventOptions {
orderSource?: string;
affiliateAddress?: string;
affiliateFeePercent?: number;
+ numberAvailableAssets?: number;
+ selectedAssetName?: string;
+ selectedAssetData?: string;
+}
+export enum TokenSelectorClosedVia {
+ ClickedX = 'Clicked X',
+ TokenChose = 'Token Chose',
}
-
export const analytics = {
addUserProperties: (properties: AnalyticsUserOptions): void => {
evaluateIfEnabled(() => {
@@ -70,12 +81,13 @@ export const analytics = {
orderSource: OrderSource,
providerState: ProviderState,
window: Window,
+ selectedAsset?: Asset,
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 {
+ const eventOptions: AnalyticsEventOptions = {
embeddedHost: window.location.host,
embeddedUrl: window.location.href,
networkId: network,
@@ -85,7 +97,10 @@ export const analytics = {
orderSource: orderSourceName,
affiliateAddress,
affiliateFeePercent,
+ selectedAssetName: selectedAsset ? selectedAsset.metaData.name : 'none',
+ selectedAssetData: selectedAsset ? selectedAsset.assetData : 'none',
};
+ return eventOptions;
},
trackInstantOpened: trackingEventFnWithoutPayload(EventNames.INSTANT_OPENED),
trackAccountLocked: trackingEventFnWithoutPayload(EventNames.ACCOUNT_LOCKED),
@@ -94,4 +109,11 @@ export const analytics = {
trackAccountUnlockDenied: trackingEventFnWithoutPayload(EventNames.ACCOUNT_UNLOCK_DENIED),
trackAccountAddressChanged: (address: string) =>
trackingEventFnWithPayload(EventNames.ACCOUNT_ADDRESS_CHANGED)({ address }),
+ trackTokenSelectorOpened: trackingEventFnWithoutPayload(EventNames.TOKEN_SELECTOR_OPENED),
+ trackTokenSelectorClosed: (closedVia: TokenSelectorClosedVia) =>
+ trackingEventFnWithPayload(EventNames.TOKEN_SELECTOR_CLOSED)({ closedVia }),
+ trackTokenSelectorChose: (payload: { assetName: string; assetData: string }) =>
+ trackingEventFnWithPayload(EventNames.TOKEN_SELECTOR_CHOSE)(payload),
+ trackTokenSelectorSearched: (searchText: string) =>
+ trackingEventFnWithPayload(EventNames.TOKEN_SELECTOR_SEARCHED)({ searchText }),
};