Repository navigation
fix(auth): stop syncing marketing consent with the OAuth backend (GE-648) - #47808
Conversation
|
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. |
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/core-extension-ux (2 files, +41 -34)
🔐 @MetaMask/web3auth (2 files, +41 -34)
|
Builds ready [662efab]
⚡ Performance Benchmarks (Total: 🟢 9 pass · 🟡 1 warn · 🔴 3 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [d4dccf2] [reused from 662efab]
⚡ Performance Benchmarks (Total: 🟢 9 pass · 🟡 1 warn · 🔴 3 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
| ); | ||
|
|
||
| // sync marketing consent with metametrics | ||
| const marketingConsent = await getMarketingConsent(); |
There was a problem hiding this comment.
Cross-device consent regression.
On a fresh-device social restore, the code previously force-synced local consent from the backend; now nothing sets it, so a user who previously opted in will show opted-out locally until they toggle again. Privacy-conservative, but it's a real behavior change on the rehydration path.
There was a problem hiding this comment.
This change is intentional, we're okay with losing cross-device marketing consent state for social login users until we move marketing consent to AUS (when the decoupling of marketing consent from metametrics lands)
| ); | ||
|
|
||
| if (termsChecked) { | ||
| dispatch(setMarketingConsent(true)); |
There was a problem hiding this comment.
This previously save the user's marketing consent in the auth-service backend.
Now, it was removed.
May I know where is it stored now? (Probably please point me to the code ref).
This will affect cross-device marketing consent for the social login user.
There was a problem hiding this comment.
We've reverted our approach to this hotfix and instead of cutting off the BE calls altogether we're mostly going to prevent rollbacks on failed remote writes.
|
Not sure if this is an issue but Cursor flagged this:
|
Thanks, that write is now restored in 6bbbe07. We've reverted our approach to this hotfix and instead of cutting off the BE calls altogether we're mostly going to prevent rollbacks on failed remote writes. |
…eting-consent-with-oauth-backend # Conflicts: # test/e2e/tests/seedless-onboarding/refresh-auth-tokens.spec.ts
Builds ready [76f316c]
⚡ Performance Benchmarks (Total: 🟢 8 pass · 🟡 2 warn · 🔴 3 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
|



Description
Social login (Google/Apple) users had marketing consent also read from and written to the OAuth auth server (
OAuthService:getMarketingConsent/OAuthService:setMarketingConsent, endpoint/api/v1/oauth/marketing_opt_in_status). When setting marketing consent on the OAuth BE fails the Settings toggle flipped and then snapped back and Brazehas_marketing_consentwent out of sync. More importantly it prevents opted-in users from opting out which is a legal/compliance issue.Temporary hotfix aligned with mobile. Reads are removed and writes are kept without the revert: social login consent lives locally in
AnalyticsControllerstate (optedInToMarketing,marketingConsentDecisionMade) as the source of truth, and every consent write also POSTs to the auth server so email marketing learns of opt-ins and opt-outs. SRP users keep behaving as before, with no marketing request. Based onmain, not onfeat/marketing-consent-aus-sync. The proper long-term fix, moving consent to Authenticated User Storage and removing the OAuth methods, is #47041.Changes
ui/pages/settings/privacy-tab/data-collection-item.tsxremoved the mount-time fetch of remote consent (the read that could overwrite the local choice). The toggle keeps dispatchingoptInToMarketing/optOutOfMarketinglocally and, for social login users, also callssetMarketingConsentfire-and-forget: a failed sync is logged and the local decision is never reverted, so the toggle no longer snaps back.ui/pages/onboarding-flow/create-password/create-password.tsxkeepssetMarketingConsent(true)on social login wallet creation as onmain(before this PR it was removed). The local opt in/out dispatch and theAnalyticsPreferenceSelectedevent stay.ui/components/app/metametrics-consent/metametrics-consent-container.tsx(the consent modal shown again to restored social login users because reads are gone) now also POSTs the user's choice (accept, decline and close) for social login users, without the revert. Non-social users do not POST.ui/store/actions.tsrestoreSocialBackupAndGetSeedPhraseno longer reads consent after a social restore, no longer dispatches opt in/out from it, and no longer tracksAnalyticsPreferenceSelectedwith locationonboarding_social_login_rehydration. The now unusedtrackEventparam is dropped andonboarding-flow.tsxis updated (unusedtrackLegacyEventForAction/useAnalyticsremoved).getMarketingConsentand theOAuthServicebackground read method are intentionally kept with no callers, to keep this easy to revert.setMarketingConsentis called again as a write-only sync (no revert on failure).test/e2e/tests/seedless-onboarding/refresh-auth-tokens.spec.tsused the marketing request as its probe for the refreshed access token. Replaced with the social identifier pairing request (/api/v2/profile/pair/identifier, bodysocial_jwt), which also carries the refreshed token. Removed the marketing GET mock, kept a marketing POST mock (consent writes still happen), and added a pairing mock. The two original tests are rewritten as two: one asserts the expired token was renewed, one asserts the refreshed token was used in later requests. The pairing request fires in e2e because the onboarding flow accepts the basic functionality migration modal, which setsisBasicFunctionalityConsolidatedEnabled. This approach is borrowed from feat(analytics): move social login marketing consent from OAuth to AUS (GE-589) #47041. The e2e spec was not run locally.Behavior changes and risks
MetaMetricsConsentContainermodal again; answering it now also POSTs the choice to the auth server.AnalyticsPreferenceSelectedevent with locationonboarding_social_login_rehydrationis no longer emitted.Verification (Node 24.22.1)
yarn jestondata-collection-item,metametrics-consent-container,create-passwordandactions.test.js: 4 suites, 293 tests pass (including new cases asserting the POST is sent for social users, not sent for SRP users, and that a failed sync does not revert the local choice).yarn lint:tscpasses (TypeScript 5.9.3).yarn lint:eslinton the whole repo, 0 errors.oxfmtcheck clean on the touched files.Changelog
CHANGELOG entry: Fixed marketing consent for social login users failing to save and snapping back in Settings
Related issues
Refs: #47041
Mobile counterpart: MetaMask/metamask-mobile#39376
Manual testing steps
/api/v1/oauth/marketing_opt_in_statuswith the new value.is_opt_in: trueis sent to the auth server.MetaMetricsConsentContainermodal sends one POST with the chosen value.Screenshots/Recordings
Before
N/A
After
N/A
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches social-login marketing consent and OAuth sync paths where opt-out correctness is compliance-sensitive; behavior change leaves server-side consent stale until the user toggles again.
Overview
Social-login marketing consent no longer pulls from the OAuth auth server on restore, in Settings, or via
restoreSocialBackupAndGetSeedPhrase—localAnalyticsControllerstate is the source of truth so failed reads cannot flip the toggle back (compliance fix).Writes remain: social users still POST consent on Settings toggle, MetaMetrics consent modal (accept/decline/close), and related flows via
setMarketingConsent, without reverting local state if the network call fails.onboarding-flowdrops the unused analytics callback when restoring social backup. Seedless e2e token-refresh tests now assert refresh via social identifier pairing (PairSocialIdentifier/social_jwt) instead of marketing opt-in traffic; mocks add pairing and simplify marketing to POST-only.Reviewed by Cursor Bugbot for commit 76f316c. Bugbot is set up for automated code reviews on this repo. Configure here.