diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-27 07:51:40 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-27 07:51:40 +0800 |
commit | 7610130f7353ea6134fae441a8fe23e0fd0ddb2f (patch) | |
tree | 5e8ff7cc28740790834a804705249c22764a2696 /packages/instant/src/util/analytics.ts | |
parent | d5898a3a050a8c97e516dba62ba040140fd74c62 (diff) | |
download | dexon-sol-tools-7610130f7353ea6134fae441a8fe23e0fd0ddb2f.tar dexon-sol-tools-7610130f7353ea6134fae441a8fe23e0fd0ddb2f.tar.gz dexon-sol-tools-7610130f7353ea6134fae441a8fe23e0fd0ddb2f.tar.bz2 dexon-sol-tools-7610130f7353ea6134fae441a8fe23e0fd0ddb2f.tar.lz dexon-sol-tools-7610130f7353ea6134fae441a8fe23e0fd0ddb2f.tar.xz dexon-sol-tools-7610130f7353ea6134fae441a8fe23e0fd0ddb2f.tar.zst dexon-sol-tools-7610130f7353ea6134fae441a8fe23e0fd0ddb2f.zip |
Track numberAvailableAssets, selectedAssetName, selectedAssetData event properties
Diffstat (limited to 'packages/instant/src/util/analytics.ts')
-rw-r--r-- | packages/instant/src/util/analytics.ts | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/packages/instant/src/util/analytics.ts b/packages/instant/src/util/analytics.ts index 51be63da2..331cd86e8 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'; @@ -25,6 +25,7 @@ enum EventNames { 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)); @@ -56,6 +57,9 @@ export interface AnalyticsEventOptions { orderSource?: string; affiliateAddress?: string; affiliateFeePercent?: number; + numberAvailableAssets?: number; + selectedAssetName?: string; + selectedAssetData?: string; } export enum TokenSelectorClosedVia { ClickedX = 'Clicked X', @@ -77,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, @@ -93,6 +98,13 @@ export const analytics = { affiliateAddress, affiliateFeePercent, }; + + if (selectedAsset) { + eventOptions.selectedAssetName = selectedAsset.metaData.name; + eventOptions.selectedAssetData = selectedAsset.assetData; + } + + return eventOptions; }, trackInstantOpened: trackingEventFnWithoutPayload(EventNames.INSTANT_OPENED), trackAccountLocked: trackingEventFnWithoutPayload(EventNames.ACCOUNT_LOCKED), |