Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add RPC Method Middleware params transform and tracking (#23236)
## **Description** Currently we track a sample of most RPC method calls, but we do not include params. This is for good reason of course since many param values are sensitive and may identify an otherwise anonymous MetaMask Metrics user. There are some param values that are not sensitive yet are not tracked as well. Our goal is to glean additional insight into the usage of our RPC methods by including non-sensitive params in the events that track them. This PR achieves that by including a map of method to transformation functions which accepts a request's params object (or array) and transforms it something that is acceptable for analytics. By default no params are included. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23236?quickstart=1) ## **Related issues** Fixes: MetaMask/MetaMask-planning#2167 ## **Manual testing steps** 1. Opt into MetaMetrics in the wallet settings 1. Open your the background console for extension 1. Add a breakpoint for trackEvent inside `createRPCMethodTrackingMiddleware.js` 1. On any page with a provider injected, use `window.ethereum.request` to make some rpc method calls 1. Check background console for breakpoint trigger * Currently only `wallet_watchAsset` should include the `type` param. All other methods should not include any params. * [the wallet_watchAsset in API playground](https://docs.metamask.io/wallet/reference/wallet_watchasset/) may be helpful to use NOTE: I recommend breakpoint and debugger over the network tab because I don't believe the tracking requests actually fire on dev. ## **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** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [x] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] 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. - [x] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [x] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **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. --------- Co-authored-by: Alex Donesky <[email protected]>
- Loading branch information