Skip to content

feat(plugin-autocapture-browser): add click cell properties to Element Clicked - #2211

Open
junjie-amplitude wants to merge 1 commit into
mainfrom
cursor/hm-39-click-cell-9eb2
Open

junjie-amplitude wants to merge 1 commit into
mainfrom
cursor/hm-39-click-cell-9eb2

Conversation

@junjie-amplitude

@junjie-amplitude junjie-amplitude commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds three event properties to [Amplitude] Element Clicked that record where inside the clicked element the pointer was. The heatmaps in Zoning Insights use them to draw click heat in the right part of large elements. Background and diagrams: proposal. Discussed in the autocapture thread.

Property Type Example Meaning
[Amplitude] Element Click Cell string 4x3:2,1 <cols>x<rows>:<col>,<row>: the cell of a grid laid over the element, zero-based from the top-left
[Amplitude] Element Click Cell Min Size number 64 minimum cell size in effect (CSS px)
[Amplitude] Element Click Cell Max Per Axis number 10 cap on cells per axis in effect
  • Grid, per axis: clamp(floor(size / minCellSizePx), 1, maxCellsPerAxis). The value carries its own grid, so events recorded under different parameters still decode.
  • Pointer clicks only. Keyboard and programmatic clicks (detail === 0) and zero-size elements send none of the properties. A click outside the element's box (an overflowing descendant) goes to the nearest edge cell.
  • Read at click time. Action clicks are tracked only after a mutation or navigation follows the click (up to 500 ms later) and re-read element properties then; by that time the element may have moved, resized or left the page. The cell is computed when the click is captured and carried on the click until it is tracked.
  • Kept out of targetElementProperties, so rage, dead and error clicks and page-action triggers are unchanged.

Option

autocapture.elementInteractions.clickCell: boolean | { enabled?, minCellSizePx?, maxCellsPerAxis? }. Defaults: on, 64 px, 10. Unusable values fall back to the defaults. It is read once, when the plugin is created.

Remote config

The same shape works under configs.analyticsSDK.browserSDK → autocapture.elementInteractions.clickCell. translateRemoteConfigToLocal rewrites { enabled: false } to false and { enabled: true } to true before the plugin reads the option, so the option accepts both the boolean and the object form. (The pre-release that was dogfooded on amplitude.com did not, and a remote enabled: false left the feature on.)

Checked in headless Chrome against the built amplitude-min.js, with the remote config response mocked:

Config Result
defaults 300×200 link → 4x3:0,0 / 4x3:3,2; 100×40 button → 1x1:0,0; Enter on the button → no properties; 700×400 action-click div whose handler shrinks it → 10x6:9,5
local clickCell: false, local { enabled: false } no properties
remote { enabled: false }, remote { enabled: false, minCellSizePx: 32 } no properties
remote { enabled: true } defaults
remote { enabled: true, minCellSizePx: 32, maxCellsPerAxis: 3 } link 3x3, button 3x1:1,0, parameters reported as 32 and 3

For reviewers

  • Default on. Every customer on the release would send the three properties on pointer clicks. Say if it should be off by default and enabled through remote config instead; it is one line in resolveClickCellConfig.
  • Remote elementInteractions replaces the local object as a whole (existing behaviour of updateBrowserConfigWithRemoteConfig). A local clickCell: false is therefore lost when remote config delivers elementInteractions without clickCell, and the default applies. Not changed here.
  • Boolean option vs. normalising in core. viewportContentUpdated solves the same enabled rewrite by converting true / false back to an object inside translateRemoteConfigToLocal. This PR accepts the boolean in the plugin instead, like deadClicks / rageClicks, so core needs no special case. Happy to switch.
  • Not in this PR: [Amplitude] Page X / Page Y and the element width and height from the dogfood draft (feat(plugin-autocapture-browser): add [Amplitude] Page X/Y and click cell to Element Clicked #2146), taxonomy descriptions and SDK docs (HM-26), and the remote config form schema (HM-32).

Tests

  • Unit tests for resolveClickCellConfig (boolean and object forms, defaults, invalid values) and getClickCellProperties (grid sizes at the boundaries, cell index at corners / edges / outside the box, custom parameters, every omission case, a bounding box that throws).
  • Plugin tests for regular clicks (defaults, true, { enabled: true }, custom grid, keyboard, false, { enabled: false }, no element size sent) and action clicks (the cell reflects the box at click time when the element changes before tracking; keyboard; false).
  • analytics-browser joined-config tests for what remote config delivers for clickCell.
  • plugin-autocapture-browser: 712 tests pass with 100% coverage. analytics-browser (531) and analytics-core (970) pass with 100% coverage. eslint, prettier and pnpm lint:deps pass.

Linear: https://linear.app/amplitude/issue/HM-39

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?: No. It adds optional event properties and one optional configuration option.
Open in Web Open in Cursor 

Note

Medium Risk
New event properties are emitted by default on every pointer Element Clicked, increasing payload and analytics surface; click-handling code on the hot path was extended but is defensive.

Reviewed by Cursor Bugbot for commit 1996724. Bugbot is set up for automated code reviews on this repo. Configure here.

…t Clicked

Record where inside the clicked element a pointer click landed. A grid is
laid over the element's bounding box, sized per axis as
clamp(floor(size / minCellSizePx), 1, maxCellsPerAxis), and the cell under
the pointer is sent as [Amplitude] Element Click Cell, formatted
<cols>x<rows>:<col>,<row> (zero-based from the top-left), e.g. 4x3:2,1.
The grid parameters in effect are sent with it as
[Amplitude] Element Click Cell Min Size and
[Amplitude] Element Click Cell Max Per Axis.

The cell is read when the click is captured. Action clicks are tracked
only after a mutation or navigation follows the click, by which time the
element may have moved, resized or left the page, so the cell is computed
when the action-click element is picked and carried to the track call.

New elementInteractions option clickCell: boolean, or
{ enabled, minCellSizePx, maxCellsPerAxis }. Default on with 64 px and 10
cells per axis; unusable values fall back to the defaults. Remote config
delivers { enabled: false } as false and { enabled: true } as true, so the
option accepts both forms. Keyboard and synthetic clicks, zero-size
elements and a disabled option send none of the properties.

HM-39
@linear-code

linear-code Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

HM-39

HM-32

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
packages/analytics-browser/lib/scripts/amplitude-min.js.gz 69.2 KB (+0.62% 🔺)
packages/session-replay-browser/lib/scripts/session-replay-browser-min.js.gz 141.16 KB (0%)
packages/unified/lib/scripts/amplitude-min.umd.js.gz 228.58 KB (+0.2% 🔺)
@amplitude/element-selector (gzipped esm) 3.48 KB (0%)
@amplitude/analytics-browser/lite (gzipped CDN bundle) 21.44 KB (0%)

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

Session Replay Browser E2E Results

passed  180 passed

Details

stats  180 tests across 20 suites
duration  7 minutes, 6 seconds
commit  4566849

@cursor
cursor Bot force-pushed the cursor/hm-39-click-cell-9eb2 branch from 4566849 to 1996724 Compare December 1, 2026 11:46
@junjie-amplitude
junjie-amplitude marked this pull request as ready for review December 2, 2026 06:03
@junjie-amplitude
junjie-amplitude requested a review from a team as a code owner December 2, 2026 06:03

This branch has not been deployed

No deployments
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.

1 participant