question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keep only last 200-400 events

See original GitHub issue

I’m trying to keep only last 200-400 events but I can’t use the checkout feature as I’m using rrweb inside of an extension. The problem with extension is that DOM related events are to be run in the content_scripts context, which re-runs after every page refresh or navigation. This. causes the new record() to be called and run again causing the checkout to also reset. I’m maintaining the count outside of content_scripts where data can persist. What I do is hacky, I create my own snapshot event and attach it to each event passed to the DB layer and check if the count is 100 I insert a snapshot event before it. At times this works without any problems but breaks with a blank screen always sometime later or with certain websites. Do I also need something other than my snapshot event or is there any better way to keep only last 200-400 events and not break the replayer. Here’s my snapshot logic

Screenshot 2021-07-06 at 11 07 06 AM

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
Juice10commented, Jul 6, 2021

You can think of full snapshot type: EventType.FullSnapshot or type: 2 events as keyframes in video files. When choosing what events to purge it is safe to do so before a full snapshot event. Just make sure you keep the full snapshot event. Mutation events (type: 3) are going to use that full snapshot as their base.

You might have to add on a meta event before that to include the page width/height but you can create those after the fact as well.

Some comments on your example code: Between the setTimeout and the document.dispatchEvent I’m afraid your events might get saved in the wrong order. It might help to push everything to an array and create a worker function that manipulates and sends the events via document.dispatchEvent. That way you can guarantee the events get sent in order. Personally I also wouldn’t change the timestamp if I where you. I’m afraid it can mess things up in the replay.

1reaction
omairnabielcommented, Jul 7, 2021

It was throwing error, then I realized I’m on the wrong version. Bumped it and it’s working like charm. I guess that’s all I need. I’ll be closing this issue. Thanks a bunch , you saved my days ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

T&F MEET MANAGER for Windows - Hy-Tek - ACTIVE
For those field events that stay together, use the choice of "Previous Event" to keep flights together. For the high jump, use random...
Read more >
How to Run the 200m Race - Complete Track and Field
Most athletes who will run this event in big meets are going to be 100/200 runners or 200/400 runners in practice. In our...
Read more >
TRACK EVENTS
Track events are closely related to field events. This packet will deal with five traditional track events: the dash, the steeplechase, the hurdle, ......
Read more >
How to Run the Curve in the 200/400 meters (Part 2)
It's no secret you will run faster on a banked track compared to a flat track. The reason is the banked track helps...
Read more >
How to Write the Vanderbilt University Essay 2022-2023
Vanderbilt University has one supplemental essay, so you want to make sure it's amazing. Use our guide to write a great essay for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found