Skip to content

feat: add an AI capture lane to AsyncPosthog - #1028

Merged
eli-r-ph merged 4 commits into
v1from
v1-capture-async-ai-lane
Oct 14, 2026
Merged

eli-r-ph merged 4 commits into
v1from
v1-capture-async-ai-lane

Conversation

@eli-r-ph

@eli-r-ph eli-r-ph commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Stacked on #1027. The sync Client sends $ai_* events on a separate AI lane, but AsyncPosthog has only the analytics lane. This PR gives AsyncPosthog the same AI lane, with the same options and defaults.

Changes

  • New AsyncPosthog.capture_ai (queued) and capture_ai_immediate (awaits delivery), both posting to /i/v1/ai/events.
  • New options with the sync defaults: capture_ai_compression, capture_ai_max_queue_size (1000), capture_ai_timeout (30 s) and capture_ai_max_event_bytes (8 MiB, can only be lowered).
  • The AI lane has its own queue and workers, which start on the first capture_ai call.
  • flush and shutdown drain both lanes.
  • New privacy_mode and enable_full_ai_capture options, read by the AI wrappers as on Client.
  • Size and queue-full logs name the lane.

With #1027, a wrapper given an AsyncPosthog client now sends to the AI endpoint.

💚 How did you test it?

  • Tests cover each lane's path, compression, timeout and size cap, and that flush and shutdown deliver both lanes.
  • Privacy tests run on both clients.
  • Breaking each behavior on purpose fails a test.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Written with Cursor (Claude Opus) under the direction of the assignee.

🤖 Generated with Claude Code

@eli-r-ph eli-r-ph self-assigned this Oct 7, 2026
@eli-r-ph eli-r-ph mentioned this pull request Oct 7, 2026
3 of 20 tasks
@eli-r-ph
eli-r-ph force-pushed the v1-capture-async-ai-lane branch from d5eb0bc to ae647de Compare October 7, 2026 03:56
@eli-r-ph
eli-r-ph force-pushed the v1-capture-ai-wrappers branch from fde9c61 to 31c13ba Compare October 7, 2026 03:56
@eli-r-ph
eli-r-ph force-pushed the v1-capture-async-ai-lane branch from 42c1d07 to 691c8bd Compare October 7, 2026 17:43
@eli-r-ph
eli-r-ph force-pushed the v1-capture-ai-wrappers branch from 31c13ba to 17eeb3b Compare October 7, 2026 17:43
@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:44
@eli-r-ph
eli-r-ph requested a review from a team as a code owner October 7, 2026 20:44

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

The async lane and both-lane lifecycle handling look consistent with the sync implementation. One minor, non-blocking malformed-input exception-boundary issue is noted inline. Consider ensuring the stack’s spec update and migration guide explicitly cover default async-wrapper routing to the AI endpoint.

AI-assisted review.

Comment thread posthog/async_client.py
@eli-r-ph
eli-r-ph force-pushed the v1-capture-async-ai-lane branch from 691c8bd to 1f784bb Compare October 8, 2026 16:25
@eli-r-ph
eli-r-ph force-pushed the v1-capture-ai-wrappers branch 2 times, most recently from 054e194 to d909586 Compare October 8, 2026 18:13
@eli-r-ph
eli-r-ph force-pushed the v1-capture-async-ai-lane branch 2 times, most recently from 04507c0 to adf5b16 Compare October 8, 2026 21:12
@eli-r-ph
eli-r-ph force-pushed the v1-capture-ai-wrappers branch 2 times, most recently from 19134a6 to d569aca Compare October 8, 2026 22:54
@eli-r-ph
eli-r-ph force-pushed the v1-capture-async-ai-lane branch from adf5b16 to 0cfa23c Compare October 8, 2026 22:54
@eli-r-ph
eli-r-ph force-pushed the v1-capture-ai-wrappers branch from d569aca to a473b99 Compare October 8, 2026 23:40
@eli-r-ph
eli-r-ph force-pushed the v1-capture-async-ai-lane branch from 0cfa23c to 252b30d Compare October 8, 2026 23:40
@eli-r-ph
eli-r-ph force-pushed the v1-capture-ai-wrappers branch from a473b99 to fd66496 Compare October 10, 2026 23:35
@eli-r-ph
eli-r-ph force-pushed the v1-capture-async-ai-lane branch from 252b30d to 6e1a501 Compare October 10, 2026 23:35
@eli-r-ph
eli-r-ph force-pushed the v1-capture-ai-wrappers branch from fd66496 to dde4812 Compare October 11, 2026 20:17
@eli-r-ph
eli-r-ph force-pushed the v1-capture-async-ai-lane branch from 6e1a501 to 2765967 Compare October 11, 2026 20:17
@eli-r-ph eli-r-ph changed the title feat: AsyncPosthog AI capture lane feat: add an AI capture lane to AsyncPosthog Oct 13, 2026
@eli-r-ph
eli-r-ph force-pushed the v1-capture-ai-wrappers branch from dde4812 to d860568 Compare October 14, 2026 03:11
@eli-r-ph
eli-r-ph force-pushed the v1-capture-async-ai-lane branch from 2765967 to 4cd3a28 Compare October 14, 2026 03:11
@eli-r-ph
eli-r-ph force-pushed the v1-capture-ai-wrappers branch from d860568 to 8232570 Compare October 14, 2026 03:47
Base automatically changed from v1-capture-ai-wrappers to v1 October 14, 2026 03:47
@eli-r-ph
eli-r-ph force-pushed the v1-capture-async-ai-lane branch from 4cd3a28 to 66b1e17 Compare October 14, 2026 03:47
@eli-r-ph
eli-r-ph merged commit ed296dc into v1 Oct 14, 2026
39 checks passed
@eli-r-ph
eli-r-ph deleted the v1-capture-async-ai-lane branch October 14, 2026 03:47
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