Skip to content

Conversation

Brunonascdev
Copy link
Contributor

@Brunonascdev Brunonascdev commented Sep 29, 2025

Description

This PR adds metrics to the Rewards flows, following the approved mapping: https://consensyssoftware.atlassian.net/wiki/spaces/GL/pages/400218488856/Metrics+Mapping.

Changelog

CHANGELOG entry:

Related issues

Fixes:

Manual testing steps

Run the code locally with IS_TEST set to false, and make sure metrics/marketing are enabled in the settings. You should then see events being triggered on the rewards screens in the terminal.

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

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

Adds comprehensive metrics to Rewards views and actions (dashboard, onboarding, referrals, settings, rewards claim), new analytics enums/utilities, and user trait updates, plus minor param and test adjustments.

  • Analytics/Events
    • Add Rewards event enums and exports in core/Analytics/MetaMetrics.events.ts (viewed/clicked/started/completed/failed across flows).
    • Extend user profile traits with HAS_REWARDS_OPTED_IN and REWARD_ENABLED_ACCOUNTS_COUNT.
  • Frontend Instrumentation
    • Track view/tab events in RewardsDashboard.tsx and RewardsReferralView.tsx.
    • Track settings view and opt-out button click in RewardsSettingsView.tsx.
    • Track onboarding started/completed in OnboardingIntroStep.tsx and OnboardingStep3.tsx.
    • Track reward view/claim in RewardsClaimBottomSheetModal.tsx (now receives seasonRewardId from RewardItem.tsx).
    • Track active boost tap in ActiveBoosts.tsx and Ways to Earn CTA/button interactions in WaysToEarn.tsx.
    • Track referral code/link copy/share in ReferralDetails.tsx.
  • Hooks/Logic
    • useOptIn.ts: emit start/complete/fail events; include referral input type; set HAS_REWARDS_OPTED_IN trait on success.
    • useOptout.ts: emit start/complete/fail events; set trait OFF on success; log cancel click.
    • useLinkAccount.ts: emit started/completed/failed events with derived account props.
    • useRewardOptinSummary.ts: update user trait with linked accounts count once per session.
  • Utilities
    • Add RewardsMetricsButtons and deriveAccountMetricProps in utils.ts.
  • Tests/Types/Minor
    • Update tests to mock metrics/enums and new params (seasonRewardId), and selector/action import paths.
    • Minor cleanup in useToAddressValidation effect formatting.

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

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.

@metamaskbot metamaskbot added the team-card Card Team label Sep 29, 2025
@Brunonascdev Brunonascdev added no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed and removed team-card Card Team labels Sep 29, 2025
trackEvent(
createEventBuilder(MetaMetricsEvents.REWARDS_REWARD_CLAIMED)
.addProperties({
reward_id: rewardId,
Copy link

Choose a reason for hiding this comment

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

This is likely not going to be useful, it's a uuid unique to our backend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But that’s the purpose, right? If we filter by this unique ID, we can retrieve how many times a specific reward was claimed

Copy link

Choose a reason for hiding this comment

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

No, this reward is specific to the subscription. There will be at most one per subscription, leading to no meaningful data. You should instead look at the associated season reward.

trackEvent(
createEventBuilder(MetaMetricsEvents.REWARDS_ACTIVE_BOOST_CLICKED)
.addProperties({
boost_id: boost.id,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there value for metrics in having an ID referenced? These are mostly UUID's

Copy link
Contributor Author

Choose a reason for hiding this comment

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

only to filter for specific boosts in MixPanel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@VGR-GIT
Copy link
Contributor

VGR-GIT commented Sep 30, 2025

@Brunonascdev A few events I'm not seeing that other features do have:

  • REWARDS_DASHBOARD_VIEWED
  • REWARDS_SETTINGS_VIEWED
  • REWARDS_REFERRALS_VIEWED

Also others we could track:

  • REWARDS_DASHBOARD_TAB_VIEWED (with specific tab as metadata)
  • REWARDS_REWARD_VIEWED (when pressing on specific reward?)

Once this PR has been rebased, there's also a few modals that we use that might be candidates for event tracking like:

  • onboarding intro modal: account not supported (ie hardware)
  • onboarding intro modal: geo not supported
  • onboarding intro modal: auth failure (should be rare)
  • dashboard modal: accounts unlinked
  • dashboard modal: current account unlinked
  • dashboard modal: account not supported

Copy link
Contributor

@VGR-GIT VGR-GIT left a comment

Choose a reason for hiding this comment

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

Hey Bruno, I left some comments. I'm not sure who has defined the currently suggested metrics but I left some proposals of events I think make sense. Could you check if they want to track them? Also you'll have to rebase your PR before doing any changes, as there have been quite a few changes recently. In general, we should be consistent when tracking actions; do we want to always log started/completed/failed/cancelled, ... And preferably those action metric tracking actions should live in the hooks.

@github-actions github-actions bot added size-L and removed size-M labels Oct 1, 2025
@Brunonascdev Brunonascdev marked this pull request as ready for review October 1, 2025 21:41
@Brunonascdev Brunonascdev requested review from a team as code owners October 1, 2025 21:41
cursor[bot]

This comment was marked as outdated.

Copy link

sonarqubecloud bot commented Oct 1, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed size-L team-rewards
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants