Repository navigation
feat(rrweb): Allow onMutation to return a filtered list of mutations - #341
Merged
Merged
Conversation
onMutation can now return an array of MutationRecords to only process that subset, in addition to returning false to skip the whole batch. It also receives an isBlocked helper that applies the recorder's block rules, so callers can e.g. exclude blocked mutations from their own mutation limits without re-implementing block logic. Co-Authored-By: Francesco Gringl-Novy <francesco.novy@sentry.io>
mydea
marked this pull request as ready for review
October 23, 2026 07:43
logaretm
approved these changes
Oct 23, 2026
logaretm
left a comment
Member
There was a problem hiding this comment.
There is a case where replay desyncs with the dom due to the dropped stuff but that was happening before already. So, LGTM!
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.
onMutationcan currently only accept or drop a whole mutation batch. The Replay SDK needs per-mutation control for two cases:mutationLimit, becauseonMutationruns before rrweb's block checks. Heavy SVG/D3 widgets can stop replays even when they are blocked._experiments.ignoreMutations(feat(replay): Add_experiments.ignoreMutationsoption sentry-javascript#16816): it currently drops the whole batch if any one mutation matches, which also drops unrelated mutations.This PR adds two things:
onMutationmay return aMutationRecord[]. rrweb then processes only that subset. Returningfalsestill skips the batch. Returningtrueor nothing still processes everything.onMutationgets a secondhelpersargument withisBlocked(node). It uses the recorder's ownblockClass/blockSelector/unblockSelectorrules, checking ancestors too, so callers don't have to re-implement them.Overhead is kept to a minimum. The helpers object is created once per observer, not per batch.
isBlockedonly runs when the caller invokes it, so the SDK can limit it to batches that exceed the mutation limit. The only new per-batch work is oneArray.isArraycheck. This also drops the per-batch.bind()onprocessMutations, which is already an arrow-function property. Existing callers that return booleans behave the same.via Francesco Gringl-Novy.
--
View Junior Session [Sentry]