rrweb-io / rrweb

record and replay the web
https://www.rrweb.io/
MIT License
15.9k stars 1.38k forks source link

[Bug]: Added nodes not showing up #1494

Closed StatsProIO closed 4 weeks ago

StatsProIO commented 1 month ago

Preflight Checklist

What package is this bug report for?

rrweb

Version

v1.1.3

Expected Behavior

Player is not adding in nodes from the adds of events. Only the nodes in the initial type:2 event are being rendered.

Actual Behavior

Player should be adding the nodes defined in the adds section of events.

Steps to Reproduce

  1. Use the Replayer to record

    
        let events = [];
    
        function startRecording() {
            rrweb.record({
                emit(event) {
                    // push event into the events array
                    events.push(event);
                }
            })
        };
    
        // this function will send events to the backend and reset the events array
        function save() {
            const body = JSON.stringify({ events });
            events = [];
            fetch('http://localhost/api/replay', { 
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body,
            });
        }
    
        // save events every 10 seconds
        setInterval(save, 10 * 1000);
    
        startRecording();
    
    </script>
  2. In my case, I got these events http://jsonblob.com/1247747721887866880
  3. Here is an example player playing those events https://rrwebdebug.com/play/index.html?url=http%3A%2F%2Fjsonblob.com%2F1247747721887866880&version=0.7.14&play=on

You can see there is an event which contains "Easy to use web analytics, no cookie banner needed!" but that is not rendered on the page.

Here is the page that was recorded

Screenshot 2024-06-04 at 11 19 33 PM

But the player only shows

Screenshot 2024-06-04 at 11 24 44 PM

Testcase Gist URL

https://rrwebdebug.com/play/index.html?url=http%3A%2F%2Fjsonblob.com%2F1247747721887866880&version=0.7.14&play=on

Additional Information

No response

StatsProIO commented 4 weeks ago

Figured it out. It was 2 things:

  1. Laravel, the framework I use automatically converts empty strings into nulls, this had to be stopped
  2. json_encode in PHP automatically escapes slashes, this had to be stopped.