From f312233dccaec229ad27529f671848d364be24e3 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Tue, 29 Sep 2026 14:26:02 +0200 Subject: [PATCH] ref(typesafe): Drop send_default_pii support --- sentry_sdk/integrations/typesafe.py | 70 ++++++++------------ tests/integrations/typesafe/test_typesafe.py | 14 +++- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/sentry_sdk/integrations/typesafe.py b/sentry_sdk/integrations/typesafe.py index bb45b3fe0b..cea237805b 100644 --- a/sentry_sdk/integrations/typesafe.py +++ b/sentry_sdk/integrations/typesafe.py @@ -6,8 +6,6 @@ import sentry_sdk from sentry_sdk.consts import OP, SPANDATA from sentry_sdk.integrations import DidNotEnable, Integration -from sentry_sdk.scope import should_send_default_pii -from sentry_sdk.utils import has_data_collection_enabled if TYPE_CHECKING: from typing import ( @@ -263,26 +261,20 @@ def wrap_system_one(self: "TypeSafeClient", *args: "Any", **kwargs: "Any") -> "A SPANDATA.GEN_AI_USAGE_OUTPUT_TOKENS, response.usage.output_tokens ) - if ( - has_data_collection_enabled(client.options) - and client.options["data_collection"]["gen_ai"]["outputs"] - ) or ( - not has_data_collection_enabled(client.options) - and should_send_default_pii() - ): - span.set_attribute( - SPANDATA.GEN_AI_OUTPUT_MESSAGES, - json.dumps( - [ - { - "type": "evaluation", - "answers": _transform_evaluation_answers( - response.answers - ), - } - ] - ), - ) + if not client.options["data_collection"]["gen_ai"]["outputs"]: + return response + + span.set_attribute( + SPANDATA.GEN_AI_OUTPUT_MESSAGES, + json.dumps( + [ + { + "type": "evaluation", + "answers": _transform_evaluation_answers(response.answers), + } + ] + ), + ) return response @@ -353,26 +345,20 @@ async def wrap_system_one_async( SPANDATA.GEN_AI_USAGE_OUTPUT_TOKENS, response.usage.output_tokens ) - if ( - has_data_collection_enabled(client.options) - and client.options["data_collection"]["gen_ai"]["outputs"] - ) or ( - not has_data_collection_enabled(client.options) - and should_send_default_pii() - ): - span.set_attribute( - SPANDATA.GEN_AI_OUTPUT_MESSAGES, - json.dumps( - [ - { - "type": "evaluation", - "answers": _transform_evaluation_answers( - response.answers - ), - } - ] - ), - ) + if not client.options["data_collection"]["gen_ai"]["outputs"]: + return response + + span.set_attribute( + SPANDATA.GEN_AI_OUTPUT_MESSAGES, + json.dumps( + [ + { + "type": "evaluation", + "answers": _transform_evaluation_answers(response.answers), + } + ] + ), + ) return response diff --git a/tests/integrations/typesafe/test_typesafe.py b/tests/integrations/typesafe/test_typesafe.py index 17d27dfbc0..8298375a71 100644 --- a/tests/integrations/typesafe/test_typesafe.py +++ b/tests/integrations/typesafe/test_typesafe.py @@ -58,7 +58,12 @@ def test_system_one(sentry_init, capture_items, typesafe_response): sentry_init( integrations=[TypeSafeIntegration()], traces_sample_rate=1.0, - data_collection={}, + data_collection={ + "gen_ai": { + "inputs": True, + "outputs": True, + } + }, ) client = TypeSafeClient(api_key="z") @@ -201,7 +206,12 @@ async def test_system_one_async(sentry_init, capture_items, typesafe_response): sentry_init( integrations=[TypeSafeIntegration()], traces_sample_rate=1.0, - data_collection={}, + data_collection={ + "gen_ai": { + "inputs": True, + "outputs": True, + } + }, ) client = AsyncTypeSafeClient(api_key="z")