rrweb icon indicating copy to clipboard operation
rrweb copied to clipboard

[Feature Request]: Buffering events before loading library and calling `record`

Open billyvg opened this issue 3 years ago • 2 comments

Preflight Checklist

  • [X] I have searched the issue tracker for a feature request that matches the one I want to file, without success.

What package is this feature request for?

rrweb

Problem Description

We need to defer calling record() but would still like to capture mutations that occur before record() is called.

Proposed Solution

A potential solution here is to initialize a MutationObserver elsewhere (e.g. in a <script> in the html body before your JS bundle is loaded) and start a buffer that can later be passed to rrweb which can process them.

Alternatives Considered

N/A

Additional Information

No response

billyvg avatar Aug 12 '22 13:08 billyvg

Actually, we are having more and more observers other than the core MutationObserver, so only initializing the MutationObserver still misses some events.

Could you share why you do not put rrweb in the HTML body before the JS bundle if you need that kind of feature? Is bundle size an issue?

Yuyz0112 avatar Aug 17 '22 14:08 Yuyz0112

Yeah bundle size is the main concern. Additionally, we would like to put loading the library behind a feature flag, which happens much later down the line and we would like to capture the DOM state when it's initially loaded.

billyvg avatar Aug 17 '22 15:08 billyvg