mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Modify transaction type and add contract method data to metrics (#15175)
This commit is contained in:
parent
2bcc1c512c
commit
f1ca3e56e7
@ -1991,6 +1991,7 @@ export default class TransactionController extends EventEmitter {
|
|||||||
|
|
||||||
async _buildEventFragmentProperties(txMeta, extraParams) {
|
async _buildEventFragmentProperties(txMeta, extraParams) {
|
||||||
const {
|
const {
|
||||||
|
id,
|
||||||
type,
|
type,
|
||||||
time,
|
time,
|
||||||
status,
|
status,
|
||||||
@ -2007,6 +2008,7 @@ export default class TransactionController extends EventEmitter {
|
|||||||
defaultGasEstimates,
|
defaultGasEstimates,
|
||||||
metamaskNetworkId: network,
|
metamaskNetworkId: network,
|
||||||
} = txMeta;
|
} = txMeta;
|
||||||
|
const { transactions } = this.store.getState();
|
||||||
const source = referrer === ORIGIN_METAMASK ? 'user' : 'dapp';
|
const source = referrer === ORIGIN_METAMASK ? 'user' : 'dapp';
|
||||||
|
|
||||||
const { assetType, tokenStandard } = await determineTransactionAssetType(
|
const { assetType, tokenStandard } = await determineTransactionAssetType(
|
||||||
@ -2081,12 +2083,39 @@ export default class TransactionController extends EventEmitter {
|
|||||||
eip1559Version = eip1559V2Enabled ? '2' : '1';
|
eip1559Version = eip1559V2Enabled ? '2' : '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const contractInteractionTypes = [
|
||||||
|
TRANSACTION_TYPES.CONTRACT_INTERACTION,
|
||||||
|
TRANSACTION_TYPES.TOKEN_METHOD_APPROVE,
|
||||||
|
TRANSACTION_TYPES.TOKEN_METHOD_SAFE_TRANSFER_FROM,
|
||||||
|
TRANSACTION_TYPES.TOKEN_METHOD_SET_APPROVAL_FOR_ALL,
|
||||||
|
TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER,
|
||||||
|
TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM,
|
||||||
|
TRANSACTION_TYPES.SMART,
|
||||||
|
TRANSACTION_TYPES.SWAP,
|
||||||
|
TRANSACTION_TYPES.SWAP_APPROVAL,
|
||||||
|
].includes(type);
|
||||||
|
|
||||||
|
let transactionType = TRANSACTION_TYPES.SIMPLE_SEND;
|
||||||
|
if (type === TRANSACTION_TYPES.CANCEL) {
|
||||||
|
transactionType = TRANSACTION_TYPES.CANCEL;
|
||||||
|
} else if (type === TRANSACTION_TYPES.RETRY) {
|
||||||
|
transactionType = TRANSACTION_TYPES.RETRY;
|
||||||
|
} else if (type === TRANSACTION_TYPES.DEPLOY_CONTRACT) {
|
||||||
|
transactionType = TRANSACTION_TYPES.DEPLOY_CONTRACT;
|
||||||
|
} else if (contractInteractionTypes) {
|
||||||
|
transactionType = TRANSACTION_TYPES.CONTRACT_INTERACTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
let transactionContractMethod;
|
||||||
|
if (transactionType === TRANSACTION_TYPES.CONTRACT_INTERACTION) {
|
||||||
|
transactionContractMethod = transactions[id]?.contractMethodName;
|
||||||
|
}
|
||||||
|
|
||||||
const properties = {
|
const properties = {
|
||||||
chain_id: chainId,
|
chain_id: chainId,
|
||||||
referrer,
|
referrer,
|
||||||
source,
|
source,
|
||||||
network,
|
network,
|
||||||
type,
|
|
||||||
eip_1559_version: eip1559Version,
|
eip_1559_version: eip1559Version,
|
||||||
gas_edit_type: 'none',
|
gas_edit_type: 'none',
|
||||||
gas_edit_attempted: 'none',
|
gas_edit_attempted: 'none',
|
||||||
@ -2094,6 +2123,7 @@ export default class TransactionController extends EventEmitter {
|
|||||||
device_model: await this.getDeviceModel(this.getSelectedAddress()),
|
device_model: await this.getDeviceModel(this.getSelectedAddress()),
|
||||||
asset_type: assetType,
|
asset_type: assetType,
|
||||||
token_standard: tokenStandard,
|
token_standard: tokenStandard,
|
||||||
|
transaction_type: transactionType,
|
||||||
};
|
};
|
||||||
|
|
||||||
const sensitiveProperties = {
|
const sensitiveProperties = {
|
||||||
@ -2103,6 +2133,7 @@ export default class TransactionController extends EventEmitter {
|
|||||||
: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
||||||
first_seen: time,
|
first_seen: time,
|
||||||
gas_limit: gasLimit,
|
gas_limit: gasLimit,
|
||||||
|
transaction_contract_method: transactionContractMethod,
|
||||||
...extraParams,
|
...extraParams,
|
||||||
...gasParamsInGwei,
|
...gasParamsInGwei,
|
||||||
};
|
};
|
||||||
|
@ -1471,7 +1471,7 @@ describe('Transaction Controller', function () {
|
|||||||
network: '42',
|
network: '42',
|
||||||
referrer: ORIGIN_METAMASK,
|
referrer: ORIGIN_METAMASK,
|
||||||
source: EVENT.SOURCE.TRANSACTION.USER,
|
source: EVENT.SOURCE.TRANSACTION.USER,
|
||||||
type: TRANSACTION_TYPES.SIMPLE_SEND,
|
transaction_type: TRANSACTION_TYPES.SIMPLE_SEND,
|
||||||
account_type: 'MetaMask',
|
account_type: 'MetaMask',
|
||||||
asset_type: ASSET_TYPES.NATIVE,
|
asset_type: ASSET_TYPES.NATIVE,
|
||||||
token_standard: TOKEN_STANDARDS.NONE,
|
token_standard: TOKEN_STANDARDS.NONE,
|
||||||
@ -1482,6 +1482,7 @@ describe('Transaction Controller', function () {
|
|||||||
default_gas_price: '2',
|
default_gas_price: '2',
|
||||||
gas_price: '2',
|
gas_price: '2',
|
||||||
gas_limit: '0x7b0d',
|
gas_limit: '0x7b0d',
|
||||||
|
transaction_contract_method: undefined,
|
||||||
first_seen: 1624408066355,
|
first_seen: 1624408066355,
|
||||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
||||||
status: 'unapproved',
|
status: 'unapproved',
|
||||||
@ -1550,7 +1551,7 @@ describe('Transaction Controller', function () {
|
|||||||
network: '42',
|
network: '42',
|
||||||
referrer: ORIGIN_METAMASK,
|
referrer: ORIGIN_METAMASK,
|
||||||
source: EVENT.SOURCE.TRANSACTION.USER,
|
source: EVENT.SOURCE.TRANSACTION.USER,
|
||||||
type: TRANSACTION_TYPES.SIMPLE_SEND,
|
transaction_type: TRANSACTION_TYPES.SIMPLE_SEND,
|
||||||
account_type: 'MetaMask',
|
account_type: 'MetaMask',
|
||||||
asset_type: ASSET_TYPES.NATIVE,
|
asset_type: ASSET_TYPES.NATIVE,
|
||||||
token_standard: TOKEN_STANDARDS.NONE,
|
token_standard: TOKEN_STANDARDS.NONE,
|
||||||
@ -1561,6 +1562,7 @@ describe('Transaction Controller', function () {
|
|||||||
default_gas_price: '2',
|
default_gas_price: '2',
|
||||||
gas_price: '2',
|
gas_price: '2',
|
||||||
gas_limit: '0x7b0d',
|
gas_limit: '0x7b0d',
|
||||||
|
transaction_contract_method: undefined,
|
||||||
first_seen: 1624408066355,
|
first_seen: 1624408066355,
|
||||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
||||||
status: 'unapproved',
|
status: 'unapproved',
|
||||||
@ -1639,7 +1641,7 @@ describe('Transaction Controller', function () {
|
|||||||
network: '42',
|
network: '42',
|
||||||
referrer: 'other',
|
referrer: 'other',
|
||||||
source: EVENT.SOURCE.TRANSACTION.DAPP,
|
source: EVENT.SOURCE.TRANSACTION.DAPP,
|
||||||
type: TRANSACTION_TYPES.SIMPLE_SEND,
|
transaction_type: TRANSACTION_TYPES.SIMPLE_SEND,
|
||||||
account_type: 'MetaMask',
|
account_type: 'MetaMask',
|
||||||
asset_type: ASSET_TYPES.NATIVE,
|
asset_type: ASSET_TYPES.NATIVE,
|
||||||
token_standard: TOKEN_STANDARDS.NONE,
|
token_standard: TOKEN_STANDARDS.NONE,
|
||||||
@ -1650,6 +1652,7 @@ describe('Transaction Controller', function () {
|
|||||||
default_gas_price: '2',
|
default_gas_price: '2',
|
||||||
gas_price: '2',
|
gas_price: '2',
|
||||||
gas_limit: '0x7b0d',
|
gas_limit: '0x7b0d',
|
||||||
|
transaction_contract_method: undefined,
|
||||||
first_seen: 1624408066355,
|
first_seen: 1624408066355,
|
||||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
||||||
status: 'unapproved',
|
status: 'unapproved',
|
||||||
@ -1720,7 +1723,7 @@ describe('Transaction Controller', function () {
|
|||||||
network: '42',
|
network: '42',
|
||||||
referrer: 'other',
|
referrer: 'other',
|
||||||
source: EVENT.SOURCE.TRANSACTION.DAPP,
|
source: EVENT.SOURCE.TRANSACTION.DAPP,
|
||||||
type: TRANSACTION_TYPES.SIMPLE_SEND,
|
transaction_type: TRANSACTION_TYPES.SIMPLE_SEND,
|
||||||
account_type: 'MetaMask',
|
account_type: 'MetaMask',
|
||||||
asset_type: ASSET_TYPES.NATIVE,
|
asset_type: ASSET_TYPES.NATIVE,
|
||||||
token_standard: TOKEN_STANDARDS.NONE,
|
token_standard: TOKEN_STANDARDS.NONE,
|
||||||
@ -1731,6 +1734,7 @@ describe('Transaction Controller', function () {
|
|||||||
default_gas_price: '2',
|
default_gas_price: '2',
|
||||||
gas_price: '2',
|
gas_price: '2',
|
||||||
gas_limit: '0x7b0d',
|
gas_limit: '0x7b0d',
|
||||||
|
transaction_contract_method: undefined,
|
||||||
first_seen: 1624408066355,
|
first_seen: 1624408066355,
|
||||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
||||||
status: 'unapproved',
|
status: 'unapproved',
|
||||||
@ -1801,7 +1805,7 @@ describe('Transaction Controller', function () {
|
|||||||
network: '42',
|
network: '42',
|
||||||
referrer: 'other',
|
referrer: 'other',
|
||||||
source: EVENT.SOURCE.TRANSACTION.DAPP,
|
source: EVENT.SOURCE.TRANSACTION.DAPP,
|
||||||
type: TRANSACTION_TYPES.SIMPLE_SEND,
|
transaction_type: TRANSACTION_TYPES.SIMPLE_SEND,
|
||||||
account_type: 'MetaMask',
|
account_type: 'MetaMask',
|
||||||
asset_type: ASSET_TYPES.NATIVE,
|
asset_type: ASSET_TYPES.NATIVE,
|
||||||
token_standard: TOKEN_STANDARDS.NONE,
|
token_standard: TOKEN_STANDARDS.NONE,
|
||||||
@ -1810,6 +1814,7 @@ describe('Transaction Controller', function () {
|
|||||||
sensitiveProperties: {
|
sensitiveProperties: {
|
||||||
gas_price: '2',
|
gas_price: '2',
|
||||||
gas_limit: '0x7b0d',
|
gas_limit: '0x7b0d',
|
||||||
|
transaction_contract_method: undefined,
|
||||||
first_seen: 1624408066355,
|
first_seen: 1624408066355,
|
||||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
||||||
status: 'unapproved',
|
status: 'unapproved',
|
||||||
@ -1860,7 +1865,7 @@ describe('Transaction Controller', function () {
|
|||||||
network: '42',
|
network: '42',
|
||||||
referrer: 'other',
|
referrer: 'other',
|
||||||
source: EVENT.SOURCE.TRANSACTION.DAPP,
|
source: EVENT.SOURCE.TRANSACTION.DAPP,
|
||||||
type: TRANSACTION_TYPES.SIMPLE_SEND,
|
transaction_type: TRANSACTION_TYPES.SIMPLE_SEND,
|
||||||
chain_id: '0x2a',
|
chain_id: '0x2a',
|
||||||
eip_1559_version: '0',
|
eip_1559_version: '0',
|
||||||
gas_edit_attempted: 'none',
|
gas_edit_attempted: 'none',
|
||||||
@ -1875,6 +1880,7 @@ describe('Transaction Controller', function () {
|
|||||||
foo: 'bar',
|
foo: 'bar',
|
||||||
gas_price: '2',
|
gas_price: '2',
|
||||||
gas_limit: '0x7b0d',
|
gas_limit: '0x7b0d',
|
||||||
|
transaction_contract_method: undefined,
|
||||||
first_seen: 1624408066355,
|
first_seen: 1624408066355,
|
||||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,
|
||||||
status: 'unapproved',
|
status: 'unapproved',
|
||||||
@ -1937,7 +1943,7 @@ describe('Transaction Controller', function () {
|
|||||||
network: '42',
|
network: '42',
|
||||||
referrer: 'other',
|
referrer: 'other',
|
||||||
source: EVENT.SOURCE.TRANSACTION.DAPP,
|
source: EVENT.SOURCE.TRANSACTION.DAPP,
|
||||||
type: TRANSACTION_TYPES.SIMPLE_SEND,
|
transaction_type: TRANSACTION_TYPES.SIMPLE_SEND,
|
||||||
account_type: 'MetaMask',
|
account_type: 'MetaMask',
|
||||||
asset_type: ASSET_TYPES.NATIVE,
|
asset_type: ASSET_TYPES.NATIVE,
|
||||||
token_standard: TOKEN_STANDARDS.NONE,
|
token_standard: TOKEN_STANDARDS.NONE,
|
||||||
@ -1949,6 +1955,7 @@ describe('Transaction Controller', function () {
|
|||||||
max_fee_per_gas: '2',
|
max_fee_per_gas: '2',
|
||||||
max_priority_fee_per_gas: '2',
|
max_priority_fee_per_gas: '2',
|
||||||
gas_limit: '0x7b0d',
|
gas_limit: '0x7b0d',
|
||||||
|
transaction_contract_method: undefined,
|
||||||
first_seen: 1624408066355,
|
first_seen: 1624408066355,
|
||||||
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.FEE_MARKET,
|
transaction_envelope_type: TRANSACTION_ENVELOPE_TYPE_NAMES.FEE_MARKET,
|
||||||
status: 'unapproved',
|
status: 'unapproved',
|
||||||
|
@ -252,6 +252,8 @@ export const TRANSACTION_GROUP_CATEGORIES = {
|
|||||||
* @property {number} id - An internally unique tx identifier.
|
* @property {number} id - An internally unique tx identifier.
|
||||||
* @property {number} time - Time the transaction was first suggested, in unix
|
* @property {number} time - Time the transaction was first suggested, in unix
|
||||||
* epoch time (ms).
|
* epoch time (ms).
|
||||||
|
* @property {string} contractMethodName - A string representing a name of
|
||||||
|
* transaction contract method.
|
||||||
* @property {TransactionTypeString} type - The type of transaction this txMeta
|
* @property {TransactionTypeString} type - The type of transaction this txMeta
|
||||||
* represents.
|
* represents.
|
||||||
* @property {TransactionStatusString} status - The current status of the
|
* @property {TransactionStatusString} status - The current status of the
|
||||||
|
@ -806,8 +806,10 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
maxFeePerGas,
|
maxFeePerGas,
|
||||||
maxPriorityFeePerGas,
|
maxPriorityFeePerGas,
|
||||||
baseFeePerGas,
|
baseFeePerGas,
|
||||||
|
methodData,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { submitting } = this.state;
|
const { submitting } = this.state;
|
||||||
|
const { name } = methodData;
|
||||||
|
|
||||||
if (submitting) {
|
if (submitting) {
|
||||||
return;
|
return;
|
||||||
@ -817,6 +819,10 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
txData.estimatedBaseFee = baseFeePerGas;
|
txData.estimatedBaseFee = baseFeePerGas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (name) {
|
||||||
|
txData.contractMethodName = name;
|
||||||
|
}
|
||||||
|
|
||||||
if (maxFeePerGas) {
|
if (maxFeePerGas) {
|
||||||
txData.txParams = {
|
txData.txParams = {
|
||||||
...txData.txParams,
|
...txData.txParams,
|
||||||
|
Loading…
Reference in New Issue
Block a user