✨ [PANA-6283] Support incremental mutation Change records#4287
Merged
sethfowler-datadog merged 2 commits intoMar 10, 2026
Merged
Conversation
bf48657 to
d097957
Compare
470d9aa to
acb02ff
Compare
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: f7676c3 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
Base automatically changed from
seth.fowler/PANA-6282-add-USE_INCREMENTAL_CHANGE_RECORDS-feature-flag
to
main
March 6, 2026 13:21
acb02ff to
973ca79
Compare
yannickadam
approved these changes
Mar 9, 2026
| attributes = new Map<AttributeName, OldValue>() | ||
| attributeMutations.set(node, attributes) | ||
| } | ||
| const attributeName = mutation.attributeName! |
Contributor
There was a problem hiding this comment.
Could we use a discriminated union for RumMutationRecord so we don't need ! here?
Contributor
Author
There was a problem hiding this comment.
We already are; RumMutationRecord is a union of RumCharacterDataMutationRecord, RumAttributesMutationRecord, and RumChildListMutationRecord, discriminated by a type field. The problem is that RumAttributesMutationRecord is wrongly defined this way:
export interface RumAttributesMutationRecord {
type: 'attributes'
target: Element
oldValue: string | null
attributeName: string | null
}It should be defined like this:
export interface RumAttributesMutationRecord {
type: 'attributes'
target: Element
oldValue: string | null
attributeName: string
}The file that defines these types has different CODEOWNERS, so I can't easily fix it in this PR, but I'll open a followup to fix it.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Motivation
Change records should support incremental mutations. After quite a few stacked PRs, it's time to make it happen.
Changes
This PR adds a new serialization implementation for
MutationObserverrecords,serializeMutationsAsChange.ts. In broads stroke, the implementation is similar to the existingserializeMutations.ts, but the output is a Change record instead of a record in the older V1 format.I've tried to make the new code a little bit simpler than the old code. Many of the simplifications are possible because of a nice property of Change records: we never reuse old node ids. In particular, this means:
Because at this stage my focus is on ensuring that the Change serialization code matches the V1 serialization algorithm's output, the testing approach this PR uses is "instrument" the existing incremental mutation tests with a helper class,
SerializationVerifier, that observes each serialization performed by the existing tests. WhenSerializationVerifiersees that a V1 serialization has occurred, it:For full snapshots, we check for byte-for-byte identical results. For incremental snapshots, we tolerate some small differences, which are documented in the code. These checks are quite strict, and combined with the extensive manual validation I've performed, I'm confident that Change serialization algorithm for both full and incremental snapshots is performing well.
Test instructions
yarn dev.use_incremental_change_records.DD_RUM.getSessionReplayLink()in the console to get a link to your session.Unfortunately you can't just rely on the live session replay feature within the browser SDK extension, because I haven't yet updated the extension with the latest replay code. I'll update this comment when that changes.
Checklist