Skip to content

Conversation

@imblue-dabadee
Copy link
Contributor

@imblue-dabadee imblue-dabadee commented Dec 4, 2025

Description

The "Transaction Added" event was missing the address_alert_response field, which made it difficult to analyze transaction flows by address security status from the initial event.

Solution
Added address_alert_response to the initial "Transaction Added" event. The field includes:

  • The actual scan result if already cached (e.g., 'Benign', 'Malicious')
  • 'Loading' if the scan is still in progress
  • 'not_applicable' when scanning cannot be performed (security alerts disabled, no to address, or unsupported chain)

The useTrustSignalMetrics hook continues to update the event fragment with the final value once the scan completes.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: null

Manual testing steps

  1. Start the mock Segment server:
node development/mock-segment.js
  1. Start the extension with Segment enabled:
yarn start
  1. Trigger a transaction (e.g., send ETH or interact with a dApp)
  2. In the mock Segment terminal, observe the "Transaction Added" event
  3. Verify address_alert_response is present with one of:
    • 'Loading' (scan in progress)
    • 'Benign', 'Malicious', 'Warning' (scan result)
    • 'not_applicable' (security alerts disabled or unsupported chain)
  4. Approve or reject the transaction
  5. Verify the "Transaction Finalized" event has the final address_alert_response value (should no longer be 'Loading')

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 address_alert_response to transaction event properties, sourcing cached trust-signal results when available or marking as Loading/not_applicable as needed.

  • Metrics (transaction events):
    • Add address_alert_response to properties built in buildEventFragmentProperties for "added", "approved", "submitted", and "finalized" flows.
    • New helper computes value using trust-signal utils (createCacheKey, mapChainIdToSupportedEVMChain, ResultType):
      • Uses cached response result_type when present.
      • Falls back to Loading or not_applicable (security alerts disabled, missing to, or unsupported chain).
  • Controller/Types:
    • Extend TransactionMetricsRequest with getAddressSecurityAlertResponse(cacheKey) and getSecurityAlertsEnabled(); expose implementations in metamask-controller.
    • Import trust-signal types (ScanAddressResponse) and utilities in metrics module.
  • Tests:
    • Update metrics tests to mock new getters and expect address_alert_response in event properties.

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

@imblue-dabadee imblue-dabadee requested a review from a team as a code owner December 4, 2025 21:48
@imblue-dabadee imblue-dabadee added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Dec 4, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

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-product-safety Push issues to Product Safety team label Dec 4, 2025
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Dec 4, 2025
@metamaskbot
Copy link
Collaborator

metamaskbot commented Dec 4, 2025

✨ Files requiring CODEOWNER review ✨

@MetaMask/confirmations (2 files, +58 -0)
  • 📁 app/
    • 📁 scripts/
      • 📁 lib/
        • 📁 transaction/
          • 📄 metrics.test.ts +5 -0
          • 📄 metrics.ts +53 -0

@github-actions github-actions bot added the size-S label Dec 4, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [865e80c]
UI Startup Metrics (1201 ± 102 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup12011009143010212751378
load100183712058510661154
domContentLoaded99583211998410601147
domInteractive2515156222085
firstPaint61877121740610171146
backgroundConnect20718224412211231
firstReactRender30206093548
getState3514134194164
initialActions108112
loadScripts79464599781847932
setupStore1272941321
numNetworkReqs1056816558
BrowserifyPower User HomeuiStartup21531779288321822772599
load1070921167113210831405
domContentLoaded1055916165913210661397
domInteractive37201332437106
firstPaint53892144040710051302
backgroundConnect268211747107246615
firstReactRender6043106146495
getState21114176194216261
initialActions104112
loadScripts83170414451298321162
setupStore211073102542
numNetworkReqs1556634157206271
WebpackStandard HomeuiStartup819701108181851984
load63956886676657812
domContentLoaded63456185975651806
domInteractive27151542523101
firstPaint23288826160214609
backgroundConnect1165671126
firstReactRender27204163239
getState271461113549
initialActions104111
loadScripts63155985074649796
setupStore1163541219
numNetworkReqs1157117559
WebpackPower User HomeuiStartup15631267218520916292029
load674578105491687875
domContentLoaded664574104891674863
domInteractive35171662735102
firstPaint26796915190268690
backgroundConnect50762212319458
firstReactRender58419386369
getState19113174297184219
initialActions102112
loadScripts662572103990672859
setupStore20658102345
numNetworkReqs1645232760216279
FirefoxBrowserifyStandard HomeuiStartup13211099181214114041581
load109294513488811501254
domContentLoaded109194513488811461254
domInteractive63331462986116
firstPaint------
backgroundConnect48221452959124
firstReactRender23184652436
getState125105121124
initialActions102112
loadScripts106492812717711211197
setupStore12471111034
numNetworkReqs1256817664
BrowserifyPower User HomeuiStartup26742081443746427683953
load12631000255228712441750
domContentLoaded1262993255228712441750
domInteractive143331024144126432
firstPaint------
backgroundConnect143281112155157456
firstReactRender5739113136286
getState30366953223346792
initialActions217123
loadScripts1218982239825312151703
setupStore1548882201144743
numNetworkReqs83531672579147
WebpackStandard HomeuiStartup15321281189015016261841
load12601074161810513321424
domContentLoaded12591073161110513321424
domInteractive63271653586139
firstPaint------
backgroundConnect54191963367122
firstReactRender27218782938
getState147155171447
initialActions103112
loadScripts1231106015949913091387
setupStore13582111437
numNetworkReqs1256617763
WebpackPower User HomeuiStartup29982205544475429334709
load14791197299742214582797
domContentLoaded14791196299742114582797
domInteractive1083247993106351
firstPaint------
backgroundConnect1973912862591631052
firstReactRender68382133266154
getState26771833203362727
initialActions207123
loadScripts14021098284131914362061
setupStore15161088213122685
numNetworkReqs84602583179153
📊 Page Load Benchmark Results

Current Commit: 865e80c | Date: 12/4/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±43ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 717ms (±39ms) 🟢 | historical mean value: 732ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±15ms) 🟢 | historical mean value: 77ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 43ms 1.00s 1.35s 1.08s 1.35s
domContentLoaded 717ms 39ms 696ms 1.01s 737ms 1.01s
firstPaint 76ms 15ms 56ms 208ms 88ms 208ms
firstContentfulPaint 76ms 15ms 56ms 208ms 88ms 208ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 960 Bytes (0.02%)
  • ui: 0 Bytes (0%)
  • common: 20 Bytes (0%)

@imblue-dabadee imblue-dabadee changed the title feat(metrics)/track address_alert_response when transactions are added feat(metrics): track address_alert_response when transactions are added Dec 5, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [c898d6f]
UI Startup Metrics (1251 ± 96 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1251103214749613181409
load103885012498211041177
domContentLoaded103284512418111001171
domInteractive21153962137
firstPaint48295123839510061154
backgroundConnect21019325511215230
firstReactRender4631101145275
getState3817123194274
initialActions105113
loadScripts829655104778891965
setupStore1263441421
numNetworkReqs86316630
BrowserifyPower User HomeuiStartup19131554226212519982161
load1098913132710011571303
domContentLoaded108490813109911441278
domInteractive27188892745
firstPaint60291133543110671223
backgroundConnect268206737113253640
firstReactRender46368674956
getState19914828532222263
initialActions102112
loadScripts86469711021009241062
setupStore17116581637
numNetworkReqs69581151467110
WebpackStandard HomeuiStartup80170494943824869
load62355873148665709
domContentLoaded61855472648661704
domInteractive21144162137
firstPaint19988671135193619
backgroundConnect1153071328
firstReactRender54331553246122
getState23134792944
initialActions102111
loadScripts61655272447659702
setupStore1062131118
numNetworkReqs86316629
WebpackPower User HomeuiStartup14831184208816115901732
load73359393390821881
domContentLoaded72658892689811874
domInteractive271678112749
firstPaint271102829193263769
backgroundConnect52757412122503
firstReactRender48399785061
getState20214266864232310
initialActions102012
loadScripts72358592389809872
setupStore1485371432
numNetworkReqs6858208176697
FirefoxBrowserifyStandard HomeuiStartup12591091210114113251527
load1036923192911910701220
domContentLoaded1035923192911910701219
domInteractive52311942772104
firstPaint------
backgroundConnect3821120204191
firstReactRender37287193857
getState1276581024
initialActions102012
loadScripts1012910190411410401194
setupStore1052441021
numNetworkReqs86326725
BrowserifyPower User HomeuiStartup26281564345357630973340
load1588963243854521272371
domContentLoaded1588963243854521272371
domInteractive9732107319569252
firstPaint------
backgroundConnect1802511452641801097
firstReactRender5434103145988
getState1518234949179241
initialActions2134423
loadScripts1497940233550320022266
setupStore665110216440326
numNetworkReqs69541141372106
WebpackStandard HomeuiStartup16681441204813417401941
load1349117215177313951495
domContentLoaded1349117115177313951494
domInteractive76312053997144
firstPaint------
backgroundConnect52221822853124
firstReactRender4938114135291
getState198254321663
initialActions114122
loadScripts1321115514867113651464
setupStore187173241461
numNetworkReqs86265724
WebpackPower User HomeuiStartup28331813408757532553526
load18971149269151423472508
domContentLoaded18971146269051423472508
domInteractive132311112250801008
firstPaint------
backgroundConnect1792510562292111014
firstReactRender5635139136182
getState1368431947169227
initialActions3144623
loadScripts18131124248947922482416
setupStore3343396127204
numNetworkReqs69511181569111
📊 Page Load Benchmark Results

Current Commit: c898d6f | Date: 12/5/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±43ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 719ms (±40ms) 🟢 | historical mean value: 718ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±14ms) 🟢 | historical mean value: 76ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 43ms 1.01s 1.38s 1.06s 1.38s
domContentLoaded 719ms 40ms 698ms 1.04s 739ms 1.04s
firstPaint 77ms 14ms 60ms 200ms 84ms 200ms
firstContentfulPaint 77ms 14ms 60ms 200ms 84ms 200ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -27.21 KiB (-0.51%)
  • ui: 4.45 KiB (0.06%)
  • common: -188.57 KiB (-2.07%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed size-S team-product-safety Push issues to Product Safety team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants