Drop PostHog new_context exception-capture workaround - #113
Open
iloveitaly wants to merge 1 commit into
Open
Conversation
posthog-python now inherits enable_exception_autocapture for new_context, so per-call capture_exceptions=False is no longer required. Keep assigning default_client so module-level APIs use the configured instance. Co-authored-by: Michael Bianco <mike@mikebian.co>
iloveitaly
marked this pull request as ready for review
September 5, 2026 13:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
posthog-python#353 is fixed in PR #680:
new_context()now inheritsenable_exception_autocapturefrom the client / default client instead of always capturing exceptions.This repo already depends on
posthog>=7.38.0(locked at 7.45.1), which includes that behavior. No extra SDK work is required to "support" the upstream change.Description
We had a workaround of passing
capture_exceptions=Falseon everyposthog.new_context()because the SDK ignored the client setting.That is no longer needed.
enable_exception_autocapture=Falseon the configured client is enough.Still required:
posthog.default_client = posthog_client. Module-level APIs (posthog.new_context,posthog.capture, …) do not automatically use a separately constructedPosthog()instance. Issue #353 also called that out; #680 did not add a different client-assignment API.Screenshots / Test
Verified against installed
posthog==7.45.1:new_context()with nocapture_exceptionsargument setscapture_exceptions=Falsewhen the default client hasenable_exception_autocapture=Falsecapture_exceptioncapture_exceptions=Truestill opts inUnit tests in
tests/unit/posthog_test.pycover the same wiring against our configured client (needs Redis because importingappruns service version checks).Links
capture_exceptions=Falseby default on new contexts if posthog is not capturing exceptions PostHog/posthog-python#353