Skip to content

Commit 40d19b3

Browse files
ref(typesafe): Drop send_default_pii support (#7754)
Closes #7752
1 parent b0bd42f commit 40d19b3

2 files changed

Lines changed: 40 additions & 44 deletions

File tree

‎sentry_sdk/integrations/typesafe.py‎

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import sentry_sdk
77
from sentry_sdk.consts import OP, SPANDATA
88
from sentry_sdk.integrations import DidNotEnable, Integration
9-
from sentry_sdk.scope import should_send_default_pii
10-
from sentry_sdk.utils import has_data_collection_enabled
119

1210
if TYPE_CHECKING:
1311
from typing import (
@@ -263,26 +261,20 @@ def wrap_system_one(self: "TypeSafeClient", *args: "Any", **kwargs: "Any") -> "A
263261
SPANDATA.GEN_AI_USAGE_OUTPUT_TOKENS, response.usage.output_tokens
264262
)
265263

266-
if (
267-
has_data_collection_enabled(client.options)
268-
and client.options["data_collection"]["gen_ai"]["outputs"]
269-
) or (
270-
not has_data_collection_enabled(client.options)
271-
and should_send_default_pii()
272-
):
273-
span.set_attribute(
274-
SPANDATA.GEN_AI_OUTPUT_MESSAGES,
275-
json.dumps(
276-
[
277-
{
278-
"type": "evaluation",
279-
"answers": _transform_evaluation_answers(
280-
response.answers
281-
),
282-
}
283-
]
284-
),
285-
)
264+
if not client.options["data_collection"]["gen_ai"]["outputs"]:
265+
return response
266+
267+
span.set_attribute(
268+
SPANDATA.GEN_AI_OUTPUT_MESSAGES,
269+
json.dumps(
270+
[
271+
{
272+
"type": "evaluation",
273+
"answers": _transform_evaluation_answers(response.answers),
274+
}
275+
]
276+
),
277+
)
286278

287279
return response
288280

@@ -353,26 +345,20 @@ async def wrap_system_one_async(
353345
SPANDATA.GEN_AI_USAGE_OUTPUT_TOKENS, response.usage.output_tokens
354346
)
355347

356-
if (
357-
has_data_collection_enabled(client.options)
358-
and client.options["data_collection"]["gen_ai"]["outputs"]
359-
) or (
360-
not has_data_collection_enabled(client.options)
361-
and should_send_default_pii()
362-
):
363-
span.set_attribute(
364-
SPANDATA.GEN_AI_OUTPUT_MESSAGES,
365-
json.dumps(
366-
[
367-
{
368-
"type": "evaluation",
369-
"answers": _transform_evaluation_answers(
370-
response.answers
371-
),
372-
}
373-
]
374-
),
375-
)
348+
if not client.options["data_collection"]["gen_ai"]["outputs"]:
349+
return response
350+
351+
span.set_attribute(
352+
SPANDATA.GEN_AI_OUTPUT_MESSAGES,
353+
json.dumps(
354+
[
355+
{
356+
"type": "evaluation",
357+
"answers": _transform_evaluation_answers(response.answers),
358+
}
359+
]
360+
),
361+
)
376362

377363
return response
378364

‎tests/integrations/typesafe/test_typesafe.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ def test_system_one(sentry_init, capture_items, typesafe_response):
5858
sentry_init(
5959
integrations=[TypeSafeIntegration()],
6060
traces_sample_rate=1.0,
61-
data_collection={},
61+
data_collection={
62+
"gen_ai": {
63+
"inputs": True,
64+
"outputs": True,
65+
}
66+
},
6267
)
6368

6469
client = TypeSafeClient(api_key="z")
@@ -201,7 +206,12 @@ async def test_system_one_async(sentry_init, capture_items, typesafe_response):
201206
sentry_init(
202207
integrations=[TypeSafeIntegration()],
203208
traces_sample_rate=1.0,
204-
data_collection={},
209+
data_collection={
210+
"gen_ai": {
211+
"inputs": True,
212+
"outputs": True,
213+
}
214+
},
205215
)
206216

207217
client = AsyncTypeSafeClient(api_key="z")

0 commit comments

Comments
 (0)