OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
fix(session): negative duration
Carl-Gerhard Lindesvärdcf01d7a54575
diff --git a/packages/db/src/buffers/session-buffer.ts b/packages/db/src/buffers/session-buffer.tsindex 4b94b4fee..0fc221add 100644--- a/packages/db/src/buffers/session-buffer.ts+++ b/packages/db/src/buffers/session-buffer.ts@@ -55,6 +55,12 @@ export class SessionBuffer extends BaseBuffer {newSession.duration =new Date(newSession.ended_at).getTime() -new Date(newSession.created_at).getTime();+ if (newSession.duration < 0) {+ this.logger.warn('Session duration is negative', {+ session: newSession,+ });+ newSession.duration = 0;+ }newSession.properties = toDots({...(event.properties || {}),...(newSession.properties || {}),