Skip to content

Commit

Permalink
fix: Fix not set estimate_type and rename dappSuggested transacti…
Browse files Browse the repository at this point in the history
…on metric property value (#29052)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

This PR aims to rename `dappSuggested` transaction event value to
`dapp_proposed`.
Also it fixes the `estimate_type` property to `default_estimate` on not
EIP1559 transactions.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/29052?quickstart=1)

## **Related issues**
 
Fixes: MetaMask/MetaMask-planning#3595

## **Manual testing steps**

N/A

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
OGPoyraz authored Dec 13, 2024
1 parent 527717e commit 788e4a2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/scripts/lib/transaction/metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
MetaMetricsTransactionEventSource,
MetaMetricsEventCategory,
MetaMetricsEventUiCustomization,
MetaMetricsEventTransactionEstimateType,
} from '../../../../shared/constants/metametrics';
import { TRANSACTION_ENVELOPE_TYPE_NAMES } from '../../../../shared/lib/transactions-controller-utils';
import {
Expand Down Expand Up @@ -165,6 +166,7 @@ describe('Transaction metrics', () => {
};

expectedSensitiveProperties = {
default_estimate: MetaMetricsEventTransactionEstimateType.DefaultEstimate,
default_gas: '0.000031501',
default_gas_price: '2',
first_seen: 1624408066355,
Expand Down
14 changes: 12 additions & 2 deletions app/scripts/lib/transaction/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ import {
TransactionType,
} from '@metamask/transaction-controller';
import { ORIGIN_METAMASK } from '../../../../shared/constants/app';
import { GasRecommendations } from '../../../../shared/constants/gas';
import {
GasRecommendations,
PriorityLevels,
} from '../../../../shared/constants/gas';
import {
MetaMetricsEventCategory,
MetaMetricsEventFragment,
MetaMetricsEventName,
MetaMetricsEventUiCustomization,
MetaMetricsEventTransactionEstimateType,
MetaMetricsPageObject,
MetaMetricsReferrerObject,
} from '../../../../shared/constants/metametrics';
Expand Down Expand Up @@ -824,12 +828,18 @@ async function buildEventFragmentProperties({
gasParams.max_priority_fee_per_gas = maxPriorityFeePerGas;
} else {
gasParams.gas_price = gasPrice;
gasParams.default_estimate =
MetaMetricsEventTransactionEstimateType.DefaultEstimate;
}

if (defaultGasEstimates) {
const { estimateType } = defaultGasEstimates;
if (estimateType) {
gasParams.default_estimate = estimateType;
gasParams.default_estimate =
estimateType === PriorityLevels.dAppSuggested
? MetaMetricsEventTransactionEstimateType.DappProposed
: estimateType;

let defaultMaxFeePerGas =
transactionMeta.defaultGasEstimates?.maxFeePerGas;
let defaultMaxPriorityFeePerGas =
Expand Down
5 changes: 5 additions & 0 deletions shared/constants/metametrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1034,3 +1034,8 @@ export enum DeleteRegulationStatus {
Running = 'RUNNING',
Unknown = 'UNKNOWN',
}

export enum MetaMetricsEventTransactionEstimateType {
DappProposed = 'dapp_proposed',
DefaultEstimate = 'default_estimate',
}

0 comments on commit 788e4a2

Please sign in to comment.