mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 17:33:23 +01:00
Add data about dropped transaction in FINALIZED metrics event (#15383)
This commit is contained in:
parent
9ce4a8f987
commit
ce901f8edb
@ -1841,6 +1841,7 @@ export default class TransactionController extends EventEmitter {
|
||||
return;
|
||||
}
|
||||
otherTxMeta.replacedBy = txMeta.hash;
|
||||
otherTxMeta.replacedById = txMeta.id;
|
||||
this.txStateManager.updateTransaction(
|
||||
txMeta,
|
||||
'transactions/pending-tx-tracker#event: tx:confirmed reference to confirmed txHash with same nonce',
|
||||
@ -1995,6 +1996,7 @@ export default class TransactionController extends EventEmitter {
|
||||
},
|
||||
defaultGasEstimates,
|
||||
originalType,
|
||||
replacedById,
|
||||
metamaskNetworkId: network,
|
||||
} = txMeta;
|
||||
const { transactions } = this.store.getState();
|
||||
@ -2098,6 +2100,24 @@ export default class TransactionController extends EventEmitter {
|
||||
transactionContractMethod = transactions[id]?.contractMethodName;
|
||||
}
|
||||
|
||||
const replacedTxMeta = this._getTransaction(replacedById);
|
||||
|
||||
const TRANSACTION_REPLACEMENT_METHODS = {
|
||||
RETRY: TRANSACTION_TYPES.RETRY,
|
||||
CANCEL: TRANSACTION_TYPES.CANCEL,
|
||||
SAME_NONCE: 'other',
|
||||
};
|
||||
|
||||
let transactionReplaced;
|
||||
if (extraParams?.dropped) {
|
||||
transactionReplaced = TRANSACTION_REPLACEMENT_METHODS.SAME_NONCE;
|
||||
if (replacedTxMeta?.type === TRANSACTION_TYPES.CANCEL) {
|
||||
transactionReplaced = TRANSACTION_REPLACEMENT_METHODS.CANCEL;
|
||||
} else if (replacedTxMeta?.type === TRANSACTION_TYPES.RETRY) {
|
||||
transactionReplaced = TRANSACTION_REPLACEMENT_METHODS.RETRY;
|
||||
}
|
||||
}
|
||||
|
||||
const properties = {
|
||||
chain_id: chainId,
|
||||
referrer,
|
||||
@ -2122,6 +2142,7 @@ export default class TransactionController extends EventEmitter {
|
||||
first_seen: time,
|
||||
gas_limit: gasLimit,
|
||||
transaction_contract_method: transactionContractMethod,
|
||||
transaction_replaced: transactionReplaced,
|
||||
...extraParams,
|
||||
...gasParamsInGwei,
|
||||
};
|
||||
@ -2330,6 +2351,8 @@ export default class TransactionController extends EventEmitter {
|
||||
_dropTransaction(txId) {
|
||||
this.txStateManager.setTxStatusDropped(txId);
|
||||
const txMeta = this.txStateManager.getTransaction(txId);
|
||||
this._trackTransactionMetricsEvent(txMeta, TRANSACTION_EVENTS.FINALIZED);
|
||||
this._trackTransactionMetricsEvent(txMeta, TRANSACTION_EVENTS.FINALIZED, {
|
||||
dropped: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1484,6 +1484,7 @@ describe('Transaction Controller', function () {
|
||||
gas_price: '2',
|
||||
gas_limit: '0x7b0d',
|
||||
transaction_contract_method: undefined,
|
||||
transaction_replaced: undefined,
|
||||
first_seen: 1624408066355,
|
||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
||||
status: 'unapproved',
|
||||
@ -1565,6 +1566,7 @@ describe('Transaction Controller', function () {
|
||||
gas_price: '2',
|
||||
gas_limit: '0x7b0d',
|
||||
transaction_contract_method: undefined,
|
||||
transaction_replaced: undefined,
|
||||
first_seen: 1624408066355,
|
||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
||||
status: 'unapproved',
|
||||
@ -1656,6 +1658,7 @@ describe('Transaction Controller', function () {
|
||||
gas_price: '2',
|
||||
gas_limit: '0x7b0d',
|
||||
transaction_contract_method: undefined,
|
||||
transaction_replaced: undefined,
|
||||
first_seen: 1624408066355,
|
||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
||||
status: 'unapproved',
|
||||
@ -1739,6 +1742,7 @@ describe('Transaction Controller', function () {
|
||||
gas_price: '2',
|
||||
gas_limit: '0x7b0d',
|
||||
transaction_contract_method: undefined,
|
||||
transaction_replaced: undefined,
|
||||
first_seen: 1624408066355,
|
||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
||||
status: 'unapproved',
|
||||
@ -1820,6 +1824,7 @@ describe('Transaction Controller', function () {
|
||||
gas_price: '2',
|
||||
gas_limit: '0x7b0d',
|
||||
transaction_contract_method: undefined,
|
||||
transaction_replaced: undefined,
|
||||
first_seen: 1624408066355,
|
||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
||||
status: 'unapproved',
|
||||
@ -1887,6 +1892,7 @@ describe('Transaction Controller', function () {
|
||||
gas_price: '2',
|
||||
gas_limit: '0x7b0d',
|
||||
transaction_contract_method: undefined,
|
||||
transaction_replaced: undefined,
|
||||
first_seen: 1624408066355,
|
||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
||||
status: 'unapproved',
|
||||
@ -1963,6 +1969,7 @@ describe('Transaction Controller', function () {
|
||||
max_priority_fee_per_gas: '2',
|
||||
gas_limit: '0x7b0d',
|
||||
transaction_contract_method: undefined,
|
||||
transaction_replaced: undefined,
|
||||
first_seen: 1624408066355,
|
||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.FEE_MARKET,
|
||||
status: 'unapproved',
|
||||
|
Loading…
Reference in New Issue
Block a user