-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(replay): Capture slow clicks (experimental) #8052
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
Conversation
size-limit report 📦
|
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
Related: getsentry/sentry#48259 |
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this so that we include more tags while in experimental phase.
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 havedownload
attribute, 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