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: don't track clicks on disabled elements #2468

Merged
merged 3 commits into from
Aug 31, 2023
Merged

Conversation

iamacook
Copy link
Member

What it solves

Resolves #2405

How this PR fixes it

Elements wrapped in Track now check whether the children is targetted. If not, it means that the clicked target is disabled and, as such, not tracked.

How to test it

Click the following elements whilst disabled and observe no tracking event for them:

  • Adding an owner
  • Removing an owner
  • Replacing an owner
  • Change policies
  • Adding a spending limit
  • Removing a spending limit
  • "Send" button in the assets table
  • "Send" from the address book
  • "Add to batch" from a tx from
  • "New transaction" from the Add to batch section that opens from the topbar
  • "Add a new tx" that shows when there are already batched tx in the menu displayed from the top bar
  • "Confirm batch" from that same menu

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

@iamacook iamacook self-assigned this Aug 29, 2023
@github-actions
Copy link

github-actions bot commented Aug 29, 2023

Branch preview

✅ Deploy successful!

https://disabled_tracking--walletweb.review-wallet-web.5afe.dev

@github-actions
Copy link

github-actions bot commented Aug 29, 2023

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 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

trackEvent(trackData)
const handleClick = (e: MouseEvent) => {
// If clicked target is disabled, event.target will be trackEl
if (e.target !== trackEl) {
Copy link
Member

Choose a reason for hiding this comment

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

What if a nested element intercepts the click? Will it always bubble up to trackEl?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. It seems to work nicely in my tests, even with stopPropagation on nested elements.

@usame-algan
Copy link
Member

I am still seeing events when I click on a disabled button. Depending on where I click the target could be the icon inside the button or another child element so the condition would still be true I think.
Screenshot 2023-08-29 at 15 41 40

@iamacook
Copy link
Member Author

I am still seeing events when I click on a disabled button.

I'm converting this to a draft whilst I investigate this further.

@iamacook iamacook marked this pull request as draft August 29, 2023 13:47
@iamacook
Copy link
Member Author

@katspaugh, @usame-algan, I've adjusted the approach to check whether child elements are disabled. Wdyt?

@iamacook iamacook marked this pull request as ready for review August 29, 2023 14:40
@usame-algan
Copy link
Member

What about the previous idea we discussed of passing a disabled flag to the Track component? There are not that many buttons that can be disabled and if they are wrapped in Track we would have access to their disabled flag anyway so it would be a simple change. Calling querySelectorAll seems like a workaround / unconventional way of doing this in React.

@iamacook
Copy link
Member Author

iamacook commented Aug 29, 2023

What about the previous idea we discussed of passing a disabled flag to the Track component? There are not that many buttons that can be disabled and if they are wrapped in Track we would have access to their disabled flag anyway so it would be a simple change. Calling querySelectorAll seems like a workaround / unconventional way of doing this in React.

Whilst I tend to agree, it is hard to enforce. As we have the input ref, I don't see it as a workaround.

@francovenica
Copy link
Contributor

LGTM

I've checked the buttons in the list.
Most of them now open the modal to connect if you are disconnected, so the "Open modal" event is tracked, which is expected.
If you are connected with no owner, nothing is tracked when you click the buttons/links as expected
If you are the owner the tracking works as normal, each button triggering the corresponding event as expected

@iamacook iamacook merged commit 2fd728b into dev Aug 31, 2023
8 of 9 checks passed
@iamacook iamacook deleted the disabled-tracking branch August 31, 2023 15:32
@github-actions github-actions bot locked and limited conversation to collaborators Aug 31, 2023
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.

[GA tracking] Actions tracked when using grayed out buttons as non-owner
4 participants