feat(replay): Reduce time limit before pausing a recording#7356
feat(replay): Reduce time limit before pausing a recording#7356
Conversation
Reduce the time limit before pausing a recording from `MAX_SESSION_LIFE` (1 hour) to `SESSION_IDLE_DURATION` (5 minutes). This reduces the amount of empty replays that are caused by a DOM mutation on a timer. An example of this is on sentry.io where there is a time component that updates every x seconds. As a reminder, there are three events that will break the idle timeout: * mouse click * user input in a form field * a navigation Closes #7352
mydea
left a comment
There was a problem hiding this comment.
this sounds reasonable to me! 👍
| expect(replay).not.toHaveSameSession(initialSession); | ||
| }); | ||
|
|
||
| it('does not create a new session if user hides the tab and comes back within [SESSION_IDLE_DURATION] seconds', () => { |
There was a problem hiding this comment.
These tests here and below are actually duplicated
size-limit report 📦
|
packages/replay/src/replay.ts
Outdated
| // content in them. | ||
| if (this._lastActivity && isExpired(this._lastActivity, this.timeouts.maxSessionLife)) { | ||
| // Pause recording | ||
| if (this._lastActivity && isExpired(this._lastActivity, this.timeouts.sessionIdle) && this.session?.sampled === 'session') { |
There was a problem hiding this comment.
Updated to only pause for session based replays. Error based replays that idle should immediately end (as any action will start a new session which isn't what we want).
There was a problem hiding this comment.
Hmm, so what would happen to an error session in that case? If my session is error-sampled, I leave the tab for an hour and come back, recording should stop?
Would it not work to pause/resume an error session? 🤔
There was a problem hiding this comment.
@mydea In that case the session completely stops, the only way is to get resampled (e.g. reload SDK).
For all sessions, pause is effectively ending the current replay/session, but for session sampled, we want to continue listening via core SDK for a user interaction to start a new session.
For error sessions we want this to end so they get resampled otherwise it leads to a new session with 0 errors. (I suppose we could restart as error sampled session).
| expect(replay.session).toBe(undefined); | ||
| }); | ||
|
|
||
| it('creates a new session if current session exceeds MAX_SESSION_LIFE', async () => { |
There was a problem hiding this comment.
New test to ensure we start a new session if we are active and exceed MAX_SESSION_LIFE
Reduce the time limit before pausing a recording from
MAX_SESSION_LIFE(1 hour) toSESSION_IDLE_DURATION(5 minutes). This reduces the amount of empty replays that are caused by a DOM mutation on a timer. An example of this is on sentry.io where there is a time component that updates every x seconds.As a reminder, there are three events that will break the idle timeout:
Closes #7352