Skip to content

feat(record): expose native interactions to recorder hooks - #142

Merged
jxiwang merged 1 commit into
masterfrom
codex/semantic-native-click-hook
Oct 22, 2026
Merged

jxiwang merged 1 commit into
masterfrom
codex/semantic-native-click-hook

Conversation

@jxiwang

@jxiwang jxiwang commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Session Replay already consumes rrweb mouse interactions for heatmaps, but the hook drops the native event. Forward it as an optional second hook argument so semantic capture can reuse the same listener while retaining modifiers, keyboard activation, trust, and composed-path targeting.

The native event is hook-only context. Pass only the existing interaction data to the recording callback, preserving the serialized event shape. Expose record.supportsNativeMouseInteraction so hosts can safely fall back with older recorder releases. Existing one-argument hooks continue working.

Validation: isolated frozen-lockfile install; TypeScript and Vite builds for all six rrweb dependency tasks; focused Puppeteer regression checks native event identity/metadata and unchanged recorded keys. The full rrweb suite was not run.

Dependency for Amplitude-TypeScript #2082. That draft currently uses a pnpm patch of its pinned recorder; publish this extension and replace the patch with a released dependency before SDK release. No npm package is published by this PR.


Note

Low Risk
Additive API and hook plumbing with an explicit guard keeping DOM events out of serialized replay data; existing one-argument hooks and event shapes stay compatible.

Overview
Extends mouseInteraction recorder hooks with an optional second argument: the native MouseEvent or TouchEvent, so hosts (e.g. Session Replay heatmaps) can read modifiers, detail, trust, and composed-path targeting without adding a separate click listener.

The serialized replay payload is unchanged: the observer still forwards only the existing interaction param object into the recording path; the native event is explicitly stripped in hook merging so it never enters emitted events. record.supportsNativeMouseInteraction = true is added for runtime feature detection on older recorder versions. One-argument hooks remain valid via the optional second parameter.

A Puppeteer test asserts hook identity/metadata on the native event and that recorded click incremental data still only includes id, source, type, x, and y.

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

@changeset-bot

changeset-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5d05db3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@jxiwang
jxiwang marked this pull request as ready for review October 22, 2026 16:12
@jxiwang
jxiwang requested a review from a team October 22, 2026 16:12

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

LGTM!

@jxiwang
jxiwang merged commit 170c07a into master Oct 22, 2026
19 checks passed
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.

2 participants