Skip to content

feat!: remove capture v0 and legacy transport options - #1018

Open
eli-r-ph wants to merge 1 commit into
v1-capture-defaultfrom
v1-remove-v0
Open

eli-r-ph wants to merge 1 commit into
v1-capture-defaultfrom
v1-remove-v0

Conversation

@eli-r-ph

@eli-r-ph eli-r-ph commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Second PR in the capture v1 series, stacked on #1017. Capture v1 becomes the only capture path, and the v0 transport is removed.

Breaking removals:

  • CaptureMode, the capture_mode kwarg, and the POSTHOG_CAPTURE_MODE env var. This follows posthog-go's v1 branch, which removed its capture mode switch too.
  • The gzip kwarg on Client/AsyncPosthog/Consumer. Use capture_compression instead (default none, env var POSTHOG_CAPTURE_COMPRESSION still honored).
  • request.batch_post, EVENTS_ENDPOINT, AI_EVENTS_ENDPOINT, and the async async_batch_post.
  • The gzip parameter of request.post and request.flags. No caller passed it, and flags requests were never gzipped by the client, so flags behavior does not change.
  • The backoff dependency.
  • Client and AsyncPosthog constructors are keyword-only after host.

Other changes:

  • Consumers always send through the v1 submitter to their lane's endpoint. The AI lane stays on /i/v1/ai/events, uncompressed.
  • AsyncPosthog capture no longer needs httpx. The httpx client is now only built for flags and remote config.
  • The server payload snapshots now record the v1 request (URL, headers, body). legacy_event_family.json is renamed to event_family.json.
  • The compliance workflow is one job again (harness 1.1.1, capture_v1). The adapter drops its v0 batch_post patching.

Things to review:

  • v1 emits options: {} on every event. This shows in the regenerated snapshots. The event options PR later in the series revisits it.
  • The old async v0 path followed same-origin 307/308 redirects itself. The v1 async path sends through requests in a thread, which matches the v1 behavior users already had when opted in.

No new changeset: the major changeset on v1 already covers v0 removal. The migration guide PR lists each breaking change.

💚 How did you test it?

  • Ran the full pytest suite, ruff format --check, ruff check, mypy with the baseline filter, python -W error -c "import posthog", the public API snapshot check, the adapter tests, and uv lock --check, all locally.
  • v0-only tests are deleted. Their v1 counterparts already live in test_capture_v1.py (retries, Retry-After, 408, terminal errors).
  • test_ai_capture_lane.py now asserts that the AI lane keeps its own path and no compression while analytics uses capture_compression="gzip", in both async and sync_mode.
  • The async http client reuse/close test moved from capture to the flags path.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran sampo add to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Written with Cursor (Claude Opus) under the direction of the assignee. Removing CaptureMode outright (rather than keeping a v1-only enum), collapsing the compliance job, and dropping gzip from request.post/request.flags were agent calls made to match posthog-go's v1 branch; flag them if you want them kept.

Capture v1 is the only capture path. Remove CaptureMode, the capture_mode
kwarg and POSTHOG_CAPTURE_MODE, the gzip kwarg, request.batch_post and the
v0 endpoint constants, and the backoff dependency. Client and AsyncPosthog
constructors are keyword-only after host.
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

posthog-python Compliance Report

Date: 2026-10-06T19:45:58.833293+00:00
Duration: 257225ms

✅ All Tests Passed!

116/116 tests passed


Capture_V1 Tests

✅ 95/95 tests passed

View Details
Test Status Duration
Endpoint And Method.Targets V1 Endpoint ✅ 516ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 510ms
Required Headers.Has Authorization Bearer Header ✅ 509ms
Required Headers.Has Content Type Json ✅ 510ms
Required Headers.Has Posthog Sdk Info Format ✅ 509ms
Required Headers.Has Posthog Attempt Header ✅ 510ms
Required Headers.Has Posthog Request Id ✅ 509ms
Required Headers.Has Posthog Request Timestamp ✅ 508ms
Required Headers.Has User Agent ✅ 510ms
Body Format.Body Has Created At And Batch ✅ 509ms
Body Format.No Api Key In Body ✅ 509ms
Body Format.No Sent At In Body ✅ 509ms
Event Format.Event Has Required Root Fields ✅ 509ms
Event Format.Event Uuid Is Valid ✅ 509ms
Event Format.Event Timestamp Is Rfc3339 ✅ 510ms
Event Format.Non Utc Event Timestamp Is Converted To Utc ✅ 515ms
Event Format.Distinct Id Is String ✅ 510ms
Event Format.Distinct Id At Root Not Properties ✅ 509ms
Event Format.Custom Properties Preserved ✅ 509ms
Event Format.Set Properties Preserved ✅ 509ms
Event Format.Set Once Properties Preserved ✅ 510ms
Event Format.Groups Properties Preserved ✅ 509ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 509ms
Event Format.Event Has Required Root Fields Batch ✅ 513ms
Event Format.Event Uuid Is Valid Batch ✅ 512ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 513ms
Event Format.Distinct Id Is String Batch ✅ 512ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 512ms
Event Format.Custom Properties Preserved Batch ✅ 512ms
Event Format.Set Properties Preserved Batch ✅ 513ms
Event Format.Set Once Properties Preserved Batch ✅ 512ms
Event Format.Groups Properties Preserved Batch ✅ 513ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 513ms
Batch Behavior.Multiple Events In Single Batch ✅ 517ms
Batch Behavior.Batch Envelope Smoke ✅ 514ms
Batch Behavior.Flush With No Events Sends Nothing ✅ 506ms
Batch Behavior.Flush At Triggers Batch ✅ 1011ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 510ms
Deduplication.Generates Unique Uuids ✅ 515ms
Deduplication.Different Events Same Content Different Uuids ✅ 512ms
Deduplication.Preserves Uuid On Retry ✅ 6514ms
Deduplication.Preserves Timestamp On Retry ✅ 6519ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 6519ms
Deduplication.No Duplicate Events In Batch ✅ 517ms
Header Behavior On Retry.Attempt Header Starts At One ✅ 510ms
Header Behavior On Retry.Attempt Header Increments On Retry ✅ 13526ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 6519ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 3018ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 6519ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 510ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 514ms
Response Format Validation.Success No Retry After When All Ok ✅ 511ms
Response Format Validation.Success Retry After Present When Retry Events ✅ 1514ms
Response Format Validation.Success No Retry After When Drop Only ✅ 511ms
Response Format Validation.Response Echoes Request Id ✅ 509ms
Retry Behavior.Retries On 408 ✅ 6519ms
Retry Behavior.Retries On 500 ✅ 6519ms
Retry Behavior.Retries On 503 ✅ 8518ms
Retry Behavior.Retries On 504 ✅ 6519ms
Retry Behavior.Retryable Errors Have Retry After ✅ 3516ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 11522ms
Retry Behavior.Does Not Retry On 400 ✅ 2513ms
Retry Behavior.Does Not Retry On 401 ✅ 2513ms
Retry Behavior.Does Not Retry On 402 ✅ 2513ms
Retry Behavior.Does Not Retry On 413 ✅ 2512ms
Retry Behavior.Does Not Retry On 415 ✅ 2512ms
Retry Behavior.Non Retryable Errors Have No Retry After ✅ 2510ms
Retry Behavior.Implements Backoff ✅ 22529ms
Retry Behavior.Max Retries Respected ✅ 22536ms
Partial Batch Handling.Handles 200 Full Success ✅ 2513ms
Partial Batch Handling.Handles 200 With All Ok ✅ 3515ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 3516ms
Partial Batch Handling.Does Not Retry Limited Events ✅ 3516ms
Partial Batch Handling.Prunes Ok Events On Partial Retry ✅ 6521ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry ✅ 6517ms
Partial Batch Handling.Retries Only Retry Events From Partial ✅ 6523ms
Partial Batch Handling.Partial Retry Preserves Uuids ✅ 6521ms
Partial Batch Handling.Partial Retry Attempt Header Increments ✅ 6522ms
Partial Batch Handling.Partial Retry Request Id Preserved ✅ 6520ms
Partial Batch Handling.Respects Retry After On Partial ✅ 8519ms
Partial Batch Handling.Unknown Result Treated As Terminal ✅ 3513ms
Partial Batch Handling.Mixed Ok Drop Limited No Retry ✅ 3519ms
Compression.Sends Gzip Content Encoding ✅ 510ms
Compression.No Content Encoding When Disabled ✅ 509ms
Compression.Compressed Body Is Decompressible ✅ 510ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 2511ms
Event Options.Cookieless Mode Override ✅ 511ms
Event Options.Disable Skew Correction Override ✅ 509ms
Event Options.Process Person Profile Override ✅ 509ms
Event Options.Product Tour Id Override ✅ 509ms
Event Options.Unset Options Omitted ✅ 509ms
Event Options.Options Override In Batch ✅ 512ms
Geoip And Historical Migration.Geoip Disable Injected Into Properties ✅ 509ms
Geoip And Historical Migration.Historical Migration Set In Body ✅ 509ms
Geoip And Historical Migration.Historical Migration Absent By Default ✅ 509ms

Feature_Flags Tests

✅ 17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 10ms
Request Payload.Flags Request Uses V2 Query Param ✅ 9ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 8ms
Request Payload.Flags Request Omits Authorization Header ✅ 9ms
Request Payload.Token In Flags Body Matches Init ✅ 9ms
Request Payload.Groups Round Trip ✅ 9ms
Request Payload.Groups Default To Empty Object ✅ 9ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 9ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 9ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 9ms
Request Lifecycle.No Flags Request On Init Alone ✅ 3ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 509ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 13ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 9ms
Retry Behavior.Retries Flags On 502 ✅ 311ms
Retry Behavior.Retries Flags On 504 ✅ 312ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 511ms

Feature_Flags_Local_Evaluation Tests

✅ 4/4 tests passed

View Details
Test Status Duration
Versioned Boolean Matching.Matching Version Missing ✅ 67ms
Versioned Boolean Matching.Matching Version 1 ✅ 67ms
Versioned Boolean Matching.Matching Version 2 ✅ 66ms
Versioned Boolean Matching.Version Only Reload 1 2 1 2 Missing ✅ 33ms

@eli-r-ph eli-r-ph mentioned this pull request Oct 7, 2026
3 of 20 tasks
@eli-r-ph

eli-r-ph commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai review

@eli-r-ph
eli-r-ph marked this pull request as ready for review October 7, 2026 20:43
@eli-r-ph
eli-r-ph requested a review from a team as a code owner October 7, 2026 20:43
Comment thread posthog/_async_consumer.py
@veria-ai

veria-ai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

@dustinbyrne dustinbyrne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI-assisted review.

Comment on lines -14 to -15
"$lib": "posthog-python",
"$lib_version": "<SDK_VERSION>",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are these repopulated at all during ingestion? we rely on these for analytics and support. /flags also considers it (though it'll fall back to the user-agent header in absence, so i suspect this still works)

Comment thread .github/workflows/sdk-compliance.yml
@dustinbyrne
dustinbyrne requested a review from a team October 8, 2026 14:40

This branch has not been deployed

No deployments
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