diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-11-27 15:11:05 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-11-27 15:11:05 +0800 |
commit | f0f991245cc52e82a9872b41e12c7bbc9243cb76 (patch) | |
tree | 8b864eaf7f548b001100f2156a381f07485ac3a2 /packages/instant/src/util/analytics.ts | |
parent | d3b0162dc979ccdc4b4ddff62199929c714ad3ca (diff) | |
parent | 10cc46779e72036b29eae8dbff4e63ee0fff8e8c (diff) | |
download | dexon-sol-tools-f0f991245cc52e82a9872b41e12c7bbc9243cb76.tar dexon-sol-tools-f0f991245cc52e82a9872b41e12c7bbc9243cb76.tar.gz dexon-sol-tools-f0f991245cc52e82a9872b41e12c7bbc9243cb76.tar.bz2 dexon-sol-tools-f0f991245cc52e82a9872b41e12c7bbc9243cb76.tar.lz dexon-sol-tools-f0f991245cc52e82a9872b41e12c7bbc9243cb76.tar.xz dexon-sol-tools-f0f991245cc52e82a9872b41e12c7bbc9243cb76.tar.zst dexon-sol-tools-f0f991245cc52e82a9872b41e12c7bbc9243cb76.zip |
Merge branch 'development' into feature/instant/events-buy
* development:
fix: add --exclude-missing flag to yarn clean command
Update CHANGELOG
fix: remove getApproved check from OrderValidator since approval is removed after a single transfer
Add comment
Force scaling input component to rerender when a different asset is chosen
Send in explicit props
feat(instant): Add more event properties to heap
Move out generating of event properties, and send in orderSource
autofocus -> hasAutoFocus
fix(instant): Right align amounts
fix(instant): Autofocus text amount input
Diffstat (limited to 'packages/instant/src/util/analytics.ts')
-rw-r--r-- | packages/instant/src/util/analytics.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/instant/src/util/analytics.ts b/packages/instant/src/util/analytics.ts index 283695ef8..d45d37b3b 100644 --- a/packages/instant/src/util/analytics.ts +++ b/packages/instant/src/util/analytics.ts @@ -1,6 +1,8 @@ import { BuyQuote } from '@0x/asset-buyer'; import * as _ from 'lodash'; +import { AffiliateInfo, Network, OrderSource, ProviderState } from '../types'; + import { EventProperties, heapUtil } from './heap'; let isDisabled = false; @@ -74,6 +76,9 @@ export interface AnalyticsEventOptions { providerName?: string; gitSha?: string; npmVersion?: string; + orderSource?: string; + affiliateAddress?: string; + affiliateFeePercent?: number; } export const analytics = { @@ -87,6 +92,28 @@ export const analytics = { heapUtil.evaluateHeapCall(heap => heap.addEventProperties(properties)); }); }, + generateEventProperties: ( + network: Network, + orderSource: OrderSource, + providerState: ProviderState, + window: Window, + 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 { + embeddedHost: window.location.host, + embeddedUrl: window.location.href, + networkId: network, + providerName: providerState.name, + gitSha: process.env.GIT_SHA, + npmVersion: process.env.NPM_PACKAGE_VERSION, + orderSource: orderSourceName, + affiliateAddress, + affiliateFeePercent, + }; + }, trackInstantOpened: trackingEventFnWithoutPayload(EventNames.INSTANT_OPENED), trackAccountLocked: trackingEventFnWithoutPayload(EventNames.ACCOUNT_LOCKED), trackAccountReady: (address: string) => trackingEventFnWithPayload(EventNames.ACCOUNT_READY)({ address }), |