Skip to content

chore(runway): cherry-pick fix(oauth): sync marketing opt-in and analytics after OAuth rehydration unlock cp-7.72.0#28255

Merged
chloeYue merged 2 commits into
release/7.72.0from
runway-cherry-pick-7.72.0-1775042620
Apr 1, 2026
Merged

chore(runway): cherry-pick fix(oauth): sync marketing opt-in and analytics after OAuth rehydration unlock cp-7.72.0#28255
chloeYue merged 2 commits into
release/7.72.0from
runway-cherry-pick-7.72.0-1775042620

Conversation

@runway-github

@runway-github runway-github Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Description

After a seedless / social-account wallet unlock on the OAuth rehydration
screen, local marketing consent and analytics could drift from the
account’s server-side marketing opt-in. That meant user profile
properties and preference events were not reliably aligned with
getMarketingOptInStatus until some other flow ran.

This change calls OAuthService.getMarketingOptInStatus() immediately
after a successful unlock on OAuthRehydration, then:

  • Dispatches setDataCollectionForMarketing so Redux matches the server
    flag.
  • Updates MetaMetrics identity with HAS_MARKETING_CONSENT.
  • Fires ANALYTICS_PREFERENCE_SELECTED with updated_after_onboarding: true, location: 'oauth_rehydration', and account_type from the
    seedless auth connection.

Failures are logged and do not block unlock. Unit tests assert the
marketing sync runs on the happy path and is skipped when navigation
does not complete that path.

Changelog

CHANGELOG entry: null

Related issues

Fixes: #28249

Manual testing steps

Feature: OAuth rehydration marketing opt-in sync

  Scenario: Successful unlock syncs marketing preference and analytics
    Given the user completes social / seedless onboarding and reaches OAuth rehydration
    And the app can reach OAuth marketing opt-in APIs
    When the user enters a valid password and unlock succeeds
    Then local marketing data collection state should match the server opt-in response
    And analytics should record preference / identity updates for marketing consent (verify in debug / staging tooling if available)

  Scenario: Unlock path that does not complete rehydration navigation
    Given a flow where OAuth rehydration does not navigate to home after unlock (e.g. error or alternate path covered by tests)
    When unlock handling does not take the success path that replaces with onboarding home
    Then marketing opt-in sync should not run (no redundant or incorrect preference sync)

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

Medium Risk
Touches the post-unlock path of OAuthRehydration by adding a
background network call plus Redux/analytics side effects; failures are
best-effort but bugs here could desync consent state or misfire
analytics.

Overview
After a successful OAuth rehydration unlock, the app now fetches
server-side marketing consent via
OAuthService.getMarketingOptInStatus() and syncs it locally.

The unlock flow dispatches setDataCollectionForMarketing, updates
MetaMetrics identity (HAS_MARKETING_CONSENT), and emits
ANALYTICS_PREFERENCE_SELECTED with updated_after_onboarding,
location: 'oauth_rehydration', and an account_type derived from the
seedless authConnection; errors are logged and do not block unlock.

Tests were updated to mock analytics/getMarketingOptInStatus,
assert the sync runs on the successful rehydration path, verify Redux +
analytics payloads, and confirm the sync is skipped for the outdated
password
(non-oauth2) unlock path.

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

[2d8b6d7](https://github.com/MetaMask/metamask-mobile/commit/2d8b6d7474d680de7e7a6bf5f6d870128b771812)

…ytics after OAuth rehydration unlock cp-7.72.0 (#28230)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
After a seedless / social-account wallet unlock on the OAuth rehydration
screen, local marketing consent and analytics could drift from the
account’s server-side marketing opt-in. That meant user profile
properties and preference events were not reliably aligned with
`getMarketingOptInStatus` until some other flow ran.

This change calls `OAuthService.getMarketingOptInStatus()` immediately
after a successful unlock on `OAuthRehydration`, then:

- Dispatches `setDataCollectionForMarketing` so Redux matches the server
flag.
- Updates MetaMetrics identity with `HAS_MARKETING_CONSENT`.
- Fires `ANALYTICS_PREFERENCE_SELECTED` with `updated_after_onboarding:
true`, `location: 'oauth_rehydration'`, and `account_type` from the
seedless auth connection.

Failures are logged and do not block unlock. Unit tests assert the
marketing sync runs on the happy path and is skipped when navigation
does not complete that path.


## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry: null

## **Related issues**

Fixes: #28249

## **Manual testing steps**

```gherkin
Feature: OAuth rehydration marketing opt-in sync

  Scenario: Successful unlock syncs marketing preference and analytics
    Given the user completes social / seedless onboarding and reaches OAuth rehydration
    And the app can reach OAuth marketing opt-in APIs
    When the user enters a valid password and unlock succeeds
    Then local marketing data collection state should match the server opt-in response
    And analytics should record preference / identity updates for marketing consent (verify in debug / staging tooling if available)

  Scenario: Unlock path that does not complete rehydration navigation
    Given a flow where OAuth rehydration does not navigate to home after unlock (e.g. error or alternate path covered by tests)
    When unlock handling does not take the success path that replaces with onboarding home
    Then marketing opt-in sync should not run (no redundant or incorrect preference sync)
```

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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
- [ ] 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 the post-unlock path of `OAuthRehydration` by adding a
background network call plus Redux/analytics side effects; failures are
best-effort but bugs here could desync consent state or misfire
analytics.
> 
> **Overview**
> After a successful OAuth rehydration unlock, the app now fetches
server-side marketing consent via
`OAuthService.getMarketingOptInStatus()` and **syncs it locally**.
> 
> The unlock flow dispatches `setDataCollectionForMarketing`, updates
MetaMetrics identity (`HAS_MARKETING_CONSENT`), and emits
`ANALYTICS_PREFERENCE_SELECTED` with `updated_after_onboarding`,
`location: 'oauth_rehydration'`, and an `account_type` derived from the
seedless `authConnection`; errors are logged and do not block unlock.
> 
> Tests were updated to mock `analytics`/`getMarketingOptInStatus`,
assert the sync runs on the successful rehydration path, verify Redux +
analytics payloads, and confirm the sync is skipped for the *outdated
password* (non-oauth2) unlock path.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0738153. 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 April 1, 2026 11:23
@github-actions

github-actions Bot commented Apr 1, 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.

@metamaskbot metamaskbot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Apr 1, 2026
@github-actions github-actions Bot added size-M risk-low Low testing needed · Low bug introduction risk labels Apr 1, 2026

@ieow ieow 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.

Please do not merge first

@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 Apr 1, 2026
@ieow

ieow commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

false alarm.
I thought my changes causes some e2e tests failed

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

@chloeYue chloeYue added the skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run label Apr 1, 2026
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 1, 2026
@github-actions

github-actions Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - skip-smart-e2e-selection label found

All E2E tests pre-selected.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented Apr 1, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Apr 1, 2026

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

@chloeYue chloeYue merged commit 14036f5 into release/7.72.0 Apr 1, 2026
345 of 370 checks passed
@chloeYue chloeYue deleted the runway-cherry-pick-7.72.0-1775042620 branch April 1, 2026 16:34
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

risk-high Extensive testing required · High bug introduction risk size-M skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run 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