Skip to content

feat: implement Homepage Perps pills empty state AB test logic and analytics#30246

Open
PatrykLucka wants to merge 2 commits into
TMCU-725-a-b-test-implement-perps-pills-on-homepage-empty-statefrom
TMCU-727-segment-track-homepage-perps-pills-exposure-and-conversion
Open

feat: implement Homepage Perps pills empty state AB test logic and analytics#30246
PatrykLucka wants to merge 2 commits into
TMCU-725-a-b-test-implement-perps-pills-on-homepage-empty-statefrom
TMCU-727-segment-track-homepage-perps-pills-exposure-and-conversion

Conversation

@PatrykLucka
Copy link
Copy Markdown
Contributor

@PatrykLucka PatrykLucka commented May 15, 2026

Description

Base branch: TMCU-725 (homepage Perps empty-state / pills work already on that branch).

This PR adds A/B analytics and attribution for the homepage Perps pills empty-state experiment—reusing existing events (Home Viewed, Perp UI Interaction, existing perps transaction pipeline)—no new event names.

  • abTestConfig: HOMEPAGE_PERPS_PILLS_AB_EXPOSED_ANALYTICS_PROPERTY, shared HOMEPAGE_PERPS_PILLS_EMPTY_AB_TEST_EXPOSURE_OPTIONS, getHomepagePerpsPillsEmptyTransactionActiveAbTests(), and two ABTestAnalyticsMapping entries for the same LD key (homeTMCU725AbtestHomepagePerpsPillsEmptyState): one for Home Viewed, one for Perp UI Interaction, each gated with injectWhenPropertiesMatch so active_ab_tests is only injected on the empty homepage perps surface (avoids pulling HomeSectionNames into abTestConfig to prevent circular imports with analytics).
  • enrichWithABTests / types / registry: optional injectWhenPropertiesMatch; registry registers both mappings.
  • mergeActiveAbTestAssignmentLists in activeABTestAssignments.ts: merge + de-dupe by key for transaction payloads.
  • useHomeViewedEvent: optional additionalProperties merged into HOME_VIEWED (used to set the exposure gate flag when appropriate).
  • PerpsSection: After hasItems is known, wires useHomepageTrendingTransactionActiveAbTests + useHomepagePerpsPillsEmptyTransactionActiveAbTests(!hasItems) into usePerpsNavigationHandlers via merged transactionActiveAbTests on market details navigation from empty carousel tiles; empty carousel uses handleTrendingMarketPress to emit Perp UI Interaction with WALLET_HOME + homepage_perps_pills_ab_exposed: true; HOME_VIEWED gets additionalProperties when section_name === perps and !hasItems. Trending-only mode: drops isDedicatedTrendingSection and passes only trending tx tests (merge still works).
  • HomepagePerpsMoversSection: Same exposure property on pill tap + useHomeViewedEvent additionalProperties for default perps section; merges trending + pills tx tests and passes them to PerpsPillItem.
  • HomepagePerpsHomeSlot: useABTest now uses HOMEPAGE_PERPS_PILLS_EMPTY_AB_TEST_EXPOSURE_OPTIONS from config (DRY).
  • PerpsPillItem: optional transactionActiveAbTests forwarded into market-details route params.

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: Homepage Perps pills experiment — analytics only
  Scenario: Home Viewed exposes active_ab_tests only on empty perps surface
    Given LaunchDarkly returns a valid variant for `homeTMCU725AbtestHomepagePerpsPillsEmptyState`
      And the user has no open perps positions/orders on the homepage Perps section (section_name `perps`)
    When the Perps section fires Home Viewed with `homepage_perps_pills_ab_exposed` true
    Then the tracked event includes `active_ab_tests` containing the TMCU-725 flag key after enrichment (e.g. Segment debugger)
  Scenario: Home Viewed does not gate exposure when user has positions
    Given the user has at least one position or qualifying order in the homepage Perps section
    When Home Viewed fires for that impression
    Then `homepage_perps_pills_ab_exposed` is not set for the main perps empty-surface path
      And active_ab_tests is not injected for this experiment via the Home Viewed mapping
  Scenario: Control empty carousel tile tap emits Perp UI Interaction with exposure flag
    Given control or empty carousel path with no positions
    When the user taps a trending market tile in the homepage Perps carousel
    Then Perp UI Interaction includes BUTTON_LOCATION WALLET_HOME and `homepage_perps_pills_ab_exposed` true
      And active_ab_tests includes the experiment on that event when enriched
  Scenario: Treatment pill tap and navigation carry merged transaction AB tests
    Given treatment shows Homepage Perps Movers pills
    When the user taps a pill and navigates to market details
    Then navigation params include merged `transactionActiveAbTests` when trending and/or perps-pills hooks supply entries

