Skip to content

fix: add metrics opt In event cp-7.71.0#27846

Merged
grvgoel81 merged 3 commits into
mainfrom
feat/metrics-optIn-event
Mar 24, 2026
Merged

fix: add metrics opt In event cp-7.71.0#27846
grvgoel81 merged 3 commits into
mainfrom
feat/metrics-optIn-event

Conversation

@grvgoel81

@grvgoel81 grvgoel81 commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Description

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: METRICS_OPT_IN analytics on user opt-in

  Scenario: User opts in from onboarding MetaMetrics screen
    Given the user is on the onboarding MetaMetrics / data collection screen with basic usage enabled by default

    When the user continues without turning off basic usage
    Then the app completes onboarding as before and analytics pipelines receive a "Metrics Opt In" event with onboarding location and expected properties in addition to "Analytics Preference Selected"

  Scenario: User enables MetaMetrics from Settings
    Given the user is logged in and MetaMetrics is currently off

    When the user opens Settings > Security & privacy and turns the MetaMetrics switch on
    Then the app opts in successfully and emits "Metrics Opt In" with settings location and updated_after_onboarding before the preference-selected event

  Scenario: User enables marketing which requires MetaMetrics
    Given MetaMetrics is off and marketing data collection is off

    When the user turns marketing data collection on (which enables MetaMetrics)
    Then MetaMetrics turns on and "Metrics Opt In" is recorded before the subsequent preference events

Screenshots/Recordings

Before

After

Screenshot 2026-03-24 at 3 35 19 PM Screenshot 2026-03-24 at 3 36 30 PM Screenshot 2026-03-24 at 3 40 10 PM

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

Low Risk
Low risk analytics-only change that adds an additional tracking call when users enable metrics (onboarding, social login, and settings). Main risk is event ordering/duplication affecting downstream dashboards rather than app behavior.

Overview
Adds a new MetaMetricsEvents.METRICS_OPT_IN event and emits it whenever users enable metrics, including the onboarding opt-in screen (location: onboarding_metametrics), social login onboarding flow (location: onboarding_social_login), and the settings MetaMetrics toggle (location: settings / onboarding_default_settings).

Updates tests to assert the new opt-in event is sent (and in settings/onboarding cases is sent before ANALYTICS_PREFERENCE_SELECTED), including verifying updated_after_onboarding and optional account_type properties.

Written by Cursor Bugbot for commit 9968f73. Configure here.

@grvgoel81 grvgoel81 self-assigned this Mar 24, 2026
@grvgoel81 grvgoel81 added the team-onboarding Onboarding team label Mar 24, 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.

@grvgoel81 grvgoel81 marked this pull request as ready for review March 24, 2026 10:11
@grvgoel81 grvgoel81 requested review from a team as code owners March 24, 2026 10:11
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.51%. Comparing base (c56e9d0) to head (9968f73).
⚠️ Report is 25 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #27846      +/-   ##
==========================================
+ Coverage   82.46%   82.51%   +0.04%     
==========================================
  Files        4801     4804       +3     
  Lines      123807   123940     +133     
  Branches    27602    27624      +22     
==========================================
+ Hits       102101   102266     +165     
+ Misses      14634    14609      -25     
+ Partials     7072     7065       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added the risk-low Low testing needed · Low bug introduction risk label Mar 24, 2026
Comment thread app/components/UI/OptinMetrics/index.tsx Outdated
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The PR adds a new METRICS_OPT_IN analytics event and instruments it in three places:

  1. OptinMetrics/index.tsx (onboarding metrics consent screen): Now tracks both opt-in AND opt-out events (previously only tracked opt-out). The logic change is minimal - same event builder, just conditional on the checkbox state.
  2. Onboarding/index.tsx (social login path): Adds METRICS_OPT_IN tracking before the social login onboarding trace starts. Also moves accountType variable declaration earlier.
  3. MetaMetricsAndDataCollectionSection.tsx (Settings > Security): Adds METRICS_OPT_IN tracking when user enables analytics from settings.

All changes are purely analytics instrumentation - no UI behavior, navigation, or core wallet logic is changed. The risk is low.

SmokeWalletPlatform is selected because it covers wallet lifecycle analytics tracking for new wallet creation and SRP import events - directly relevant since onboarding analytics tracking is modified.

SmokeAccounts is selected because the onboarding flow (including social login path) is touched, and account creation/import flows are affected by the analytics changes.

No other feature areas (confirmations, network, trade, snaps, ramps, etc.) are impacted by these purely analytics-focused changes.

Performance Test Selection:
The changes are purely analytics event tracking additions with no UI rendering changes, no state management changes, no data loading changes, and no impact on app startup or initialization. No performance tests are warranted.

View GitHub Actions results

@smgv smgv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@github-actions

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
17 value mismatches detected (expected — fixture represents an existing user).
View details

@sonarqubecloud

Copy link
Copy Markdown

@grvgoel81 grvgoel81 added this pull request to the merge queue Mar 24, 2026
Merged via the queue into main with commit 79b1aa8 Mar 24, 2026
95 checks passed
@grvgoel81 grvgoel81 deleted the feat/metrics-optIn-event branch March 24, 2026 13:39
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 24, 2026
@metamaskbot metamaskbot added the release-7.72.0 Issue or pull request that will be included in release 7.72.0 label Mar 24, 2026
@grvgoel81 grvgoel81 changed the title feat: add metrics opt In event fix: add metrics opt In event Mar 24, 2026
@grvgoel81 grvgoel81 changed the title fix: add metrics opt In event fix: add metrics opt In event cp-7.71.0 Mar 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.72.0 Issue or pull request that will be included in release 7.72.0 risk-low Low testing needed · Low bug introduction risk size-M team-onboarding Onboarding team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants