Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

fix: better network comparison + WC peer tracking #3729

Merged
merged 4 commits into from
Mar 29, 2022
Merged

Conversation

iamacook
Copy link
Member

What it solves

Resolves #2812 + #3579

How this PR fixes it

The name of the WalletConnect peer is now tracked in the provider middleware alongside the connected wallet when the user is connected to a network. shouldSwitchNetwork was improved to prevent this from being over-tracked.

How to test it

Connect to the Safe via MM as an example and observe the following wallet tracking:

  1. Initial connection
  2. Account switching
  3. Changing chain in the UI then MM

The WC peer should be tracked in the same instances.

The "Switch wallet to {{chainName}}" button should continue to work as before.

Analytics changes

The WC peer name should now be tracked, tracking as 'Unknown' if one doesn't exist.

Screenshots

image

@iamacook iamacook self-assigned this Mar 25, 2022
@github-actions
Copy link

CLA Assistant Lite All Contributors have signed the CLA.

@@ -15,7 +15,7 @@ export const onConnectButtonClick = async (): Promise<void> => {
}

const ConnectButton = (props: { 'data-testid': string }): ReactElement => (
<Track {...OVERVIEW_EVENTS.ONBOARD}>
<Track {...OVERVIEW_EVENTS.OPEN_ONBOARD}>
Copy link
Member Author

Choose a reason for hiding this comment

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

This was not the correct event key.

@github-actions
Copy link

github-actions bot commented Mar 25, 2022

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 1 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

if (payload === account) {
trackEvent({ ...WALLET_EVENTS.CONNECT, label: name })
// Only track when store/UI is in sync with onboard
if (account === checksumAddress(address) && !shouldSwitchNetwork(wallet)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

The address retrieved from onboard's state is not checksummed.

@github-actions
Copy link

Deployment links

🟠 Rinkeby Mainnet 🟣 Polygon 🟡 BSC Arbitrum 🟢 Gnosis Chain

Copy link
Member

@usame-algan usame-algan left a comment

Choose a reason for hiding this comment

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

Looking good!

src/logic/wallets/__tests__/network.test.ts Show resolved Hide resolved
Copy link
Member

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

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

Looks good!

Base automatically changed from set-web3-middleware to dev March 28, 2022 14:24
@francovenica
Copy link
Contributor

Note: I had a clarification about switching accounts. I was exepcting at fist see an event "switch account" or something like that, but no, there is a new "connect" event instead. This is fine

Looks good to me.
I tried the new events Connecting with WC, switching account and switching from rinkeby to mainnet and back.
Some snapshots

Connecting:
image

Switching accounts in the MM phone app:
image

Switching from rin: to eth: and back:
image

Connecting with a safe as owner:
image

@coveralls
Copy link

Pull Request Test Coverage Report for Build 2059294936

  • 15 of 27 (55.56%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.06%) to 35.594%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/logic/wallets/patchedWalletConnect.ts 1 2 50.0%
src/logic/wallets/store/middleware/index.ts 3 14 21.43%
Totals Coverage Status
Change from base Build 2059248015: 0.06%
Covered Lines: 3477
Relevant Lines: 8845

💛 - Coveralls

@iamacook iamacook merged commit 40cfac9 into dev Mar 29, 2022
@iamacook iamacook deleted the track-wc-peer branch March 29, 2022 15:03
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

shouldSwitchNetwork is not provider agnostic Add tracking for wallets connected via WalletConnect
5 participants