Skip to content

Commit 7e7fe22

Browse files
refactor(perps): differentiate screen_type for perps screen viewed events (MetaMask#24308)
## **Description** Previously, both `PerpsTabView` (the Perps tab on wallet home screen) and `PerpsHomeView` (the dedicated Perps home screen) were using the same `screen_type` value (`homescreen`) for `PERPS_SCREEN_VIEWED` analytics events. This made it impossible to distinguish between the two screens in analytics dashboards. This PR introduces two distinct screen type values: - `wallet_home_perps_tab` - Used when viewing the Perps tab within the wallet home screen - `perps_home` - Used when viewing the full dedicated Perps home screen The legacy `HOMESCREEN` value is preserved with a comment indicating it should not be used for new implementations. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/TAT-1835 ## **Manual testing steps** ```gherkin Feature: Perps screen analytics differentiation Scenario: user views Perps tab on wallet home Given user is on the wallet home screen When user taps on the Perps tab Then PERPS_SCREEN_VIEWED event is fired with screen_type: "wallet_home_perps_tab" Scenario: user navigates to Perps home screen Given user is on any screen in the app When user navigates to the Perps home screen (via manage balance or navigation) Then PERPS_SCREEN_VIEWED event is fired with screen_type: "perps_home" ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** N/A ### **After** N/A ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Separates analytics tracking to uniquely identify Perps views across app surfaces. > > - Updates `PerpsTabView` to emit `PERPS_SCREEN_VIEWED` with `screen_type` `wallet_home_perps_tab` > - Updates `PerpsHomeView` to emit `PERPS_SCREEN_VIEWED` with `screen_type` `perps_home` > - Extends `constants/eventNames.ts` with `WALLET_HOME_PERPS_TAB` and `PERPS_HOME`; marks `HOMESCREEN` as legacy > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit a3fbd97. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent bcf7c34 commit 7e7fe22

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

app/components/UI/Perps/Views/PerpsHomeView/PerpsHomeView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ const PerpsHomeView = () => {
178178
conditions: [!isAnyLoading],
179179
properties: {
180180
[PerpsEventProperties.SCREEN_TYPE]:
181-
PerpsEventValues.SCREEN_TYPE.HOMESCREEN,
181+
PerpsEventValues.SCREEN_TYPE.PERPS_HOME,
182182
[PerpsEventProperties.SOURCE]: source,
183183
[PerpsEventProperties.HAS_PERP_BALANCE]: hasPerpBalance,
184184
...(buttonClicked && {

app/components/UI/Perps/Views/PerpsTabView/PerpsTabView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const PerpsTabView: React.FC<PerpsTabViewProps> = () => {
9292
],
9393
properties: {
9494
[PerpsEventProperties.SCREEN_TYPE]:
95-
PerpsEventValues.SCREEN_TYPE.HOMESCREEN,
95+
PerpsEventValues.SCREEN_TYPE.WALLET_HOME_PERPS_TAB,
9696
[PerpsEventProperties.OPEN_POSITION]: positions?.length || 0,
9797
},
9898
});

app/components/UI/Perps/constants/eventNames.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ export const PerpsEventValues = {
245245
MARKET_LIST: 'market_list',
246246
ASSET_DETAILS: 'asset_details',
247247
TRADING: 'trading',
248-
HOMESCREEN: 'homescreen',
248+
HOMESCREEN: 'homescreen', // Legacy - use WALLET_HOME_PERPS_TAB or PERPS_HOME instead
249+
WALLET_HOME_PERPS_TAB: 'wallet_home_perps_tab',
250+
PERPS_HOME: 'perps_home',
249251
POSITION_CLOSE: 'position_close',
250252
LEVERAGE: 'leverage',
251253
TUTORIAL: 'tutorial',

0 commit comments

Comments
 (0)