chore(homepage): homepage session summary segment event#26634
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. |
7ef7d6c to
6c1270c
Compare
There was a problem hiding this comment.
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.
| // Reset viewed sections on each new visit so session summary starts fresh. | ||
| useEffect(() => { | ||
| viewedSectionsRef.current.clear(); | ||
| }, [visitId]); |
There was a problem hiding this comment.
Race condition: non-rendered sections never counted in summary
Low Severity
Non-rendered sections (e.g. DeFi with no positions, where sectionRef is null) call notifySectionViewed synchronously inside a child useEffect triggered by visitId. The parent useEffect in Wallet that calls viewedSectionsRef.current.clear() is triggered by the same visitId change but runs after child effects (React's bottom-up effect ordering). This silently erases any sections added by the child, so non-rendered sections fire a section_viewed event but are never reflected in the session summary's total_sections_viewed, creating inconsistent analytics data.
Additional Locations (1)
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
These changes:
Since the changes touch the Wallet view and Homepage components (core wallet platform areas), selecting SmokeWalletPlatform provides basic validation that the wallet home screen still functions correctly. The risk is low because the changes are additive analytics code that doesn't modify existing functionality. Performance Test Selection: |
The committed fixture schema is out of date. To update, comment: |
|





Description
Adds a
session_summaryanalytics event that fires when a user navigates away from the homepage. This completes the homepage sections analytics suite alongside the existingsection_viewedevent.The event reuses the
HOMEPAGE_SECTION_VIEWEDSegment event withinteraction_type: 'session_summary'and captures:total_sections_viewed— how many sections reached ≥50% visibility this visittotal_sections_loaded— how many sections were enabled via feature flagsentry_point— how the user arrived (app_opened, home_tab, navigated_back)session_time— seconds spent on the homepagelocation: 'home'
Implementation details:
useHomepageSessionSummaryhook owns all session tracking. All state lives in refs — zero re-renders on scroll or blur path.useHomepageEntryPointto detect focus and reset per-visit state.notifySectionViewedadded toHomepageScrollContextso sections self-report views when theirsection_viewedevent fires.Segment Event PR: https://github.com/Consensys/segment-schema/pull/477
This PR needs to be merged first before review: #26529
Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
session.mov
Before
~After
~Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Adds new analytics firing on homepage blur and expands
HomepageScrollContextcontract, which could affect event volume/accuracy if focus/visit tracking is wrong. Runtime risk is limited since it uses refs/sets and doesn’t change wallet transaction or account logic.Overview
Adds a new homepage session summary analytics emission:
useHomeSessionSummaryfiresMetaMetricsEvents.HOME_VIEWEDwithinteraction_type: 'session_summary'when the homepage blurs, includingsession_time,entry_point,total_sections_loaded, andtotal_sections_viewed.Extends
HomepageScrollContextwithnotifySectionViewed/getViewedSectionCount;Walletnow tracks distinct viewed sections pervisitIdin a ref-backedSet, anduseHomeViewedEventreports section views into this aggregator. Includes new unit tests for the session-summary hook and updates existing section-view tests for the new context fields.Written by Cursor Bugbot for commit d91715f. This will update automatically on new commits. Configure here.