1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00

Add data point to 'Swaps Completed' segment event: estimated vs used gas (#9571)

* Add data point to 'Swaps Completed' segment event: estimated vs used gas

* Linted

* Correct property name for estimated gas on swapMetaData in _trackSwapsMetrics()

* Set estimated_gas property on swapMetaData to a hex string

* Correct base when dividing by estimated_gas

Co-authored-by: Dan Finlay <dan@danfinlay.com>
This commit is contained in:
Dan J Miller 2020-10-13 16:11:26 -02:30 committed by GitHub
parent fe11075418
commit 00c8609f95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -858,6 +858,13 @@ export default class TransactionController extends EventEmitter {
.round(2) .round(2)
}%` }%`
const estimatedVsUsedGasRatio = `${
(new BigNumber(txMeta.txReceipt.gasUsed, 16))
.div(txMeta.swapMetaData.estimated_gas, 16)
.times(100)
.round(2)
}%`
this._trackSegmentEvent({ this._trackSegmentEvent({
event: 'Swap Completed', event: 'Swap Completed',
category: 'swaps', category: 'swaps',
@ -871,6 +878,7 @@ export default class TransactionController extends EventEmitter {
...txMeta.swapMetaData, ...txMeta.swapMetaData,
token_to_amount_received: tokensReceived, token_to_amount_received: tokensReceived,
quote_vs_executionRatio: quoteVsExecutionRatio, quote_vs_executionRatio: quoteVsExecutionRatio,
estimated_vs_used_gasRatio: estimatedVsUsedGasRatio,
}, },
excludeMetaMetricsId: true, excludeMetaMetricsId: true,
}) })

View File

@ -474,6 +474,7 @@ export const signAndSendTransactions = (history, metaMetricsEvent) => {
other_quote_selected: usedQuote.aggregator !== getTopQuote(state)?.aggregator, other_quote_selected: usedQuote.aggregator !== getTopQuote(state)?.aggregator,
other_quote_selected_source: usedQuote.aggregator === getTopQuote(state)?.aggregator ? '' : usedQuote.aggregator, other_quote_selected_source: usedQuote.aggregator === getTopQuote(state)?.aggregator ? '' : usedQuote.aggregator,
gas_fees: formatCurrency(gasEstimateTotalInEth, 'usd')?.slice(1), gas_fees: formatCurrency(gasEstimateTotalInEth, 'usd')?.slice(1),
estimated_gas: estimatedGasLimit.toString(16),
} }
const metaMetricsConfig = { const metaMetricsConfig = {