Skip to content

Conversation

@andrepimenta
Copy link
Member

@andrepimenta andrepimenta commented Nov 13, 2025

Predict: Entry Point Tracking & User Trait Implementation

Overview

This PR implements comprehensive entry point tracking for the Predict feature and adds a persistent user trait for Polymarket account creation. These changes enable better analytics attribution and user segmentation across all Predict interactions.

CHANGELOG entry: null

Changes

1. User Trait for Polymarket Account Creation

Added persistent user trait to track Polymarket account creation via MetaMask:

  • New Property: CREATED_POLYMARKET_ACCOUNT_VIA_MM
  • Type: boolean
  • Location: Set directly in PolymarketProvider.prepareDeposit() when deployment transaction is included
  • Persistence: Automatically attached to all future analytics events for the user

Benefits:

  • ✅ Enables cohort analysis (users with vs without Polymarket accounts)
  • ✅ Tracks conversion funnel from MetaMask user → Polymarket account creator
  • ✅ Attribution analysis for acquisition channels driving account creation
  • ✅ Long-term retention analysis for users who created accounts via MetaMask

Files Changed:

  • app/util/metrics/UserSettingsAnalyticsMetaData/UserProfileAnalyticsMetaData.types.ts
  • app/components/UI/Predict/providers/polymarket/PolymarketProvider.ts

2. Deeplink Origin Parameter Handling

Fixed deeplink manager to correctly pass origin parameter to Predict navigation:

  • Issue: Carousel banner clicks were not being tracked as carousel entry point
  • Solution: Updated deeplink flow to pass origin through entire chain and map directly to entryPoint
  • Mapping: origin === 'carousel'entryPoint: 'carousel', otherwise → entryPoint: 'deeplink'

Files Changed:

  • app/core/DeeplinkManager/DeeplinkManager.ts
  • app/core/DeeplinkManager/ParseManager/handleUniversalLink.ts
  • app/core/DeeplinkManager/Handlers/handlePredictUrl.ts

3. Comprehensive Entry Point Tracking

Added missing entryPoint parameters across all Predict navigation paths:

New Entry Point Constants

CAROUSEL: 'carousel',        // Wallet carousel banner
REWARDS: 'rewards',          // Rewards ways to earn CTA
GTM_MODAL: 'gtm_modal',      // What's New modal

Navigation Paths Updated

Component Entry Point Trigger
PredictPositionsHeader homepage_balance Balance card touch
PredictPositionEmpty homepage_positions Empty positions "Explore" button
PredictNewButton homepage_new_prediction New prediction button
PredictGTMModal gtm_modal What's New modal "Get Started"
TradeWalletActions main_trade_button Wallet actions predict button
WalletActions main_trade_button Bottom sheet predict action
WaysToEarn (Rewards) rewards Rewards predict CTA
PredictionSection homepage_new_prediction Trending view "View all"

Files Changed:

  • app/components/UI/Predict/constants/eventNames.ts
  • app/components/UI/Predict/components/PredictPositionsHeader/PredictPositionsHeader.tsx
  • app/components/UI/Predict/components/PredictPositionEmpty/PredictPositionEmpty.tsx
  • app/components/UI/Predict/components/PredictNewButton/PredictNewButton.tsx
  • app/components/UI/Predict/components/PredictGTMModal/PredictGTMModal.tsx
  • app/components/Views/TradeWalletActions/TradeWalletActions.tsx
  • app/components/Views/WalletActions/WalletActions.tsx
  • app/components/UI/Rewards/components/Tabs/OverviewTab/WaysToEarn/WaysToEarn.tsx
  • app/components/Views/TrendingView/PredictionSection/PredictionSection.tsx

4. Test Updates

Updated all tests to expect entryPoint parameters:

  • Fixed handleUniversalLink.test.ts to expect origin parameter in _handlePredict calls
  • Updated 9 component tests to expect entryPoint in navigation assertions
  • All tests use expect.any(String) for flexibility while ensuring parameter presence

