Skip to content

Add ScheduledStreamCapture for extended leading replay support#1372

Merged
matux merged 6 commits into
masterfrom
feature/matux/streaming-capture
Oct 13, 2025
Merged

Add ScheduledStreamCapture for extended leading replay support#1372
matux merged 6 commits into
masterfrom
feature/matux/streaming-capture

Conversation

@matux

@matux matux commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

Description of the change

Enables extended leading (post-trigger) replay captures by streaming chunks at safe intervals to prevent event loss during long postDuration windows.

Sub-PRs (All Approved)

Extract LeadingCapture coordination logic

Refactored ReplayManager by extracting 150 lines of leading capture logic into dedicated LeadingCapture component using delegate pattern for coordination.

Add comprehensive unit tests for LeadingCapture

Added 38 dedicated unit tests covering scheduling, export, coordination, error handling, and state management for LeadingCapture.

Rename LeadingCapture to ScheduledCapture

Renamed to reflect generic utility nature - coordinates delayed, cursor-based captures without knowledge of "leading" vs "trailing" concepts.

Implement ScheduledStreamCapture for extended captures

Replaces ScheduledCapture with streaming implementation that exports multiple chunks at checkout-safe intervals, preventing event loss during long postDuration windows.

Key Features

  • Sequential chunk sending (maintains rrweb continuity)
  • Fail-fast abort (chunk failure discards remaining chunks)
  • Opportunistic delivery (sends as trailing succeeds, not at end)
  • Backward compatible (single chunk for short postDuration)

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Maintenance
  • New release

Related issues

CAT-485/extended-post-trigger-replay-duration

@matux matux requested review from Copilot and waltjones October 13, 2025 22:02
@matux matux self-assigned this Oct 13, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements ScheduledStreamCapture to enable extended leading (post-trigger) replay captures by streaming chunks at safe intervals during long postDuration windows, preventing event loss. The implementation replaces ScheduledCapture with a streaming version that exports multiple chunks sequentially rather than a single delayed export.

  • Adds ScheduledStreamCapture class that streams chunks at checkout-safe intervals
  • Refactors ScheduledCapture to improve error handling and extract common patterns
  • Updates ReplayManager to use streaming capture for extended post-trigger replay duration
  • Adds comprehensive unit tests and updates integration tests to handle the new streaming behavior

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/browser/replay/scheduledStreamCapture.js New streaming capture implementation with interval-based chunk export and sequential sending
src/browser/replay/scheduledCapture.js Refactored with improved error handling, extracted helper methods, and consistent patterns
src/browser/replay/replayManager.js Updated to use ScheduledStreamCapture and improved error logging
test/replay/unit/scheduledCapture.test.js Updated tests for refactored ScheduledCapture API changes and new helper methods
test/replay/unit/replayManager.test.js Updated error message expectations for improved logging
Multiple integration test files Added logger initialization and updated expectations for streaming behavior
Test index files Removed export statements (likely replaced by different test organization)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/browser/replay/scheduledStreamCapture.js
@rollbar rollbar deleted a comment from Copilot AI Oct 13, 2025
@rollbar rollbar deleted a comment from Copilot AI Oct 13, 2025
@matux matux merged commit 8914c10 into master Oct 13, 2025
6 checks passed
@matux matux deleted the feature/matux/streaming-capture branch October 13, 2025 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants