Repository navigation
fix(python): use the framework integrations for exception capture - #437
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Test against a wizard branch:
Add Results will be posted here when complete. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hpouillot
approved these changes
Oct 22, 2026
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.
Changes
The Python framework rules in
commandments.yamland theposthog-best-practicesskill point agents at the posthog-python framework integrations and leave the setup details to the docs:Posthog()client toPosthogContextMiddlewarewithPOSTHOG_MW_CLIENT, as the Django docs show. Settings are not assigned at runtime.PosthogFlaskIntegrationwith onePosthog()client, as the Flask docs show. No@app.errorhandler(Exception)is added for capture.PosthogASGIMiddleware, as the Python docs show, with the client created where the app is built, not in the lifespan. Nocapture_exception()in anExceptioncatch-all handler.posthog>=7.69.0.The stale rules that told agents to capture exceptions by hand, configure the global
posthog.api_key, and that "no middleware ships" for Flask or FastAPI are removed.Depends on the docs in PostHog/posthog#121769 and PostHog/posthog.com#21477.
Verification
Ran the wizard's error-tracking flow on the workbench fixtures with this branch on a local context-mill, serving the content of both docs PRs, then ran each instrumented app, raised an exception in a route, and checked the event in PostHog:
no-posthog-djangoPOSTHOG_MW_CLIENT = Posthog(...)insettings.py$exception_source = django.middleware,/boompython-flaskPosthogFlaskIntegration(app, client=posthog_client)increate_app(),posthog>=7.69.0$exception_source = flask.got_request_exception,/boomno-posthog-fastapi-uvapp.add_middleware(PosthogASGIMiddleware, client=posthog_client)beside the existingExceptionhandler$exception_source = asgi.middleware,/reports/supplier-syncEach route exception arrived once. Without the version rule, all three runs required only
posthog>=7.59.0, the release-linking minimum.pnpm testpasses.🤖 Generated with Claude Code