Skip to content

Commit e0be487

Browse files
committed
refactor: remove privacy_mode param, always use client setting
1 parent eee31fc commit e0be487

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

posthog/ai/pydantic_ai/instrument.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
def instrument_pydantic_ai(
1313
client: PostHogClient,
1414
distinct_id: Optional[str] = None,
15-
privacy_mode: Optional[bool] = None,
1615
properties: Optional[Dict[str, Any]] = None,
1716
groups: Optional[Dict[str, Any]] = None,
1817
debug: bool = False,
@@ -39,8 +38,6 @@ def instrument_pydantic_ai(
3938
client: PostHog client instance for sending events
4039
distinct_id: Default distinct ID for all events. If not provided,
4140
events will use the trace ID as distinct_id.
42-
privacy_mode: If True, message content will be redacted from events.
43-
If not specified, inherits from client.privacy_mode.
4441
properties: Additional properties to include in all events
4542
groups: PostHog groups to associate with all events
4643
debug: Enable debug logging for troubleshooting
@@ -68,9 +65,7 @@ def instrument_pydantic_ai(
6865

6966
from posthog.ai.pydantic_ai.exporter import PydanticAISpanExporter
7067

71-
# Resolve privacy_mode from client if not explicitly set
72-
if privacy_mode is None:
73-
privacy_mode = getattr(client, "privacy_mode", False)
68+
privacy_mode = getattr(client, "privacy_mode", False)
7469

7570
# Create the Pydantic AI-specific exporter (handles message format normalization)
7671
exporter = PydanticAISpanExporter(

posthog/test/ai/pydantic_ai/test_instrument.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ def test_basic_instrumentation(self, mock_client):
4141
settings = mock_instrument_all.call_args[0][0]
4242
assert isinstance(settings, InstrumentationSettings)
4343

44-
def test_privacy_mode_disables_content(self, mock_client):
44+
def test_privacy_mode_disables_content(self):
4545
from posthog.ai.pydantic_ai import instrument_pydantic_ai
4646

47+
client = MagicMock()
48+
client.privacy_mode = True
49+
4750
with patch.object(Agent, "instrument_all") as mock_instrument_all:
48-
instrument_pydantic_ai(mock_client, privacy_mode=True)
51+
instrument_pydantic_ai(client)
4952

5053
settings = mock_instrument_all.call_args[0][0]
5154
assert settings.include_content is False
@@ -54,7 +57,7 @@ def test_privacy_mode_false_includes_content(self, mock_client):
5457
from posthog.ai.pydantic_ai import instrument_pydantic_ai
5558

5659
with patch.object(Agent, "instrument_all") as mock_instrument_all:
57-
instrument_pydantic_ai(mock_client, privacy_mode=False)
60+
instrument_pydantic_ai(mock_client)
5861

5962
settings = mock_instrument_all.call_args[0][0]
6063
assert settings.include_content is True

0 commit comments

Comments
 (0)