diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-06-15 01:28:02 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-06-15 06:43:10 +0800 |
commit | 677e77d0ae3f0daf9c5c6d43f73a089c24d60ea6 (patch) | |
tree | 100c8dcf3bc59996c2a95fa3e0ec056dde5dc8c5 /packages/website/ts/components/wallet/wrap_ether_item.tsx | |
parent | 4efd28c092e74b438d0397069c0c55cc90c537f2 (diff) | |
download | dexon-0x-contracts-677e77d0ae3f0daf9c5c6d43f73a089c24d60ea6.tar dexon-0x-contracts-677e77d0ae3f0daf9c5c6d43f73a089c24d60ea6.tar.gz dexon-0x-contracts-677e77d0ae3f0daf9c5c6d43f73a089c24d60ea6.tar.bz2 dexon-0x-contracts-677e77d0ae3f0daf9c5c6d43f73a089c24d60ea6.tar.lz dexon-0x-contracts-677e77d0ae3f0daf9c5c6d43f73a089c24d60ea6.tar.xz dexon-0x-contracts-677e77d0ae3f0daf9c5c6d43f73a089c24d60ea6.tar.zst dexon-0x-contracts-677e77d0ae3f0daf9c5c6d43f73a089c24d60ea6.zip |
Add Portal v2 logging
Diffstat (limited to 'packages/website/ts/components/wallet/wrap_ether_item.tsx')
-rw-r--r-- | packages/website/ts/components/wallet/wrap_ether_item.tsx | 18 |
1 files changed, 12 insertions, 6 deletions
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<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); } } |