Skip to content

Commit

Permalink
fix: Add metric trait for token network filter preference
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing committed Nov 11, 2024
1 parent d887c79 commit 7764d87
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/scripts/controllers/metametrics-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ describe('MetaMetricsController', function () {
participateInMetaMetrics: true,
currentCurrency: 'usd',
dataCollectionForMarketing: false,
preferences: { privacyMode: true },
preferences: { privacyMode: true, tokenNetworkFilter: {} },
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
custodyAccountDetails: {},
///: END:ONLY_INCLUDE_IF
Expand Down Expand Up @@ -1494,6 +1494,7 @@ describe('MetaMetricsController', function () {
///: END:ONLY_INCLUDE_IF
[MetaMetricsUserTrait.TokenSortPreference]: 'token-sort-key',
[MetaMetricsUserTrait.PrivacyModeEnabled]: true,
[MetaMetricsUserTrait.NetworkFilterPreference]: {},
});
});
});
Expand Down Expand Up @@ -1543,7 +1544,7 @@ describe('MetaMetricsController', function () {
allNfts: {},
participateInMetaMetrics: true,
dataCollectionForMarketing: false,
preferences: { privacyMode: true },
preferences: { privacyMode: true, tokenNetworkFilter: {} },
securityAlertsEnabled: true,
names: {
ethereumAddress: {},
Expand Down Expand Up @@ -1607,7 +1608,7 @@ describe('MetaMetricsController', function () {
allNfts: {},
participateInMetaMetrics: true,
dataCollectionForMarketing: false,
preferences: { privacyMode: true },
preferences: { privacyMode: true, tokenNetworkFilter: {} },
securityAlertsEnabled: true,
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
custodyAccountDetails: {},
Expand Down Expand Up @@ -1672,7 +1673,7 @@ describe('MetaMetricsController', function () {
},
participateInMetaMetrics: true,
dataCollectionForMarketing: false,
preferences: { privacyMode: true },
preferences: { privacyMode: true, tokenNetworkFilter: {} },
securityAlertsEnabled: true,
security_providers: ['blockaid'],
currentCurrency: 'usd',
Expand Down Expand Up @@ -1718,7 +1719,7 @@ describe('MetaMetricsController', function () {
allNfts: {},
participateInMetaMetrics: true,
dataCollectionForMarketing: false,
preferences: { privacyMode: true },
preferences: { privacyMode: true, tokenNetworkFilter: {} },
names: {
ethereumAddress: {},
},
Expand Down
3 changes: 3 additions & 0 deletions app/scripts/controllers/metametrics-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export type MetaMaskState = {
currentCurrency: string;
preferences: {
privacyMode: PreferencesControllerState['preferences']['privacyMode'];
tokenNetworkFilter: PreferencesControllerState['preferences']['tokenNetworkFilter'];
};
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
custodyAccountDetails: {
Expand Down Expand Up @@ -1233,6 +1234,8 @@ export default class MetaMetricsController extends BaseController<
metamaskState.tokenSortConfig?.key || '',
[MetaMetricsUserTrait.PrivacyModeEnabled]:
metamaskState.preferences.privacyMode,
[MetaMetricsUserTrait.NetworkFilterPreference]:
metamaskState.preferences.tokenNetworkFilter,
};

if (!previousUserTraits) {
Expand Down
4 changes: 4 additions & 0 deletions shared/constants/metametrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,10 @@ export enum MetaMetricsUserTrait {
* Identifies if the Privacy Mode is enabled
*/
PrivacyModeEnabled = 'privacy_mode_toggle',
/**
* Identified when the user prefers to see all tokens or current network tokens in wallet list
*/
NetworkFilterPreference = 'selected_network_filter',
}

/**
Expand Down

0 comments on commit 7764d87

Please sign in to comment.