Skip to content

refactor(analytics): PR A1 move SegmentPersistor, PrivacyPlugin, constants, whenEngineReady, snapKeyring to app/util/analytics#26891

Merged
NicolasMassart merged 7 commits into
mainfrom
refactor/26810_a1-platform_move-files
Mar 10, 2026
Merged

refactor(analytics): PR A1 move SegmentPersistor, PrivacyPlugin, constants, whenEngineReady, snapKeyring to app/util/analytics#26891
NicolasMassart merged 7 commits into
mainfrom
refactor/26810_a1-platform_move-files

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Description

Part of the analytics cleanup workstream (#26686).

  • Moves infrastructure files out of app/core/Analytics/ into app/util/analytics/
  • Renames files to drop the MetaMetrics prefix:
    • MetaMetricsPrivacySegmentPluginprivacySegmentPlugin
    • MetaMetrics.constantsconstants
  • Renames the exported constant METAMETRICS_ANONYMOUS_IDANALYTICS_ANONYMOUS_ID
  • Updates import paths
  • Adds a previously missing whenEngineReady.test.ts

Files scheduled for deletion in later PRs (e.g. MetaMetrics.ts) are intentionally left untouched.

Changelog

CHANGELOG entry: null

Related issues

Fixes: #26810

Manual testing steps

N/A

Screenshots/Recordings

N/A

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

Medium Risk
Moderate risk because it rewires import paths and constants across analytics, Engine readiness polling, and Segment setup used at runtime; mistakes could break analytics initialization or cause lingering timers, though behavior is intended to be unchanged and is now covered by new tests.

Overview
Refactors analytics infrastructure by moving whenEngineReady, Segment persistence (segmentPersistor), the privacy Segment plugin, and the anonymous-id constant out of core/Analytics into util/analytics, including renaming METAMETRICS_ANONYMOUS_ID to ANALYTICS_ANONYMOUS_ID.

Updates runtime imports (e.g., analytics.ts, platform-adapter.ts, OAuthService.ts, SnapKeyring.ts) and a broad set of Jest tests/global test setup to mock the new module paths, and adds a dedicated whenEngineReady unit test to validate retry/backoff behavior.

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

…tants, whenEngineReady, snapKeyring to app/util/analytics
@NicolasMassart NicolasMassart added the team-mobile-platform Mobile Platform team label Mar 3, 2026
@NicolasMassart NicolasMassart self-assigned this Mar 3, 2026
@github-actions

github-actions Bot commented Mar 3, 2026

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.

@github-actions github-actions Bot added the size-M label Mar 3, 2026
@NicolasMassart NicolasMassart marked this pull request as ready for review March 4, 2026 13:02
@NicolasMassart NicolasMassart requested review from a team as code owners March 4, 2026 13:02

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

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.

Comment thread app/util/analytics/whenEngineReady.test.ts
@NicolasMassart NicolasMassart enabled auto-merge March 4, 2026 16:30
@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeIdentity, SmokeAccounts, SmokeWalletPlatform, SmokeNetworkExpansion, SmokeConfirmations, FlaskBuildTests
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: high
  • AI Confidence: 70%
click to see 🤖 AI reasoning details

E2E Test Selection:
This PR introduces changes across several core runtime modules:

  1. SnapKeyring (app/core/SnapKeyring/SnapKeyring.ts)

    • Directly impacts Snaps-managed accounts and keyring behavior.
    • SnapKeyring is foundational for snap-derived accounts (including non-EVM chains like Solana).
    • High impact area because keyring changes affect account creation, signing, and account exposure to dApps.
    • Requires running FlaskBuildTests (Snaps lifecycle and provider integration).
    • Also impacts multi-chain/Solana flows → include SmokeNetworkExpansion.
    • Since Solana transactions/signing hit confirmations, include SmokeConfirmations.
    • Keyring changes may affect account listing and management → include SmokeAccounts.
  2. OAuthService (app/core/OAuthService/OAuthService.ts)

    • Tied to identity and account sync flows.
    • Changes here can affect profile sync, login state, and multi-SRP synchronization.
    • Requires SmokeIdentity.
    • Per tag dependency rules, when selecting SmokeIdentity also select SmokeAccounts and SmokeWalletPlatform.
  3. Analytics-related changes (MetaMetrics.constants.ts, analytics.ts, SegmentPersistor.ts, privacySegmentPlugin.ts, platform-adapter.ts, whenEngineReady.ts)

    • These are cross-cutting concerns triggered during Engine readiness and user flows.
    • While primarily telemetry, they are wired into Engine lifecycle and could indirectly affect app startup, account events, or Snap tracking.
    • Covered indirectly by broad functional tags (SmokeWalletPlatform, SmokeAccounts, SmokeIdentity, SmokeNetworkExpansion).
  4. EngineService.test.ts and analytics-controller/platform-adapter.ts

    • Engine-related integration layer (though changes appear analytics-focused).
    • Given Engine centrality, risk is elevated.

Because changes touch core key management (SnapKeyring), identity/OAuth, and Engine-integrated analytics, the overall risk is HIGH with potential cross-domain impact.

Selected tags ensure coverage of:

  • Account management and SRP flows (SmokeAccounts)
  • Identity and sync flows (SmokeIdentity)
  • Core wallet platform and lifecycle (SmokeWalletPlatform)
  • Solana & multi-chain provider behavior (SmokeNetworkExpansion)
  • Transaction/signature confirmations (SmokeConfirmations)
  • Snaps lifecycle and provider APIs (FlaskBuildTests)

No Trade/Perps/Predictions/Card/Ramps specific logic was modified, so those tags are excluded to minimize unnecessary execution.

Performance Test Selection:
Changes are focused on analytics, OAuth service logic, and Snap keyring behavior. There are no UI rendering changes, list virtualization updates, onboarding/login performance modifications, swap/perps performance changes, or Engine initialization performance refactors. Therefore, no dedicated performance test suites are required for this PR.

View GitHub Actions results

@NicolasMassart NicolasMassart moved this to Needs dev review in PR review queue Mar 9, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.70%. Comparing base (0ea672c) to head (2737a6e).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26891      +/-   ##
==========================================
+ Coverage   81.68%   81.70%   +0.01%     
==========================================
  Files        4652     4654       +2     
  Lines      121697   121764      +67     
  Branches    26740    26754      +14     
==========================================
+ Hits        99412    99487      +75     
+ Misses      15369    15359      -10     
- Partials     6916     6918       +2     

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

@sonarqubecloud

sonarqubecloud Bot commented Mar 9, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

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

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

@gantunesr gantunesr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved for Accounts CO,

- app/component-library/components-temp/MultichainAccounts/MultichainAccountSelectorList/MultichainAccountSelectorList.test.tsx
- app/core/SnapKeyring/SnapKeyring.test.ts
- app/core/SnapKeyring/SnapKeyring.ts

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

@NicolasMassart NicolasMassart added this pull request to the merge queue Mar 10, 2026
@github-project-automation github-project-automation Bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Mar 10, 2026
Merged via the queue into main with commit e1d9a57 Mar 10, 2026
115 checks passed
@NicolasMassart NicolasMassart deleted the refactor/26810_a1-platform_move-files branch March 10, 2026 11:24
@github-project-automation github-project-automation Bot moved this from Review finalised - Ready to be merged to Merged, Closed or Archived in PR review queue Mar 10, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 10, 2026
@metamaskbot metamaskbot added the release-7.70.0 Issue or pull request that will be included in release 7.70.0 label Mar 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.70.0 Issue or pull request that will be included in release 7.70.0 size-M team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

PR A1: move infra files to app/util/analytics via git mv (SegmentPersistor, PrivacyPlugin, constants, whenEngineReady, snapKeyring)

9 participants