From f71c781530a98a49ed5dd5b7014337c2427d48da Mon Sep 17 00:00:00 2001 From: eddie <66155195+just-toby@users.noreply.github.com> Date: Mon, 11 Sep 2023 10:15:02 -0700 Subject: [PATCH] fix: add tax amounts to swap quote received (#7299) --- src/lib/utils/analytics.ts | 6 +++++- src/pages/Swap/index.tsx | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/utils/analytics.ts b/src/lib/utils/analytics.ts index 51046a345a..3676ffd8f4 100644 --- a/src/lib/utils/analytics.ts +++ b/src/lib/utils/analytics.ts @@ -86,7 +86,9 @@ function getQuoteMethod(trade: InterfaceTrade) { export const formatSwapQuoteReceivedEventProperties = ( trade: InterfaceTrade, allowedSlippage: Percent, - swapQuoteLatencyMs: number | undefined + swapQuoteLatencyMs: number | undefined, + inputTax: Percent, + outputTax: Percent ) => { return { ...formatCommonPropertiesForTrade(trade, allowedSlippage), @@ -95,5 +97,7 @@ export const formatSwapQuoteReceivedEventProperties = ( token_in_amount_max: trade.maximumAmountIn(allowedSlippage).toExact(), token_out_amount_min: trade.minimumAmountOut(allowedSlippage).toExact(), quote_latency_milliseconds: swapQuoteLatencyMs, + token_out_detected_tax: formatPercentNumber(outputTax), + token_in_detected_tax: formatPercentNumber(inputTax), } } diff --git a/src/pages/Swap/index.tsx b/src/pages/Swap/index.tsx index be0dd24936..27ac1e7e97 100644 --- a/src/pages/Swap/index.tsx +++ b/src/pages/Swap/index.tsx @@ -552,10 +552,10 @@ export function Swap({ if (!trade || prevTrade === trade) return // no new swap quote to log sendAnalyticsEvent(SwapEventName.SWAP_QUOTE_RECEIVED, { - ...formatSwapQuoteReceivedEventProperties(trade, allowedSlippage, swapQuoteLatency), + ...formatSwapQuoteReceivedEventProperties(trade, allowedSlippage, swapQuoteLatency, inputTax, outputTax), ...trace, }) - }, [prevTrade, trade, trace, allowedSlippage, swapQuoteLatency]) + }, [prevTrade, trade, trace, allowedSlippage, swapQuoteLatency, inputTax, outputTax]) const showDetailsDropdown = Boolean( !showWrap && userHasSpecifiedInputOutput && (trade || routeIsLoading || routeIsSyncing)