aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/buy_quote_updater.ts
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-12-01 03:58:05 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-12-01 03:58:05 +0800
commitea11e8c62dac9ff6352bc983efc707d855b8e881 (patch)
treecdfc9ad01c2a4e56c560809cb7e01895987ef442 /packages/instant/src/util/buy_quote_updater.ts
parent7479a7db58f5504416a88450c92b092899bf3df3 (diff)
parenta1d4aa66bc6b3de041ec6e4eb4fe40383945510b (diff)
downloaddexon-sol-tools-ea11e8c62dac9ff6352bc983efc707d855b8e881.tar
dexon-sol-tools-ea11e8c62dac9ff6352bc983efc707d855b8e881.tar.gz
dexon-sol-tools-ea11e8c62dac9ff6352bc983efc707d855b8e881.tar.bz2
dexon-sol-tools-ea11e8c62dac9ff6352bc983efc707d855b8e881.tar.lz
dexon-sol-tools-ea11e8c62dac9ff6352bc983efc707d855b8e881.tar.xz
dexon-sol-tools-ea11e8c62dac9ff6352bc983efc707d855b8e881.tar.zst
dexon-sol-tools-ea11e8c62dac9ff6352bc983efc707d855b8e881.zip
Merge branch 'development' of https://github.com/0xProject/0x-monorepo into fix/instant/instant-bounces-on-error
Diffstat (limited to 'packages/instant/src/util/buy_quote_updater.ts')
-rw-r--r--packages/instant/src/util/buy_quote_updater.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/packages/instant/src/util/buy_quote_updater.ts b/packages/instant/src/util/buy_quote_updater.ts
index 2fd16d781..c1899f8c1 100644
--- a/packages/instant/src/util/buy_quote_updater.ts
+++ b/packages/instant/src/util/buy_quote_updater.ts
@@ -6,7 +6,8 @@ import { Dispatch } from 'redux';
import { oc } from 'ts-optchain';
import { Action, actions } from '../redux/actions';
-import { AffiliateInfo, ERC20Asset } from '../types';
+import { AffiliateInfo, ERC20Asset, QuoteFetchOrigin } from '../types';
+import { analytics } from '../util/analytics';
import { assetUtils } from '../util/asset';
import { errorFlasher } from '../util/error_flasher';
@@ -16,7 +17,12 @@ export const buyQuoteUpdater = {
dispatch: Dispatch<Action>,
asset: ERC20Asset,
assetUnitAmount: BigNumber,
- options: { setPending: boolean; dispatchErrors: boolean; affiliateInfo?: AffiliateInfo },
+ fetchOrigin: QuoteFetchOrigin,
+ options: {
+ setPending: boolean;
+ dispatchErrors: boolean;
+ affiliateInfo?: AffiliateInfo;
+ },
): Promise<void> => {
// get a new buy quote.
const baseUnitValue = Web3Wrapper.toBaseUnitAmount(assetUnitAmount, asset.metaData.decimals);
@@ -31,6 +37,7 @@ export const buyQuoteUpdater = {
} catch (error) {
if (options.dispatchErrors) {
dispatch(actions.setQuoteRequestStateFailure());
+ analytics.trackQuoteError(error.message ? error.message : 'other', baseUnitValue, fetchOrigin);
let errorMessage;
if (error.message === AssetBuyerError.InsufficientAssetLiquidity) {
const assetName = assetUtils.bestNameForAsset(asset, 'of this asset');
@@ -58,5 +65,6 @@ export const buyQuoteUpdater = {
errorFlasher.clearError(dispatch);
// invalidate the last buy quote.
dispatch(actions.updateLatestBuyQuote(newBuyQuote));
+ analytics.trackQuoteFetched(newBuyQuote, fetchOrigin);
},
};