Repository navigation
Conversation
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.
… 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.
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
Two v1 behavior fixes so the Rust SDK matches the other server SDKs.
The immediate AI variants now apply the 8 MiB per-event limit locally. The background AI lane already drops an event whose serialized
propertiesexceedAI_MAX_EVENT_BYTES(strictly greater).capture_ai_immediateandcapture_ai_batch_immediatesent such an event and relied on the backend to refuse it. Nowprepare_immediatemeasures each event against a per-lanemax_event_bytes. An event over the limit is not sent. It gets a localEventResult { result: Drop, details: "ai_event_too_big" }, which counts insubmitted()andnot_persisted()exactly like the backend's verdict would. If every event in a call is over the limit, no request is made. The analytics lane has no ceiling and its behavior is unchanged.Retry defaults.
max_capture_attemptsnow defaults to 4 (was 3).retry_initial_backoff_msnow defaults to 100 (was 200)./flagsretries no longer read the capture retry options. They use a fixed backoff of 300 ms, doubling up to 30 s, which matches posthog-python and posthog-go.feature_flags_request_max_retriesstill controls how many/flagsretries happen.exponential_backoff.The migration guide's Retry section and a
capture-retry-defaultschangeset describe the new defaults. The guide and changeset text for the AI immediate drop lives in #280, which already rewrites those sentences. I pushed a follow-up commit there so the two PRs agree.💚 How did you test it?
New and changed tests:
prepare_immediate_drops_events_over_the_lane_ceiling_locallycovers an event exactly at the ceiling (sent), one byte over (local drop), and every event over the ceiling (no request). It runs on both lanes.capture_ai_batch_immediate_drops_an_oversize_event_locallyreplaces the old "server returns too-big verdict" test, async and blocking. The mock only answers a request that carries the normal event and not the oversize one. The test assertssubmitted() == 2,not_persisted() == 1, the localai_event_too_bigdrop, and the normal event'sOk.feature_flags_backoff_doubles_from_300ms_up_to_30scovers the/flagsschedule and its cap./flagsdecision tests now assert the exact 300 ms wait while the capture backoff options are set to 1/5 ms, which proves/flagsignores them.backoff_exponential_growth_with_default_optionsnow uses the builder defaults, so it pins 4 attempts and 100/200/400 ms.Mutation checks. Each mutant fails at least one test, and each was reverted afterwards:
max_event_bytesset toNone: the async and the blocking integration tests fail.>changed to>=: the unit test fails./flagspointed back at the capture backoff: both/flagsdecision tests fail.Ran locally and passing:
cargo fmt -- --checkcargo clippy -- -D warningscargo test --workspacecargo test --no-default-featurescargo test --no-default-features --features error-trackingtest_tls_no_providervariantscargo test --features e2e-test,tls --no-default-featuresscripts/check-public-api.sh(no public API change)cargo package --lockedTrial merges into #279, #280 (including its new commit) and #285 are all clean. The combined #285 + #280 + this branch passes clippy and
cargo test --workspace.📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
Written with Claude Opus 5.5 in Cursor, directed and reviewed by @eli-r-ph.