Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherrypick v12.7.0 feat: Add simulation metrics to "Transaction Submitted" and "Transaction Finalized" events #28314

Conversation

digiwand
Copy link
Contributor

@digiwand digiwand commented Nov 6, 2024

Description

Cherry-picks #28240 into v12.7.0.

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/3507

Manual testing steps

  1. Turn on "Participate in MetaMetrics" setting
  2. Confirm or Reject a Send transaction (old transaction, not redesign transaction)
  3. Observe simulation props are added to Transaction Submitted and Transaction Finalized events

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

…ion Finalized" events (#28240)

## **Description**

This PR adds simulation metrics to the `Transaction Submitted` and
`Transaction Finalized` events.

Please refer to **Solution B)** below for details.

----



The challenge here is that there are two separate transaction fragment
buckets: `transaction-added-<id>` and `transaction-submitted-<id>`.
 `transaction-added-<id>` fragments are associated with the events:
- Transaction Added
- Transaction Approved
- Transaction Rejected

`transaction-submitted-<id>` fragments are associated with the events: 
- Transaction Submitted
- Transaction Finalized

Simulation metrics were added to "Transaction Approved" and "Transaction
Rejected" events using updateEventFragment. When they were added here
through the useTransactionEventFragment hook, the
`transaction-submitted-<id>` fragment had not yet been created. The
`transaction-submitted-<id>` fragment is created after a user clicks the
Confirm button on a transaction which invokes
metrics#handleTransactionSubmitted and calls
createTransactionEventFragment

To solve this, I proposed two solutions (TLDR; went with Solution B): 

#### Solution A) 
- Create a single transaction fragment ID to handle all related
transaction events. Here, the fragment would specify the props:
```
initialEvent: "Transaction Added"
successEvent:"Transaction Finalized"
failureEvent: "Transaction Rejected"
```
- Add new method to MetaMetricsController to call trackEvent with
specified eventName utilizing fragment props. This would support calling
"Transaction Approved" and "Transaction Submitted" ad-hoc style.

#### Solution B)
- Allow a premature fragment to exist for `transaction-submitted-<id>`
fragment. Prior to this PR fragments only exist once they are created.
- From  useTransactionEventFragment hook
  - Adds a premature `transaction-submitted-<id>` fragment
- Calls "updateEventFragment(`transaction-submitted-${transactionId}`,
params)" to store simulation metric props
- When handleTransactionSubmitted event is invoked, creating the
fragment now merges the premature fragment with the newly created
fragment
- When a premature fragment is found as an abandoned fragment, we delete
it from the store

#### Solution C)
- store unlinked props in new store state: fragmentsUnlinkedProps on
updateEventFragment
- fragmentsUnlinkedProps can be applied to newly created fragments on
createEventFragment
- deleted abandoned fragmentsUnlinkedProps would need more investigation

I went with solution B due to time constraints.

## **Related issues**

Fixes: MetaMask/MetaMask-planning#3507

## **Manual testing steps**

1. Turn on "Participate in MetaMetrics" setting
2. Confirm or Reject a Send transaction
3. Observe simulation props are added to `Transaction Submitted` and
`Transaction Finalized` events

## **Screenshots/Recordings**

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

no UI/UX changes 

### **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/develop/.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/develop/.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.
@digiwand digiwand requested review from a team as code owners November 6, 2024 07:31
Copy link
Contributor

github-actions bot commented Nov 6, 2024

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.

@digiwand digiwand added the team-confirmations Push issues to confirmations team label Nov 6, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [08ec2ab]
Page Load Metrics (2152 ± 62 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint26923261884682327
domContentLoaded18802272211712560
load19332326215212962
domInteractive298659188
backgroundConnect87326199
firstReactRender561641022512
getState665222110
initialActions01000
loadScripts13851709157410550
setupStore1276372412
uiStartup21012563237613766
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 502 Bytes (0.01%)
  • ui: 58 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@digiwand digiwand added the release-12.7.0 Issue or pull request that will be included in release 12.7.0 label Nov 6, 2024
danjm pushed a commit that referenced this pull request Nov 7, 2024
…actions (#28324)

<!--
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**

Cherry-picks #28280
into V12.7.0

Discovered this missing behavior while working on
#28314. The feat was
unexpectedly missing

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

## **Related issues**

Fixes: #28292

## **Manual testing steps**

1. Go to this page...
2.
3.

## **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/develop/.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/develop/.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.
@danjm danjm merged commit 3b597d9 into Version-v12.7.0 Nov 7, 2024
76 checks passed
@danjm danjm deleted the cherrypick-v12.7.0-add-tx-simulation-metrics-for-submitted-and-finalized branch November 7, 2024 15:18
@github-actions github-actions bot locked and limited conversation to collaborators Nov 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.7.0 Issue or pull request that will be included in release 12.7.0 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants