Repository navigation
Conversation
eli-r-ph
force-pushed
the
v1-ai-require-capture-ai
branch
from
October 10, 2026 23:35
dfa7894 to
585ce8b
Compare
eli-r-ph
force-pushed
the
v1-capture-api-fixes
branch
from
October 10, 2026 23:35
6982671 to
0c99129
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
Stacked on #1046.
In 7.x, an AI integration given a client object without
capture_aisent its events throughcaptureinstead. In 8.0 that fallback is wrong in two ways:capturesends to/i/v1/analytics/events, not to/i/v1/ai/events, so the events skip the AI lane's 8 MiB size limit and itscapture_ai_*settings.This PR removes the fallback and fails fast instead:
_resolve_ai_clienthelper inposthog/ai/utils.pyreplaces everyposthog_client or setup()in the integrations. It returns the given client or the global one, and raisesTypeErrorwhen the client has no callablecapture_ai.CallbackHandler, and the OpenAI Agents and Claude Agent SDK processors. Gemini's own_resolve_posthog_clientgoes away.capture_ai, notcapture, and_capture_ai_eventalways callscapture_ai.ClientorAsyncPosthoginstance, and the default global client, work as before.Two behavior changes to call out for review:
PostHogClaudeAgentProcessor(client=object())used to build and then drop events silently. It now raisesTypeError. The test that pinned the old behavior now asserts the error.setupat module level, so the public API snapshot drops those incidental<module>.setupaliases and gainsposthog.ai.utils.setup. A test that patchesposthog.ai.<integration>.setupnow gets anAttributeError, which is louder than a re-export that would silently stop taking effect. The repository's own two such tests now patchposthog.ai.utils.setup.The migration guide's AI capture section and a changeset cover it.
💚 How did you test it?
capturebut nocapture_ai. Each one raisesTypeErrorat construction and never callscapture.capturefallback is gone. The test stand-ins that only hadcapturenow implementcapture_ai.ruff format --check,ruff check, mypy with the baseline filter,make public_api_check, andpytest --timeout=30(4616 passed) all pass.📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Written with Cursor (Claude Opus 5.5). The reviewer chose to fail fast at construction over keeping the
capturefallback or failing at send time, after the agent mapped how the failure would surface in each integration. The agent implemented it, removed the fallback test, and checked that no shipped client type lackscapture_ai.