Add Portal v2 logging

This commit is contained in:
fragosti
2018-06-14 10:28:02 -07:00
parent 4efd28c092
commit 677e77d0ae
8 changed files with 62 additions and 15 deletions

View File

@@ -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<RelayerGridTileProps> = (
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 (
<Island style={styles.root} Component={GridTile}>
<div style={styles.innerDiv}>
<a href={link} target="_blank" style={{ textDecoration: 'none' }}>
<a href={link} target="_blank" style={{ textDecoration: 'none' }} onClick={trackRelayerClick}>
<ImgWithFallback
src={props.relayerInfo.headerImgUrl}
fallbackSrc={FALLBACK_IMG_SRC}

View File

@@ -1,6 +1,7 @@
import { colors, 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';
import { WebsiteBackendTokenInfo } from 'ts/types';
@@ -61,6 +62,9 @@ class TokenLink extends React.Component<TokenLinkProps, TokenLinkState> {
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 (
<a
href={tokenLinkFromToken(this.props.tokenInfo, this.props.networkId)}
@@ -68,6 +72,7 @@ class TokenLink extends React.Component<TokenLinkProps, TokenLinkState> {
style={style}
onMouseEnter={this._onToggleHover.bind(this, true)}
onMouseLeave={this._onToggleHover.bind(this, false)}
onClick={trackTokenClick}
>
{this.props.tokenInfo.symbol}
</a>