Repository navigation
V1 release - DO NOT MERGE - #231
Draft
marandaneto wants to merge 66 commits into
Draft
marandaneto wants to merge 66 commits into
marandaneto wants to merge 66 commits into
Conversation
Deletes the V0 capture implementation and the `capture-v1` Cargo feature. Capture V1 (`POST /i/v1/analytics/events`) is now the only capture path and compiles unconditionally. No V1 logic, retry policy, buffering, or option-extraction behavior changes — the V1 code is byte-identical, it just stops being `#[cfg]`-gated. - Delete `src/client/v0_capture.rs`, the V0 transport pipeline, the V0 retry decisions (`should_retry_v0` and friends), the V0 wire format's `BatchRequest`, and both `send_immediate` V0 bodies. - Drop the `capture-v1` feature; `brotli` and `zstd` become unconditional dependencies. All four codecs the endpoint accepts (gzip/deflate/br/zstd) now work by default instead of silently degrading to uncompressed. - Compliance adapter advertises `capture_v1` unconditionally and reports as `posthog-rs`; delete the V0 adapter image and its workflow. The `capture_v1` capability string is a frozen harness contract key. - Collapse the CI build/test matrices, whose V0 and V1 entries became duplicates, and drop `--features capture-v1` from `check-public-api.sh`. `Event::prepare_for_v0` and `InnerEvent` are retained temporarily as test-only scaffolding; the tests that depend on them are ported to the V1 builder in the next commit, which then deletes them. Verified against a pre-change baseline: 379/316/356 tests pass for the default, blocking, and blocking+error-tracking configs — identical counts to the same suites under `--features capture-v1` before this change. Public API snapshot unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rewrites the tests that depended on the V0 serialization scaffolding, then deletes that scaffolding, so nothing V0 remains in the tree. - `src/error_tracking.rs`: `built_event_json` now serializes through `V1Event::from_event`, so all 33 tests assert the shape actually sent. Two assertions move `$process_person_profile` from `properties` to the typed `options` object and additionally pin that it is stripped from `properties`. - `src/event.rs`: 10 `v0_*` tests ported to assert the V1 shape and renamed without the version marker. `v0_adds_lib_properties` and `v0_preserves_existing_lib_properties` are dropped instead — the V1 builder never touches `$lib`/`$lib_version`, which now travel in the `posthog-sdk-info` header and are covered by `build_headers_sdk_info_is_canonical_lib_slash_version`. - Delete `Event::prepare_for_v0`, `Event::apply_minimal_flag_called_allowlist`, and `InnerEvent`. The shared `is_minimal_flag_called_property` predicate is kept — the V1 path uses it. `semver` was only used by `prepare_for_v0`, so it is dropped as a dependency. - Port the orphaned integration assertions that had no V1 twin, in both the async and blocking variants: `Event::with_flags` attaching flag properties without a second `/flags` fetch, `$is_server` on `$feature_flag_called`, client-level `ErrorTrackingOptions` applying to `capture_exception`, and the blank/whitespace API-key noop path. Test totals move 379/316/356 -> 381/317/358 for the default, blocking, and blocking+error-tracking configs: four ported tests added per applicable config, less the two `$lib` tests whose behavior moved to the header. Public API snapshot unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The `V1` markers existed only to scope the new pipeline during the dual-use
period. With V0 gone they are noise, so this adopts plain capture names —
including the pre-existing public `Endpoint::Capture`. Mechanical rename only:
no logic, retry, buffering, or option-extraction behavior changes, and no
existing test's assertions were altered.
Breaking:
- `V1ErrorResponse` -> `CaptureErrorResponse`, which also re-signatures the
public `CaptureFailure::error_response()`.
- `Endpoint::Batch` removed; `Endpoint` is now `#[non_exhaustive]`.
- `Endpoint::Capture` re-points from `/i/v0/e/` to `/i/v1/analytics/events`.
Callers of `Endpoint::Capture.path()` compile unchanged but see a different
URL — the one change here with no compile-time signal.
Internal:
- `V1Event` -> `CaptureEvent` (not `Event`, which is taken by the public input
type), `V1BatchRequest{,Ref}` -> `BatchRequest{,Ref}`, `PreparedV1` ->
`Prepared`.
- `src/event_v1.rs` -> `src/capture_event.rs`, `src/client/v1_capture.rs` ->
`src/client/capture.rs`. The former cannot be `event.rs` — the public `Event`
lives there.
- `V1_CAPTURE_PATH` is deleted; both call sites now go through
`build_url(Endpoint::Capture)`, which is byte-identical output since
`build_custom_url` only normalized a leading slash that was already present.
- Tests renamed to match: `test_v1_capture.rs` -> `test_capture.rs`,
`test_v1_blocking.rs` -> `test_capture_blocking.rs` (not `test_blocking.rs`,
which survives), `test_error_tracking_v1.rs` -> `test_error_tracking.rs`.
- `compliance/v1/` -> `compliance/harness/`, and the compliance workflow drops
its `-v1` suffixes.
The harness contract keys are deliberately untouched: the `capture_v1`
capability advertised by the adapter and the `--suite capture_v1` argument are
external strings the test harness matches on.
Adds the major-release changeset. Test counts are unchanged from the previous
commit (381/317/358), and the public API diff is exactly the three intended
items with nothing else moving.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`compliance/harness/Dockerfile` does `COPY . .` from the repo root, so with no .dockerignore the build context included the whole local `target/` tree — 33GB after a few cargo runs here — and the build died with ResourceExhausted while hardlinking incremental artifacts. CI never hit this because a fresh checkout has no `target/`, which is why the documented local compose path was quietly broken for anyone who had built the crate. Excluding target/, .git/, and .github/ drops the context from 33GB to 1.14MB, which also trims the CI build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Porting the V0 tests left `event.rs` asserting the capture wire shape, which `capture_event.rs` already owns — six were straight duplicates (timestamp normalization, the anon/group/explicit `$process_person_profile` cases, and `$groups`). Wire-shape assertions now live only in `capture_event.rs`, next to the builder they exercise; `event.rs` keeps just its `Event`-level timestamp tests. The four assertions that were genuinely unique moved across rather than being dropped: `distinct_id` at the root (with no legacy `$distinct_id` and no duplicate in properties), auto-generated and caller-overridden `uuid`, and `$process_person_profile` being absent from *both* options and properties when unset. The `$lib`-coverage note moved with them. Net -6 tests per config (375/311/352) — the duplicates, nothing else. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…h exists The v0/v1 split left scaffolding that no longer earns its keep. - Drop `--suite capture_v1` from the local compose. That filter existed only to pick v0 and v1 apart; with one capture path the harness selects suites from the adapter's advertised /health capabilities, which is what CI already does (it passes no --suite). Local runs were silently narrower than CI as a result — 94 tests instead of 111, skipping feature_flags entirely. - Flatten `compliance/harness/` back to `compliance/`. The extra directory level only existed to hold the two per-mode variants. Verified from the new layout: 111/111, capabilities `capture_v1, encoding_gzip`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This reverts commit bd6da7f.
* refactor!: remove deprecated APIs * refactor!: rename local evaluation secret key field * fix local evaluation API fallback * preserve local-only evaluation privacy
* feat!: mark evaluate flags options as non-exhaustive * fix non-exhaustive options call sites
# Conflicts: # .github/workflows/sdk-compliance-tests-v1.yml # .github/workflows/sdk-compliance-tests.yml
Contributor
posthog-rs Compliance ReportDate: 2026-08-31 08:00:38 UTC ✅ All Tests Passed!111/111 tests passed Capture_V1 Tests✅ 94/94 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
# Conflicts: # api/public-api.txt # src/event.rs
* refactor: unify feature flag evaluation engine * test: consolidate feature evaluation cases
# Conflicts: # api/public-api.txt # src/event.rs
* refactor(error-tracking): centralize debug image filtering * fix: avoid self-joining transport worker on drop * refactor: unify feature flag evaluation engine * refactor: share feature flag retry classifier * refactor: centralize capture preprocessing * refactor: share feature flag event host * refactor: share feature flag evaluation state * refactor: centralize capture enqueue policy * test: consolidate malformed capture responses * test: consolidate client runtime assertions * test: consolidate feature evaluation cases * fix: avoid async shutdown worker deadlock * style: format shutdown regression test * fix: avoid async shutdown worker deadlock
* fix: avoid self-joining transport worker on drop * refactor: share feature flag retry classifier * fix: avoid async shutdown worker deadlock
* fix: avoid self-joining transport worker on drop * refactor: share feature flag retry classifier * refactor: centralize capture preprocessing * fix: avoid async shutdown worker deadlock
* fix: avoid self-joining transport worker on drop * refactor: share feature flag retry classifier * refactor: centralize capture preprocessing * refactor: share feature flag event host * fix: avoid async shutdown worker deadlock
* fix: avoid self-joining transport worker on drop * refactor: share feature flag retry classifier * refactor: centralize capture preprocessing * refactor: share feature flag event host * refactor: share feature flag evaluation state * fix: avoid async shutdown worker deadlock
* fix: avoid self-joining transport worker on drop * refactor: share feature flag retry classifier * refactor: centralize capture preprocessing * refactor: share feature flag event host * refactor: share feature flag evaluation state * refactor: centralize capture enqueue policy * fix: avoid async shutdown worker deadlock
* fix: avoid self-joining transport worker on drop * refactor: share feature flag retry classifier * refactor: centralize capture preprocessing * refactor: share feature flag event host * refactor: share feature flag evaluation state * refactor: centralize capture enqueue policy * test: consolidate client runtime assertions * fix: avoid async shutdown worker deadlock
* fix: avoid self-joining transport worker on drop * refactor: share feature flag retry classifier * refactor: centralize capture preprocessing * refactor: share feature flag event host * refactor: share feature flag evaluation state * refactor: centralize capture enqueue policy * test: consolidate malformed capture responses * fix: avoid async shutdown worker deadlock
# Conflicts: # src/client/async_client.rs # src/client/blocking.rs # tests/test_group_identify.rs
* ci: run compliance tests against sdk-test-harness 1.13.0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: allow deprecated fetch_update so Clippy passes on Rust 1.99 Rust 1.99 renames AtomicUsize::fetch_update to try_update. The crate's minimum Rust (1.78) has no try_update, so keep the old name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
4 of 5 tasks
…ption (#279) * feat!: stop forcing person processing for groups; new_anon sets the option * test: pin legacy option properties surviving minimal flag events * feat!: add SDK values before before_send; caller values win $os, $os_version, $is_server and $geoip_disable now go in before the before_send hooks, only for keys the event leaves unset. The hook sees them and can remove them; the wire builder no longer adds them again. Event::with_flags keeps flag properties the event already has, and add_group groups merge into a $groups property key by key. * fix(capture): strip caller-set $lib and $lib_version before send Capture sets both from the PostHog-Sdk-Info header and appends them after the event's keys, so a copy left in properties is a duplicate JSON key. Also corrects two migration guide lines: new_anon differs from every 0.x build, and the default V0 path already added $os before before_send. * docs: note group person processing on exceptions and show insert_option
Contributor
There was a problem hiding this comment.
PostHog Review · Standard · reviewed c809f88: 5 Should fix. This pull request is large, so the review ran in 4 parts with less depth than usual.
This is the only automatic review while this pull request is a draft. Comment @posthog review to review new changes sooner. Otherwise, a review of the new changes runs when you mark it ready for review.
# Conflicts: # .github/workflows/ci.yaml # .github/workflows/codeql.yml # .github/workflows/posthog-upgrade.yml # .github/workflows/release.yml # .github/workflows/sdk-compliance-tests-v0.yml # .github/workflows/sdk-compliance-tests-v1.yml # src/client/transport.rs
# Conflicts: # .github/workflows/sdk-compliance-tests-v0.yml # .github/workflows/sdk-compliance-tests-v1.yml
* fix(capture): drop oversize AI events locally on the immediate path capture_ai_immediate and capture_ai_batch_immediate now apply the 8 MiB per-event limit before sending, like the background AI lane. An event over the limit is not sent and gets a local drop verdict with the detail ai_event_too_big in the returned CaptureSummary. * fix(retry): default to 4 capture attempts from 100 ms and give /flags its own backoff max_capture_attempts now defaults to 4 and retry_initial_backoff_ms to 100. Remote /flags retries use a fixed backoff of 300 ms, doubling up to 30 s, instead of the capture retry options. * test: set explicit uuids in the immediate size-ceiling test The test read each event's uuid before capture; setting it explicitly keeps the test independent of when the SDK assigns uuids. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…lank ids as anonymous (#287) A cloned or reused Event no longer sends one uuid twice: the client assigns the uuid when it takes the event, unless set_uuid was called. set_timestamp no longer rejects future timestamps; PostHog clamps them. Event::new with an empty or whitespace-only distinct id creates an anonymous event. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A phx_ key passed as the project api_key disables the client with one error log, as an empty key does, so a key PostHog always rejects is never sent. The empty-key message moves to error level, and an explicitly disabled client logs nothing about its key. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…iB (#288) Capture V1 refuses an analytics body over 10 MiB, and the SDK sends bodies uncompressed by default, so a count-only batch of large events could fail whole. The analytics lane now splits each send by serialized bytes with the check-before-append rule. Events are still built at send time, so before_send timing is unchanged; immediate batches stay one request. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix: add jitter to capture retry waits Each capture retry wait is scaled by a random factor between 0.75 and 1.25, then clamped to retry_max_backoff_ms, so clients that fail together do not retry together. A Retry-After header stays the minimum wait. Feature flag retries are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: draw capture retry jitter with fastrand fastrand is tiny, has no dependencies and supports Rust 1.63, so the jitter factor is one plain call instead of bits from the std hasher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: draw retry jitter from std instead of fastrand Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* docs: explain that the sdk-info header sets $lib on 1.0 * docs: complete the 1.0 migration guide and changesets Covers the event ID rules, the $lib strip and the removed $lib_version parts, AI lane size limits, the C compiler need, retryable statuses and the no-hook log line, newly non-exhaustive types, and $debug_images. Adds changesets for capture_ai, the TLS features, the non-exhaustive types and the SDK identity header, and uses real per-event quota tags in test fixtures. * docs: the immediate AI variants also drop events over 8 MiB locally
…298) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…299) * docs: note the 200-byte distinct ID limit in the 1.0 migration guide Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: drop product_tour_id from the guide; PostHog owns the $ai_ prefix Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: note the 200-byte event name limit in the 1.0 migration guide Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # src/feature_flags.rs
* fix: report capture's dropped duplicate copies as drops Capture v1 keeps the first event for each uuid in a request and drops later copies, reporting the count as duplicates_dropped on the uuid's result. The SDK now treats those copies as terminal drops: it never resends them, and counts them as lost in on_error (drop/duplicate_event_uuid) and in CaptureSummary::not_persisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: note the retry gap and older capture's 400 for duplicate uuids Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
3 of 33 tasks
) A `$trace_id` or `$span_id` set as an exception property now wins over the trace context provider, and setting either one stops the SDK adding both provider IDs, so an event never mixes IDs from two trace contexts. An explicit `CaptureExceptionOptions::trace_context` still wins over both. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…e-origin redirects only (#307) * fix: run before_send after groups and the flag-event trim, follow same-origin redirects only Merge typed groups into $groups and trim minimized $feature_flag_called events before before_send, so the hook sees groups and its additions are sent. SDK-built HTTP clients follow only 307/308 redirects to the first request's origin, at most 5 times. Shutdown and queue-full drop warnings name the capture endpoint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: list $product_tour_id among the legacy option properties Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: reverse proxy checklist for capture v1 in the migration guide Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: shutdown drops reach on_error once a batch has used all its attempts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # .github/workflows/ci.yaml # .github/workflows/sdk-compliance-tests-v0.yml # .github/workflows/sdk-compliance-tests-v1.yml # Cargo.lock # Cargo.toml # scripts/check-public-api.sh # src/client/transport.rs # src/error_tracking.rs # tests/test_async.rs # tests/test_blocking.rs # tests/test_capture.rs # tests/test_capture_blocking.rs # tests/test_capture_immediate.rs # tests/test_error_tracking.rs # tests/test_error_tracking_v1.rs # tests/test_evaluate_flags.rs # tests/test_v0_blocking_retry.rs # tests/test_v0_retry.rs
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* chore: run the capture v1 compliance suites from harness 1.23.0 Declare the adapter capabilities harness 1.23.0 uses to gate tests: event_uuid_override, bounded_retries, disable_geoip and historical_migration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: support the harness reported_drops, log_capture, generated_payloads, property_layers and fail_open features Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: run the capture v1 compliance suites from harness 1.25.0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
Closes #207
💚 How did you test it?
📝 Checklist
If releasing new changes
sampo addto generate a changeset file