Skip to content

Commit fde9c61

Browse files
committed
feat!: AI wrappers always send through capture_ai
enable_full_ai_capture now controls only truncation and media redaction. A client object without capture_ai still gets capture calls.
1 parent db5b4d0 commit fde9c61

15 files changed

Lines changed: 486 additions & 640 deletions

‎posthog/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ def get_context_options() -> Dict[str, Any]:
475475
# We recommend setting this to False if you are only using the personalApiKey for evaluating remote config payloads via `get_remote_config_payload` and not using local evaluation.
476476
enable_local_evaluation = True # type: bool
477477
flag_definition_cache_provider = None # type: Optional[FlagDefinitionCacheProvider]
478-
# Routes AI SDK wrapper events through the dedicated AI capture lane, skips
479-
# truncation, and passes media unredacted. `privacy_mode` always wins.
478+
# Captures full AI content in AI SDK wrapper events: skips truncation and
479+
# passes media unredacted. `privacy_mode` always wins.
480480
enable_full_ai_capture = False # type: bool
481481
# Deprecated aliases for `enable_full_ai_capture`.
482482
_use_ai_lane = False # type: bool

‎posthog/ai/utils.py‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from posthog import get_tags, identify_context, new_context, tag, contexts
77
from posthog.ai.gateway import warn_if_posthog_ai_gateway
8-
from posthog.ai.sanitization import _full_ai_capture_enabled, redact_media
8+
from posthog.ai.sanitization import redact_media
99
from posthog.ai.sanitization import sanitize_messages # noqa: F401 -- re-exported for back-compat
1010
from posthog.ai.types import FormattedMessage, StreamingEventData, TokenUsage
1111
from posthog.client import Client as PostHogClient
@@ -64,11 +64,6 @@ def _get_tokens_source(
6464
return "sdk"
6565

6666

67-
def _ai_lane_enabled(ph_client) -> bool:
68-
"""The client's full-AI-capture opt-in routes wrapper events onto the AI lane."""
69-
return _full_ai_capture_enabled(ph_client)
70-
71-
7267
def _capture_ai_event(ph_client, event: str, *, personless: bool = False, **kwargs):
7368
"""Capture a wrapper-emitted AI event with the PostHog AI library identity.
7469
@@ -87,10 +82,10 @@ def _capture_ai_event(ph_client, event: str, *, personless: bool = False, **kwar
8782
**(kwargs.get("options") or {}),
8883
"process_person_profile": False,
8984
}
90-
if _ai_lane_enabled(ph_client):
91-
capture_ai = getattr(ph_client, "capture_ai", None)
92-
if callable(capture_ai):
93-
return capture_ai(event=event, **kwargs)
85+
# Clients without capture_ai, such as custom stand-ins, keep the analytics lane.
86+
capture_ai = getattr(ph_client, "capture_ai", None)
87+
if callable(capture_ai):
88+
return capture_ai(event=event, **kwargs)
9489
return ph_client.capture(event=event, **kwargs)
9590

9691

‎posthog/client.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,11 +812,11 @@ def __init__(
812812
captured exceptions. Defaults to the current working directory.
813813
privacy_mode: For AI observability, capture usage metadata without
814814
prompt inputs or outputs.
815-
enable_full_ai_capture: Route PostHog AI wrapper events through
816-
the dedicated AI capture endpoint and capture full AI content:
817-
skips string truncation and passes media (base64/data URIs)
818-
through unredacted. ``privacy_mode`` always wins. Defaults to
819-
False.
815+
enable_full_ai_capture: Capture full AI content in PostHog AI
816+
wrapper events: skips string truncation and passes media
817+
(base64/data URIs) through unredacted. ``privacy_mode`` always
818+
wins. Wrapper events use the AI capture endpoint whether or not
819+
this is set. Defaults to False.
820820
before_send: Optional callback that can modify or drop events before
821821
upload. Return ``None`` to drop an event.
822822
flag_fallback_cache_url: Optional feature flag fallback cache URL,

0 commit comments

Comments
 (0)