From 677e77d0ae3f0daf9c5c6d43f73a089c24d60ea6 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 14 Jun 2018 10:28:02 -0700 Subject: Add Portal v2 logging --- .../components/onboarding/portal_onboarding_flow.tsx | 19 +++++++++++++++++-- packages/website/ts/components/portal/portal.tsx | 6 +++++- .../ts/components/relayer_index/relayer_grid_tile.tsx | 9 +++++++-- .../components/relayer_index/relayer_top_tokens.tsx | 7 ++++++- packages/website/ts/components/wallet/wallet.tsx | 14 +++++++++++--- .../website/ts/components/wallet/wrap_ether_item.tsx | 18 ++++++++++++------ 6 files changed, 58 insertions(+), 15 deletions(-) (limited to 'packages/website/ts/components') diff --git a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx index bf52684d7..086cddc52 100644 --- a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx +++ b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx @@ -1,12 +1,15 @@ +import { constants as sharedConstants } from '@0xproject/react-shared'; import * as _ from 'lodash'; import * as React from 'react'; import { BigNumber } from '@0xproject/utils'; +import { analytics } from 'ts/utils/analytics'; import { OnboardingFlow, Step } from 'ts/components/onboarding/onboarding_flow'; import { ProviderType, TokenByAddress, TokenStateByAddress } from 'ts/types'; import { utils } from 'ts/utils/utils'; export interface PortalOnboardingFlowProps { + networkId: number; stepIndex: number; isRunning: boolean; userAddress: string; @@ -34,8 +37,8 @@ export class PortalOnboardingFlow extends React.Component ); } @@ -122,7 +125,19 @@ export class PortalOnboardingFlow extends React.Component { } private _startOnboarding(): void { + const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId]; + analytics.logEvent('Portal', 'Onboarding Started - Manual', networkName, this.props.portalOnboardingStep); this.props.dispatcher.updatePortalOnboardingShowing(true); } private _renderWalletSection(): React.ReactNode { diff --git a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx index fbb634164..7ff8208b0 100644 --- a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx +++ b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx @@ -1,7 +1,8 @@ -import { Styles } from '@0xproject/react-shared'; +import { constants as sharedConstants, Styles } from '@0xproject/react-shared'; import * as _ from 'lodash'; import { GridTile } from 'material-ui/GridList'; import * as React from 'react'; +import { analytics } from 'ts/utils/analytics'; import { TopTokens } from 'ts/components/relayer_index/relayer_top_tokens'; import { Container } from 'ts/components/ui/container'; @@ -64,10 +65,14 @@ export const RelayerGridTile: React.StatelessComponent = ( const link = props.relayerInfo.appUrl || props.relayerInfo.url; const topTokens = props.relayerInfo.topTokens; const weeklyTxnVolume = props.relayerInfo.weeklyTxnVolume; + let trackRelayerClick = (): void => undefined; + const networkName = sharedConstants.NETWORK_NAME_BY_ID[props.networkId]; + const eventLabel = `${props.relayerInfo.name}-${networkName}`; + trackRelayerClick = () => analytics.logEvent('Portal', 'Relayer Click', eventLabel); return (
- + { cursor: 'pointer', opacity: this.state.isHovering ? 0.5 : 1, }; + const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId]; + const eventLabel = `${this.props.tokenInfo.symbol}-${networkName}`; + const trackTokenClick = () => analytics.logEvent('Portal', 'Token Click', eventLabel); return ( { style={style} onMouseEnter={this._onToggleHover.bind(this, true)} onMouseLeave={this._onToggleHover.bind(this, false)} + onClick={trackTokenClick} > {this.props.tokenInfo.symbol} diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx index f80be6313..237e86306 100644 --- a/packages/website/ts/components/wallet/wallet.tsx +++ b/packages/website/ts/components/wallet/wallet.tsx @@ -1,9 +1,10 @@ -import { EtherscanLinkSuffixes, Styles, utils as sharedUtils } from '@0xproject/react-shared'; +import { constants as sharedConstants, EtherscanLinkSuffixes, Styles, utils as sharedUtils } from '@0xproject/react-shared'; import { BigNumber, errorUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import CircularProgress from 'material-ui/CircularProgress'; import FloatingActionButton from 'material-ui/FloatingActionButton'; + import { ListItem } from 'material-ui/List'; import ActionAccountBalanceWallet from 'material-ui/svg-icons/action/account-balance-wallet'; import ContentAdd from 'material-ui/svg-icons/content/add'; @@ -12,6 +13,7 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; import firstBy = require('thenby'); +import { analytics } from 'ts/utils/analytics'; import { Blockchain } from 'ts/blockchain'; import { AllowanceToggle } from 'ts/components/inputs/allowance_toggle'; import { Container } from 'ts/components/ui/container'; @@ -495,18 +497,24 @@ export class Wallet extends React.Component { } } const onClick = isWrappedEtherDirectionOpen - ? this._closeWrappedEtherActionRow.bind(this) + ? this._closeWrappedEtherActionRow.bind(this, wrappedEtherDirection) : this._openWrappedEtherActionRow.bind(this, wrappedEtherDirection); return ( ); } private _openWrappedEtherActionRow(wrappedEtherDirection: Side): void { + const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId]; + const action = wrappedEtherDirection === Side.Deposit ? 'Wallet - Wrap ETH Opened' : 'Wallet - Unwrap WETH Opened'; + analytics.logEvent('Portal', action, networkName); this.setState({ wrappedEtherDirection, }); } - private _closeWrappedEtherActionRow(): void { + private _closeWrappedEtherActionRow(wrappedEtherDirection: Side): void { + const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId]; + const action = wrappedEtherDirection === Side.Deposit ? 'Wallet - Wrap ETH Closed' : 'Wallet - Unwrap WETH Closed'; + analytics.logEvent('Portal', action, networkName); this.setState({ wrappedEtherDirection: undefined, }); diff --git a/packages/website/ts/components/wallet/wrap_ether_item.tsx b/packages/website/ts/components/wallet/wrap_ether_item.tsx index f65257142..1651595ca 100644 --- a/packages/website/ts/components/wallet/wrap_ether_item.tsx +++ b/packages/website/ts/components/wallet/wrap_ether_item.tsx @@ -1,4 +1,4 @@ -import { Styles } from '@0xproject/react-shared'; +import { constants as sharedConstants, Styles } from '@0xproject/react-shared'; import { BigNumber, logUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; @@ -6,6 +6,7 @@ import FlatButton from 'material-ui/FlatButton'; import * as React from 'react'; import { Blockchain } from 'ts/blockchain'; +import { analytics } from 'ts/utils/analytics'; import { EthAmountInput } from 'ts/components/inputs/eth_amount_input'; import { TokenAmountInput } from 'ts/components/inputs/token_amount_input'; import { Dispatcher } from 'ts/redux/dispatcher'; @@ -186,6 +187,7 @@ export class WrapEtherItem extends React.Component Date: Thu, 14 Jun 2018 15:47:59 -0700 Subject: Run linter --- .../ts/components/onboarding/portal_onboarding_flow.tsx | 2 +- packages/website/ts/components/portal/portal.tsx | 2 +- .../ts/components/relayer_index/relayer_top_tokens.tsx | 8 +++++++- packages/website/ts/components/wallet/wallet.tsx | 15 +++++++++++---- packages/website/ts/components/wallet/wrap_ether_item.tsx | 2 +- 5 files changed, 21 insertions(+), 8 deletions(-) (limited to 'packages/website/ts/components') diff --git a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx index 086cddc52..e4df1ec36 100644 --- a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx +++ b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx @@ -3,9 +3,9 @@ import * as _ from 'lodash'; import * as React from 'react'; import { BigNumber } from '@0xproject/utils'; -import { analytics } from 'ts/utils/analytics'; import { OnboardingFlow, Step } from 'ts/components/onboarding/onboarding_flow'; import { ProviderType, TokenByAddress, TokenStateByAddress } from 'ts/types'; +import { analytics } from 'ts/utils/analytics'; import { utils } from 'ts/utils/utils'; export interface PortalOnboardingFlowProps { diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx index 3e9f4ebb2..9c89145ca 100644 --- a/packages/website/ts/components/portal/portal.tsx +++ b/packages/website/ts/components/portal/portal.tsx @@ -6,7 +6,6 @@ import * as DocumentTitle from 'react-document-title'; import { Route, RouteComponentProps, Switch } from 'react-router-dom'; import { Blockchain } from 'ts/blockchain'; -import { analytics } from 'ts/utils/analytics'; import { BlockchainErrDialog } from 'ts/components/dialogs/blockchain_err_dialog'; import { LedgerConfigDialog } from 'ts/components/dialogs/ledger_config_dialog'; import { PortalDisclaimerDialog } from 'ts/components/dialogs/portal_disclaimer_dialog'; @@ -45,6 +44,7 @@ import { TokenVisibility, WebsitePaths, } from 'ts/types'; +import { analytics } from 'ts/utils/analytics'; import { backendClient } from 'ts/utils/backend_client'; import { configs } from 'ts/utils/configs'; import { constants } from 'ts/utils/constants'; diff --git a/packages/website/ts/components/relayer_index/relayer_top_tokens.tsx b/packages/website/ts/components/relayer_index/relayer_top_tokens.tsx index 75335185a..b599e7123 100644 --- a/packages/website/ts/components/relayer_index/relayer_top_tokens.tsx +++ b/packages/website/ts/components/relayer_index/relayer_top_tokens.tsx @@ -1,4 +1,10 @@ -import { colors, constants as sharedConstants, EtherscanLinkSuffixes, Styles, utils as sharedUtils } from '@0xproject/react-shared'; +import { + colors, + constants as sharedConstants, + EtherscanLinkSuffixes, + Styles, + utils as sharedUtils, +} from '@0xproject/react-shared'; import * as _ from 'lodash'; import * as React from 'react'; import { analytics } from 'ts/utils/analytics'; diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx index 237e86306..42aa5af5d 100644 --- a/packages/website/ts/components/wallet/wallet.tsx +++ b/packages/website/ts/components/wallet/wallet.tsx @@ -1,4 +1,9 @@ -import { constants as sharedConstants, EtherscanLinkSuffixes, Styles, utils as sharedUtils } from '@0xproject/react-shared'; +import { + constants as sharedConstants, + EtherscanLinkSuffixes, + Styles, + utils as sharedUtils, +} from '@0xproject/react-shared'; import { BigNumber, errorUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; @@ -13,7 +18,6 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; import firstBy = require('thenby'); -import { analytics } from 'ts/utils/analytics'; import { Blockchain } from 'ts/blockchain'; import { AllowanceToggle } from 'ts/components/inputs/allowance_toggle'; import { Container } from 'ts/components/ui/container'; @@ -37,6 +41,7 @@ import { TokenStateByAddress, WebsitePaths, } from 'ts/types'; +import { analytics } from 'ts/utils/analytics'; import { constants } from 'ts/utils/constants'; import { utils } from 'ts/utils/utils'; import { styles as walletItemStyles } from 'ts/utils/wallet_item_styles'; @@ -505,7 +510,8 @@ export class Wallet extends React.Component { } private _openWrappedEtherActionRow(wrappedEtherDirection: Side): void { const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId]; - const action = wrappedEtherDirection === Side.Deposit ? 'Wallet - Wrap ETH Opened' : 'Wallet - Unwrap WETH Opened'; + const action = + wrappedEtherDirection === Side.Deposit ? 'Wallet - Wrap ETH Opened' : 'Wallet - Unwrap WETH Opened'; analytics.logEvent('Portal', action, networkName); this.setState({ wrappedEtherDirection, @@ -513,7 +519,8 @@ export class Wallet extends React.Component { } private _closeWrappedEtherActionRow(wrappedEtherDirection: Side): void { const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId]; - const action = wrappedEtherDirection === Side.Deposit ? 'Wallet - Wrap ETH Closed' : 'Wallet - Unwrap WETH Closed'; + const action = + wrappedEtherDirection === Side.Deposit ? 'Wallet - Wrap ETH Closed' : 'Wallet - Unwrap WETH Closed'; analytics.logEvent('Portal', action, networkName); this.setState({ wrappedEtherDirection: undefined, diff --git a/packages/website/ts/components/wallet/wrap_ether_item.tsx b/packages/website/ts/components/wallet/wrap_ether_item.tsx index 1651595ca..d6135ce4d 100644 --- a/packages/website/ts/components/wallet/wrap_ether_item.tsx +++ b/packages/website/ts/components/wallet/wrap_ether_item.tsx @@ -6,12 +6,12 @@ import FlatButton from 'material-ui/FlatButton'; import * as React from 'react'; import { Blockchain } from 'ts/blockchain'; -import { analytics } from 'ts/utils/analytics'; import { EthAmountInput } from 'ts/components/inputs/eth_amount_input'; import { TokenAmountInput } from 'ts/components/inputs/token_amount_input'; import { Dispatcher } from 'ts/redux/dispatcher'; import { colors } from 'ts/style/colors'; import { BlockchainCallErrs, Side, Token } from 'ts/types'; +import { analytics } from 'ts/utils/analytics'; import { constants } from 'ts/utils/constants'; import { errorReporter } from 'ts/utils/error_reporter'; import { utils } from 'ts/utils/utils'; -- cgit v1.2.3