fix: cp-7.44.0 Update traits when tracked settings change 2/2#14088
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
There was a problem hiding this comment.
Pull Request Overview
This pull request updates how NFT-related traits are tracked when display settings change by leveraging the useMetrics hook across various components.
- Introduces additional metrics tracking by adding traits when users enable or disable NFT display and auto-detection.
- Updates trait objects in multiple views to reflect the new behavior for enabling/disabling the OpenSea API and auto-detection.
- Adjusts callback implementations to include these metric updates.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| app/components/Views/ShowDisplayMediaNFTSheet/ShowDisplayNFTMediaSheet.tsx | Imports metrics types/hooks and updates the confirm callback to add NFT display trait. |
| app/components/Views/Settings/DisplayNFTMediaSettings/index.tsx | Updates the setting toggle to conditionally include the OpenSea API trait along with NFT auto-detection. |
| app/components/Views/NFTAutoDetectionModal/NFTAutoDetectionModal.tsx | Incorporates metrics addition in the auto-detection modal when enabling NFT auto-detection. |
| app/components/Views/Settings/AutoDetectNFTSettings/index.tsx | Constructs trait objects reflecting state changes for both NFT auto-detection and OpenSea API. |
| app/components/UI/CollectibleDetectionModal/index.tsx | Adds a metrics trait update to the collectible detection modal alongside NFT detection status. |
Comments suppressed due to low confidence (2)
app/components/Views/ShowDisplayMediaNFTSheet/ShowDisplayNFTMediaSheet.tsx:22
- [nitpick] The component name 'ShowDisplayNftMediaSheet' inconsistently capitalizes 'NFT' relative to the filename. Consider renaming it to 'ShowDisplayNFTMediaSheet' for consistency.
const ShowDisplayNftMediaSheet = () => {
app/components/UI/CollectibleDetectionModal/index.tsx:39
- [nitpick] The function name 'showToastAndEnableNFtDetection' has inconsistent casing ('NFt' instead of 'NFT'). Consider renaming it to 'showToastAndEnableNFTDetection' for clarity.
const showToastAndEnableNFtDetection = useCallback(async () => {
Must be true/false different than identify ON/OFF
|
…-mobile into fix/2150_update_traits
…-mobile into fix/2150_update_traits
|
|



Description
This PR allows to instantly update user traits used in
app/util/metrics/UserSettingsAnalyticsMetaData/generateUserProfileAnalyticsMetaData.tswhen a property used in the traits is changed.This prevents having to wait for user to background/foreground the app to have the metrics profile updated.
Updated traits are:
Note
THEME can be updated only on app foregrounding as it requires to go on system settings to change, forcing app background then foreground. We already have this on app state listener. So no code change, but we still have manual test process in this PR.
Out of scope:
What was updated
Related issues
Fixes https://github.com/MetaMask/mobile-planning/issues/2150
Manual testing steps
Start testing with a fully onboarded app with user optin for metrics.
Testing ENABLE_OPENSEA_API and NFT_AUTODETECTION
Display NFT Media
Note
There's no track event here, no event defined for this and this may be something product could be interested in adding in the future, but for now, no track.
Important
Initial state should be both switches to ON for the test (change if needed).
Both ON is the expected state after a regular onboarding
Switch Display NFT Media to OFF
Switch Display NFT Media to ON
Autodetect NFT
Important
Initial state should be both switches to ON for the test (change if needed).
Both ON is the expected state after a regular onboarding
Switch Autodetect NFT to OFF
Switch Autodetect NFT to ON
Switch Autodetect NFT to ON when Display NFT Media is OFF
Testing THEME
Testing TOKEN_DETECTION
Note
There's no track event here, no event defined for this and this may be something product could be interested in adding in the future, but for now, no track.
Important
Initial state should be ON for the test (change if needed).
ON is the expected state after a regular onboarding
Switch Autodetect tokens to OFF
Switch Autodetect tokens to ON
Testing MULTI_ACCOUNT_BALANCE
Note
There's no track event here, no event defined for this and this may be something product could be interested in adding in the future, but for now, no track.
Important
Initial state should be ON for the test (change if needed).
ON is the expected state after a regular onboarding
Switch Batch account balance requests to OFF
Switch Batch account balance requests to ON
Testing SECURITY_PROVIDERS
Important
Initial state should be ON for the test (change if needed).
ON is the expected state after a regular onboarding
Switch Security alerts to OFF
Switch Security alerts to ON
Important
Track event has been added to this change to ON.
It was not fired and code was very non optimal.
So now we should have the Settings Updated to true in our metrics when it was not there before.
Screenshots/Recordings
Before
Unchanged, see screenshots in tests above
After
Unchanged, see screenshots in tests above
Pre-merge author checklist
Pre-merge reviewer checklist