Skip to content

feat(capture-sdk): cross-page recording via sessionStorage persistence#76

Open
Swahjak wants to merge 7 commits into
redpangilinan:masterfrom
toppynl:feat/cross-page-recording-upstream
Open

feat(capture-sdk): cross-page recording via sessionStorage persistence#76
Swahjak wants to merge 7 commits into
redpangilinan:masterfrom
toppynl:feat/cross-page-recording-upstream

Conversation

@Swahjak

@Swahjak Swahjak commented May 1, 2026

Copy link
Copy Markdown

Summary

  • Persists the active debugger session (network, console, actions) to sessionStorage on pagehide so events survive full-page navigations
  • On the next page, init() detects the stored session and resumes the recording dock automatically with the original startedAt timestamp
  • When the user stops recording on a new page with no active MediaRecorder (recorder died during navigation), falls back to a screenshot so the report still includes the full cross-page debugger trace
  • Events accumulated before the navigation are inherited by startSession() on the new page, giving a continuous timeline in the final report

Changes

  • sdks/capture/src/debugger/session-storage.ts — new helpers: persistSession, loadPersistedSession, clearPersistedSession (5-minute expiry, version guard, try/catch for private browsing)
  • sdks/capture/src/debugger/debugger-collector.ts — persist on pagehide, restore on install(), clear on finalize/reset; adds hasActiveSession() and getSessionStartedAt()
  • sdks/capture/src/debugger/lazy-debugger-collector.ts — exposes ensureSessionRestored(): Promise<number | null>
  • sdks/capture/src/runtime/capture-runtime.ts — calls resumePersistedSession() in init() when storage has a session; onStopRecording falls back to screenshot when no active recording

Test Plan

  • 22/22 unit + integration tests pass (bun test sdks/capture/test)
  • session-storage.test.ts — 8 tests covering round-trip, expiry, malformed input, invalid events
  • cross-page-recording.test.ts — 4 integration tests: no-session init, session-present init, screenshot fallback, full recording flow after resume
  • Manually verify: start recording on page A → navigate to page B → recording dock appears → stop → review shows events from both pages

Known limitations

  • Video across pages: MediaRecorder cannot survive a navigation. The resumed page gets screenshot + full cross-page debugger trace, not a stitched video.
  • Cross-origin navigation: sessionStorage is origin-scoped. Navigation to a different origin loses the session.

@vercel

vercel Bot commented May 1, 2026

Copy link
Copy Markdown

@Swahjak is attempting to deploy a commit to the redpangilinan's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant