Skip to content

chore(homepage): add homepage section viewed segment event#26529

Merged
vinnyhoward merged 22 commits intomainfrom
feat-tmcu-465-homepage-section-viewed-segment-event
Mar 5, 2026
Merged

chore(homepage): add homepage section viewed segment event#26529
vinnyhoward merged 22 commits intomainfrom
feat-tmcu-465-homepage-section-viewed-segment-event

Conversation

@vinnyhoward
Copy link
Contributor

@vinnyhoward vinnyhoward commented Feb 24, 2026

Description

Implements the Homepage Section Viewed Segment event for the redesigned homepage. The new homepage renders content as stacked sections (Tokens, Perps, Predictions, DeFi, NFTs) rather than the old tab view, and product requires visibility tracking for each section.

What changed:

  • Added HOMEPAGE_SECTION_VIEWED1 ('Homepage Viewed') to MetaMetrics.events.ts`
  • Created HomepageScrollContext — bridges scroll position from the parent ScrollView in Wallet down to section components via a subscription pattern (ref-based, no React state updates on scroll to avoid re-renders)
  • Created useHomepageSectionViewedEvent hook — uses measureInWindow() to detect 50% viewport visibility, fires once per homepage visit, resets on each focus via visitId
  • Updated Wallet/index.tsx to provide scroll context, viewport height, and entry_point detection (app_opened, home_tab, navigated_back)
  • Updated Homepage.tsx to compute per-section indices based on enabled feature flags
  • Integrated the hook into all 5 section components (Tokens, Perps, Predictions, DeFi, NFTs)

Segment Event PR: https://github.com/Consensys/segment-schema/pull/477

Changelog

CHANGELOG entry: null

Related issues

Fixes: TMCU-465

Manual testing steps

Feature: Homepage Section Viewed event

  Scenario: user opens the app with homepage sections enabled
    Given the isHomepageSectionsV1Enabled feature flag is enabled
    And the user opens the app fresh

    When the homepage loads
    Then a "Homepage Viewed" event fires for each visible section
    And each event has entry_point: "app_opened"
    And each event has the correct index and total_sections_loaded

  Scenario: user scrolls to a section below the fold
    Given the homepage is loaded
    And a section is not yet in the viewport

    When the user scrolls until 50% of the section is visible
    Then a "Homepage Viewed" event fires for that section
    And it does not fire again on the same visit

  Scenario: user navigates away and returns via back gesture
    Given the user previously viewed the homepage
    When the user navigates back to the homepage
    Then all section events re-fire with entry_point: "navigated_back"

  Scenario: user switches to the home tab
    Given the user is on another tab
    When the user taps the home tab
    Then all section events re-fire with entry_point: "home_tab"

  Scenario: DeFi section is empty or disabled
    Given the user has no DeFi positions or the DeFi flag is disabled
    When the homepage loads
    Then a "Homepage Viewed" event fires for DeFi with is_empty: true and item_count: 0

Screenshots/Recordings

App Opened

app_opened.mov

Navigated Back

navigated_back.mov

Home Tab

home_tab.mov

Before

~

After

~

Pre-merge author checklist

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.

Note

Medium Risk
Adds new scroll-driven analytics instrumentation to Wallet/homepage sections, which can affect event firing accuracy and scroll performance if mis-measured or over-triggered. Changes are mostly additive but touch the main wallet screen render/scroll path and multiple section components/tests.

Overview
Implements a new MetaMetricsEvents.HOME_VIEWED Segment event for the redesigned homepage, fired when a section reaches ≥50% viewport visibility and re-fired on each homepage visit with an entry_point.

Adds HomepageScrollContext + useHomepageEntryPoint to provide scroll/viewport measurements, a throttled scroll subscription mechanism (no re-renders on scroll), and per-visit visitId from Wallet.

Updates Homepage and all section components (Tokens/Perps/Predict/DeFi/NFTs) to compute feature-flag-aware sectionIndex/totalSectionsLoaded, wrap content with measurable View refs, and call useHomeViewedEvent with loading/empty/itemCount semantics; tests are expanded/adjusted accordingly (plus a small Date.now restore in BridgeView tests for debounce reliability).

Written by Cursor Bugbot for commit 8c6d3ad. This will update automatically on new commits. Configure here.

@vinnyhoward vinnyhoward requested a review from a team as a code owner February 24, 2026 23:32
@vinnyhoward vinnyhoward added team-mobile-ux Mobile UX team team-perps Perps team labels Feb 24, 2026
@github-actions
Copy link
Contributor

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.

@vinnyhoward vinnyhoward requested a review from a team as a code owner February 25, 2026 04:52
…tmcu-465-homepage-section-viewed-segment-event
@vinnyhoward vinnyhoward changed the title chore: add Homepage Section Viewed segment event chore: add homepage section viewed segment event Feb 26, 2026
* In the `useFocusEffect` cleanup (blur), walk up the navigator tree and record
* the Tab navigator's active-tab index. After a tab-press the Tab state has
* already updated to the new tab's index (≠ 0 for Home); after a back-navigation
* or modal dismiss within the Home tab the index stays 0.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hook determines why the Homepage gained focus on each visit

  • APP_OPENED
  • HOME_TAB
  • NAVIGATED_BACK
    by snapshotting the Tab navigator's active-tab index on blur and comparing it on the next focus.

gambinish
gambinish previously approved these changes Feb 26, 2026
@vinnyhoward vinnyhoward changed the title chore: add homepage section viewed segment event chore(homepage): add homepage section viewed segment event Feb 26, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeWalletPlatform, SmokePerps, SmokePredictions
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 82%
click to see 🤖 AI reasoning details

E2E Test Selection:
This PR adds a new "Home Viewed" analytics event that tracks when users view different sections of the redesigned Homepage. The changes include:

  1. New Analytics Infrastructure:

    • Added HOME_VIEWED event to MetaMetrics.events.ts
    • New HomepageScrollContext for tracking scroll position and entry point
    • New useHomeViewedEvent hook that fires analytics when sections become ≥50% visible
    • New useHomepageEntryPoint hook to track how users arrived at the homepage
  2. Core Wallet/Homepage Changes:

    • Wallet/index.tsx - Added scroll tracking, viewport measurement, and HomepageScrollContext provider
    • Homepage.tsx - Now computes enabled sections and passes sectionIndex/totalSectionsLoaded to each section
  3. Section Updates (all sections now integrate useHomeViewedEvent):

    • TokensSection, PerpsSection, PredictionsSection, DeFiSection, NFTsSection

Tag Selection Rationale:

  • SmokeWalletPlatform: Required because the Wallet/index.tsx and Homepage.tsx are core wallet platform components. The Trending tab and homepage sections (Perps, Predictions, Tokens) are all part of this tag's coverage. Changes to scroll handling and context providers could affect navigation and display.
  • SmokePerps: Required because PerpsSection.tsx has significant changes including new props, View refs, and useHomeViewedEvent integration. Per tag description, changes to Perps views affect Trending (SmokeWalletPlatform).
  • SmokePredictions: Required because PredictionsSection.tsx has significant changes including new props, View refs, and useHomeViewedEvent integration. Per tag description, changes to Predictions views affect Trending (SmokeWalletPlatform).

The changes are primarily analytics-focused and don't modify core business logic, but they do add new state management (scroll context), refs, and props to multiple components. The risk is medium because while the changes are additive (analytics tracking), they touch the core wallet view and multiple feature sections.

Performance Test Selection:
The changes are primarily focused on analytics event tracking (Home Viewed event) and scroll-based visibility detection. While the changes add new state management (scroll context, viewport measurements) and refs to components, they are designed to be performance-conscious: the scroll subscription pattern explicitly avoids React state updates during scrolling to prevent re-renders, and visibility checks are throttled (100ms). The changes don't affect: UI rendering performance, data loading patterns, list rendering, app startup, or critical user flows. The analytics events fire asynchronously and don't block UI. No performance tests are needed.

View GitHub Actions results

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

⚠️ E2E Fixture Validation — Structural changes detected

Category Count
New keys 68
Missing keys 11
Type mismatches 0
Value mismatches 7 (informational)

The committed fixture schema is out of date. To update, comment:

@metamaskbot update-mobile-fixture

View full details | Download diff report

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 5, 2026

@vinnyhoward vinnyhoward added this pull request to the merge queue Mar 5, 2026
Merged via the queue into main with commit 7631621 Mar 5, 2026
92 of 93 checks passed
@vinnyhoward vinnyhoward deleted the feat-tmcu-465-homepage-section-viewed-segment-event branch March 5, 2026 11:40
@github-actions github-actions bot locked and limited conversation to collaborators Mar 5, 2026
@metamaskbot metamaskbot added the release-7.69.0 Issue or pull request that will be included in release 7.69.0 label Mar 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.69.0 Issue or pull request that will be included in release 7.69.0 size-XL team-mobile-ux Mobile UX team team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants