Hi, I'm trying to understand how RUM replay works ...
# openobserve
i
Hi, I'm trying to understand how RUM replay works and how to configure it properly. I have no need to record all sessions, but I would like to record sessions that have errors, the documentation talks about doing this using
._startSessionReplayRecording
what I am noticing though is it only starts recording after the error has occurs, thus not actually showing the cause of the error, so what is the use of doing it this way? Is there a way to always "record" but only send it to openobserve when an error actually occurs so that we can se what the user did that caused the issue?_
đź‘€ 1
s
For “record always, but only send the replay when an error occurs,” that isn’t currently possible.
Session Replay isn’t a video recorder keeping the whole session in memory. Once recording starts, the SDK captures the DOM and sends replay data in small compressed segments. If recording hasn’t started yet, the actions before that point were never captured, so they can’t be recovered when an error occurs. There’s also no way to record everything and discard it later , stopping the replay flushes the pending data rather than throwing it away.
A partial workaround is to keep replay sampling at
0
and force replay when an error occurs:
Copy code
openobserveRum.init({
  sessionSampleRate: 100,
  sessionReplaySampleRate: 0,
  startSessionReplayRecordingManually: false,

  beforeSend: (event) => {
    if (event.type === 'error') {
      openobserveRum.startSessionReplayRecording({ force: true });
    }
    return true;
  },
});
This means normal sessions won’t generate replay data. When an error occurs, replay starts from that point and continues capturing the session. So it won’t show what caused the first error, but it can capture what happens afterward and help with subsequent occurrences in the same session.
A true “capture the last 10–30 seconds before an error” workflow would require a rolling replay buffer, which isn’t supported currently.
i
Ahh thats a bummer but makes sense though, it doesn't happen often that an error is repeated so that's not much help, I guess I will set it up that it will record all the time (for logged in users). Storage size will grow quite a bit that way though. Is it possible (or future improvement idea) to have retention rules? For example that the default retention for replays is X days but if the session has a error then store it Y days
s
Yeah, that sounds like a good idea. Let me check the feasibility of this, and I’ll get back to you.