Skip to content

Conversation

@daibhin
Copy link
Contributor

@daibhin daibhin commented Jun 6, 2025

We cannot guarantee that the default PostHog client is always created. This means things like exception autocapture handlers will not get set until some other function creates the client e.g. capture. Let's expose a function to setup the client for use in environments like Celery where we could potentially need to capture an exception event if no events are being captured

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 a new setup() function to explicitly initialize the PostHog client, improving reliability in environments like Celery where exception handling needs to be available before event tracking occurs.

  • Extracted client initialization logic from _proxy() into dedicated setup() function in posthog/__init__.py
  • Version bump to 4.3.3 in posthog/version.py to reflect this enhancement
  • Added safety measure for exception handlers to ensure they're initialized even without event capture

3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@daibhin daibhin requested review from a team, hpouillot and oliverb123 June 9, 2025 13:22
Copy link
Member

@pauldambra pauldambra left a comment

Choose a reason for hiding this comment

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

LGTM

@daibhin
Copy link
Contributor Author

daibhin commented Jun 9, 2025

Kept hitting rebase issues with the changelog so folded this into #252

@daibhin daibhin closed this Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants