Fix gas_fees properties collected for swaps analytics events#9727
Fix gas_fees properties collected for swaps analytics events#9727
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
| speed_set: speedSet, | ||
| gas_mode: this.state.selectedTab, | ||
| gas_fees: sumHexWEIsToRenderableFiat([this.props.value, newSwapGasTotal, this.props.customTotalSupplement], 'usd', this.props.conversionRate)?.slice(1), | ||
| gas_fees: sumHexWEIsToUnformattedFiat( |
There was a problem hiding this comment.
this.props.value should not be included in the "gas_fees" that are calculated here
| const usedGasLimitEstimate = usedQuote?.gasEstimateWithRefund || (`0x${decimalToHex(usedQuote?.averageGas || 0)}`) | ||
| const totalGasLimitEstimate = (new BigNumber(usedGasLimitEstimate, 16)).plus(usedQuote.approvalNeeded?.gas || '0x0', 16).toString(16) | ||
| const gasEstimateTotalInEth = getValueFromWeiHex({ | ||
| const gasEstimateTotalInUSD = getValueFromWeiHex({ |
There was a problem hiding this comment.
The name gasEstimateTotalInEth did not reflect the the content/value of this variable
| other_quote_selected: usedQuote.aggregator !== getTopQuote(state)?.aggregator, | ||
| other_quote_selected_source: usedQuote.aggregator === getTopQuote(state)?.aggregator ? '' : usedQuote.aggregator, | ||
| gas_fees: formatCurrency(gasEstimateTotalInEth, 'usd')?.slice(1), | ||
| gas_fees: gasEstimateTotalInUSD, |
There was a problem hiding this comment.
Formatting is both unnecessary and diverges from what we want in our analytics, which is an unformatted decimal number
| @@ -171,14 +171,23 @@ export function addHexes (aHexWEI, bHexWEI) { | |||
| }) | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
The changes in this file don't change the functionality of sumHexWEIsToRenderableFiat, while making part of the logic previously in sumHexWEIsToRenderableFiat exportable via sumHexWEIsToUnformattedFiat
| if (usedQuote && tradeTxParams) { | ||
| const renderableGasFees = getRenderableGasFeesForQuote(usedQuote.gasEstimateWithRefund || usedQuote.averageGas, approveTxParams?.gas || '0x0', tradeTxParams.gasPrice, currentCurrency, conversionRate) | ||
| feeinFiat = renderableGasFees.feeinFiat?.slice(1) | ||
| const renderableGasFees = getRenderableGasFeesForQuote(usedQuote.gasEstimateWithRefund || usedQuote.averageGas, approveTxParams?.gas || '0x0', tradeTxParams.gasPrice, currentCurrency, usdConversionRate) |
There was a problem hiding this comment.
Formatting is both unnecessary and diverges from what we want in our analytics, which is an unformatted decimal number, which is what rawNetworkFees gives us.
ui/app/ducks/swaps/swaps.js
Outdated
| usedQuote.savings?.total, | ||
| 'usd', | ||
| conversionRate, | ||
| usdConversionRate, |
There was a problem hiding this comment.
While not a gas_fees property, the averageSavings calculation was also incorrectly using on the conversionRate, when we want our analytics in USD
|
@danjm sorry for dropping the ball on reviewing this. Could you rebase and I'll make this my next priority? |
a1e44a1 to
9aa8bd5
Compare
|
@brad-decker this has been rebased on top of latest develop |
9aa8bd5 to
c9eac81
Compare
|
@danjm this has conflict markers in it, e.g |
c9eac81 to
6f15458
Compare
|
@brad-decker This has been rebased, and the error you identified removed |
6f15458 to
eedd5e4
Compare
Builds ready [eedd5e4]
Page Load Metrics (434 ± 60 ms)
|
brad-decker
left a comment
There was a problem hiding this comment.
LGTM, just a question that is non blocking
| slippage: fetchParams?.slippage, | ||
| custom_slippage: fetchParams?.slippage === 2, | ||
| gas_fees: feeinFiat, | ||
| gas_fees: feeinUnformattedFiat, |
There was a problem hiding this comment.
do we also want to trade the usdConversionRate at the time of transaction or no?
There was a problem hiding this comment.
yeah, sounds like a good idea
There was a problem hiding this comment.
oh, actually, maybe not...
There was a problem hiding this comment.
I don't think this gives us anything we need. We might want to also add the used gas limit here (as we already know the price). But I think that is for a separate PR.
eedd5e4 to
588f472
Compare
588f472 to
2198a8a
Compare
Builds ready [2198a8a]
Page Load Metrics (375 ± 63 ms)
|
This is in response to a comment on another PR.
A few fixes are included here. The most important is that the
gas_feesproperty on analytics events should be denominated in USD. This will allow all gas fees data to be easily comparible. This requires MetaMask/core#292Additional fixes are commented on in the diff