aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/analytics.ts
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-27 07:11:16 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-27 07:11:16 +0800
commitb055055253c53a9db4ec730d7285dce9c38e7a59 (patch)
tree057e6f24529b03f6d4565361bb2cef61836ab482 /packages/instant/src/util/analytics.ts
parentae570dba05cfc0d696c616d05804152791d29677 (diff)
parent6e3d70af566b9d1fcfce83a055793a08f19ee160 (diff)
downloaddexon-sol-tools-b055055253c53a9db4ec730d7285dce9c38e7a59.tar
dexon-sol-tools-b055055253c53a9db4ec730d7285dce9c38e7a59.tar.gz
dexon-sol-tools-b055055253c53a9db4ec730d7285dce9c38e7a59.tar.bz2
dexon-sol-tools-b055055253c53a9db4ec730d7285dce9c38e7a59.tar.lz
dexon-sol-tools-b055055253c53a9db4ec730d7285dce9c38e7a59.tar.xz
dexon-sol-tools-b055055253c53a9db4ec730d7285dce9c38e7a59.tar.zst
dexon-sol-tools-b055055253c53a9db4ec730d7285dce9c38e7a59.zip
Merge branch 'development' into feature/instant/token-picker-events
Diffstat (limited to 'packages/instant/src/util/analytics.ts')
-rw-r--r--packages/instant/src/util/analytics.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/instant/src/util/analytics.ts b/packages/instant/src/util/analytics.ts
index 8f8cec284..1dda649b3 100644
--- a/packages/instant/src/util/analytics.ts
+++ b/packages/instant/src/util/analytics.ts
@@ -1,3 +1,5 @@
+import { AffiliateInfo, Network, OrderSource, ProviderState } from '../types';
+
import { EventProperties, heapUtil } from './heap';
let isDisabled = false;
@@ -51,6 +53,9 @@ export interface AnalyticsEventOptions {
providerName?: string;
gitSha?: string;
npmVersion?: string;
+ orderSource?: string;
+ affiliateAddress?: string;
+ affiliateFeePercent?: number;
}
export enum TokenSelectorClosedVia {
ClickedX = 'Clicked X',
@@ -67,6 +72,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 }),