Skip to content

Commit

Permalink
fix: update wallet_addEthereumChain.js with correct MetricsEventBuild…
Browse files Browse the repository at this point in the history
…er (#12446)

<!--
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**
* fixes breaking e2e test anter updating analytics
<!--
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?
-->

## **Related issues**

Fixes: MetaMask/mobile-planning#2044
Breaking change: #12180

## **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 Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/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-mobile/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
frankvonhoven authored Nov 26, 2024
1 parent 4a2b689 commit 6a17b3e
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions app/core/RPCMethods/wallet_addEthereumChain.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ChainId } from '@metamask/controller-utils';
import Engine from '../Engine';
import { providerErrors, rpcErrors } from '@metamask/rpc-errors';
import { MetaMetricsEvents, MetaMetrics } from '../../core/Analytics';
import { MetricsEventBuilder } from '../../core/Analytics/MetricsEventBuilder';
import {
selectChainId,
selectNetworkConfigurations,
Expand Down Expand Up @@ -145,8 +146,7 @@ const wallet_addEthereumChain = async ({
});

MetaMetrics.getInstance().trackEvent(
MetaMetrics.getInstance()
.createEventBuilder(MetaMetricsEvents.NETWORK_SWITCHED)
MetricsEventBuilder.createEventBuilder(MetaMetricsEvents.NETWORK_SWITCHED)
.addProperties(analyticsParams)
.build(),
);
Expand All @@ -172,8 +172,7 @@ const wallet_addEthereumChain = async ({
requestData.alerts = alerts;

MetaMetrics.getInstance().trackEvent(
MetaMetrics.getInstance()
.createEventBuilder(MetaMetricsEvents.NETWORK_REQUESTED)
MetricsEventBuilder.createEventBuilder(MetaMetricsEvents.NETWORK_REQUESTED)
.addProperties({
chain_id: getDecimalChainId(chainId),
source: 'Custom Network API',
Expand All @@ -198,8 +197,9 @@ const wallet_addEthereumChain = async ({
});
} catch (error) {
MetaMetrics.getInstance().trackEvent(
MetaMetrics.getInstance()
.createEventBuilder(MetaMetricsEvents.NETWORK_REQUEST_REJECTED)
MetricsEventBuilder.createEventBuilder(
MetaMetricsEvents.NETWORK_REQUEST_REJECTED,
)
.addProperties({
chain_id: getDecimalChainId(chainId),
source: 'Custom Network API',
Expand Down Expand Up @@ -227,8 +227,7 @@ const wallet_addEthereumChain = async ({
});

MetaMetrics.getInstance().trackEvent(
MetaMetrics.getInstance()
.createEventBuilder(MetaMetricsEvents.NETWORK_ADDED)
MetricsEventBuilder.createEventBuilder(MetaMetricsEvents.NETWORK_ADDED)
.addProperties({
chain_id: getDecimalChainId(chainId),
source: 'Custom Network API',
Expand Down Expand Up @@ -260,8 +259,7 @@ const wallet_addEthereumChain = async ({
});

MetaMetrics.getInstance().trackEvent(
MetaMetrics.getInstance()
.createEventBuilder(MetaMetricsEvents.NETWORK_SWITCHED)
MetricsEventBuilder.createEventBuilder(MetaMetricsEvents.NETWORK_SWITCHED)
.addProperties(analyticsParams)
.build(),
);
Expand Down

0 comments on commit 6a17b3e

Please sign in to comment.