Capture leading replay#1334
Conversation
25314bc to
056833e
Compare
056833e to
f118acd
Compare
| /** | ||
| * Gets the current count of events in the buffers. | ||
| * This represents a marker for where trailing events end. | ||
| * | ||
| * @returns {number} The total number of events currently stored | ||
| */ | ||
| getCurrentEventCount() { | ||
| return this._events.previous.length + this._events.current.length; | ||
| } |
There was a problem hiding this comment.
We use the event count as a boundary marker rather than tracking the specific event. This has a fatal flaw, though: If during those N post-seconds we get a checkout from rrweb, we rotate the buffer and this number becomes invalid (out of bounds).
I have a fix for this, but I'll send it in a subsequent PR.
There was a problem hiding this comment.
👍 Looking forward to the fix. We had talked about tracking both the buffer and the index in the buffer.
| exportRecordingSpan(tracing, attributes = {}) { | ||
| const events = this._collectEvents(); | ||
| exportRecordingSpan(tracing, attributes = {}, afterCount = 0) { | ||
| const events = this._collectEvents(afterCount); |
There was a problem hiding this comment.
Maybe startIndex or startPosition?
There was a problem hiding this comment.
Since this is changing completely, can we leave it like this? So I can merge this and move on to the next PRs!
Then we circle back.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Description of the change
Note
PR Description by Copilot.
This pull request introduces support for "leading replay" capture in addition to the existing "trailing replay" functionality. Leading replay allows capturing and sending a short window of user events that occur after an error is triggered, improving the context available for debugging. The changes include new configuration options, enhancements to the replay recording and management logic, and additional state tracking for coordinating leading and trailing replay sends.
Leading replay capture and coordination:
postDurationoption todefaults.jsto specify the number of seconds of events to capture after an error is triggered.ReplayManager(replayManager.js) to schedule and export leading replay events after the trailing replay is sent, including logic for managing pending leading captures and coordinating their sending/discarding based on trailing replay status. [1] [2] [3]TrailingStatusenum and state tracking inReplayManagerto manage the status of trailing and leading replay sends. [1] [2] [3]Recorder improvements:
Recorder(recorder.js) to support exporting only events after a specific point for leading replay, added a method to get the current event count, and adjusted validity checks for exported recordings. [1] [2] [3]Test updates:
recorder.test.jsto reflect new validity checks for replay recordings.replayManager.test.jsfor clarity and to accommodate new method signatures. [1] [2] [3]