Skip to content

Cherry-picking commits from main to release/7.67.0 for PR #26292#26316

Merged
joaoloureirop merged 1 commit intorelease/7.67.0from
runway-cherry-pick-7.67.0-1771549039
Feb 20, 2026
Merged

Cherry-picking commits from main to release/7.67.0 for PR #26292#26316
joaoloureirop merged 1 commit intorelease/7.67.0from
runway-cherry-pick-7.67.0-1771549039

Conversation

@runway-github
Copy link
Contributor

@runway-github runway-github bot commented Feb 20, 2026

Description

Phase 2 analytics migration (Batch 2-11): migrate Stake/Earn's
useMetrics hook and MetaMetrics.getInstance() calls from the legacy
MetaMetrics system to the new analytics system.

Reason: Deprecate MetaMetrics in favour of the shared analytics
utility and AnalyticsController.

Changes: Stake components and hooks now use useAnalytics from
hooks/useAnalytics/useAnalytics and import MetaMetricsEvents
directly from core/Analytics; withMetaMetrics utility now uses
analytics.trackEvent() and AnalyticsEventBuilder instead of
MetaMetrics.getInstance().trackEvent() and MetricsEventBuilder; test
mocks updated accordingly.

Changes

Source files (6):

  • LearnMoreModalFooter.tsx, StakingButtons.tsx,
    StakingBalance.tsx, StakeButton/index.tsx: replaced useMetrics
    with useAnalytics; MetaMetricsEvents now imported from
    core/Analytics
  • usePoolStakedDeposit/index.ts: replaced useMetrics with
    useAnalytics (also migrated as it's the source for a listed test file)
  • withMetaMetrics.ts: replaced
    MetaMetrics.getInstance().trackEvent() with analytics.trackEvent()
    and MetricsEventBuilder with AnalyticsEventBuilder

Test files (3):

  • StakeButton.test.tsx: replaced useMetrics mock with useAnalytics
    mock; added transitive useMetrics mock for unmigrated
    useStablecoinLendingRedirect dependency; replaced
    MetricsEventBuilder with AnalyticsEventBuilder
  • usePoolStakedDeposit.test.tsx: replaced useMetrics mock/import
    with useAnalytics; replaced MetricsEventBuilder with
    AnalyticsEventBuilder
  • withMetaMetrics.test.ts: replaced MetaMetrics.getInstance() spy
    with analytics module mock; updated MetaMetricsEvents import from
    core/Analytics

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MCWP-298 (Batch
2-11)

Manual testing steps

Feature: Stake/Earn analytics

  Scenario: user triggers a stake/earn flow event
    Given app is open and user is in a stake/earn flow

    When user performs an action that triggers analytics (e.g. stake button, unstake button, learn more, view staked positions)
    Then the event is tracked on Mixpanel

Screenshots/Recordings

N/A – analytics migration, no UI change.

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
This is a broad analytics plumbing migration across Stake/Earn UI and transaction hooks; risk is mainly missed/changed event emission or metadata due to swapped builders and tracking surfaces, not user-facing flow changes.

Overview
Migrates Stake/Earn (Earn CTA, staking balance/buttons, learn-more modal, and pooled-stake deposit hook) from legacy useMetrics/MetaMetrics.getInstance() tracking to the new analytics stack via useAnalytics, analytics.trackEvent, and AnalyticsEventBuilder.

Updates related unit tests to mock useAnalytics/analytics instead of useMetrics/MetaMetrics, including a new mock for useStablecoinLendingRedirect to avoid transitive legacy metrics behavior and keep navigation assertions stable.

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

b5b8c71

## **Description**

Phase 2 analytics migration (Batch 2-11): migrate Stake/Earn's
`useMetrics` hook and `MetaMetrics.getInstance()` calls from the legacy
MetaMetrics system to the new analytics system.

**Reason**: Deprecate MetaMetrics in favour of the shared analytics
utility and AnalyticsController.

**Changes**: Stake components and hooks now use `useAnalytics` from
`hooks/useAnalytics/useAnalytics` and import `MetaMetricsEvents`
directly from `core/Analytics`; `withMetaMetrics` utility now uses
`analytics.trackEvent()` and `AnalyticsEventBuilder` instead of
`MetaMetrics.getInstance().trackEvent()` and `MetricsEventBuilder`; test
mocks updated accordingly.

### Changes

**Source files (6)**:
- `LearnMoreModalFooter.tsx`, `StakingButtons.tsx`,
`StakingBalance.tsx`, `StakeButton/index.tsx`: replaced `useMetrics`
with `useAnalytics`; `MetaMetricsEvents` now imported from
`core/Analytics`
- `usePoolStakedDeposit/index.ts`: replaced `useMetrics` with
`useAnalytics` (also migrated as it's the source for a listed test file)
- `withMetaMetrics.ts`: replaced
`MetaMetrics.getInstance().trackEvent()` with `analytics.trackEvent()`
and `MetricsEventBuilder` with `AnalyticsEventBuilder`

**Test files (3)**:
- `StakeButton.test.tsx`: replaced `useMetrics` mock with `useAnalytics`
mock; added transitive `useMetrics` mock for unmigrated
`useStablecoinLendingRedirect` dependency; replaced
`MetricsEventBuilder` with `AnalyticsEventBuilder`
- `usePoolStakedDeposit.test.tsx`: replaced `useMetrics` mock/import
with `useAnalytics`; replaced `MetricsEventBuilder` with
`AnalyticsEventBuilder`
- `withMetaMetrics.test.ts`: replaced `MetaMetrics.getInstance()` spy
with `analytics` module mock; updated `MetaMetricsEvents` import from
`core/Analytics`

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes: https://consensyssoftware.atlassian.net/browse/MCWP-298 (Batch
2-11)

## **Manual testing steps**

```gherkin
Feature: Stake/Earn analytics

  Scenario: user triggers a stake/earn flow event
    Given app is open and user is in a stake/earn flow

    When user performs an action that triggers analytics (e.g. stake button, unstake button, learn more, view staked positions)
    Then the event is tracked on Mixpanel
```

## **Screenshots/Recordings**

N/A – analytics migration, no UI change.

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Touches analytics instrumentation across multiple stake/earn entry
points and a shared `withMetaMetrics` wrapper, so incorrect wiring could
silently drop or duplicate events; functional app behavior should be
unchanged.
> 
> **Overview**
> Updates Stake/Earn UI components and staking hooks to use the new
analytics stack by replacing legacy `useMetrics`/`MetricsEventBuilder`
and `MetaMetrics.getInstance().trackEvent()` calls with `useAnalytics`,
`AnalyticsEventBuilder`, and `analytics.trackEvent()`, while importing
`MetaMetricsEvents` from `core/Analytics`.
> 
> Refactors `withMetaMetrics` to build events with the new builder and
dispatch via the shared analytics utility (including promise-handling),
and updates affected unit tests/mocks accordingly (including a
`useStablecoinLendingRedirect` mock to keep navigation tests stable).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
160d885. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@runway-github runway-github bot requested a review from a team as a code owner February 20, 2026 00:58
@github-actions
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-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Feb 20, 2026
@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - base branch is not main (base: release/7.67.0)

All E2E tests pre-selected.

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

}

