Skip to content

Commit

Permalink
fix: Add metric trait for privacy mode
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing committed Nov 11, 2024
1 parent 4752afd commit 8df6e70
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/scripts/controllers/metametrics-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1453,6 +1453,7 @@ describe('MetaMetricsController', function () {
participateInMetaMetrics: true,
currentCurrency: 'usd',
dataCollectionForMarketing: false,
preferences: { privacyMode: true },
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
custodyAccountDetails: {},
///: END:ONLY_INCLUDE_IF
Expand Down Expand Up @@ -1492,6 +1493,7 @@ describe('MetaMetricsController', function () {
[MetaMetricsUserTrait.PetnameAddressCount]: 3,
///: END:ONLY_INCLUDE_IF
[MetaMetricsUserTrait.TokenSortPreference]: 'token-sort-key',
[MetaMetricsUserTrait.PrivacyModeEnabled]: true,
});
});
});
Expand Down Expand Up @@ -1541,6 +1543,7 @@ describe('MetaMetricsController', function () {
allNfts: {},
participateInMetaMetrics: true,
dataCollectionForMarketing: false,
preferences: { privacyMode: true },
securityAlertsEnabled: true,
names: {
ethereumAddress: {},
Expand Down Expand Up @@ -1604,6 +1607,7 @@ describe('MetaMetricsController', function () {
allNfts: {},
participateInMetaMetrics: true,
dataCollectionForMarketing: false,
preferences: { privacyMode: true },
securityAlertsEnabled: true,
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
custodyAccountDetails: {},
Expand Down Expand Up @@ -1668,6 +1672,7 @@ describe('MetaMetricsController', function () {
},
participateInMetaMetrics: true,
dataCollectionForMarketing: false,
preferences: { privacyMode: true },
securityAlertsEnabled: true,
security_providers: ['blockaid'],
currentCurrency: 'usd',
Expand Down Expand Up @@ -1713,6 +1718,7 @@ describe('MetaMetricsController', function () {
allNfts: {},
participateInMetaMetrics: true,
dataCollectionForMarketing: false,
preferences: { privacyMode: true },
names: {
ethereumAddress: {},
},
Expand Down
5 changes: 5 additions & 0 deletions app/scripts/controllers/metametrics-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ export type MetaMaskState = {
security_providers: string[];
addressBook: AddressBookControllerState['addressBook'];
currentCurrency: string;
preferences: {
privacyMode: PreferencesControllerState['preferences']['privacyMode'];
};
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
custodyAccountDetails: {
[address: string]: {
Expand Down Expand Up @@ -1228,6 +1231,8 @@ export default class MetaMetricsController extends BaseController<
metamaskState.dataCollectionForMarketing,
[MetaMetricsUserTrait.TokenSortPreference]:
metamaskState.tokenSortConfig?.key || '',
[MetaMetricsUserTrait.PrivacyModeEnabled]:
metamaskState.preferences.privacyMode,
};

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 @@ -590,6 +590,10 @@ export enum MetaMetricsUserTrait {
* Identified when the user changes token sort order on asset-list
*/
TokenSortPreference = 'token_sort_preference',
/**
* Identifies if the Privacy Mode is enabled
*/
PrivacyModeEnabled = 'privacy_mode_toggle',
}

/**
Expand Down

0 comments on commit 8df6e70

Please sign in to comment.