Screenshots/Recordings

Before

After

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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
Moderate risk because it changes analytics enrichment rules and propagates A/B assignment metadata through perps navigation, which could affect event payloads and downstream attribution if gated incorrectly.

Overview
Adds gated A/B exposure + attribution for the homepage Perps empty-state pills experiment, including a new homepage_perps_pills_ab_exposed property used to conditionally inject active_ab_tests on Home Viewed and Perp UI Interaction events.

Updates homepage Perps surfaces (PerpsSection, HomepagePerpsMoversSection, HomepagePerpsHomeSlot) to tag the relevant events, merge/de-dupe multiple transactionActiveAbTests sources, and pass those assignments through to market-details navigation (including new support in PerpsPillItem).

Extends the analytics enrichment framework with injectWhenPropertiesMatch gating and adds coverage/tests for the new gating behavior and perps empty-surface assignment hook.

Reviewed by Cursor Bugbot for commit b8efec8. Bugbot is set up for automated code reviews on this repo. Configure here.

@PatrykLucka PatrykLucka self-assigned this May 15, 2026
@github-actions
Copy link
Copy Markdown
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.

@metamaskbotv2 metamaskbotv2 Bot added the team-mobile-ux Mobile UX team label May 15, 2026
@PatrykLucka PatrykLucka marked this pull request as ready for review May 15, 2026 13:06
@PatrykLucka PatrykLucka requested review from a team as code owners May 15, 2026 13:06
Copy link
Copy Markdown
Contributor

@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.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit 0c80a46. Configure here.

Comment thread app/components/Views/Homepage/Sections/Perpetuals/PerpsSection.tsx Outdated
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: @PerformancePreps
  • Risk Level: medium
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
Changes are concentrated in the Perpetuals (Perps) UI within the Homepage and Trending sections, including PerpsSection, HomepagePerpsHomeSlot, PerpsPillItem, related hooks, and A/B test analytics enrichment utilities. These directly impact the Perps entry points and display logic embedded inside the Trending tab.

SmokePerps is required because it validates the Perps trading flows (including Add Funds deposit and balance updates) and ensures that UI changes in Perps surfaces do not break trading entry points or state handling.

Per tag requirements, selecting SmokePerps also requires:

  • SmokeWalletPlatform (Perps is embedded in the Trending tab; UI/header/list changes in Perps sections affect Trending navigation and rendering).
  • SmokeConfirmations (Perps Add Funds flow triggers on-chain deposit confirmations).

No changes were made to controllers, Engine, network abstractions, identity/sync, swaps, stake, money, browser, or onboarding flows, so other tags are not necessary.

Risk is medium: changes affect user-facing UI components and analytics enrichment logic tied to A/B tests, which can influence rendering and conditional display of Perps content, but do not modify core transaction, controller, or network logic.

Performance Test Selection:
UI and feed-related changes in Perps sections (Homepage and Trending feeds) can affect rendering performance, market list loading, and Perps entry responsiveness. Running @PerformancePreps ensures no regressions in Perps market loading, add funds flow timing, or overall trading interface responsiveness. No broader asset loading or onboarding performance impact is expected.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant