Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adds a unique id to RPC events for extension #996

Merged
merged 22 commits into from
Aug 29, 2024

Conversation

andreahaku
Copy link
Contributor

@andreahaku andreahaku commented Aug 23, 2024

Explanation

Fixes the unique id (5a374dcd2e5eb762b527af3a5bab6072a4d24493 - SHA1 of sdk string) for all analytics events coming from extension. It adds a UUID that is stored in the localStorage with a key that is the base64 of the url and name coming from the dapp metadata.

It also includes #1000 setting the from to mobile for RPC calls events when a dapp is opened in the MM mobile in-app browser.

Testing

  • Check that when using MM Extension on a dapp using the MM SDK, a unique id (uuid) is sent when tracking RPC calls and that this id is not 5a374dcd2e5eb762b527af3a5bab6072a4d24493
  • Check that when opening a dapp using the MM SDK, in the MM mobile in-app browser, when tracking RPC calls events, the from is set to mobile and not extension

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@andreahaku andreahaku self-assigned this Aug 23, 2024
@andreahaku andreahaku marked this pull request as ready for review August 26, 2024 09:44
@andreahaku andreahaku requested a review from a team as a code owner August 26, 2024 09:44
Copy link

@BjornGunnarsson BjornGunnarsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can use this approach.
After thinking it through, sending the address ( even hashed ) to then store and use in our analytics is not something we can do as pertains to Privacy.
There has been a lot of work related to MetaMetricsID, that down the line we can use, but as a short term solution we should just generate a random ID.

So if we can generate and store a randomID on the client browser to use for the sdk_analytics.

@andreahaku andreahaku force-pushed the fix/unique_extension_userid branch from eef8b44 to 51cf5b9 Compare August 27, 2024 07:55
@andreahaku andreahaku force-pushed the fix/unique_extension_userid branch from 51cf5b9 to ecd3e74 Compare August 27, 2024 07:57
Copy link

socket-security bot commented Aug 27, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@types/uuid@10.0.0 None 0 7.82 kB types

View full report↗︎

Copy link

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 2 lines in your changes missing coverage. Please review.

Project coverage is 80.69%. Comparing base (ec20994) to head (9b4dd06).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rc/provider/extensionProviderHelpers/handleUuid.ts 93.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #996      +/-   ##
==========================================
+ Coverage   80.57%   80.69%   +0.11%     
==========================================
  Files         177      178       +1     
  Lines        4001     4035      +34     
  Branches      993     1001       +8     
==========================================
+ Hits         3224     3256      +32     
- Misses        777      779       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

abretonc7s
abretonc7s previously approved these changes Aug 27, 2024
Copy link
Collaborator

@abretonc7s abretonc7s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@BjornGunnarsson BjornGunnarsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

#1000)

fix: sets the `from` to `mobile` when connected via MM mobile in-app browser
@andreahaku andreahaku dismissed stale reviews from BjornGunnarsson and abretonc7s via b4e0bb8 August 27, 2024 13:16
@christopherferreira9
Copy link
Collaborator

Analytics being sent to socket server with unique UUID for extension connection different than 5a374dcd2e5eb762b527af3a5bab6072a4d24493:

Screenshot 2024-08-28 at 10 09 17

localStorage storing the key above:

Screenshot 2024-08-28 at 10 09 35

Base64 decoding of the key stored in localStorage that referes to the UUID above:

Screenshot 2024-08-28 at 10 10 09

@christopherferreira9
Copy link
Collaborator

Inapp browser showing from as mobile.

Screenshot 2024-08-28 at 11 20 08

@andreahaku andreahaku requested a review from abretonc7s August 28, 2024 10:43
Copy link

@BjornGunnarsson BjornGunnarsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality of how we distinguish what the "from" value is critical.
I do not see any reason for us to re-implement that if we already have a method exposed by the SDK that can get the connected "from" in a more detailed manner.

@andreahaku
Copy link
Contributor Author

The functionality of how we distinguish what the "from" value is critical. I do not see any reason for us to re-implement that if we already have a method exposed by the SDK that can get the connected "from" in a more detailed manner.

When on a desktop browser, the user connects with the MM mobile app via QRCode, the from is correctly set to mobile:
Screenshot 2024-08-28 at 18 15 34

Video:
https://github.com/user-attachments/assets/ff97c582-f157-44c4-a725-f431153efeea

@BjornGunnarsson
Copy link

@omridan159 could you take a look over the code here, and approve if everything is good.
Then we can get this into the next release of the SDK

Copy link
Collaborator

@abretonc7s abretonc7s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved to get into release but might need to adjust logic to simplify later.

@abretonc7s abretonc7s merged commit 3e478c2 into main Aug 29, 2024
28 checks passed
@abretonc7s abretonc7s deleted the fix/unique_extension_userid branch August 29, 2024 13:14
Copy link

@abretonc7s abretonc7s mentioned this pull request Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants