Skip to content

feat(amp-semantic): capture clicks, fields, and form submissions - #2153

Open
jxiwang wants to merge 30 commits into
codex/semantic-recordingfrom
codex/semantic-interaction-events
Open

jxiwang wants to merge 30 commits into
codex/semantic-recordingfrom
codex/semantic-interaction-events

Conversation

@jxiwang

@jxiwang jxiwang commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add amp-semantic/click, amp-semantic/field, and amp-semantic/submit with accessible target descriptions, privacy-aware field values, validity, and stable rrweb node IDs.
  • Reuse Session Replay’s rrweb native mouse interaction hook with the existing heatmap click handler, including selector caching for the same click. Keep the DOM click fallback for hosts without the native hook.
  • Extend the schema, local inspector, browser tests, and package documentation. Supersedes the interaction portion of the older draft feat(amp-semantic): add package contracts and interaction capture #2079.

Stack

Base: #2152. Merge after #2128, #2150, #2151, and #2152.

Validation

  • pnpm --filter @amplitude/amp-semantic... build
  • pnpm --filter @amplitude/session-replay-browser... build
  • pnpm --filter @amplitude/amp-semantic test: 134 passed, 100% coverage
  • pnpm --filter @amplitude/session-replay-browser test: 1,183 passed, 100% coverage
  • pnpm --filter @amplitude/amp-semantic test:playwright: 11 passed
  • pnpm lint, pnpm lint:deps, pnpm test:examples

The full workspace build stalls in the unchanged Segment Session Replay Rollup step, and the full workspace test run has two existing analytics-react-native failures. These are tracked on the earlier stack drafts.

Linear: SRAI-57, SRAI-59, SRAI-60.


Note

Medium Risk
Adds user-interaction capture with privacy gates, but touches shared click hooks and form listeners in the replay path where masking or timing bugs could leak data or miss events.

Overview
Adds click, field, and submit semantic capture families to @amplitude/amp-semantic, registers them as default recorders, and documents independent family toggles and higher per-session budgets (2k / 1k / 300).

A new interactionsRecorder and shared helpers layer build privacy-aware payloads: accessible targets, rrweb node IDs, masked or templated URLs, field state/validity without reading sensitive inputs, and submit summaries without calling checkValidity(). JSON Schema, Playwright e2e, and the local semantic test harness are extended accordingly.

Session Replay wires the host with getNodeId, URL filtering, and selector lookup; native rrweb clicks are forwarded through a createSharedHook on ClickHandler so heatmaps and semantics share one click path and cached finder results. Heatmap hooks can be initialized lazily when a session ID appears after init.

Minor fix: optional autocomplete access in dom-privacy policy.

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

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
packages/analytics-browser/lib/scripts/amplitude-min.js.gz 68.78 KB (0%)
packages/session-replay-browser/lib/scripts/session-replay-browser-min.js.gz 142.26 KB (+0.38% 🔺)
packages/unified/lib/scripts/amplitude-min.umd.js.gz 229.24 KB (+0.25% 🔺)
@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 Nov 11, 2026 •

Copy link
Copy Markdown

Session Replay Browser E2E Results

passed  180 passed

Details

stats  180 tests across 20 suites
duration  7 minutes, 14 seconds
commit  bbd1de8

@jxiwang
jxiwang marked this pull request as ready for review November 13, 2026 20:08
@jxiwang
jxiwang requested review from a team as code owners November 13, 2026 20:08

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread packages/amp-semantic/src/helpers.ts Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread packages/amp-semantic/src/helpers.ts Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c5507e6. Configure here.

Comment thread packages/amp-semantic/src/helpers.ts Resolved

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