Skip to content

Conversation

@lricoy
Copy link
Member

@lricoy lricoy commented Jun 20, 2025

I am investigating some tickets (e.g, https://posthoghelp.zendesk.com/agent/tickets/32213) that send events on both frontend and backend, and wish to keep the sessionId in sync.

The changes here build upon #264 (thanks @oliverb123, great work!) to ensure we can also keep the session_id in context for the page utility function, as well as some redundant tests to verify that we're passing it on to other methods.

@lricoy lricoy marked this pull request as ready for review June 20, 2025 20:13
self.assertEqual(msg["uuid"], "new-uuid")
self.assertEqual(msg["distinct_id"], "distinct_id")

@parameterized.expand(
Copy link
Member Author

@lricoy lricoy Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those were for finding my way around the SDK, but I think they're fine to keep. I can remove them otherwise

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Added support for session ID preservation in the PostHog Python client's page() function to maintain consistent session tracking between frontend and backend events.

  • Added session ID handling in page() function to match behavior of identify() and capture() methods
  • Modified context handling to ensure automatic inclusion of session IDs when available in global context
  • Added comprehensive test suite covering session ID persistence across different event capture scenarios
  • Improved cross-platform session tracking by standardizing session ID handling between frontend and backend events

2 files reviewed, no comments
Edit PR Review Bot Settings | Greptile

@lricoy lricoy requested review from a team, haacked, jabahamondes, oliverb123 and robbie-c and removed request for a team June 20, 2025 20:19
@dmarticus dmarticus moved this to In Review in Feature Flags Jun 20, 2025
@lricoy lricoy changed the title chore: ensure session_id context works with page function chore: ensure session_id context works with page method Jun 20, 2025
@lricoy lricoy requested review from rafaeelaudibert and removed request for jabahamondes and robbie-c June 20, 2025 20:19
Copy link
Member

@rafaeelaudibert rafaeelaudibert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes a lot of sense to me, LGTM :)

@github-project-automation github-project-automation bot moved this from In Review to Approved in Feature Flags Jun 20, 2025
@dmarticus dmarticus moved this from Approved to In Review in Feature Flags Jun 20, 2025
@lricoy lricoy merged commit e23ca94 into master Jun 20, 2025
7 checks passed
@lricoy lricoy deleted the chore/ensure-session-id-context-works-with-page branch June 20, 2025 22:49
@github-project-automation github-project-automation bot moved this from In Review to Done in Feature Flags Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants