quote_vs_executionRatio property to Swap Completed segment event (#9508)

feature/default_network_editable
Dan J Miller 4 years ago committed by GitHub
parent a939853989
commit 443c280b4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      app/scripts/controllers/transactions/index.js

@ -8,6 +8,7 @@ import abi from 'human-standard-token-abi'
import { ethers } from 'ethers' import { ethers } from 'ethers'
import NonceTracker from 'nonce-tracker' import NonceTracker from 'nonce-tracker'
import log from 'loglevel' import log from 'loglevel'
import BigNumber from 'bignumber.js'
import { import {
TOKEN_METHOD_APPROVE, TOKEN_METHOD_APPROVE,
TOKEN_METHOD_TRANSFER, TOKEN_METHOD_TRANSFER,
@ -606,12 +607,23 @@ export default class TransactionController extends EventEmitter {
const metametricsId = this.preferencesStore.getState().metaMetricsId const metametricsId = this.preferencesStore.getState().metaMetricsId
if (metametricsId && txMeta.swapMetaData && txReceipt.status !== '0x0') { if (metametricsId && txMeta.swapMetaData && txReceipt.status !== '0x0') {
const tokensReceived = getSwapsTokensReceivedFromTxMeta(
txMeta.destinationTokenSymbol,
txMeta,
txMeta.destinationTokenAddress,
txMeta.txParams.from,
txMeta.destinationTokenDecimals,
)
const quoteVsExecutionRatio = `${(new BigNumber(tokensReceived, 10))
.div(txMeta.swapMetaData?.['token_to_amount'], 10).times(100).round(2)}%`
segment.track({ event: 'Swap Completed', userId: metametricsId, context: segmentContext, category: 'swaps' }) segment.track({ event: 'Swap Completed', userId: metametricsId, context: segmentContext, category: 'swaps' })
segment.track({ segment.track({
event: 'Swap Completed', event: 'Swap Completed',
properties: { properties: {
...txMeta.swapMetaData, ...txMeta.swapMetaData,
token_to_amount_received: getSwapsTokensReceivedFromTxMeta(txMeta.destinationTokenSymbol, txMeta, txMeta.destinationTokenAddress, txMeta.txParams.from, txMeta.destinationTokenDecimals), token_to_amount_received: tokensReceived,
quote_vs_executionRatio: quoteVsExecutionRatio,
}, },
context: segmentContext, context: segmentContext,
anonymousId: METAMETRICS_ANONYMOUS_ID, anonymousId: METAMETRICS_ANONYMOUS_ID,

Loading…
Cancel
Save