Skip to content

Commit d569aca

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 9dcf4df commit d569aca

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
@@ -485,8 +485,8 @@ def get_context_options() -> Dict[str, Any]:
485485
# 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.
486486
enable_local_evaluation = True # type: bool
487487
flag_definition_cache_provider = None # type: Optional[FlagDefinitionCacheProvider]
488-
# Routes AI SDK wrapper events through the dedicated AI capture lane, skips
489-
# truncation, and passes media unredacted. `privacy_mode` always wins.
488+
# Captures full AI content in AI SDK wrapper events: skips truncation and
489+
# passes media unredacted. `privacy_mode` always wins.
490490
enable_full_ai_capture = False # type: bool
491491
# Deprecated aliases for `enable_full_ai_capture`.
492492
_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
@@ -840,11 +840,11 @@ def __init__(
840840
captured exceptions. Defaults to the current working directory.
841841
privacy_mode: For AI observability, capture usage metadata without
842842
prompt inputs or outputs.
843-
enable_full_ai_capture: Route PostHog AI wrapper events through
844-
the dedicated AI capture endpoint and capture full AI content:
845-
skips string truncation and passes media (base64/data URIs)
846-
through unredacted. ``privacy_mode`` always wins. Defaults to
847-
False.
843+
enable_full_ai_capture: Capture full AI content in PostHog AI
844+
wrapper events: skips string truncation and passes media
845+
(base64/data URIs) through unredacted. ``privacy_mode`` always
846+
wins. Wrapper events use the AI capture endpoint whether or not
847+
this is set. Defaults to False.
848848
before_send: Optional callback that can modify or drop events before
849849
upload. Return ``None`` to drop an event. Context tags,
850850
context options, ``super_properties``, ``super_options`` and

0 commit comments

Comments
 (0)