Skip to content

Commit f889979

Browse files
committed
Merge branch 'main' into feat/dynamic-parameters
2 parents 1c9ed70 + 822bc47 commit f889979

File tree

18 files changed

+45
-359
lines changed

18 files changed

+45
-359
lines changed

shared/constants/app-state.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export enum AccountOverviewTabKey {
1313
export const ACCOUNT_OVERVIEW_TAB_KEY_TO_METAMETRICS_EVENT_NAME_MAP = {
1414
[AccountOverviewTabKey.Tokens]: MetaMetricsEventName.TokenScreenOpened,
1515
[AccountOverviewTabKey.DeFi]: MetaMetricsEventName.DeFiScreenOpened,
16-
[AccountOverviewTabKey.Nfts]: MetaMetricsEventName.NftScreenOpened,
1716
[AccountOverviewTabKey.Activity]: MetaMetricsEventName.ActivityScreenOpened,
1817
} as const;
1918

shared/constants/metametrics.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,9 @@ export enum MetaMetricsEventName {
699699
BannerDisplay = 'Banner Display',
700700
BannerCloseAll = 'Banner Close All',
701701
BannerSelect = 'Banner Select',
702-
BannerNavigated = 'Banner Navigated',
703702
BridgeLinkClicked = 'Bridge Link Clicked',
704703
SwapLinkClicked = 'Swap Link Clicked',
705-
CurrentCurrency = 'Current Currency',
704+
CurrentCurrency = 'Selected Currency Changed',
706705
DappViewed = 'Dapp Viewed',
707706
DecryptionApproved = 'Decryption Approved',
708707
DecryptionRejected = 'Decryption Rejected',
@@ -714,9 +713,7 @@ export enum MetaMetricsEventName {
714713
EmptyBuyBannerClicked = 'Empty Buy Banner Clicked',
715714
EmptyReceiveBannerDisplayed = 'Empty Receive Banner Displayed',
716715
EmptyReceiveBannerClicked = 'Empty Receive Banner Clicked',
717-
EmptyNftsBannerDisplayed = 'Empty NFTs Banner Displayed',
718716
EmptyNftsBannerClicked = 'Empty NFTs Banner Clicked',
719-
EnablingNotifications = 'Notifications Enabled',
720717
EncryptionPublicKeyApproved = 'Encryption Approved',
721718
EncryptionPublicKeyRejected = 'Encryption Rejected',
722719
EncryptionPublicKeyRequested = 'Encryption Requested',
@@ -734,8 +731,6 @@ export enum MetaMetricsEventName {
734731
KeyGlobalSecurityToggleSelected = 'Key Global Security/Privacy Settings',
735732
KeyBalanceTokenPriceChecker = 'Key Show Balance and Token Price Checker Settings',
736733
KeyGasFeeEstimationBuySwapTokens = 'Key Show Gas Fee Estimation, Buy Crypto and Swap Tokens',
737-
KeyAutoDetectTokens = 'Key Autodetect tokens',
738-
KeyBatchAccountBalanceRequests = 'Key Batch account balance requests',
739734
MarkAllNotificationsRead = 'Notifications Marked All as Read',
740735
MetricsOptIn = 'Metrics Opt In',
741736
MetricsOptOut = 'Metrics Opt Out',
@@ -826,16 +821,12 @@ export enum MetaMetricsEventName {
826821
TokenImportButtonClicked = 'Import Token Button Clicked',
827822
TokenScreenOpened = 'Token Screen Opened',
828823
TokenAdded = 'Token Added',
829-
TokenRemoved = 'Token Removed',
830-
TokenSortPreference = 'Token Sort Preference',
831-
TokenListRefreshed = 'Token List Refreshed',
832-
NFTRemoved = 'NFT Removed',
824+
TokenSortPreference = 'Token Sort Preference Updated',
833825
EmptyNFTTabButtonClicked = 'Empty NFT Tab Button Clicked',
834826
TokenDetected = 'Token Detected',
835827
TokenHidden = 'Token Hidden',
836828
TokenImportCanceled = 'Token Import Canceled',
837829
TokenImportClicked = 'Token Import Clicked',
838-
ShowNativeTokenAsMainBalance = 'Show native token as main balance',
839830
WalletSetupStarted = 'Wallet Setup Started',
840831
WalletFundsObtained = 'Wallet Funds Obtained',
841832
WalletImportStarted = 'Wallet Import Started',
@@ -862,7 +853,6 @@ export enum MetaMetricsEventName {
862853
AddNetworkButtonClick = 'Add Network Button Clicked',
863854
CustomNetworkAdded = 'Custom Network Added',
864855
TokenDetailsOpened = 'Token Details Opened',
865-
NftScreenOpened = 'NFT Screen Opened',
866856
NftDetailsOpened = 'NFT Details Opened',
867857
DeFiScreenOpened = 'DeFi Screen Opened',
868858
DeFiDetailsOpened = 'DeFi Details Opened',

test/e2e/tests/metrics/nft-detection-metrics.spec.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ async function mockSegment(mockServer: Mockttp) {
2828
statusCode: 200,
2929
};
3030
}),
31-
await mockServer
32-
.forPost('https://api.segment.io/v1/batch')
33-
.withJsonBodyIncluding({
34-
batch: [{ type: 'track', event: 'nft_autodetection_enabled' }],
35-
})
36-
.thenCallback(() => {
37-
return {
38-
statusCode: 200,
39-
};
40-
}),
4131
];
4232
}
4333

Lines changed: 1 addition & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
1-
import { expect } from '@playwright/test';
2-
import { getEventPayloads, withFixtures } from '../../helpers';
3-
import { MockedEndpoint, Mockttp } from '../../mock-e2e';
1+
import { withFixtures } from '../../helpers';
42
import { Driver } from '../../webdriver/driver';
53
import FixtureBuilder from '../../fixture-builder';
64
import AdvancedSettings from '../../page-objects/pages/settings/advanced-settings';
75
import AssetListPage from '../../page-objects/pages/home/asset-list';
8-
import HeaderNavbar from '../../page-objects/pages/header-navbar';
96
import HomePage from '../../page-objects/pages/home/homepage';
107
import SettingsPage from '../../page-objects/pages/settings/settings-page';
118
import {
129
loginWithBalanceValidation,
1310
loginWithoutBalanceValidation,
1411
} from '../../page-objects/flows/login.flow';
1512

16-
async function mockSegment(mockServer: Mockttp) {
17-
return [
18-
await mockServer
19-
.forPost('https://api.segment.io/v1/batch')
20-
.withJsonBodyIncluding({
21-
batch: [{ type: 'track', event: 'Show native token as main balance' }],
22-
})
23-
.thenCallback(() => {
24-
return {
25-
statusCode: 200,
26-
};
27-
}),
28-
];
29-
}
30-
3113
describe('Settings: Show native token as main balance', function () {
3214
it('Should show balance in crypto when toggle is off', async function () {
3315
await withFixtures(
@@ -106,95 +88,4 @@ describe('Settings: Show native token as main balance', function () {
10688
},
10789
);
10890
});
109-
110-
it('Should Successfully track the event when toggle is turned off', async function () {
111-
await withFixtures(
112-
{
113-
fixtures: new FixtureBuilder()
114-
.withMetaMetricsController({
115-
metaMetricsId: 'fake-metrics-fd20',
116-
participateInMetaMetrics: true,
117-
})
118-
.build(),
119-
title: this.test?.fullTitle(),
120-
testSpecificMock: mockSegment,
121-
},
122-
async ({
123-
driver,
124-
mockedEndpoint: mockedEndpoints,
125-
}: {
126-
driver: Driver;
127-
mockedEndpoint: MockedEndpoint[];
128-
}) => {
129-
await loginWithBalanceValidation(driver);
130-
await new HeaderNavbar(driver).openSettingsPage();
131-
const settingsPage = new SettingsPage(driver);
132-
await settingsPage.checkPageIsLoaded();
133-
await settingsPage.toggleBalanceSetting();
134-
135-
const events = await getEventPayloads(driver, mockedEndpoints);
136-
expect(events[0].properties).toMatchObject({
137-
// TODO: Fix in https://github.com/MetaMask/metamask-extension/issues/31860
138-
// eslint-disable-next-line @typescript-eslint/naming-convention
139-
show_native_token_as_main_balance: false,
140-
category: 'Settings',
141-
locale: 'en',
142-
// TODO: Fix in https://github.com/MetaMask/metamask-extension/issues/31860
143-
// eslint-disable-next-line @typescript-eslint/naming-convention
144-
chain_id: '0x539',
145-
// TODO: Fix in https://github.com/MetaMask/metamask-extension/issues/31860
146-
// eslint-disable-next-line @typescript-eslint/naming-convention
147-
environment_type: 'fullscreen',
148-
});
149-
},
150-
);
151-
});
152-
153-
it('Should Successfully track the event when toggle is turned on', async function () {
154-
await withFixtures(
155-
{
156-
fixtures: new FixtureBuilder()
157-
.withMetaMetricsController({
158-
metaMetricsId: 'fake-metrics-fd20',
159-
participateInMetaMetrics: true,
160-
})
161-
.withPreferencesControllerShowNativeTokenAsMainBalanceDisabled()
162-
.build(),
163-
title: this.test?.fullTitle(),
164-
testSpecificMock: mockSegment,
165-
},
166-
async ({
167-
driver,
168-
mockedEndpoint: mockedEndpoints,
169-
}: {
170-
driver: Driver;
171-
mockedEndpoint: MockedEndpoint[];
172-
}) => {
173-
await loginWithoutBalanceValidation(driver);
174-
const homePage = new HomePage(driver);
175-
await homePage.checkPageIsLoaded();
176-
await homePage.checkExpectedBalanceIsDisplayed('$42,500.00', 'USD');
177-
178-
await homePage.headerNavbar.openSettingsPage();
179-
const settingsPage = new SettingsPage(driver);
180-
await settingsPage.checkPageIsLoaded();
181-
await settingsPage.toggleBalanceSetting();
182-
183-
const events = await getEventPayloads(driver, mockedEndpoints);
184-
expect(events[0].properties).toMatchObject({
185-
// TODO: Fix in https://github.com/MetaMask/metamask-extension/issues/31860
186-
// eslint-disable-next-line @typescript-eslint/naming-convention
187-
show_native_token_as_main_balance: true,
188-
category: 'Settings',
189-
locale: 'en',
190-
// TODO: Fix in https://github.com/MetaMask/metamask-extension/issues/31860
191-
// eslint-disable-next-line @typescript-eslint/naming-convention
192-
chain_id: '0x539',
193-
// TODO: Fix in https://github.com/MetaMask/metamask-extension/issues/31860
194-
// eslint-disable-next-line @typescript-eslint/naming-convention
195-
environment_type: 'fullscreen',
196-
});
197-
},
198-
);
199-
});
20091
});

test/e2e/tests/tokens/nft/remove-nft.spec.ts

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,16 @@
1-
import { strict as assert } from 'assert';
2-
import { MockttpServer } from 'mockttp';
3-
import { withFixtures, getEventPayloads } from '../../../helpers';
1+
import { withFixtures } from '../../../helpers';
42
import { SMART_CONTRACTS } from '../../../seeder/smart-contracts';
53
import FixtureBuilder from '../../../fixture-builder';
6-
import { MetaMetricsEventName } from '../../../../../shared/constants/metametrics';
7-
import { CHAIN_IDS } from '../../../../../shared/constants/network';
84
import { MOCK_META_METRICS_ID } from '../../../constants';
95
import Homepage from '../../../page-objects/pages/home/homepage';
106
import NFTDetailsPage from '../../../page-objects/pages/nft-details-page';
117
import NftListPage from '../../../page-objects/pages/home/nft-list';
128
import { loginWithBalanceValidation } from '../../../page-objects/flows/login.flow';
139

14-
async function mockedNftRemoved(mockServer: MockttpServer) {
15-
return await mockServer
16-
.forPost('https://api.segment.io/v1/batch')
17-
.withJsonBodyIncluding({
18-
batch: [{ type: 'track', event: MetaMetricsEventName.NFTRemoved }],
19-
})
20-
.thenCallback(() => {
21-
return {
22-
statusCode: 200,
23-
};
24-
});
25-
}
26-
2710
describe('Remove NFT', function () {
2811
const smartContract = SMART_CONTRACTS.NFTS;
2912

30-
it('user should be able to remove ERC721 NFT on details page and removeNft event should be emitted', async function () {
31-
async function mockSegment(mockServer: MockttpServer) {
32-
return [await mockedNftRemoved(mockServer)];
33-
}
13+
it('user should be able to remove ERC721 NFT on details page', async function () {
3414
await withFixtures(
3515
{
3616
dappOptions: { numberOfTestDapps: 1 },
@@ -43,19 +23,10 @@ describe('Remove NFT', function () {
4323
.build(),
4424
smartContract,
4525
title: this.test?.fullTitle(),
46-
testSpecificMock: mockSegment,
4726
},
48-
async ({
49-
driver,
50-
localNodes,
51-
mockedEndpoint: mockedEndpoints,
52-
contractRegistry,
53-
}) => {
27+
async ({ driver, localNodes }) => {
5428
await loginWithBalanceValidation(driver, localNodes[0]);
5529

56-
const contractAddress =
57-
await contractRegistry.getContractAddress(smartContract);
58-
5930
// Open the NFT details page and click to remove NFT
6031
await new Homepage(driver).goToNftTab();
6132
const nftListPage = new NftListPage(driver);
@@ -68,20 +39,6 @@ describe('Remove NFT', function () {
6839
// Check the success remove NFT toaster is displayed and the NFT is removed from the NFT tab
6940
await nftListPage.checkSuccessRemoveNftMessageIsDisplayed();
7041
await nftListPage.checkNoNftInfoIsDisplayed();
71-
72-
// Check if event was emitted
73-
const events = await getEventPayloads(driver, mockedEndpoints);
74-
const nftRemovedProperties = events[0].properties;
75-
assert.equal(
76-
nftRemovedProperties.token_contract_address,
77-
contractAddress,
78-
);
79-
assert.equal(nftRemovedProperties.tokenId, '1');
80-
assert.equal(nftRemovedProperties.asset_type, 'NFT');
81-
assert.equal(nftRemovedProperties.token_standard, 'ERC721');
82-
assert.equal(nftRemovedProperties.token_standard, 'ERC721');
83-
assert.equal(nftRemovedProperties.isSuccessful, true);
84-
assert.equal(nftRemovedProperties.chain_id, CHAIN_IDS.LOCALHOST);
8542
},
8643
);
8744
});

test/integration/nfts/nfts.test.tsx

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { act, screen, waitFor } from '@testing-library/react';
22
import nock from 'nock';
3-
import {
4-
MetaMetricsEventCategory,
5-
MetaMetricsEventName,
6-
} from '../../../shared/constants/metametrics';
73
import * as backgroundConnection from '../../../ui/store/background-connection';
84
import { integrationTestRender } from '../../lib/render-helpers';
95
import mockMetaMaskState from '../data/integration-init-state.json';
@@ -97,28 +93,6 @@ describe('NFTs list', () => {
9793
await waitForElementByText('MUNK #1 Mainnet');
9894
await waitForElementByText('MUNK #1 Chain 137');
9995
await waitForElementByText('MUNK #1 Chain 5');
100-
101-
let nftScreenOpenedMetricsEvent;
102-
103-
await waitFor(() => {
104-
nftScreenOpenedMetricsEvent =
105-
mockedBackgroundConnection.submitRequestToBackground.mock.calls?.find(
106-
(call) =>
107-
call[0] === 'trackMetaMetricsEvent' &&
108-
call[1]?.[0].category === MetaMetricsEventCategory.Home,
109-
);
110-
111-
expect(nftScreenOpenedMetricsEvent?.[0]).toBe('trackMetaMetricsEvent');
112-
113-
expect(nftScreenOpenedMetricsEvent?.[1]).toEqual(
114-
expect.arrayContaining([
115-
expect.objectContaining({
116-
category: MetaMetricsEventCategory.Home,
117-
event: MetaMetricsEventName.NftScreenOpened,
118-
}),
119-
]),
120-
);
121-
});
12296
});
12397

12498
it('filters the nfts list for the current network', async () => {

ui/components/app/assets/asset-list/asset-list-control-bar/asset-list-control-bar.test.tsx

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ import { AVAILABLE_MULTICHAIN_NETWORK_CONFIGURATIONS } from '@metamask/multichai
55
import type { NetworkConfiguration } from '@metamask/network-controller';
66
import { fireEvent } from '../../../../../../test/jest';
77
import { renderWithProvider } from '../../../../../../test/lib/render-helpers-navigate';
8-
import { MetaMetricsContext } from '../../../../../contexts/metametrics';
9-
import {
10-
MetaMetricsEventCategory,
11-
MetaMetricsEventName,
12-
} from '../../../../../../shared/constants/metametrics';
138
import mockState from '../../../../../../test/data/mock-state.json';
149
import * as actions from '../../../../../store/actions';
1510
import { SECURITY_ROUTE } from '../../../../../helpers/constants/routes';
@@ -59,40 +54,6 @@ const createMockState = () => ({
5954
},
6055
});
6156

62-
describe('AssetListControlBar', () => {
63-
afterEach(() => {
64-
jest.clearAllMocks();
65-
});
66-
67-
it('should fire metrics event when refresh button is clicked', async () => {
68-
const state = createMockState();
69-
const store = configureMockStore([thunk])(state);
70-
71-
const mockTrackEvent = jest.fn();
72-
73-
const { findByTestId } = renderWithProvider(
74-
<MetaMetricsContext.Provider value={mockTrackEvent}>
75-
<AssetListControlBar showTokensLinks />
76-
</MetaMetricsContext.Provider>,
77-
store,
78-
);
79-
80-
const importButton = await findByTestId(
81-
'asset-list-control-bar-action-button',
82-
);
83-
importButton.click();
84-
85-
const refreshListItem = await findByTestId('refreshList__button');
86-
refreshListItem.click();
87-
88-
expect(mockTrackEvent).toHaveBeenCalledTimes(1);
89-
expect(mockTrackEvent).toHaveBeenCalledWith({
90-
category: MetaMetricsEventCategory.Tokens,
91-
event: MetaMetricsEventName.TokenListRefreshed,
92-
});
93-
});
94-
});
95-
9657
describe('NFTs options', () => {
9758
afterEach(() => {
9859
jest.clearAllMocks();

ui/components/app/assets/asset-list/asset-list-control-bar/asset-list-control-bar.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,6 @@ const AssetListControlBar = ({
276276
const handleRefresh = () => {
277277
dispatch(detectTokens(Object.keys(enabledNetworksByNamespace)));
278278
closePopover();
279-
trackEvent({
280-
category: MetaMetricsEventCategory.Tokens,
281-
event: MetaMetricsEventName.TokenListRefreshed,
282-
});
283279
};
284280

285281
const onEnableAutoDetect = () => {

0 commit comments

Comments
 (0)