Skip to content

Conversation

@daniel-graham-amplitude
Copy link
Collaborator

@daniel-graham-amplitude daniel-graham-amplitude commented Jan 1, 2026

Summary

It's been observed that when a user scrolls quickly on mobile web, it will often trigger a false "Rage Click". This is because a scroll event involves touching the same part of the screen several times.

What this fix does is changes the bounding box requirements for a rage click

  • Previously: the bounding box was defined as a space in the viewport (clientX, clientY)
  • Now: the bounding box is defined as a space in the window (pageX, pageY)

This prevents scrolling events from being registered, because each touch will be in a different part of the window, because the page is scrolling

Extras

  • I noticed there were some imports like import * from 'src/<modulePath>'. Refactored this to use relative paths instead, it was making it so that I couldn't do npx jest <filepath>
  • Cleaned up "track-rage-click.test.ts" to remove repetitive code (ie: moved code into "beforeEach" and "afterEach")

Checklist

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

Note

Implements window-based rage-click detection to reduce scroll-induced false positives and streamlines related tests/imports.

  • Uses pageX/pageY instead of clientX/clientY in track-rage-click.ts for bounding box calculation and emitted [Amplitude] Clicks data; updates out-of-bounds logic accordingly
  • Refactors track-rage-click.test.ts to use pageX/pageY, centralizes subscription setup/teardown, and adds assertions for out-of-bounds and element-switch scenarios
  • Converts several src/... imports to relative paths across autocapture modules; minor typing improvement in track-click.ts
  • Adds test-server/scroll-test.html for manual long-page scroll testing with rage clicks enabled

Written by Cursor Bugbot for commit 8a4fbdd. This will update automatically on new commits. Configure here.

@daniel-graham-amplitude daniel-graham-amplitude marked this pull request as draft January 1, 2026 01:24
@macroscopeapp
Copy link
Contributor

macroscopeapp bot commented Jan 1, 2026

Fix rage click detection in plugin-autocapture-browser to use page coordinates and apply window-level bounds for frustrationInteractions.rageClicks

Switch rage click region calculations and emitted coordinates from MouseEvent.clientX/clientY to MouseEvent.pageX/pageY, update related tests, and repoint internal imports in autocapture and pageActions modules. Core logic change resides in [track-rage-click.ts] utilities; a manual test page is added for scroll scenarios.

🖇️ Linked Issues

Addresses AMP-146045 under the AMP-146043 epic by correcting rage click detection to exclude viewport-based misclassification.

📍Where to Start

Start with the rage click logic in packages/plugin-autocapture-browser/src/autocapture/track-rage-click.ts, focusing on addCoordinates and getRageClickAnalyticsEvent.


Macroscope summarized 87c90f1.

@daniel-graham-amplitude daniel-graham-amplitude marked this pull request as ready for review January 2, 2026 17:22
@macroscopeapp
Copy link
Contributor

macroscopeapp bot commented Jan 2, 2026

Apply page-based coordinates to rage click detection and analytics in packages/plugin-autocapture-browser/src/autocapture/track-rage-click.ts to exclude mobile scrolling touches

Switch rage click bounding and payloads to MouseEvent.pageX/pageY and update tests and import paths accordingly.

🖇️ Linked Issues

This pull request addresses AMP-146045 under the AMP-146043 epic by using page coordinates for rage clicks to exclude mobile scrolling touches.

📍Where to Start

Start with trackRageClicks.addCoordinates and trackRageClicks.getRageClickAnalyticsEvent in track-rage-click.ts.


Macroscope summarized 8a4fbdd.

Copy link
Contributor

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 fixes false rage click detection on mobile web by changing the coordinate system from viewport-based (clientX/clientY) to window-based (pageX/pageY). This prevents scrolling gestures from being incorrectly flagged as rage clicks, since each touch during a scroll will be at different window coordinates even if they appear in the same viewport position. Additionally, the PR refactors imports from absolute src/* paths to relative paths.

  • Changed rage click bounding box calculations to use window coordinates (pageX/pageY)
  • Updated all rage click tests to use pageX/pageY coordinates
  • Refactored imports from src/* to relative paths for better module resolution

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test-server/scroll-test.html Adds manual testing page with 15,000px height to verify scroll gesture vs rage click detection
packages/plugin-autocapture-browser/test/autocapture-plugin/track-rage-click.test.ts Updates all test cases to use pageX/pageY instead of clientX/clientY; adds edge case test for out-of-bounds detection with fixed viewport coordinates
packages/plugin-autocapture-browser/src/pageActions/triggers.ts Refactors import from src/helpers to relative path ../helpers
packages/plugin-autocapture-browser/src/pageActions/matchEventToFilter.ts Refactors import from src/helpers to relative path ../helpers
packages/plugin-autocapture-browser/src/autocapture/track-rage-click.ts Changes coordinate system from viewport (clientX/clientY) to window (pageX/pageY) in bounding box calculations and tracked event data; refactors import path
packages/plugin-autocapture-browser/src/autocapture/track-dead-click.ts Refactors import from src/frustration-plugin to relative path ../frustration-plugin
packages/plugin-autocapture-browser/src/autocapture/track-click.ts Refactors imports to relative paths and adds explicit type annotation for click event subscription
packages/plugin-autocapture-browser/src/autocapture/track-change.ts Refactors imports to relative paths and consolidates import statements
packages/plugin-autocapture-browser/src/autocapture/track-action-click.ts Refactors import from src/autocapture-plugin to relative path ../autocapture-plugin

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@daniel-graham-amplitude daniel-graham-amplitude changed the title fix: apply rage clicks to window over viewport fix(plugin-autocapture-browser): apply rage clicks to window over viewport Jan 3, 2026
Copy link
Contributor

@Mercy811 Mercy811 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-146045-rage-click-fix-mobile-scroll-false-positive branch from 3696ef2 to 2f9f9a5 Compare January 5, 2026 17:34
Base automatically changed from pnpm-migration to main January 5, 2026 17:54
… AMP-146045-rage-click-fix-mobile-scroll-false-positive
@daniel-graham-amplitude daniel-graham-amplitude merged commit ee71e48 into main Jan 5, 2026
11 checks passed
@daniel-graham-amplitude daniel-graham-amplitude deleted the AMP-146045-rage-click-fix-mobile-scroll-false-positive branch January 5, 2026 22:37
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.

5 participants