Make session replay opt-in so rrweb isn't shipped when it's disabled

Open
#414 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

@grootbro is already working on this.

Since Oct 20, 2026.

  • #489 by @grootbro — closed without merging
  • #566 by @grootbro — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

Start by tracing loadReplayModule and the existing replay import, then inspect the @openpanel/web package entry points and the IIFE build's esbuild replay stub. Compare how the proposed @openpanel/web/replay entry and recorder option fit the current API. Done means replay users can import the recorder explicitly while apps without that import no longer receive the rrweb chunk; validate both build outputs.

Written by the indexing model from the issue text.

Description

@openpanel/web emits the replay chunk (rrweb, ~55 KB gz) even for apps that never set sessionReplay.enabled. #336 made it lazy, so no TTI cost, but loadReplayModule still does an unconditional import('./replay'), so the bundler always emits it and deploys it as dead code. Consumers can only drop it by stubbing rrweb or patching the package. (context: https://github.com/Openpanel-dev/openpanel/issues/336#issuecomment-4959858749)

Proposal: opt-in replay subpath

Base package stops importing ./replay; expose the recorder as @openpanel/web/replay and let consumers pass it in:

import { OpenPanel } from '@openpanel/web'
import { startReplayRecorder } from '@openpanel/web/replay'

new OpenPanel({ sessionReplay: { enabled: true, recorder: startReplayRecorder } })

rrweb then only enters a bundle when the subpath is imported. Replay users add one import, everyone else gets a lean build for free. The IIFE build already stubs replay via an esbuild plugin, so this mostly surfaces existing decoupling at the API level.

Smaller alternative if the API change is too much: a replay-free library entry or a build flag.

Follows up on #336.

Dominant language
TypeScript
Stars
7.3k
Forks
552
Avg merge
1d 2h
Merged PRs (30d)
18

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Openpanel-dev/openpanel

All issues in Openpanel-dev/openpanel

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.