Repository navigation
feat(integrations): align request middleware configuration - #1040
Merged
Merged
Conversation
Contributor
posthog-python Compliance ReportDate: 2026-10-08T15:14:31.996902+00:00 ✅ All Tests Passed!121/121 tests passed Capture_V1 Tests✅ 95/95 tests passed View Details
Capture_Ai Tests✅ 5/5 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
Feature_Flags_Local_Evaluation Tests✅ 4/4 tests passed View Details
|
hpouillot
marked this pull request as draft
October 8, 2026 16:21
hpouillot
marked this pull request as ready for review
October 8, 2026 16:26
ablaszkiewicz
approved these changes
Oct 10, 2026
This was referenced Oct 12, 2026
5 tasks done
eli-r-ph
pushed a commit
that referenced
this pull request
Oct 20, 2026
* Align ASGI and Flask integration defaults * feat(integrations): align request middleware configuration (cherry picked from commit 2f0d67d)
eli-r-ph
added a commit
that referenced
this pull request
Oct 20, 2026
* feat(mcp): set $mcp_interface on mcp analytics events (#1032) feat(mcp): add interface property to server events Generated-By: PostHog Desktop Task-Id: 651bf7d9-01f4-4d75-8583-868e29fdd314 (cherry picked from commit a3bd254) * chore: Release v7.67.1 [skip ci] (cherry picked from commit 4ae3d26) * Update generated references (cherry picked from commit 492d71b) * feat(integrations): align request middleware configuration (#1040) * Align ASGI and Flask integration defaults * feat(integrations): align request middleware configuration (cherry picked from commit 2f0d67d) * chore: Release v7.68.0 [skip ci] (cherry picked from commit ad553de) * Update generated references (cherry picked from commit 90f8d69) * chore(deps): bump the uv group across 2 directories with 3 updates (#1042) Bumps the uv group with 1 update in the /examples/example-ai-llamaindex directory: [banks](https://github.com/masci/banks). Bumps the uv group with 2 updates in the /examples/example-ai-pydantic-ai directory: [pydantic-ai](https://github.com/pydantic/pydantic-ai) and [pydantic-ai-slim](https://github.com/pydantic/pydantic-ai). Updates `banks` from 2.4.5 to 2.5.1 - [Release notes](https://github.com/masci/banks/releases) - [Commits](masci/banks@v2.4.5...v2.5.1) Updates `pydantic-ai` from 1.102.0 to 1.107.7 - [Release notes](https://github.com/pydantic/pydantic-ai/releases) - [Changelog](https://github.com/pydantic/pydantic-ai/blob/main/docs/changelog.md) - [Commits](pydantic/pydantic-ai@v1.102.0...v1.107.7) Updates `pydantic-ai-slim` from 1.102.0 to 1.107.7 - [Release notes](https://github.com/pydantic/pydantic-ai/releases) - [Changelog](https://github.com/pydantic/pydantic-ai/blob/main/docs/changelog.md) - [Commits](pydantic/pydantic-ai@v1.102.0...v1.107.7) --- updated-dependencies: - dependency-name: banks dependency-version: 2.5.1 dependency-type: indirect dependency-group: uv - dependency-name: pydantic-ai dependency-version: 1.107.7 dependency-type: direct:production dependency-group: uv - dependency-name: pydantic-ai-slim dependency-version: 1.107.7 dependency-type: indirect dependency-group: uv ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commit ee686ff) * test(django): read the middleware context test's event after defaults fill On v1, context properties are filled inside _enqueue, before before_send. The test patched _enqueue itself, so it saw the event before the fill and lost $request_path and role. It now records the event in before_send. The assertions are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix: redirect origin and logging fixes from review; scope AI routing docs - Compare redirect origins as requests sends them, so a Unicode host matches its IDNA form. - Log a refused or exhausted capture redirect at debug; failed-batch reporting owns warnings. - The migration guide says the OpenTelemetry integration still exports to /i/v0/ai/otel. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Georgis Andonis <[email protected]> Co-authored-by: releaser-posthog-python[bot] <262414804+releaser-posthog-python[bot]@users.noreply.github.com> Co-authored-by: Hugues Pouillot <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <[email protected]>
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 and Context
Public API change: align ASGI, Flask, and Django request integration options so request enrichment can be used independently of error tracking. This follows the ASGI/Flask integrations in #1037 and #1038. The matching DRF handler update is in #1036.
capture_exceptionstoNone, inheriting the effective client'senable_exception_autocapture; explicitTrue/Falseoverrides remain available. Inheritance is resolved when exceptions occur, including when global client setup happens after middleware registration.trust_tracing_headers=Falseto Flask andPOSTHOG_MW_TRUST_TRACING_HEADERS=Falseto Django, matching ASGI. Browser identity/session attribution now requires explicit opt-in; these identifiers are analytics context, never authentication.POSTHOG_MW_EXTRA_PROPERTIES,POSTHOG_MW_PROPERTIES_MAP, and property-named extraction methods. Existing settings, attributes, and methods remain aliases, with new settings taking precedence.POSTHOG_MW_CAPTURE_EXCEPTIONS=Noneto inherit the client, orFalsefor context-only behavior.references/middleware_configuration.md. The integration client routes automatic exceptions only; manually captured events keep their chosen destination and inherit request context independently.Behavior changes: ASGI/Flask no longer enable integration error tracking by default on clients with autocapture disabled. Django/Flask no longer accept tracing identity/session headers unless explicitly enabled.
💚 How did you test it?
📝 Checklist
If releasing new changes
sampo addto generate a changeset fileAdded
.sampo/changesets/consistent-request-integration-api.mdmanually.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with the pi coding agent and Cockpit child sessions, using local file/command tools and the GitHub CLI. The human-directed API keeps one integration per framework rather than introducing ordering-sensitive middleware layers. Shared semantics use the existing private client-default resolver and preserve Django's capture default and old property-setting aliases for compatibility. Session:
344b8733-8056-4f90-b182-7535cf8db88b.Human review is required; this PR has not been auto-approved or merged.