Test Files Changed:

  • app/core/DeeplinkManager/ParseManager/handleUniversalLink.test.ts
  • app/core/DeeplinkManager/Handlers/handlePredictUrl.test.ts
  • app/components/UI/Predict/components/PredictPositionsHeader/PredictPositionsHeader.test.tsx
  • app/components/UI/Predict/components/PredictPositionEmpty/PredictPositionEmpty.test.tsx
  • app/components/UI/Predict/components/PredictNewButton/PredictNewButton.test.tsx
  • app/components/UI/Predict/components/PredictGTMModal/PredictGTMModal.test.tsx
  • app/components/Views/TradeWalletActions/TradeWalletActions.test.tsx
  • app/components/Views/WalletActions/WalletActions.test.tsx
  • app/components/UI/Rewards/components/Tabs/OverviewTab/WaysToEarn/WaysToEarn.test.tsx
  • app/components/Views/TrendingView/PredictionSection/PredictionSection.test.tsx

Analytics Impact

Entry Point Coverage

All user journeys to Predict now include proper entry_point attribution:

  • ✅ Carousel/banner clicks
  • ✅ Homepage interactions (balance, positions, new prediction button)
  • ✅ Main trade button
  • ✅ Rewards integration
  • ✅ What's New modal
  • ✅ Deeplinks (notification, carousel, generic)

User Trait Usage

The created_polymarket_account_via_mm trait will be automatically included in:

  • All Predict analytics events
  • All MetaMask analytics events
  • Segment user profiles
  • Allows filtering/segmentation in any analytics tool

Testing

Unit Tests

# All deeplink tests passing
yarn jest handleUniversalLink.test.ts  # 55 tests ✅
yarn jest handlePredictUrl.test.ts     # 30 tests ✅

# All component tests passing
yarn jest PredictPositionsHeader.test.tsx
yarn jest PredictPositionEmpty.test.tsx
yarn jest PredictNewButton.test.tsx
yarn jest PredictGTMModal.test.tsx
yarn jest TradeWalletActions.test.tsx
yarn jest WalletActions.test.tsx
yarn jest WaysToEarn.test.tsx
yarn jest PredictionSection.test.tsx

Manual Testing

  • Click carousel banner → Verify entryPoint: 'carousel' in analytics
  • Click balance card → Verify entryPoint: 'homepage_balance'
  • Use trade button → Verify entryPoint: 'main_trade_button'
  • Open from rewards → Verify entryPoint: 'rewards'
  • Complete first deposit (creates Polymarket account) → Verify created_polymarket_account_via_mm: true in subsequent events

Migration Notes

No Breaking Changes

  • All changes are additive (new parameters, new trait)
  • Existing analytics events continue to work
  • Entry points default to appropriate values when missing

Analytics Team Action Items

  1. Verify trait propagation: Confirm created_polymarket_account_via_mm appears in Segment
  2. Update dashboards: Add entry point filters to Predict funnels
  3. Create cohorts: Set up user segments for Polymarket account creators

Related Documentation

  • Analytics Events: See segment-schema repo for Predict event schemas
  • Entry Points: Defined in app/components/UI/Predict/constants/eventNames.ts
  • User Traits: Defined in app/util/metrics/UserSettingsAnalyticsMetaData/UserProfileAnalyticsMetaData.types.ts

Checklist

  • Added user trait for Polymarket account creation
  • Fixed deeplink origin parameter handling
  • Added entry point tracking to all navigation paths
  • Added new entry point constants
  • Updated all affected component tests
  • All unit tests passing
  • No linter errors
  • Code follows project guidelines

Note

Adds consistent entryPoint analytics to all Predict navigations and deeplinks, and sets a persistent user trait when a Polymarket account is created via MetaMask.

  • Predict analytics:
    • Add ENTRY_POINT values (e.g., carousel, rewards, gtm_modal) in constants/eventNames.ts and pass params.entryPoint on navigations from PredictGTMModal, PredictNewButton, PredictPositionEmpty, PredictPositionsHeader, TradeWalletActions, WalletActions, and Rewards WaysToEarn CTA to Routes.PREDICT.MARKET_LIST.
  • Deeplinks:
    • Propagate origin to Predict handler via DeeplinkManager and handleUniversalLink; map origin -> params.entryPoint in handlePredictUrl (defaults to deeplink) for both market details and list routes; enhance logging.
  • User trait:
    • Add UserProfileProperty.CREATED_POLYMARKET_ACCOUNT_VIA_MM and set it in PolymarketProvider.prepareDeposit() when deploying proxy wallet (fire-and-forget with error logging).
  • Tests:
    • Update/unit tests to assert params.entryPoint and origin propagation across components and deeplink handlers.

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

