MetaMask / metamask-sdk

The simplest yet most secure way to connect your blockchain-based applications to millions of MetaMask Wallet users.
https://metamask.io/sdk/
Other
188 stars 115 forks source link

fix: send missing originator info in rpc request analytics #1073

Closed elefantel closed 3 weeks ago

elefantel commented 1 month ago

Explanation

This PR adds originator info in the sdk_rpc_request analytics. This information is currently missing making it not possible to attribute sdk_rpc_request_done to the corresponding request.

Currently the sdk_rpc_request analytics analytics looks like this:

{
  "id": "f24a4662-ed1c-4628-a31c-ea3f0ee60675",
  "event": "sdk_rpc_request",
  "method": "personal_sign",
  "from": "mobile"
}

While the corresponding the sdk_rpc_request_done analytics analytics looks like this:

{
  "id": "f24a4662-ed1c-4628-a31c-ea3f0ee60675",
  "event": "sdk_rpc_request_done",
  "sdkVersion": "0.29.2",
  "commLayerVersion": "0.29.2",
  "url": "http://localhost:3000",
  "title": "Demo React App",
  "source": "direct",
  "dappId": "localhost",
  "icon": "http://localhost:3000/favicon.ico",
  "platform": "web-desktop",
  "apiVersion": "0.29.2",
  "method": "personal_sign",
  "from": "mobile"
}

Checklist

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 78.02%. Comparing base (95a6a83) to head (afe78b7). Report is 14 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1073 +/- ## ======================================= Coverage 78.02% 78.02% ======================================= Files 179 179 Lines 4164 4164 Branches 1023 1023 ======================================= Hits 3249 3249 Misses 915 915 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

andreahaku commented 1 month ago

The Socket.io server should be able to add all the additional info by automatically attaching them to all events with the same id.

elefantel commented 3 weeks ago

Tested this without the changes proposed in this PR, on local server and the data seems right. Had previously inspected analytics logs from network tab on the browser, which is before originator info is added on socket code.