MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / shouldAddEvent

Function shouldAddEvent

packages/replay-internal/src/util/addEvent.ts:110–133  ·  view source on GitHub ↗
(replay: ReplayContainer, event: RecordingEvent)

Source from the content-addressed store, hash-verified

108
109/** Exported only for tests. */
110export 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
135function maybeApplyCallback(
136 event: RecordingEvent,

Callers 3

addEvent.test.tsFile · 0.90
addEventSyncFunction · 0.85
addEventFunction · 0.85

Calls 6

timestampToMsFunction · 0.90
isPausedMethod · 0.65
isEnabledMethod · 0.65
nowMethod · 0.65
getContextMethod · 0.65
getOptionsMethod · 0.65

Tested by

no test coverage detected