Skip to content

fix: shield-cohort-post-tx-modal-not-show#39898

Merged
tuna1207 merged 12 commits intomainfrom
fix/shield-cohort-post-tx-modal-not-show
Feb 12, 2026
Merged

fix: shield-cohort-post-tx-modal-not-show#39898
tuna1207 merged 12 commits intomainfrom
fix/shield-cohort-post-tx-modal-not-show

Conversation

@tuna1207
Copy link
Copy Markdown
Member

@tuna1207 tuna1207 commented Feb 8, 2026

Description

The Shield announcement modal uses a cohort strategy (wallet_home / post_tx) to determine when to show users the entry modal. Users assigned to the post_tx cohort were never seeing the modal due to multiple issues in the evaluation flow:

  1. pendingShieldCohort was not persisted - With persist: false, the POST_TX cohort value set by #assignPostTxCohort after a swap/transfer was lost whenever the MV3 service worker restarted. On the next Home page visit, componentDidMount would overwrite it with WALLET_HOME, causing the evaluation to return early for pending-but-not-expired users. Changed to persist: true so the value survives service worker restarts.

  2. Pending cohort cleared before evaluation completed - setPendingShieldCohort(null) was called synchronously before evaluateCohortEligibility had a chance to finish. If the evaluation failed, the pending cohort was permanently lost with no retry. Now the pending cohort is only cleared after the evaluation promise resolves successfully.

  3. Timeout event fired incorrectly for non-expired cohorts - When entrypointCohort === POST_TX, the guard entrypointCohort !== POST_TX && !hasExpired was always false, causing the ShieldEligibilityCohortTimeout event to fire even when the assigned cohort had not actually expired. Added a hasExpired guard so the timeout event only fires when the cohort has genuinely expired.

  4. Missing error observability - Failures in evaluateCohortEligibility were only logged with log.warn. Added Sentry error capture so cohort evaluation failures surface in monitoring.

  5. post_tx could not overwrite an existing wallet_home pending cohort - #assignPostTxCohort only set POST_TX when pendingShieldCohort was falsy (!pendingShieldCohort). If the user had already visited Home (setting it to WALLET_HOME), a subsequent swap would not overwrite it. Now the guard checks specifically for pendingShieldCohort === POST_TX instead, allowing POST_TX to take priority over WALLET_HOME.

Ref: cohort technical details

Open in GitHub Codespaces

Changelog

CHANGELOG entry: Fixed a bug where users assigned to the post-transaction Shield cohort would never see the Shield announcement modal

Related issues

Fixes:

Manual testing steps

  1. Build and load the extension with Shield feature enabled
  2. For post_tx cohort, sign in and navigate to the Home pageverify no modal appears (initial cohort assignment happens silently for post_tx users)
  3. Perform a swap or token transfer transaction
  4. Navigate back to the Home page
  5. Verify the Shield entry modal appears for users assigned to the post_tx cohort
  6. Close the extension completely, reopen it, and repeat steps 3-5, verify the pendingShieldCohort value persists across restarts and the modal still appears
  7. For wallet_home cohort users: verify the modal still appears immediately on first Home page visit (no regression)

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 persisted app state and Shield cohort/metrics flow, which could affect when modals appear and what telemetry is emitted, but changes are localized and largely additive/guarded.

Overview
Fixes Shield cohort handling so users assigned to the post_tx cohort reliably see the Shield entry modal.

pendingShieldCohort is now persisted in AppStateController, SubscriptionService now allows POST_TX to override an existing pending cohort, and the UI evaluation flow was hardened by clearing/restoring the pending cohort around async eligibility checks (with added Sentry capture), awaiting modal state updates, and only emitting the ShieldEligibilityCohortTimeout metric when the assigned cohort has actually expired. Test fixtures/state snapshots were updated to reflect the new persisted pendingShieldCohort state.

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

@metamaskbot metamaskbot added the team-onboarding Onboarding team label Feb 8, 2026
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 8, 2026

✨ Files requiring CODEOWNER review ✨

👨‍🔧 @MetaMask/core-extension-ux (1 files, +0 -2)
  • 📁 ui/
    • 📁 pages/
      • 📁 home/
        • 📄 home.component.js +0 -2

👨‍🔧 @MetaMask/extension-platform (1 files, +1 -0)
  • 📁 test/
    • 📁 e2e/
      • 📁 fixtures/
        • 📄 onboarding-fixture.json +1 -0

🕵️ @MetaMask/extension-privacy-reviewers (1 files, +1 -1)
  • 📁 test/
    • 📁 e2e/
      • 📁 tests/
        • 📁 settings/
          • 📄 state-logs.json +1 -1

🧪 @MetaMask/qa (2 files, +2 -1)
  • 📁 test/
    • 📁 e2e/
      • 📁 fixtures/
        • 📄 onboarding-fixture.json +1 -0
      • 📁 tests/
        • 📁 settings/
          • 📄 state-logs.json +1 -1

🔐 @MetaMask/web3auth (1 files, +41 -11)
  • 📁 ui/
    • 📁 contexts/
      • 📁 shield/
        • 📄 shield-subscription.tsx +41 -11

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 8, 2026

Builds ready [a8d7a95]
UI Startup Metrics (1455 ± 110 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup14551233174711015271647
load12411035151210613181427
domContentLoaded12341025150610613121421
domInteractive2914107202482
firstPaint186671409201219352
backgroundConnect24222032215248274
firstReactRender16103441825
initialActions109113
loadScripts1006781128210710791201
setupStore1473141621
numNetworkReqs231585201581
BrowserifyPower User HomeuiStartup17161361294421917872133
load1115994220218810861564
domContentLoaded1101986218818410681536
domInteractive3317170253199
firstPaint224661665220242391
backgroundConnect31427546235320381
firstReactRender21144142229
initialActions107111
loadScripts87276418631728441279
setupStore1353341522
numNetworkReqs1135127949136210
WebpackStandard HomeuiStartup85167510821019311026
load71560493384785864
domContentLoaded71059992884780854
domInteractive2615106192376
firstPaint1015834945117181
backgroundConnect3718233294187
firstReactRender16103561831
initialActions104112
loadScripts70759792683777848
setupStore1254161223
numNetworkReqs231599221586
WebpackPower User HomeuiStartup1267955204220713621740
load71961812411387021100
domContentLoaded70961212341376901074
domInteractive38181683334128
firstPaint158651167166145343
backgroundConnect16613040962156321
firstReactRender22173032427
initialActions102011
loadScripts70661012261356881067
setupStore1252031418
numNetworkReqs1214828656147268
FirefoxBrowserifyStandard HomeuiStartup16281331232119817451973
load13671148178616014581687
domContentLoaded13661148178616014581687
domInteractive803526844107147
firstPaint------
backgroundConnect753022944109166
firstReactRender1291821316
initialActions103122
loadScripts13261127174214113971596
setupStore155177211234
numNetworkReqs251299231893
BrowserifyPower User HomeuiStartup28032047441559330243998
load15691266246131016662375
domContentLoaded15681266246131016632375
domInteractive1133468299111253
firstPaint------
backgroundConnect3191101395269325909
firstReactRender18146051923
initialActions102122
loadScripts15121227242928115782231
setupStore1307711182146568
numNetworkReqs66381413094120
WebpackStandard HomeuiStartup16401323218817917361996
load13921182177711314641573
domContentLoaded13921182177711314631573
domInteractive803025847105144
firstPaint------
backgroundConnect72252555185183
firstReactRender15115951522
initialActions103122
loadScripts13551168164910014191507
setupStore186233321249
numNetworkReqs231396181873
WebpackPower User HomeuiStartup28012053786082129723641
load16291246652069817192259
domContentLoaded16291246651969817192258
domInteractive11529738127104405
firstPaint------
backgroundConnect2991171381238333869
firstReactRender21153442330
initialActions204122
loadScripts15661194649368616512110
setupStore1678908223234654
numNetworkReqs63371543287120
📊 Page Load Benchmark Results

Current Commit: a8d7a95 | Date: 2/8/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±55ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 718ms (±53ms) 🟢 | historical mean value: 731ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±31ms) 🟢 | historical mean value: 78ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 55ms 1.01s 1.53s 1.06s 1.53s
domContentLoaded 718ms 53ms 695ms 1.20s 736ms 1.20s
firstPaint 77ms 31ms 60ms 376ms 84ms 376ms
firstContentfulPaint 77ms 31ms 60ms 376ms 84ms 376ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 58 Bytes (0%)
  • ui: 337 Bytes (0%)
  • common: 20 Bytes (0%)

@tuna1207 tuna1207 marked this pull request as ready for review February 8, 2026 14:51
@tuna1207 tuna1207 requested review from a team as code owners February 8, 2026 14:51
lwin-kyaw
lwin-kyaw previously approved these changes Feb 10, 2026
LeVinhGithub
LeVinhGithub previously approved these changes Feb 11, 2026
@chaitanyapotti chaitanyapotti added this pull request to the merge queue Feb 11, 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 Feb 11, 2026
@huggingbot huggingbot removed this pull request from the merge queue due to a manual request Feb 11, 2026
Copy link
Copy Markdown

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

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 11, 2026

Builds ready [a08c365]
UI Startup Metrics (1331 ± 90 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1331114215419013871516
load114496713308312001277
domContentLoaded113796513228211931257
domInteractive251396182276
firstPaint177591302161197274
backgroundConnect22320727713227246
firstReactRender15103541723
initialActions105113
loadScripts9297521110829851053
setupStore1263151419
numNetworkReqs2415101231589
BrowserifyPower User HomeuiStartup3170141610182186440476344
load12191055172414012421581
domContentLoaded12021047165913212261548
domInteractive3418196293098
firstPaint246812459276259495
backgroundConnect10142874741105911723563
firstReactRender23154562638
initialActions106112
loadScripts96882214051259901307
setupStore1344161524
numNetworkReqs914618428106143
WebpackStandard HomeuiStartup812669107592875963
load71159997291777870
domContentLoaded70659496491771865
domInteractive251695192180
firstPaint1046033453123201
backgroundConnect24174662635
firstReactRender13102331620
initialActions104112
loadScripts70359296290769860
setupStore1163151123
numNetworkReqs231593211584
WebpackPower User HomeuiStartup1328896322534813931923
load75964812351267541100
domContentLoaded74764112221257441091
domInteractive45193074539130
firstPaint188711128131222353
backgroundConnect2171541146151185343
firstReactRender23173642532
initialActions103111
loadScripts74463912141237421079
setupStore1254251420
numNetworkReqs1394423735156194
FirefoxBrowserifyStandard HomeuiStartup15531312220918515801939
load13321122197413813841627
domContentLoaded13311122196613813831627
domInteractive71312735086149
firstPaint------
backgroundConnect5528179215498
firstReactRender11101811213
initialActions103012
loadScripts13071107194413513571575
setupStore186184311347
numNetworkReqs241298211784
BrowserifyPower User HomeuiStartup28402168599152829463472
load15851317468744316341844
domContentLoaded15841316468744316341844
domInteractive15256702106170372
firstPaint------
backgroundConnect42911812573126071073
firstReactRender19146371823
initialActions207122
loadScripts15441293463343815821782
setupStore12016717154112511
numNetworkReqs903921834106152
WebpackStandard HomeuiStartup15731283199613516251848
load13591181171210314071535
domContentLoaded13581178171110314071535
domInteractive812823144122135
firstPaint------
backgroundConnect57242333461107
firstReactRender14115351420
initialActions103112
loadScripts1328113415719113851508
setupStore186240311150
numNetworkReqs241395201782
WebpackPower User HomeuiStartup28112134865569929233408
load15561260308227816382165
domContentLoaded15561259308227816382164
domInteractive195511068199180738
firstPaint------
backgroundConnect4741155953611528995
firstReactRender21163042328
initialActions213122
loadScripts15121235304027516022018
setupStore17915932202225628
numNetworkReqs90412283695162
📊 Page Load Benchmark Results

Current Commit: a08c365 | Date: 2/11/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.02s (±44ms) 🟡 | historical mean value: 1.03s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 703ms (±40ms) 🟢 | historical mean value: 717ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±11ms) 🟢 | historical mean value: 76ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.02s 44ms 972ms 1.31s 1.06s 1.31s
domContentLoaded 703ms 40ms 670ms 978ms 740ms 978ms
firstPaint 78ms 11ms 64ms 172ms 84ms 172ms
firstContentfulPaint 78ms 11ms 64ms 172ms 84ms 172ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -52.2 KiB (-1.29%)
  • ui: 55.25 KiB (0.67%)
  • common: 169.69 KiB (1.58%)

@tuna1207 tuna1207 added this pull request to the merge queue Feb 12, 2026
Merged via the queue into main with commit e6d841e Feb 12, 2026
333 of 335 checks passed
@tuna1207 tuna1207 deleted the fix/shield-cohort-post-tx-modal-not-show branch February 12, 2026 01:11
@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 Feb 12, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Feb 12, 2026
@metamaskbot metamaskbot added the release-13.19.0 Issue or pull request that will be included in release 13.19.0 label Feb 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-shield release-13.19.0 Issue or pull request that will be included in release 13.19.0 size-S team-shield Shield team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants