fix(analytics): fix user traits types violations#27461
fix(analytics): fix user traits types violations#27461anzzyspeaksgit wants to merge 1 commit intoMetaMask:mainfrom
Conversation
Closes MetaMask#23970 Updates the following traits to comply with Segment's analytics schema definitions: - `traits.security_providers`: Expected an array, was previously providing a string. Updated to return `['blockaid']` or `[]` - `traits.has_marketing_consent`: Expected a boolean, was previously providing a string representation `UserProfileProperty.ON` or `UserProfileProperty.OFF`. Updated to explicitly return `Boolean(isDataCollectionForMarketingEnabled)` Tests were also updated to verify these strict type definitions. AI Disclosure: This PR was generated autonomously by anzzyspeaksgit.
|
CLA Signature Action: Thank you for your submission, we really appreciate it. We ask that you read and sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just by adding a comment to this pull request with this exact sentence:
By commenting with the above message you are agreeing to the terms of the CLA. Your account will be recorded as agreeing to our CLA so you don't need to sign it again for future contributions to this repository. 0 out of 1 committers have signed the CLA. |
| [UserProfileProperty.SECURITY_PROVIDERS]: 'blockaid', | ||
| [UserProfileProperty.HAS_MARKETING_CONSENT]: UserProfileProperty.ON, | ||
| [UserProfileProperty.SECURITY_PROVIDERS]: ['blockaid'], | ||
| [UserProfileProperty.HAS_MARKETING_CONSENT]: true, |
There was a problem hiding this comment.
Marketing consent test expects stale ON/OFF string values
High Severity
The parameterized test at line 82 still expects UserProfileProperty.ON ('ON') and UserProfileProperty.OFF ('OFF') as the marketing consent values, but the implementation now returns Boolean(isDataCollectionForMarketingEnabled) — i.e. true / false. The test parameters need to be [true, true] and [false, false] instead of [UserProfileProperty.ON, true] and [UserProfileProperty.OFF, false]. This test will fail as-is.
| [UserProfileProperty.SECURITY_PROVIDERS]: 'blockaid', | ||
| [UserProfileProperty.HAS_MARKETING_CONSENT]: UserProfileProperty.ON, | ||
| [UserProfileProperty.SECURITY_PROVIDERS]: ['blockaid'], | ||
| [UserProfileProperty.HAS_MARKETING_CONSENT]: true, |
There was a problem hiding this comment.
Missing test update for empty security providers array
Medium Severity
The "missing preferences controller" test still expects '' (empty string) for SECURITY_PROVIDERS, but the implementation now returns [] (empty array) when securityAlertsEnabled is falsy. This assertion will fail because toMatchObject checks deep equality and '' !== [].


Description
Fixes #23970
Addresses a Segment schema violation occurring during
identifycalls where certain user traits were being assigned incorrect types.Changes
traits.security_providers: Updated to return an array (['blockaid']or[]) instead of a string to conform to the expectedarraytype constraint.traits.has_marketing_consent: Updated to explicitly return aboolean(Boolean(isDataCollectionForMarketingEnabled)) rather than a string representation (UserProfileProperty.ONorUserProfileProperty.OFF).generateUserProfileAnalyticsMetaData.test.tsto reflect these typing changes.🤖 Generated by anzzyspeaksgit (Autonomous AI OSS Contributor)
Note
Low Risk
Low risk type/shape changes to analytics identify traits; main risk is downstream consumers expecting the previous string values for
security_providersorhas_marketing_consent.Overview
Fixes Segment
identifytrait type violations by changinggenerateUserProfileAnalyticsMetaDatato emitsecurity_providersas an array (e.g.,['blockaid']/[]) instead of a string, andhas_marketing_consentas a boolean instead ofON/OFF.Updates the corresponding unit test expectation for these traits to match the new shapes.
Written by Cursor Bugbot for commit 84cc92a. This will update automatically on new commits. Configure here.