- Pass origin parameter through deeplink handler chain
- Use origin value directly as entryPoint (carousel, notification, etc.)
- Default to 'deeplink' when origin is undefined
- Update PredictEventValues to use CAROUSEL instead of BANNER
- Add comprehensive tests for origin parameter handling
- All navigations now include entryPoint for accurate analytics tracking
…ion paths

- Add new entry point constants: REWARDS, GTM_MODAL
- Track entry points for all Predict feed navigations:
  - homepage_positions: Explore from empty positions
  - homepage_new_prediction: New prediction button
  - homepage_balance: Balance card touch
  - main_trade_button: Wallet actions & trade button
  - rewards: Rewards ways to earn CTA
  - gtm_modal: What's new modal engagement
- Replace hardcoded strings with type-safe constants
- Update all navigation calls to include entryPoint params
- Update all tests to expect entry point parameters
- All 36 tests passing
@andrepimenta andrepimenta requested review from a team as code owners November 13, 2025 17:25
@metamaskbot metamaskbot added the team-mobile-platform Mobile Platform team label Nov 13, 2025
@andrepimenta andrepimenta added No QA Needed Apply this label when your PR does not need any QA effort. team-predict Predict team and removed team-mobile-platform Mobile Platform team labels Nov 13, 2025
…aMask

- Add CREATED_POLYMARKET_ACCOUNT_VIA_MM user profile property
- Set trait when deployment transaction is included in deposit preparation
- Trait is automatically attached to all future analytics events
- Non-blocking: errors in trait setting don't affect deposit flow
- Enables cohort analysis and funnel tracking for Polymarket adoption
- Update all Predict deeplink test assertions to expect origin parameter
- All 4 Predict action tests now pass with correct parameter expectations
- Tests verify origin is properly passed from universal link to deeplink handler
- All 55 tests passing
- Include entryPoint parameter in handleMarketNavigation fallback when no market ID provided
- Ensures consistent analytics tracking for all deeplink navigation paths
- All 30 tests passing
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Nov 13, 2025
matallui
matallui previously approved these changes Nov 13, 2025
- Create private setPolymarketAccountCreatedTrait() method
- Use .catch() for proper async error handling (fire-and-forget pattern)
- Clean separation of concerns with descriptive method name
- Non-blocking trait setting with error logging to Sentry
- All 169 tests passing
@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeCore, SmokeConfirmationsRedesigned, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeTrade, SmokeWalletPlatform, SmokeWalletUX, SmokeAssets, SmokeSwaps, SmokeStake, SmokeCard, SmokeNotifications, SmokeRewards, SmokePerps, SmokeRamps, SmokeMultiChainPermissions, SmokeAnalytics, SmokeMultiChainAPI, SmokePredictions
  • Risk Level: high
  • AI Confidence: %
click to see 🤖 AI reasoning details

Fallback: AI analysis did not complete successfully. Running all tests.

View GitHub Actions results

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.

Bug: Predict Button: Network Compatibility Issue

The Predict button is missing the isEvmSelected check that exists in TradeWalletActions.tsx and is used for the Perps button in the same file. Predict only works on EVM networks (Polygon), so the button will incorrectly appear on non-EVM networks, leading to navigation to a non-functional feature. The condition should be isPredictEnabled && isEvmSelected to match the pattern used elsewhere.

app/components/Views/WalletActions/WalletActions.tsx#L204-L213

{isPredictEnabled && (
<ActionListItem
label={strings('asset_overview.predict_button')}
description={strings('asset_overview.predict_description')}
iconName={IconName.Speedometer}
onPress={onPredict}
testID={WalletActionsBottomSheetSelectorsIDs.PREDICT_BUTTON}
isDisabled={!canSignTransactions}
/>

Fix in Cursor Fix in Web


@sonarqubecloud
Copy link

@andrepimenta andrepimenta added this pull request to the merge queue Nov 13, 2025
Merged via the queue into main with commit a7e247c Nov 13, 2025
91 checks passed
@andrepimenta andrepimenta deleted the feature/predict/add-carousel-entry-point branch November 13, 2025 22:11
@github-actions github-actions bot locked and limited conversation to collaborators Nov 13, 2025
@metamaskbot metamaskbot added the release-7.60.0 Issue or pull request that will be included in release 7.60.0 label Nov 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template No QA Needed Apply this label when your PR does not need any QA effort. release-7.60.0 Issue or pull request that will be included in release 7.60.0 size-M team-predict Predict team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants