Openpanel-dev / Openpanel-dev/openpanel
Make session replay opt-in so rrweb isn't shipped when it's disabled
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7k
- Forks
- 481
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 21
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- typescript
- Domain
- analytics, build-system, frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100