-
Notifications
You must be signed in to change notification settings - Fork 49
fix: use sliding window to capture rage clicks #1202
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: use sliding window to capture rage clicks #1202
Conversation
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.
Pull Request Overview
This PR refactors rage click detection to use a sliding time window, updates related tests to the default threshold, and adds configuration for rageClicks
in the test server example.
- Switches from
bufferTime
to a manual sliding-window algorithm intrack-rage-click.ts
- Updates tests to remove the overridden config and adjust expected click counts
- Changes the test-server example to accept a
cssSelectorAllowlist
object forrageClicks
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
test-server/autocapture/element-interactions.html | Replaced rageClicks: true with an object allowing CSS selector configuration for inputs |
packages/plugin-autocapture-browser/test/autocapture-plugin/track-rage-click.test.ts | Removed test-only config override and adjusted loop counts and expected click counts |
packages/plugin-autocapture-browser/src/autocapture/track-rage-click.ts | Removed bufferTime logic, added manual sliding-window management, dropped test override function |
Comments suppressed due to low confidence (1)
packages/plugin-autocapture-browser/src/autocapture/track-rage-click.ts:50
- The function
shouldTrackRageClick
is referenced but not imported, leading to a runtime error. Either import it from the correct module (e.g.,../helpers
) or replace it with the intended predicate (such asshouldTrackEvent
).
return shouldTrackRageClick('click', click.closestTrackedAncestor);
packages/plugin-autocapture-browser/src/autocapture/track-rage-click.ts
Outdated
Show resolved
Hide resolved
packages/plugin-autocapture-browser/test/autocapture-plugin/track-rage-click.test.ts
Outdated
Show resolved
Hide resolved
✅ No documentation updates required. |
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.
lgtm!
packages/plugin-autocapture-browser/src/autocapture/track-rage-click.ts
Outdated
Show resolved
Hide resolved
bc051ff
to
352b919
Compare
bugbot run |
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.
✅ BugBot reviewed your changes and found no bugs!
Comment bugbot run
to trigger another review on this PR
Was this report helpful? Give feedback by reacting with 👍 or 👎
Logic makes sense to me. Do we have a test case that covers this new scenario? |
Test added thanks! |
Summary
Use a sliding window for rage click instead of a buffer.
Previously, it used a buffer, which has an edge case where 3 events could happen in one window and then another 3 events could happen in the next window, and it could miss a rage click if the buffer time elapsed between the calls.
This PR fixes it so that it just adds clicks to a sliding window, where the clicks expire after a certain time, and the window gets cleared if the next clicked element is not the same as the previously clicked on element.
Checklist