Repository navigation
feat(record): expose native interactions to recorder hooks - #142
Merged
Merged
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.supportsNativeMouseInteractionso 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
mouseInteractionrecorder hooks with an optional second argument: the nativeMouseEventorTouchEvent, 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 = trueis 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, andy.Reviewed by Cursor Bugbot for commit 5d05db3. Bugbot is set up for automated code reviews on this repo. Configure here.