Skip to content

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

Merged
eli-r-ph merged 1 commit into
v1from
v1-remove-v0
Oct 10, 2026
Merged

eli-r-ph merged 1 commit into
v1from
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.

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

posthog-python Compliance Report

Date: 2026-10-10T22:43:11.175948+00:00
Duration: 256860ms

✅ 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 ✅ 514ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 509ms
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 ✅ 508ms
Required Headers.Has Posthog Request Id ✅ 509ms
Required Headers.Has Posthog Request Timestamp ✅ 509ms
Required Headers.Has User Agent ✅ 508ms
Body Format.Body Has Created At And Batch ✅ 509ms
Body Format.No Api Key In Body ✅ 508ms
Body Format.No Sent At In Body ✅ 509ms
Event Format.Event Has Required Root Fields ✅ 508ms
Event Format.Event Uuid Is Valid ✅ 508ms
Event Format.Event Timestamp Is Rfc3339 ✅ 509ms
Event Format.Non Utc Event Timestamp Is Converted To Utc ✅ 514ms
Event Format.Distinct Id Is String ✅ 508ms
Event Format.Distinct Id At Root Not Properties ✅ 509ms
Event Format.Custom Properties Preserved ✅ 508ms
Event Format.Set Properties Preserved ✅ 509ms
Event Format.Set Once Properties Preserved ✅ 509ms
Event Format.Groups Properties Preserved ✅ 508ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 508ms
Event Format.Event Has Required Root Fields Batch ✅ 511ms
Event Format.Event Uuid Is Valid Batch ✅ 511ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 511ms
Event Format.Distinct Id Is String Batch ✅ 512ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 511ms
Event Format.Custom Properties Preserved Batch ✅ 511ms
Event Format.Set Properties Preserved Batch ✅ 512ms
Event Format.Set Once Properties Preserved Batch ✅ 512ms
Event Format.Groups Properties Preserved Batch ✅ 511ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 511ms
Batch Behavior.Multiple Events In Single Batch ✅ 515ms
Batch Behavior.Batch Envelope Smoke ✅ 512ms
Batch Behavior.Flush With No Events Sends Nothing ✅ 505ms
Batch Behavior.Flush At Triggers Batch ✅ 1009ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 509ms
Deduplication.Generates Unique Uuids ✅ 514ms
Deduplication.Different Events Same Content Different Uuids ✅ 510ms
Deduplication.Preserves Uuid On Retry ✅ 6512ms
Deduplication.Preserves Timestamp On Retry ✅ 6517ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 6516ms
Deduplication.No Duplicate Events In Batch ✅ 515ms
Header Behavior On Retry.Attempt Header Starts At One ✅ 509ms
Header Behavior On Retry.Attempt Header Increments On Retry ✅ 13516ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 6518ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 3017ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 6514ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 509ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 512ms
Response Format Validation.Success No Retry After When All Ok ✅ 510ms
Response Format Validation.Success Retry After Present When Retry Events ✅ 1514ms
Response Format Validation.Success No Retry After When Drop Only ✅ 510ms
Response Format Validation.Response Echoes Request Id ✅ 508ms
Retry Behavior.Retries On 408 ✅ 6514ms
Retry Behavior.Retries On 500 ✅ 6514ms
Retry Behavior.Retries On 503 ✅ 8520ms
Retry Behavior.Retries On 504 ✅ 6517ms
Retry Behavior.Retryable Errors Have Retry After ✅ 3514ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 11521ms
Retry Behavior.Does Not Retry On 400 ✅ 2512ms
Retry Behavior.Does Not Retry On 401 ✅ 2512ms
Retry Behavior.Does Not Retry On 402 ✅ 2511ms
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 ✅ 2511ms
Retry Behavior.Implements Backoff ✅ 22522ms
Retry Behavior.Max Retries Respected ✅ 22523ms
Partial Batch Handling.Handles 200 Full Success ✅ 2509ms
Partial Batch Handling.Handles 200 With All Ok ✅ 3513ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 3514ms
Partial Batch Handling.Does Not Retry Limited Events ✅ 3514ms
Partial Batch Handling.Prunes Ok Events On Partial Retry ✅ 6520ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry ✅ 6519ms
Partial Batch Handling.Retries Only Retry Events From Partial ✅ 6520ms
Partial Batch Handling.Partial Retry Preserves Uuids ✅ 6518ms
Partial Batch Handling.Partial Retry Attempt Header Increments ✅ 6514ms
Partial Batch Handling.Partial Retry Request Id Preserved ✅ 6515ms
Partial Batch Handling.Respects Retry After On Partial ✅ 8519ms
Partial Batch Handling.Unknown Result Treated As Terminal ✅ 3514ms
Partial Batch Handling.Mixed Ok Drop Limited No Retry ✅ 3516ms
Compression.Sends Gzip Content Encoding ✅ 510ms
Compression.No Content Encoding When Disabled ✅ 508ms
Compression.Compressed Body Is Decompressible ✅ 508ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 2512ms
Event Options.Cookieless Mode Override ✅ 509ms
Event Options.Disable Skew Correction Override ✅ 508ms
Event Options.Process Person Profile Override ✅ 508ms
Event Options.Product Tour Id Override ✅ 508ms
Event Options.Unset Options Omitted ✅ 508ms
Event Options.Options Override In Batch ✅ 512ms
Geoip And Historical Migration.Geoip Disable Injected Into Properties ✅ 508ms
Geoip And Historical Migration.Historical Migration Set In Body ✅ 509ms
Geoip And Historical Migration.Historical Migration Absent By Default ✅ 508ms

Feature_Flags Tests

✅ 17/17 tests passed

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

Feature_Flags_Local_Evaluation Tests

✅ 4/4 tests passed

View Details
Test Status Duration
Versioned Boolean Matching.Matching Version Missing ✅ 54ms
Versioned Boolean Matching.Matching Version 1 ✅ 55ms
Versioned Boolean Matching.Matching Version 2 ✅ 53ms
Versioned Boolean Matching.Version Only Reload 1 2 1 2 Missing ✅ 28ms

@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 thread posthog/test/snapshots/legacy_event_family.json
Comment thread .github/workflows/sdk-compliance.yml
@dustinbyrne
dustinbyrne requested a review from a team October 8, 2026 14:40
@eli-r-ph
eli-r-ph requested a review from dustinbyrne October 9, 2026 23:26
@nunyaMFbusinessbot

Copy link
Copy Markdown

💡 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.

@eli-r-ph
eli-r-ph changed the base branch from v1-capture-default to v1 October 10, 2026 22:37
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.
@eli-r-ph
eli-r-ph merged commit 8da46d8 into v1 Oct 10, 2026
37 checks passed
@eli-r-ph
eli-r-ph deleted the v1-remove-v0 branch October 10, 2026 22:38
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.

3 participants