-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Replay events depend a lot on the order they are sent, as the recordings are basically incremental.
this means that a whole bunch of issues can arise when one or multiple payloads are lost/not sent in the correct order.
Some related issues:
- [Replay] Ensure we avoid sending replays when hitting rate limits #6520
- [Replay] Improve Missing Segments #6533
- Replay SDK and client reports #6502
I propose to instead change how we send replays by start to use a queue of outstanding events instead. This could work something like this:
- When a segment is ready to be sent, it is added to the bottom of the queue.
- Each e.g. second, we try to send the top item of the queue. If it fails, it remains on the top of the queue, else it is removed.
This means that we can always ensure that all events are sent in order.
There are two additional wrinkles with this:
a) We need to make sure to send all queue items when the user is leaving the page
b) We may want to store unsent queue items in session storage, so we can recover them after e.g. the user was offline
These two are a bit contradictory, as if we send everything on unload, we can't be sure that is has been sent, so we can't really decide if we need to remove it from a local storage 🤔