Repository navigation
feat(analytics): move social login marketing consent from OAuth to AUS (GE-589) - #47041
zelkibuilds wants to merge 8 commits into
Conversation
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/core-extension-ux (2 files, +14 -44)
🫰 @MetaMask/core-platform (2 files, +0 -8)
👨🔧 @MetaMask/extension-platform (1 files, +0 -6)
🔐 @MetaMask/web3auth (5 files, +1 -119)
|
8222424 to
01cfc53
Compare
|
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. |
Builds ready [01cfc53]
⚡ Performance Benchmarks (Total: 🟢 8 pass · 🟡 3 warn · 🔴 2 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort 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.
Reviewed by Cursor Bugbot for commit 01cfc53. Configure here.
01cfc53 to
40627e3
Compare
Builds ready [31841a6] [reused from 96975bc]
⚡ Performance Benchmarks (Total: 🟢 4 pass · 🟡 1 warn · 🔴 0 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [958a12b]
⚡ Performance Benchmarks (Total: 🟢 8 pass · 🟡 3 warn · 🔴 2 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [23bbd7b]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 5 warn · 🔴 2 fail)
Bundle Size Diffs [🚀 Bundle size reduced!]
|
Builds ready [c91ed6b]
⚡ Performance Benchmarks (Total: 🟢 8 pass · 🟡 3 warn · 🔴 2 fail)
Bundle Size Diffs [🚀 Bundle size reduced!]
|
Builds ready [8d4566e]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 4 warn · 🔴 3 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [891e4bb]
⚡ Performance Benchmarks (Total: 🟢 8 pass · 🟡 3 warn · 🔴 2 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Marketing consent for social-login users was stored on the auth server through OAuthService. AUS is now the single remote source for marketing consent, synced in the background, so the OAuth get/set consent methods, their background bindings and UI actions are removed. Social-login rehydration and the Privacy settings toggle no longer fetch or write consent through OAuth. The refresh-auth-tokens E2E used the OAuth consent endpoint to trigger a token refresh, so it now checks the token grants directly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: zelkibuilds <zelkibuilds@users.noreply.github.com>
This branch removed the import when its last use went away, and a test merged from main uses it again.
Removing the OAuth marketing consent methods also removed the blank line before the next method, which fails lines-between-class-members.
…ctor The rehydration event repeated getDataCollectionForMarketing inline. Use the selector and cover the case where a decision was made.
It counted profile-sync OIDC token requests, which happen on every unlock, so it passed whether or not the seedless token was refreshed. With the marketing consent request removed, nothing in the flow sends the seedless access token after unlock. Core covers keeping the newer token on unlock.
Builds ready [f4c7e47]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 4 warn · 🔴 2 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
lwin-kyaw
left a comment
There was a problem hiding this comment.
On the side note, we should also align the mobile with the same logics here.
| ); | ||
| }); | ||
|
|
||
| it('should use valid Access Token after lock/unlock cycle', async function () { |
There was a problem hiding this comment.
Hey @zelkibuilds can I check why do you remove this spec?
This is a valid test to assert that Social Login tokens are refreshed at unlock, AUS marketing consent replacement should not remove this.
There was a problem hiding this comment.
Ideally, we should assert that the next network call after token refresh, use the refreshed token instead of old one.
There was a problem hiding this comment.
The test checked the token by watching one network call, marketing_opt_in_status/AuthServer.GetMarketingOptInStatus. Given that call is gone I removed the test.
| assert.strictEqual( | ||
| (decodedAccessToken as JwtPayload).mode, | ||
| 'refreshed', | ||
| grants.includes('refresh_token'), |
There was a problem hiding this comment.
This spec is incomplete.
This only asserts that refreshToken request made, but never assert that the later requests use the refreshed token.
We need to test the full refresh flow, i.e,
- refresh token request is made
- refreshed tokens are successfully saved in the state
- refreshed tokens are used in the next requests instead of old tokens
This spec only tests the step 1.
There was a problem hiding this comment.
Sorry for the hassle, but token refresh logic in social login onboarding is a bit complicated and involves multiple moving pieces under the hood.
So, we need to test the full flow to make sure that everything is working as expected.
There was a problem hiding this comment.
I see, I'll extend the test to assert the next request that carries the social token. Thanks!
Does this also address your previous comment, assuming you agree with my reasoning for the previous spec's removal?
Ideally, we should assert that the next network call after token refresh, use the refreshed token instead of old one.
| ); | ||
|
|
||
| if (termsChecked) { | ||
| dispatch(setMarketingConsent(true)); |
There was a problem hiding this comment.
Since we remove this, where do we actually set the social login marketing consent now?
I couldn't find any caller to AuthenticatedUserStorageService:putMarketingConsent
There was a problem hiding this comment.
Marketing consent is set in Analytics controller, then Marketing Consent controller listens for this change and synchs the change to AUS. The putMarketingConsent call is made inside Marketing Consent controller,
| } | ||
| let cancelled = false; | ||
| const fetchConsent = async () => { | ||
| const marketingConsentFromRemote = await getMarketingConsent(); |
There was a problem hiding this comment.
We should fetch the fresh state from the AUS here, instead of relying on the local state.
The user could opt out the consent from the another device and the status might not be refreshed in the current state yet.
There was a problem hiding this comment.
We already refresh the value of marketing consent on: UI open, unlock and sign-in so this should be a fresh value unless the user, using another installation, changed the value while this page is already open, which I think is acceptable
| ); | ||
|
|
||
| // sync marketing consent with metametrics | ||
| const marketingConsent = await getMarketingConsent(); |
There was a problem hiding this comment.
May I check where is the AUS equivalent for this?
If I understand it correctly, AUS runs after onboarding is completed? But I can't find any usage of AuthenticatedUserStorageService:getMarketingConsent in the extension.
There was a problem hiding this comment.
Yes, most of the logic and calls related to marketing consent have been moved to a new core controller so we can reuse across extension and mobile: MarketingConsentController. MCC synchs with AUS on unlock, sign-in and ui open and since sign-in happens after onboarding we get marketing consent synched.
Keep in mind that marketing consent and metametrics are now two distinct preferences so they have no reason to be in synch anymore.
The refresh test only checked that the refresh_token grant was requested. Mock the social identifier pairing endpoint and assert the social_jwt it sends is the refreshed token.
getMockedRequests waits out the driver timeout while unmatched mock rules are pending, so calling it three times added about 20s. Wait for the pairing request directly and reuse the single fetched result.
Builds ready [2d14dc3] [reused from 004909c]
⚡ Performance Benchmarks (Total: 🟢 0 pass · 🟡 0 warn · 🔴 0 fail)
Bundle Size Diffs [🚀 Bundle size reduced!]
|
Builds ready [8c2f4ee]
⚡ Performance Benchmarks (Total: 🟢 5 pass · 🟡 5 warn · 🔴 3 fail)
Bundle Size Diffs [🚀 Bundle size reduced!]
|
|




Description
With #47040, AUS stores marketing consent for every user, so the auth server (OAuth) copy kept for social login users is removed. AUS becomes the only remote store for marketing consent.
getMarketingConsent/setMarketingConsentare removed fromOAuthService, its messenger, the background API and the UI actions.falseif that request fails) on every social login restore, and that value then overwrites AUS.Notes for code owners
@MetaMask/web3auth(app/scripts/services/oauth,create-password.tsx): theOAuthServicemessenger no longer needsSeedlessOnboardingController:getAccessToken.refresh-auth-tokens.spec.tschecks the auth serverrefresh_tokengrant directly, since it used the removed consent endpoint to observe the refresh, and asserts that the social identifier pairing request (/api/v2/profile/pair/identifier, now mocked) carries the refreshedsocial_jwt. The lock/unlock test is removed: nothing in the e2e flow sends the social access token after unlock anymore, and core covers keeping the newer token (SeedlessOnboardingController.test.ts).@MetaMask/core-extension-ux(data-collection-item.tsx): the marketing toggle no longer fetches or writes OAuth consent; the social login description stays.@MetaMask/core-platform/@MetaMask/extension-platform(metamask-controller.js,legacy-background-api-snapshot.json): only the two OAuth consent bindings are removed.Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/GE-513 (part 3 of 5)
Manual testing steps
Screenshots/Recordings
Before
N/A, no visual changes. Behavior changes are listed in the description.
After
N/A, no visual changes. Behavior changes are listed in the description.
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches onboarding analytics and privacy settings for social-login users; behavior depends on AUS (#47040) being deployed so consent is not lost when the OAuth sync path is gone.
Overview
Removes auth-server marketing opt-in from the OAuth path so social-login marketing consent is no longer read or written via
OAuthServiceor the legacy background API (getMarketingConsent/setMarketingConsent).OAuthServicedrops the marketing GET/POST helpers and no longer delegatesSeedlessOnboardingController:getAccessTokento its messenger. Onboarding create-password and Settings → Privacy only update localsetDataCollectionForMarketing; social-login restore reports analytics from Redux instead of overwriting consent from the auth server.E2E and unit tests are updated: token-refresh coverage now asserts a
refresh_tokengrant and refreshed JWT on social identifier pairing, with marketing opt-in mocks removed.Reviewed by Cursor Bugbot for commit 2d14dc3. Bugbot is set up for automated code reviews on this repo. Configure here.
Jira: GE-589