Tracking quote errors

This commit is contained in:
Steve Klebanoff
2018-11-27 15:28:38 -08:00
parent c5d6b925e4
commit d3739488ae
2 changed files with 23 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
import { BuyQuote } from '@0x/asset-buyer';
import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import { AffiliateInfo, Asset, Network, OrderSource, ProviderState, QuoteFetchedVia } from '../types';
@@ -184,4 +185,19 @@ export const analytics = {
...buyQuoteEventProperties(buyQuote),
fetchedVia,
}),
trackQuoteError: (
errorMessage: string,
assetName: string,
assetData: string,
assetAmount: BigNumber,
fetchedVia: QuoteFetchedVia,
) => {
trackingEventFnWithPayload(EventNames.QUOTE_ERROR)({
errorMessage,
assetName,
assetData,
assetAmount: assetAmount.toString(),
fetchedVia,
});
},
};

View File

@@ -37,6 +37,13 @@ export const buyQuoteUpdater = {
} catch (error) {
if (options.dispatchErrors) {
dispatch(actions.setQuoteRequestStateFailure());
analytics.trackQuoteError(
error.message ? error.message : 'other',
asset.metaData.name,
asset.assetData,
assetUnitAmount,
options.fetchedVia,
);
let errorMessage;
if (error.message === AssetBuyerError.InsufficientAssetLiquidity) {
const assetName = assetUtils.bestNameForAsset(asset, 'of this asset');