metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

New metrics data for token approval transactions

Open VSaric opened this issue 3 years ago • 14 comments

Explanation

We are adding new metrics data for token approval transactions. Additionally, we are adding a new property called transaction_approval_amount_type if transaction_contract_method is approve and token_standard is ERC20. Values for property transaction_approval_amount_type can be custom, revoke or dapp_proposed. Here we have some notes on technical implementation.

I added TransactionApprovalAmountType object into shared/constants/transaction.js to ensure types that are specific to the transaction approval amount.

The dappProposedTokenAmount property is the tokenAmount property passed to ConfirmApprove, that property is dapp proposed token amount and transaction_approval_amount_type will be dapp_proposed.

The customTokenAmount property is the customPermissionAmount in ConfirmApprove, that property is custom token amount transaction_approval_amount_type will be custom.

If the selected amount (either dappProposedTokenAmount or customTokenAmount) is 0, then transaction_approval_amount_type will be revoke.

To calculate transaction_approval_amount_vs_proposed_ratio property, we need to have both the originally proposed amount and the chosen amount (which will be the same as the original if the user does not edit the amount or will be a custom amount set by the user). We added two new properties originalApprovalAmount and finalApprovalAmount to the txData before calling sendTransaction in handleSubmit. originalApprovalAmount property is dapp proposed token amount. finalApprovalAmount property depends if the user does not edit the amount then it will be dappProposedTokenAmount. If the user does edit the amount then finalApprovalAmount will be customTokenAmount.

If transaction_approval_amount_type is custom we can calculate transaction_approval_amount_vs_proposed_ratio, otherwise it will be null.

To calculate transaction_approval_amount_vs_balance_ratio property, we added currentTokenBalance property to the txData, which is the balance of the token that is being send and matches the balance that is rendered.

If transaction_approval_amount_type is custom or dapp_proposed we can calculate transaction_approval_amount_vs_balance_ratio, otherwise it will be null.

More Information

  • Fixes #15152

Screenshots/Screencaps

Before

After

Manual Testing Steps

VSaric avatar Jul 20 '22 12:07 VSaric

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

github-actions[bot] avatar Jul 20 '22 12:07 github-actions[bot]

Builds ready [59c8196]
Page Load Metrics (1973 ± 74 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint951801222211
domContentLoaded17332259193814670
load17512269197315574
domInteractive17332259193814670

highlights:

storybook

metamaskbot avatar Jul 21 '22 08:07 metamaskbot

Builds ready [72f0dd9]
Page Load Metrics (1861 ± 51 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint95163117189
domContentLoaded16372125183310952
load16552125186110751
domInteractive16372125183310952

highlights:

storybook

metamaskbot avatar Jul 22 '22 13:07 metamaskbot

Builds ready [60a01e0]
Page Load Metrics (1900 ± 70 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint922252234464223
domContentLoaded16632257187514268
load16702257190014670
domInteractive16632257187514268

highlights:

storybook

metamaskbot avatar Jul 25 '22 09:07 metamaskbot

Builds ready [aebd8eb]
Page Load Metrics (2025 ± 136 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1042061362612
domContentLoaded165926652016283136
load165926652025284136
domInteractive165926652016283136

highlights:

storybook

metamaskbot avatar Jul 26 '22 09:07 metamaskbot

@worldlyjohn could you take a look at this

brad-decker avatar Jul 26 '22 14:07 brad-decker

Builds ready [cfb6e00]
Page Load Metrics (1820 ± 48 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint922016211414199
domContentLoaded1622202017929144
load1641202018209948
domInteractive1622202017929144

highlights:

storybook

metamaskbot avatar Jul 26 '22 15:07 metamaskbot

Builds ready [7976ffe]
Page Load Metrics (1754 ± 63 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint911963287505242
domContentLoaded15882109174013163
load15882110175413163
domInteractive15882109174013163

highlights:

storybook

metamaskbot avatar Jul 27 '22 08:07 metamaskbot

Builds ready [cbebce7]
Page Load Metrics (1941 ± 102 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint872030218416200
domContentLoaded153222221918209100
load153222221941213102
domInteractive153222221918209100

highlights:

storybook

metamaskbot avatar Aug 01 '22 09:08 metamaskbot

@worldlyjohn could you take a look at this

Just for awareness, John B. has reviewed and helped define this metrics update if that's what the @ is for :) but if the @ was for help reviewing code implementation just ignore me here 😅 cc: @brad-decker

bschorchit avatar Aug 02 '22 00:08 bschorchit

i'd be happy to QA this by looking at the events/properties being sent to segment. @VSaric if you want to run through different scenarios locally ping me and ill confirm it matches the spec @bschorchit and I worked out. (cc @brad-decker )

worldlyjohn avatar Aug 02 '22 18:08 worldlyjohn

Builds ready [546ec42]
Page Load Metrics (1921 ± 65 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1101897221385185
domContentLoaded17382225190513163
load17382225192113565
domInteractive17382224190513163

highlights:

storybook

metamaskbot avatar Aug 04 '22 10:08 metamaskbot

Builds ready [6cd3b32]
Page Load Metrics (1863 ± 60 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint961647190335161
domContentLoaded16512018184011254
load16512100186312660
domInteractive16512018184011254

highlights:

storybook

metamaskbot avatar Aug 08 '22 08:08 metamaskbot

Builds ready [aff3eef]
Page Load Metrics (1783 ± 55 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint862211123416
domContentLoaded16462179177211555
load16462179178311555
domInteractive16462179177211555

highlights:

storybook

metamaskbot avatar Aug 10 '22 08:08 metamaskbot

Builds ready [0067699]
Page Load Metrics (1898 ± 63 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint92145117157
domContentLoaded17122237187712761
load17122262189813263
domInteractive17122237187712761

highlights:

storybook

metamaskbot avatar Aug 11 '22 15:08 metamaskbot

Builds ready [814e93c]
Page Load Metrics (2009 ± 143 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint913641406933
domContentLoaded159726491984285137
load161727632009298143
domInteractive159726491984285137

highlights:

storybook

metamaskbot avatar Aug 15 '22 09:08 metamaskbot