(replay: ReplayContainer, event: RecordingEvent)
| 108 | |
| 109 | /** Exported only for tests. */ |
| 110 | export function shouldAddEvent(replay: ReplayContainer, event: RecordingEvent): boolean { |
| 111 | if (!replay.eventBuffer || replay.isPaused() || !replay.isEnabled()) { |
| 112 | return false; |
| 113 | } |
| 114 | |
| 115 | const timestampInMs = timestampToMs(event.timestamp); |
| 116 | |
| 117 | // Throw out events that happen more than 5 minutes ago. This can happen if |
| 118 | // page has been left open and idle for a long period of time and user |
| 119 | // comes back to trigger a new session. The performance entries rely on |
| 120 | // `performance.timeOrigin`, which is when the page first opened. |
| 121 | if (timestampInMs + replay.timeouts.sessionIdlePause < Date.now()) { |
| 122 | return false; |
| 123 | } |
| 124 | |
| 125 | // Throw out events that are +60min from the initial timestamp |
| 126 | if (timestampInMs > replay.getContext().initialTimestamp + replay.getOptions().maxReplayDuration) { |
| 127 | DEBUG_BUILD && |
| 128 | debug.infoTick(`Skipping event with timestamp ${timestampInMs} because it is after maxReplayDuration`); |
| 129 | return false; |
| 130 | } |
| 131 | |
| 132 | return true; |
| 133 | } |
| 134 | |
| 135 | function maybeApplyCallback( |
| 136 | event: RecordingEvent, |
no test coverage detected