Skip to content

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

Merged
merged 4 commits into from
Jul 10, 2025

Conversation

daniel-graham-amplitude
Copy link
Collaborator

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

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?: Yes

@daniel-graham-amplitude daniel-graham-amplitude requested review from Dogfalo, Copilot, jxiwang and tkainrad and removed request for Dogfalo July 8, 2025 22:07
Copy link
Contributor

@Copilot Copilot AI left a 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 in track-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 for rageClicks

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 as shouldTrackEvent).
        return shouldTrackRageClick('click', click.closestTrackedAncestor);

Copy link

promptless bot commented Jul 8, 2025

✅ No documentation updates required.

Copy link

@tkainrad tkainrad left a comment

Choose a reason for hiding this comment

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

lgtm!

@daniel-graham-amplitude daniel-graham-amplitude force-pushed the AMP-125613/rage-click-sliding-window branch from bc051ff to 352b919 Compare July 9, 2025 21:15
@daniel-graham-amplitude
Copy link
Collaborator Author

bugbot run

Copy link

@cursor cursor bot left a 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 👎

@Dogfalo
Copy link
Collaborator

Dogfalo commented Jul 10, 2025

Logic makes sense to me. Do we have a test case that covers this new scenario?

@daniel-graham-amplitude
Copy link
Collaborator Author

Test added thanks!

@daniel-graham-amplitude daniel-graham-amplitude merged commit b80f09e into main Jul 10, 2025
8 of 9 checks passed
@daniel-graham-amplitude daniel-graham-amplitude deleted the AMP-125613/rage-click-sliding-window branch July 10, 2025 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants