feat(replay): Capture slow clicks (experimental)#8052
Merged
Conversation
Contributor
size-limit report 📦
|
ryan953
approved these changes
May 9, 2023
packages/browser-integration-tests/suites/replay/slowClick/template.html
Outdated
Show resolved
Hide resolved
packages/browser-integration-tests/suites/replay/slowClick/template.html
Outdated
Show resolved
Hide resolved
1ef65cc to
1402cff
Compare
efad913 to
231a5f0
Compare
Member
|
Related: getsentry/sentry#48259 |
billyvg
reviewed
May 11, 2023
Comment on lines
+43
to
+45
| const event = isClick && (handlerData.event as PointerEvent); | ||
| // Ignore clicks if ctrl/alt/meta keys are held down as they alter behavior of clicks (e.g. open in new tab) | ||
| if (isClick && slowClickConfig && event && !event.altKey && !event.metaKey && !event.ctrlKey) { |
Member
There was a problem hiding this comment.
I changed this to ignore clicks made while alt/meta/ctrl are held down since they can alter behavior that would consider it a dead click.
billyvg
reviewed
May 11, 2023
Comment on lines
+117
to
+144
| const SLOW_CLICK_IGNORE_TAGS = ['SELECT', 'OPTION']; | ||
|
|
||
| function ignoreElement(node: HTMLElement, config: SlowClickConfig): boolean { | ||
| // If <input> tag, we only want to consider input[type='submit'] & input[type='button'] | ||
| if (node.tagName === 'INPUT' && !['submit', 'button'].includes(node.getAttribute('type') || '')) { | ||
| return true; | ||
| } | ||
|
|
||
| if (SLOW_CLICK_IGNORE_TAGS.includes(node.tagName)) { | ||
| return true; | ||
| } | ||
|
|
||
| // If <a> tag, detect special variants that may not lead to an action | ||
| // If target !== _self, we may open the link somewhere else, which would lead to no action | ||
| // Also, when downloading a file, we may not leave the page, but still not trigger an action | ||
| if ( | ||
| node.tagName === 'A' && | ||
| (node.hasAttribute('download') || (node.hasAttribute('target') && node.getAttribute('target') !== '_self')) | ||
| ) { | ||
| return true; | ||
| } | ||
|
|
||
| if (config.ignoreSelector && node.matches(config.ignoreSelector)) { | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } |
Member
There was a problem hiding this comment.
I changed this so that we include more tags while in experimental phase.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds an experimental config to allow capturing slow clicks in the UI.
Enable via:
Currently, we consider for this:
<button>,<a>,<input type='button'>,<input type='submit'>For
<a>elements, we only consider them if they do not havedownloadattribute, or atarget !== '_self'. As downloads or links opened in other tabs should not result in a slow click. This should cover the most relevant cases for<a>, as links with a hash (e.g.#heading1) should be covered by the scroll detection.Closes #8021