Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions posthog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ def get_context_options() -> Dict[str, Any]:
# 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.
enable_local_evaluation = True # type: bool
flag_definition_cache_provider = None # type: Optional[FlagDefinitionCacheProvider]
# Routes AI SDK wrapper events through the dedicated AI capture lane, skips
# truncation, and passes media unredacted. `privacy_mode` always wins.
# Captures full AI content in AI SDK wrapper events: skips truncation and
# passes media unredacted. `privacy_mode` always wins.
enable_full_ai_capture = False # type: bool
# Deprecated aliases for `enable_full_ai_capture`.
_use_ai_lane = False # type: bool
Expand Down
15 changes: 5 additions & 10 deletions posthog/ai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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


def _ai_lane_enabled(ph_client) -> bool:
"""The client's full-AI-capture opt-in routes wrapper events onto the AI lane."""
return _full_ai_capture_enabled(ph_client)


def _capture_ai_event(ph_client, event: str, *, personless: bool = False, **kwargs):
"""Capture a wrapper-emitted AI event with the PostHog AI library identity.

Expand All @@ -87,10 +82,10 @@ def _capture_ai_event(ph_client, event: str, *, personless: bool = False, **kwar
**(kwargs.get("options") or {}),
"process_person_profile": False,
}
if _ai_lane_enabled(ph_client):
capture_ai = getattr(ph_client, "capture_ai", None)
if callable(capture_ai):
return capture_ai(event=event, **kwargs)
# Clients without capture_ai, such as custom stand-ins, keep the analytics lane.
capture_ai = getattr(ph_client, "capture_ai", None)
if callable(capture_ai):
return capture_ai(event=event, **kwargs)
return ph_client.capture(event=event, **kwargs)


Expand Down
10 changes: 5 additions & 5 deletions posthog/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,11 @@ def __init__(
captured exceptions. Defaults to the current working directory.
privacy_mode: For AI observability, capture usage metadata without
prompt inputs or outputs.
enable_full_ai_capture: Route PostHog AI wrapper events through
the dedicated AI capture endpoint and capture full AI content:
skips string truncation and passes media (base64/data URIs)
through unredacted. ``privacy_mode`` always wins. Defaults to
False.
enable_full_ai_capture: Capture full AI content in PostHog AI
wrapper events: skips string truncation and passes media
(base64/data URIs) through unredacted. ``privacy_mode`` always
wins. Wrapper events use the AI capture endpoint whether or not
this is set. Defaults to False.
before_send: Optional callback that can modify or drop events before
upload. Return ``None`` to drop an event. Context tags,
context options, ``super_properties``, ``super_options`` and
Expand Down
Loading
Loading