Add Portal v2 logging
This commit is contained in:
@@ -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<PortalOnboardingFlowPr
|
||||
steps={this._getSteps()}
|
||||
stepIndex={this.props.stepIndex}
|
||||
isRunning={this.props.isRunning}
|
||||
onClose={this.props.updateIsRunning.bind(this, false)}
|
||||
updateOnboardingStep={this.props.updateOnboardingStep}
|
||||
onClose={this._closeOnboarding.bind(this)}
|
||||
updateOnboardingStep={this._updateOnboardingStep.bind(this)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -122,7 +125,19 @@ export class PortalOnboardingFlow extends React.Component<PortalOnboardingFlowPr
|
||||
}
|
||||
private _autoStartOnboardingIfShould(): void {
|
||||
if (!this.props.isRunning && !this.props.hasBeenSeen && this.props.blockchainIsLoaded) {
|
||||
const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
|
||||
analytics.logEvent('Portal', 'Onboarding Started - Automatic', networkName, this.props.stepIndex);
|
||||
this.props.updateIsRunning(true);
|
||||
}
|
||||
}
|
||||
private _updateOnboardingStep(stepIndex: number): void {
|
||||
const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
|
||||
this.props.updateOnboardingStep(stepIndex);
|
||||
analytics.logEvent('Portal', 'Update Onboarding Step', networkName, stepIndex);
|
||||
}
|
||||
private _closeOnboarding(): void {
|
||||
const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
|
||||
this.props.updateIsRunning(false);
|
||||
analytics.logEvent('Portal', 'Onboarding Closed', networkName, this.props.stepIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { colors, Styles } from '@0xproject/react-shared';
|
||||
import { colors, constants as sharedConstants, Styles } from '@0xproject/react-shared';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
import * as React from 'react';
|
||||
@@ -6,6 +6,7 @@ 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';
|
||||
@@ -71,6 +72,7 @@ export interface PortalProps {
|
||||
flashMessage?: string | React.ReactNode;
|
||||
lastForceTokenStateRefetch: number;
|
||||
translate: Translate;
|
||||
portalOnboardingStep: number;
|
||||
}
|
||||
|
||||
interface PortalState {
|
||||
@@ -358,6 +360,8 @@ export class Portal extends React.Component<PortalProps, PortalState> {
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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<WalletProps, WalletState> {
|
||||
}
|
||||
}
|
||||
const onClick = isWrappedEtherDirectionOpen
|
||||
? this._closeWrappedEtherActionRow.bind(this)
|
||||
? this._closeWrappedEtherActionRow.bind(this, wrappedEtherDirection)
|
||||
: this._openWrappedEtherActionRow.bind(this, wrappedEtherDirection);
|
||||
return (
|
||||
<IconButton iconName={buttonIconName} labelText={buttonLabel} onClick={onClick} color={colors.mediumBlue} />
|
||||
);
|
||||
}
|
||||
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,
|
||||
});
|
||||
|
||||
@@ -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<WrapEtherItemProps, WrapEther
|
||||
this.setState({
|
||||
isEthConversionHappening: true,
|
||||
});
|
||||
const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
|
||||
try {
|
||||
const etherToken = this.props.etherToken;
|
||||
const amountToConvert = this.state.currentInputAmount;
|
||||
@@ -193,10 +195,12 @@ export class WrapEtherItem extends React.Component<WrapEtherItemProps, WrapEther
|
||||
await this.props.blockchain.convertEthToWrappedEthTokensAsync(etherToken.address, amountToConvert);
|
||||
const ethAmount = Web3Wrapper.toUnitAmount(amountToConvert, constants.DECIMAL_PLACES_ETH);
|
||||
this.props.dispatcher.showFlashMessage(`Successfully wrapped ${ethAmount.toString()} ETH to WETH`);
|
||||
analytics.logEvent('Portal', 'Wrap ETH Successfully', networkName);
|
||||
} else {
|
||||
await this.props.blockchain.convertWrappedEthTokensToEthAsync(etherToken.address, amountToConvert);
|
||||
const tokenAmount = Web3Wrapper.toUnitAmount(amountToConvert, etherToken.decimals);
|
||||
this.props.dispatcher.showFlashMessage(`Successfully unwrapped ${tokenAmount.toString()} WETH to ETH`);
|
||||
analytics.logEvent('Portal', 'Unwrap WETH Successfully', networkName);
|
||||
}
|
||||
await this.props.refetchEthTokenStateAsync();
|
||||
this.props.onConversionSuccessful();
|
||||
@@ -207,11 +211,13 @@ export class WrapEtherItem extends React.Component<WrapEtherItemProps, WrapEther
|
||||
} else if (!utils.didUserDenyWeb3Request(errMsg)) {
|
||||
logUtils.log(`Unexpected error encountered: ${err}`);
|
||||
logUtils.log(err.stack);
|
||||
const errorMsg =
|
||||
this.props.direction === Side.Deposit
|
||||
? 'Failed to wrap your ETH. Please try again.'
|
||||
: 'Failed to unwrap your WETH. Please try again.';
|
||||
this.props.dispatcher.showFlashMessage(errorMsg);
|
||||
if (this.props.direction === Side.Deposit) {
|
||||
this.props.dispatcher.showFlashMessage('Failed to wrap your ETH. Please try again.');
|
||||
analytics.logEvent('Portal', 'Wrap ETH Failed', networkName);
|
||||
} else {
|
||||
this.props.dispatcher.showFlashMessage('Failed to unwrap your WETH. Please try again.');
|
||||
analytics.logEvent('Portal', 'Unwrap WETH Failed', networkName);
|
||||
}
|
||||
await errorReporter.reportAsync(err);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user