Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: account for negative timestamps from rrweb #17849

Merged
merged 10 commits into from
Oct 11, 2023
5 changes: 4 additions & 1 deletion plugin-server/src/worker/ingestion/process-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ export const createSessionReplayEvent = (
) => {
const timestamps = events
.filter((e) => !!e?.timestamp)
.map((e) => castTimestampOrNow(DateTime.fromMillis(e.timestamp), TimestampFormat.ClickHouse))
.filter((e) => Math.sign(e.timestamp) === 1)
pauldambra marked this conversation as resolved.
Show resolved Hide resolved
.map((e) => DateTime.fromMillis(e.timestamp))
pauldambra marked this conversation as resolved.
Show resolved Hide resolved
.filter((e) => e.isValid)
.map((e) => castTimestampOrNow(e, TimestampFormat.ClickHouse))
.sort()

// but every event where chunk index = 0 must have an eventsSummary
Expand Down
25 changes: 25 additions & 0 deletions plugin-server/tests/main/process-event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,31 @@ const sessionReplayEventTestCases: {
message_count: 1,
},
},
{
snapshotData: {
events_summary: [
// a negative timestamp is ignored
{ timestamp: 1682449093000, type: 3, data: { source: 2 }, windowId: '1' },
{ timestamp: 1682449095000, type: 3, data: { source: 2 }, windowId: '1' },
{ timestamp: -922167545571, type: 3, data: { source: 2 }, windowId: '1' },
],
},
expected: {
click_count: 3,
keypress_count: 0,
mouse_activity_count: 3,
first_url: null,
first_timestamp: '2023-04-25 18:58:13.000',
last_timestamp: '2023-04-25 18:58:15.000',
active_milliseconds: 1,
console_log_count: 0,
console_warn_count: 0,
console_error_count: 0,
size: 217,
event_count: 3,
message_count: 1,
},
},
{
snapshotData: {
events_summary: [
Expand Down
Loading