Skip to content

feat(amp-semantic): capture navigation keys and shortcuts - #2154

Open
jxiwang wants to merge 28 commits into
codex/semantic-interaction-eventsfrom
codex/semantic-keys
Open

jxiwang wants to merge 28 commits into
codex/semantic-interaction-eventsfrom
codex/semantic-keys

Conversation

@jxiwang

@jxiwang jxiwang commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add amp-semantic/keys for navigation keys and Ctrl/Meta K, P, and F shortcuts only.
  • Describe the rrweb target with its role, accessible name, and states, while excluding typed characters, composition, repeats, and editable contents.
  • Add schema, docs, local inspector description, unit tests, and a browser replay test. Supersedes the keys portion of the older draft feat(session-replay): integrate semantic lifecycle capture #2080.

Stack

Base: #2153. Merge after #2128 and #2150–#2153.

Validation

  • pnpm --filter @amplitude/amp-semantic... build
  • pnpm --filter @amplitude/session-replay-browser... build
  • pnpm --filter @amplitude/amp-semantic test: 140 passed, 100% coverage
  • pnpm --filter @amplitude/session-replay-browser test: 1,183 passed, 100% coverage
  • pnpm --filter @amplitude/amp-semantic test:playwright: 12 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, as documented in earlier stack drafts.

Linear: SRAI-81.


Note

Medium Risk
New document-level keydown capture with explicit privacy filters, but keyboard instrumentation still needs careful review so no typed content or sensitive target names leak.

Overview
Adds a new amp-semantic/keys semantic family and wires it into default capture with a 1,000 events/session cap and families: { keys: false } opt-out.

The new recorder listens on keydown but only emits allowlisted navigation keys (Escape, Enter, Tab, arrows, Home/End, Page Up/Down, F1–F12) and Ctrl/Meta shortcuts for K, P, and F. It skips ordinary typing, repeats, IME/composition, and sensitive targets (password/hidden fields, blocked hosts, masked names from editable content). Each event carries the key combo plus a privacy-safe target (rrweb id, role, accessible name source, states).

Schema, types, README, the local semantic playground, unit tests, and a Playwright replay test (Escape on a focused button) cover the new tag and validation.

Reviewed by Cursor Bugbot for commit 2d02b62. 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%)
packages/unified/lib/scripts/amplitude-min.umd.js.gz 229.24 KB (0%)
@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  179 passed
flaky  1 flaky

Details

stats  180 tests across 20 suites
duration  6 minutes, 46 seconds
commit  2d02b62

Flaky tests

chromium › e2e/set-session-id.spec.ts › setSessionId no-op (SR2-3635) › session id change still restarts recording

@jxiwang
jxiwang marked this pull request as ready for review November 17, 2026 22:12
@jxiwang
jxiwang requested a review from a team as a code owner November 17, 2026 22:12

@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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 2d02b62. Configure here.

const suppressName =
description.source === 'value' ||
(description.source === 'text' &&
!!target.closest('input,textarea,select,[contenteditable]:not([contenteditable="false"])'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Editable names leak across shadow

Medium Severity

Name suppression for editable content uses closest(), which stops at shadow roots, while blocked-target detection already walks composedPath(). A focused node inside an open shadow tree can still contribute its accessible name when a contenteditable ancestor sits outside that tree, so editor chips or other web components can leak user-authored text into amp-semantic/keys events.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2d02b62. Configure here.

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