Track install wallet clicked

This commit is contained in:
Steve Klebanoff
2018-11-27 11:25:51 -08:00
parent 4653e4c011
commit b50187f59c
3 changed files with 30 additions and 17 deletions

View File

@@ -11,7 +11,7 @@ import {
import { Action, actions } from '../redux/actions';
import { asyncData } from '../redux/async_data';
import { State } from '../redux/reducer';
import { Network, Omit, OperatingSystem, ProviderState, StandardSlidingPanelContent } from '../types';
import { Network, Omit, OperatingSystem, ProviderState, StandardSlidingPanelContent, WalletSuggestion } from '../types';
import { analytics } from '../util/analytics';
import { envUtil } from '../util/env';
@@ -60,23 +60,28 @@ const mergeProps = (
onUnlockWalletClick: () => connectedDispatch.unlockWalletAndDispatchToStore(connectedState.providerState),
onInstallWalletClick: () => {
const isMobile = envUtil.isMobileOperatingSystem();
if (!isMobile) {
const walletSuggestion: WalletSuggestion = isMobile
? WalletSuggestion.CoinbaseWallet
: WalletSuggestion.MetaMask;
analytics.trackInstallWalletClicked(walletSuggestion);
if (walletSuggestion === WalletSuggestion.MetaMask) {
connectedDispatch.openInstallWalletPanel();
return;
} else {
const operatingSystem = envUtil.getOperatingSystem();
let url = COINBASE_WALLET_SITE_URL;
switch (operatingSystem) {
case OperatingSystem.Android:
url = COINBASE_WALLET_ANDROID_APP_STORE_URL;
break;
case OperatingSystem.iOS:
url = COINBASE_WALLET_IOS_APP_STORE_URL;
break;
default:
break;
}
window.open(url, '_blank');
}
const operatingSystem = envUtil.getOperatingSystem();
let url = COINBASE_WALLET_SITE_URL;
switch (operatingSystem) {
case OperatingSystem.Android:
url = COINBASE_WALLET_ANDROID_APP_STORE_URL;
break;
case OperatingSystem.iOS:
url = COINBASE_WALLET_IOS_APP_STORE_URL;
break;
default:
break;
}
window.open(url, '_blank');
},
});

View File

@@ -149,6 +149,11 @@ export enum Browser {
Other = 'OTHER',
}
export enum WalletSuggestion {
CoinbaseWallet = 'Coinbase Wallet',
MetaMask = 'MetaMask',
}
export enum OperatingSystem {
Android = 'ANDROID',
iOS = 'IOS',

View File

@@ -1,7 +1,7 @@
import { BuyQuote } from '@0x/asset-buyer';
import * as _ from 'lodash';
import { AffiliateInfo, Asset, Network, OrderSource, ProviderState } from '../types';
import { AffiliateInfo, Asset, Network, OrderSource, ProviderState, WalletSuggestion } from '../types';
import { EventProperties, heapUtil } from './heap';
@@ -30,6 +30,7 @@ enum EventNames {
BUY_TX_SUBMITTED = 'Buy - Tx Submitted',
BUY_TX_SUCCEEDED = 'Buy - Tx Succeeded',
BUY_TX_FAILED = 'Buy - Tx Failed',
INSTALL_WALLET_CLICKED = 'Install Wallet - Clicked',
TOKEN_SELECTOR_OPENED = 'Token Selector - Opened',
TOKEN_SELECTOR_CLOSED = 'Token Selector - Closed',
TOKEN_SELECTOR_CHOSE = 'Token Selector - Chose',
@@ -164,6 +165,8 @@ export const analytics = {
expectedTxTimeMs: expectedEndTimeUnix - startTimeUnix,
actualTxTimeMs: new Date().getTime() - startTimeUnix,
}),
trackInstallWalletClicked: (walletSuggestion: WalletSuggestion) =>
trackingEventFnWithPayload(EventNames.INSTALL_WALLET_CLICKED)({ walletSuggestion }),
trackTokenSelectorOpened: trackingEventFnWithoutPayload(EventNames.TOKEN_SELECTOR_OPENED),
trackTokenSelectorClosed: (closedVia: TokenSelectorClosedVia) =>
trackingEventFnWithPayload(EventNames.TOKEN_SELECTOR_CLOSED)({ closedVia }),