🎨 [PANA-4929] Add the concept of serialization transactions and reorganize state #3982
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
The next PR in this series will introduce support for an experimental second session replay serialization code path into the code base. To make this process smoother, it will be helpful to have a couple of basic abstractions in place:
The first abstraction was already added in #3887; this PR builds on that work. The second abstraction is new in this PR.
Changes
Added:
SerializationTransactionSerializationTransactiontype has been added. It holds builder-like methods and ephemeral state that lives only during a specific serialization operation. This is effectively a replacement for the oldSerializeOptionstype, which has been removed.SerializationTransactionhas been threaded through the serialization code; function arguments have been reworked where needed.startFullSnapshots(),trackMutations()) now wraps that serialization work in the newserializeInTransaction()function, which creates aSerializationTransactionand handles other bookkeeping before handing things off to the existing code to perform the real work.Enhanced:
RecordingScope(formerlySerializationScope)SerializationScopehas been renamed toRecordingScope.SerializationContexttype has been migrated ontoRecordingScope.SerializationContexthas been removed.RecordingScope. This includes the oldRecordIdstype, which has been renamed toEventIdssince it's used to assign ids to events.RecordingScopehas been threaded through much of the recording code, including all of the trackers.These changes conclude the preliminary refactoring for the new serialization code path; future PRs will focus on the new code path itself.
Test instructions
This PR is a pure refactoring PR that affects only the recording code for session replay. To test it, it's enough to test session replay itself.
Checklist