Skip to content

Commit d887c79

Browse files
authored
fix: Add metric trait for privacy mode (#28335)
## **Description** Adds a user trait for if privacy mode is enabled. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28335?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. Open debugger 2. Put a breakpoint in `app/scripts/controllers/metametrics.ts`'s `_buildUserTraitsObject` function 3. See value being passed ## **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 Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.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-extension/blob/develop/.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.
1 parent 3fedf45 commit d887c79

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

app/scripts/controllers/metametrics-controller.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,7 @@ describe('MetaMetricsController', function () {
14531453
participateInMetaMetrics: true,
14541454
currentCurrency: 'usd',
14551455
dataCollectionForMarketing: false,
1456+
preferences: { privacyMode: true },
14561457
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
14571458
custodyAccountDetails: {},
14581459
///: END:ONLY_INCLUDE_IF
@@ -1492,6 +1493,7 @@ describe('MetaMetricsController', function () {
14921493
[MetaMetricsUserTrait.PetnameAddressCount]: 3,
14931494
///: END:ONLY_INCLUDE_IF
14941495
[MetaMetricsUserTrait.TokenSortPreference]: 'token-sort-key',
1496+
[MetaMetricsUserTrait.PrivacyModeEnabled]: true,
14951497
});
14961498
});
14971499
});
@@ -1541,6 +1543,7 @@ describe('MetaMetricsController', function () {
15411543
allNfts: {},
15421544
participateInMetaMetrics: true,
15431545
dataCollectionForMarketing: false,
1546+
preferences: { privacyMode: true },
15441547
securityAlertsEnabled: true,
15451548
names: {
15461549
ethereumAddress: {},
@@ -1604,6 +1607,7 @@ describe('MetaMetricsController', function () {
16041607
allNfts: {},
16051608
participateInMetaMetrics: true,
16061609
dataCollectionForMarketing: false,
1610+
preferences: { privacyMode: true },
16071611
securityAlertsEnabled: true,
16081612
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
16091613
custodyAccountDetails: {},
@@ -1668,6 +1672,7 @@ describe('MetaMetricsController', function () {
16681672
},
16691673
participateInMetaMetrics: true,
16701674
dataCollectionForMarketing: false,
1675+
preferences: { privacyMode: true },
16711676
securityAlertsEnabled: true,
16721677
security_providers: ['blockaid'],
16731678
currentCurrency: 'usd',
@@ -1713,6 +1718,7 @@ describe('MetaMetricsController', function () {
17131718
allNfts: {},
17141719
participateInMetaMetrics: true,
17151720
dataCollectionForMarketing: false,
1721+
preferences: { privacyMode: true },
17161722
names: {
17171723
ethereumAddress: {},
17181724
},

app/scripts/controllers/metametrics-controller.ts

+5
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ export type MetaMaskState = {
164164
security_providers: string[];
165165
addressBook: AddressBookControllerState['addressBook'];
166166
currentCurrency: string;
167+
preferences: {
168+
privacyMode: PreferencesControllerState['preferences']['privacyMode'];
169+
};
167170
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
168171
custodyAccountDetails: {
169172
[address: string]: {
@@ -1228,6 +1231,8 @@ export default class MetaMetricsController extends BaseController<
12281231
metamaskState.dataCollectionForMarketing,
12291232
[MetaMetricsUserTrait.TokenSortPreference]:
12301233
metamaskState.tokenSortConfig?.key || '',
1234+
[MetaMetricsUserTrait.PrivacyModeEnabled]:
1235+
metamaskState.preferences.privacyMode,
12311236
};
12321237

12331238
if (!previousUserTraits) {

shared/constants/metametrics.ts

+4
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,10 @@ export enum MetaMetricsUserTrait {
590590
* Identified when the user changes token sort order on asset-list
591591
*/
592592
TokenSortPreference = 'token_sort_preference',
593+
/**
594+
* Identifies if the Privacy Mode is enabled
595+
*/
596+
PrivacyModeEnabled = 'privacy_mode_toggle',
593597
}
594598

595599
/**

0 commit comments

Comments
 (0)