builtEvents.forEach((event) => MetaMetrics.getInstance().trackEvent(event));
builtEvents.forEach((event) => analytics.trackEvent(event));
Copy link

Choose a reason for hiding this comment

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

saveDataRecording silently flipped from true to false

Medium Severity

Events tracked through withMetaMetrics now have saveDataRecording defaulting to false instead of true. The old path went through MetaMetrics.getInstance().trackEvent() which explicitly called .setSaveDataRecording(true). The new path calls analytics.trackEvent(event) directly, passing the event as-is from AnalyticsEventBuilder, which defaults saveDataRecording to false in createAnalyticsEvent. Unlike useAnalytics().trackEvent() — which overrides this to true via .setSaveDataRecording(saveDataRecording ?? true) — the direct analytics.trackEvent() call applies no such override. This affects GDPR data-recording compliance tracking for all events fired through withMetaMetrics.

Additional Locations (1)

Fix in Cursor Fix in Web

@sonarqubecloud
Copy link

@joaoloureirop joaoloureirop enabled auto-merge (squash) February 20, 2026 01:46
@joaoloureirop joaoloureirop merged commit 5b312f8 into release/7.67.0 Feb 20, 2026
194 of 197 checks passed
@joaoloureirop joaoloureirop deleted the runway-cherry-pick-7.67.0-1771549039 branch February 20, 2026 01:54
@github-actions github-actions bot locked and limited conversation to collaborators Feb 20, 2026
@metamaskbot metamaskbot added the release-7.67.0 Issue or pull request that will be included in release 7.67.0 label Feb 23, 2026
@metamaskbot
Copy link
Collaborator

No release label on PR. Adding release label release-7.67.0 on PR, as PR was cherry-picked in branch 7.67.0.

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

Labels

release-7.67.0 Issue or pull request that will be included in release 7.67.0 size-M team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants