Skip to content

Drop PostHog new_context exception-capture workaround - #113

Open
iloveitaly wants to merge 1 commit into
masterfrom
cursor/posthog-context-exceptions-5cef
Open

Drop PostHog new_context exception-capture workaround#113
iloveitaly wants to merge 1 commit into
masterfrom
cursor/posthog-context-exceptions-5cef

Conversation

@iloveitaly

@iloveitaly iloveitaly commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Motivation

posthog-python#353 is fixed in PR #680: new_context() now inherits enable_exception_autocapture from 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=False on every posthog.new_context() because the SDK ignored the client setting.

That is no longer needed. enable_exception_autocapture=False on 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 constructed Posthog() 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 no capture_exceptions argument sets capture_exceptions=False when the default client has enable_exception_autocapture=False
  • exceptions inside that context do not call capture_exception
  • explicit capture_exceptions=True still opts in

Unit tests in tests/unit/posthog_test.py cover the same wiring against our configured client (needs Redis because importing app runs service version checks).

Links

Open in Web Open in Cursor 

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
iloveitaly marked this pull request as ready for review September 5, 2026 13:52
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.

2 participants