Repository navigation
Conversation
3 of 18 tasks
eli-r-ph
force-pushed
the
v1-capture-async-ai-lane
branch
from
October 7, 2026 03:56
d5eb0bc to
ae647de
Compare
eli-r-ph
force-pushed
the
v1-capture-ai-wrappers
branch
from
October 7, 2026 03:56
fde9c61 to
31c13ba
Compare
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
Clienthas a separate AI lane:capture_aiposts to/i/v1/ai/eventswith its own queue, compression, timeout and 8 MiB event cap (feat!: send capture through v1 by default; capture_ai to /i/v1/ai/events #1017, feat: AI lane config and size-aware batching #1022).AsyncPosthoghas only the analytics lane. An async user has no way to send a large$ai_*event to the AI endpoint.This PR gives
AsyncPosthogthe same AI lane, with the same knobs and defaults as the sync client.Changes
AsyncPosthog.capture_ai(queued) andcapture_ai_immediate(awaits delivery). Both post to/i/v1/ai/events.capture_ai_compression(default none; the env var does not apply)capture_ai_max_queue_size(1000)capture_ai_timeout(30s)capture_ai_max_event_bytes(8 MiB; it can only be lowered)capture_aicall, not before.flushwakes both lanes before it waits on either, so one lane's partial batch does not sit out itsflush_interval.shutdownstops and awaits the workers of both lanes.privacy_modeandenable_full_ai_captureoptions, read by the AI wrappers the same way as onClient. Without them, a wrapper given anAsyncPosthogclient always truncated and redacted media.requestsstub typetimeoutasfloat, so the 30s float AI timeout type-checks end to end.Note
With #1027, the AI wrappers call
capture_aion any client that has it. A wrapper given anAsyncPosthogclient now sends to the AI endpoint, where it used to fall back tocapture.💚 How did you test it?
test_capture_immediate_uses_its_lane_without_building_httpx_clientchecks that each immediate method uses its own lane's path, compression and timeout.test_ai_events_queue_on_their_own_lane_and_flush_drains_both:capture_aiflushdelivers both lanesshutdowndelivers a later AI event and clears every workertest_capture_immediate_applies_its_lane_size_cap_after_before_sendcovers the analytics cap, the larger AI cap, and a lowered AI cap.test_rejects_invalid_batch_settingsadds the three AI options.TestCaptureAiPrivacyModeruns on both clients:privacy_modestrips content even with full capture on, andenable_full_ai_capturealone decides media redaction.capture_aion the analytics laneflushdraining only the analytics lanecapture_ai_immediateusing the analytics timeoutAsyncPosthognot storingprivacy_mode, or not storingenable_full_ai_capture📝 Checklist
If releasing new changes
sampo addto generate a changeset fileCovered by the existing
capture-v1-majorchangeset; the migration guide lands later in this stack.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Written with Cursor (Claude Opus) under the direction of the assignee. Skills used:
writing-tests,writing-pr-descriptions.Agent calls worth review:
_AsyncLaneholder instead of parallel attributes per lane, to mirror the sync client's_Lane.AsyncPosthoggetsprivacy_modeandenable_full_ai_capturehere, not in a follow-up. It does not get the sync client's deprecated_use_ai_lane/_enable_multimodal_capturealiases, since async never had them.