chore: refactors metametrics to common function#13963
Conversation
|
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. |
701049e to
40ebe22
Compare
40ebe22 to
af3d497
Compare
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the MetaMetrics analytics tracking by moving event tracking into the common function switchToNetwork and fixes a variable naming typo. It also adds a new test for the updated util code.
- Moves MetaMetrics tracking into switchToNetwork.
- Removes duplicate tracking calls from wallet_switchEthereumChain and wallet_addEthereumChain.
- Fixes a typo in a variable name and adds test coverage for the util code.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| app/core/RPCMethods/lib/ethereum-chain-utils.test.js | Adds tests for the network switch event tracking in the utils function |
| app/core/RPCMethods/lib/ethereum-chain-utils.js | Consolidates MetaMetrics event tracking inside switchToNetwork |
| app/core/RPCMethods/wallet_switchEthereumChain.js | Removes duplicate tracking call after refactoring into the common function |
| app/core/RPCMethods/wallet_addEthereumChain.js | Removes duplicate tracking call and fixes a typo in a variable name |
| app/core/RPCMethods/wallet_switchEthereumChain.test.js | Updates tests by removing unnecessary MetaMetrics mocks |
Comments suppressed due to low confidence (2)
app/core/RPCMethods/lib/ethereum-chain-utils.js:311
- Consider adding error handling around the MetaMetrics tracking call to prevent potential runtime issues if the analytics service is unavailable.
MetaMetrics.getInstance().trackEvent(
app/core/RPCMethods/wallet_switchEthereumChain.test.js:1
- [nitpick] Ensure that the tests are updated to verify the new analytics tracking behavior now handled by switchToNetwork, as the MetaMetrics mocks have been removed.
import MetaMetrics from '../Analytics/MetaMetrics';
NicolasMassart
left a comment
There was a problem hiding this comment.
A few questions about typing and why not using TS for new files
|
|
NicolasMassart
left a comment
There was a problem hiding this comment.
Looks good to me.



Description
This PR aims to address some review comments from a previous PR that fixed a bug and that needed to be merged fast. No changes in behaviour should occur from this PR.
Specifically:
#13883
Related issues
Fixes: See Description
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist