Skip to content

Conversation

@vinistevam
Copy link
Contributor

@vinistevam vinistevam commented Nov 13, 2025

Description

This PR aims to add metrics for transaction shield.

  • shield_result_response_latency_ms: latency to receive response from Shield

Upgrading @metamask/shield-controller from ^1.2.0 to ^2.1.0, to support tracking latency of the requests.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/6136

Manual testing steps

  1. Start the app
  2. Switch to Sepolia network
  3. Mint some USDC on sepolia on this smart contract (at least 80 for annual plan, 96 for monthly).
  4. Import the token manually in the assets list
  5. Navigate to Settings > Transaction Shield
  6. Select pay with crypto, and Continue
  7. The confirmation screen should appear and new shield properties should be added to the transaction/signature events
  8. Check Segment

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

Adds shield_result_response_latency_ms to transaction/signature event fragments, introduces getCoverageMetrics selector, updates tests, and bumps @metamask/shield-controller to ^2.1.0.

  • Alerts/Telemetry:
    • useShieldCoverageAlert now records shield_result_response_latency_ms (from metrics.latency or "N/A") in event fragments.
    • Pulls metrics via new selector getCoverageMetrics; refines getShieldResult default handling and effect dependencies.
  • Selectors:
    • Add types CoverageStatusResult, CoverageMetrics and helper getFirstCoverageResult.
    • Implement getCoverageMetrics and refactor getCoverageStatus to use shared helper.
  • Tests:
    • Extend useShieldCoverageAlert.test to assert latency propagation for tx/signature paths and various statuses.
    • Add comprehensive tests for getCoverageMetrics and edge cases in getCoverageStatus.
  • Dependencies:
    • Upgrade @metamask/shield-controller to ^2.1.0.

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

@vinistevam vinistevam requested review from a team as code owners November 13, 2025 16:48
@vinistevam vinistevam added the team-confirmations Push issues to confirmations team label Nov 13, 2025
@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.

@vinistevam vinistevam changed the title fix: enhance metrics for Transaction/Signatures evens (Shield) fix: enhance metrics for Transaction/Signatures events (Shield) Nov 13, 2025
@socket-security
Copy link

socket-security bot commented Nov 13, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​metamask/​shield-controller@​1.2.0 ⏵ 2.1.098 +110076 +196 +1100

View full report

@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

@MetaMask/confirmations (2 files, +33 -9)
  • 📁 ui/
    • 📁 pages/
      • 📁 confirmations/
        • 📁 hooks/
          • 📁 alerts/
            • 📄 useShieldCoverageAlert.test.ts +16 -2
            • 📄 useShieldCoverageAlert.ts +17 -7

🔐 @MetaMask/web3auth (2 files, +33 -9)
  • 📁 ui/
    • 📁 pages/
      • 📁 confirmations/
        • 📁 hooks/
          • 📁 alerts/
            • 📄 useShieldCoverageAlert.test.ts +16 -2
            • 📄 useShieldCoverageAlert.ts +17 -7

@metamaskbot
Copy link
Collaborator

Builds ready [fd8b295]
UI Startup Metrics (1247 ± 94 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1247109214689413221425
load108294712998911541238
domContentLoaded107594312898811501223
domInteractive2414101172166
firstPaint63488132142310531200
backgroundConnect23822431412241253
firstReactRender25175352635
getState2087082436
initialActions105112
loadScripts844719106287920994
setupStore1062221114
numNetworkReqs1367720671
BrowserifyPower User HomeuiStartup22851891283923624702839
load1099918145217913341452
domContentLoaded1078907144317713221443
domInteractive611924266130242
firstPaint813243145441810391454
backgroundConnect2432342637245263
firstReactRender74401432490143
getState21416035352247353
initialActions102112
loadScripts854678121217510791212
setupStore291551113951
numNetworkReqs1529729775251297
WebpackStandard HomeuiStartup8066941150908091055
load60155094882596839
domContentLoaded59454491979590826
domInteractive1711118151348
firstPaint20861948203200789
backgroundConnect251180153059
firstReactRender28177693234
getState1171931316
initialActions102111
loadScripts59154190676588816
setupStore1153851315
numNetworkReqs1367620673
WebpackPower User HomeuiStartup1070906155321812311553
load668578978127733978
domContentLoaded652560947119719947
domInteractive41131464287146
firstPaint396129895236574895
backgroundConnect56111885980188
firstReactRender38334334043
getState1368516325150163
initialActions101011
loadScripts648558937116708937
setupStore14633102433
numNetworkReqs1117022546161225
FirefoxBrowserifyStandard HomeuiStartup14451286196112114731679
load1219111414708212491397
domContentLoaded1218111314708112491396
domInteractive1063530548108209
firstPaint------
backgroundConnect4125127184976
firstReactRender25204952638
getState127180171018
initialActions102122
loadScripts1194109714407712221367
setupStore1175261124
numNetworkReqs1267216757
BrowserifyPower User HomeuiStartup34832707437951338944379
load15651275235331818382353
domContentLoaded15651274235331818382353
domInteractive337122720205542720
firstPaint------
backgroundConnect54913613054109781305
firstReactRender845212119103121
getState1958450592239505
initialActions218238
loadScripts15121214221030317852210
setupStore73301252997125
numNetworkReqs1539131067225310
WebpackStandard HomeuiStartup17941561225814718392105
load15071274190311215591740
domContentLoaded15071274190211215591739
domInteractive1103640744118174
firstPaint------
backgroundConnect66273144372132
firstReactRender352593123646
getState158174181425
initialActions213122
loadScripts14711254186210615281697
setupStore17881141457
numNetworkReqs1366617865
WebpackPower User HomeuiStartup34292983435741137054357
load16631442202719118952027
domContentLoaded16621441202719118952027
domInteractive307105711188534711
firstPaint------
backgroundConnect407140917264759917
firstReactRender824511722102117
getState1549924837174248
initialActions213133
loadScripts16121401196418818121964
setupStore14249504121162504
numNetworkReqs1497832078231320
📊 Page Load Benchmark Results

Current Commit: fd8b295 | Date: 11/13/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±70ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 737ms (±68ms) 🟢 | historical mean value: 725ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±13ms) 🟢 | historical mean value: 80ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 70ms 1.01s 1.32s 1.26s 1.32s
domContentLoaded 737ms 68ms 702ms 1.00s 944ms 1.00s
firstPaint 78ms 13ms 64ms 192ms 92ms 192ms
firstContentfulPaint 78ms 13ms 64ms 192ms 92ms 192ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 148 Bytes (0%)
  • ui: 307 Bytes (0%)
  • common: 20 Bytes (0%)

@metamaskbot
Copy link
Collaborator

Builds ready [bab9a95]
UI Startup Metrics (1270 ± 104 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup12701115161510413411462
load109695513459411851263
domContentLoaded109093313399311791256
domInteractive241597182174
firstPaint63682134743410901219
backgroundConnect24122334013244259
firstReactRender27198292846
getState2287992538
initialActions104112
loadScripts8557001108919411017
setupStore1172431217
numNetworkReqs1367719670
BrowserifyPower User HomeuiStartup22691949283924124872839
load1176992160720314541607
domContentLoaded1154978160020814461600
domInteractive641919166167191
firstPaint637144152350010281523
backgroundConnect25423727611260276
firstReactRender73521071483107
getState24515433048298330
initialActions103113
loadScripts923748136620312171366
setupStore27114083440
numNetworkReqs1239117929166179
WebpackStandard HomeuiStartup82770412041008251108
load61455897089603882
domContentLoaded60755394284596865
domInteractive181178131454
firstPaint20261971206201786
backgroundConnect251274143062
firstReactRender3018127133438
getState1162131216
initialActions104111
loadScripts60455293182594855
setupStore1153841316
numNetworkReqs1367319870
WebpackPower User HomeuiStartup1105903169628413291696
load67357610261537901026
domContentLoaded653566988138770988
domInteractive34131183578118
firstPaint32069949260572949
backgroundConnect641123974145239
firstReactRender38344223842
getState1459717424155174
initialActions101011
loadScripts648564977134760977
setupStore1462892528
numNetworkReqs826313327120133
FirefoxBrowserifyStandard HomeuiStartup15331350209413215571852
load1287116215789213241465
domContentLoaded1287116215779213241465
domInteractive1193638072114313
firstPaint------
backgroundConnect48282202754106
firstReactRender27227272743
getState1274971229
initialActions213123
loadScripts1260114415368512961438
setupStore15889121340
numNetworkReqs1266915756
BrowserifyPower User HomeuiStartup30822301421660336534216
load14721254192120116811921
domContentLoaded14721254192120116801921
domInteractive22054584181482584
firstPaint------
backgroundConnect49212010463297731046
firstReactRender84441151898115
getState1629926342186263
initialActions213123
loadScripts14181194175118216271751
setupStore943420455144204
numNetworkReqs1266923157194231
WebpackStandard HomeuiStartup16581435224615417051990
load14101214175011514891667
domContentLoaded14101214175011514881667
domInteractive983525638106178
firstPaint------
backgroundConnect54261923155135
firstReactRender31247663339
getState1286791219
initialActions103122
loadScripts13781195172110814421606
setupStore187211261272
numNetworkReqs1366817865
WebpackPower User HomeuiStartup33072471463260436794632
load16901452222926919572229
domContentLoaded16901452222826919572228
domInteractive333115900268567900
firstPaint------
backgroundConnect44910810062636751006
firstReactRender875013020104130
getState193104658128198658
initialActions317137
loadScripts16351381219227218722192
setupStore14927503128188503
numNetworkReqs1277623155191231
📊 Page Load Benchmark Results

Current Commit: bab9a95 | Date: 11/14/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±72ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 732ms (±69ms) 🟢 | historical mean value: 727ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 75ms (±12ms) 🟢 | historical mean value: 78ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 72ms 1.00s 1.33s 1.26s 1.33s
domContentLoaded 732ms 69ms 692ms 1.01s 940ms 1.01s
firstPaint 75ms 12ms 56ms 176ms 84ms 176ms
firstContentfulPaint 75ms 12ms 56ms 176ms 84ms 176ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 148 Bytes (0%)
  • ui: 307 Bytes (0%)
  • common: 20 Bytes (0%)

@chaitanyapotti chaitanyapotti changed the title fix: enhance metrics for Transaction/Signatures events (Shield) fix: enhance metrics for Transaction/Signatures events (Shield) cp-13.10.0 Nov 14, 2025
@vinistevam vinistevam enabled auto-merge November 14, 2025 09:16
@vinistevam vinistevam added this pull request to the merge queue Nov 14, 2025
Merged via the queue into main with commit ac3f905 Nov 14, 2025
332 of 334 checks passed
@vinistevam vinistevam deleted the vs/add-metrics-shield-latency branch November 14, 2025 09:54
@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2025
@metamaskbot metamaskbot added the release-13.11.0 Issue or pull request that will be included in release 13.11.0 label Nov 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.11.0 Issue or pull request that will be included in release 13.11.0 size-M team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants