Skip to content

Commit

Permalink
fix: page leave shouldn't start a new session
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Nov 7, 2023
1 parent 10fd7f4 commit 8450408
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/posthog-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,10 @@ export class PostHog {
const infoProperties = _info.properties()

if (this.sessionManager) {
const { sessionId, windowId } = this.sessionManager.checkAndGetSessionAndWindowId()
// don't let a delayed page leave start a new session
const { sessionId, windowId } = this.sessionManager.checkAndGetSessionAndWindowId(
event_name !== '$pageleave'
)
properties['$session_id'] = sessionId
properties['$window_id'] = windowId
}
Expand Down

0 comments on commit 8450408

Please sign in to comment.