From cbeed94b0811429200a1fadb72a72b5e11d81e4b Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Thu, 24 Sep 2026 11:13:22 +0200 Subject: [PATCH 1/2] chore: Deprecate send_default_pii --- sentry_sdk/client.py | 8 ++++++++ sentry_sdk/utils.py | 10 ++++++++++ tests/test_client.py | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py index e3c6370c9c..26cebfa741 100644 --- a/sentry_sdk/client.py +++ b/sentry_sdk/client.py @@ -56,6 +56,7 @@ capture_internal_exceptions, current_stacktrace, datetime_from_isoformat, + deprecation_warning, env_to_bool, format_timestamp, get_before_send_log, @@ -350,6 +351,13 @@ def _get_options(*args: "Optional[str]", **kwargs: "Any") -> "Dict[str, Any]": if rv["enable_tracing"] is True and rv["traces_sample_rate"] is None: rv["traces_sample_rate"] = 1.0 + if rv["send_default_pii"] is None: + deprecation_warning( + "The send_default_pii option is deprecated. Use data_collection " + "instead. " + "See https://docs.sentry.io/platforms/python/data-management/data-collected/" + ) + rv["data_collection"] = _resolve_data_collection(rv) # Do not add the event scrubber if data collection is enabled as it can remove data that's diff --git a/sentry_sdk/utils.py b/sentry_sdk/utils.py index 2e20a789b8..310cc0fd23 100644 --- a/sentry_sdk/utils.py +++ b/sentry_sdk/utils.py @@ -10,6 +10,7 @@ import sys import threading import time +import warnings from collections import namedtuple from contextlib import contextmanager from datetime import datetime, timezone @@ -2209,3 +2210,12 @@ def serialize_attribute(val: "AttributeValue") -> "SerializedAttributeValue": @contextmanager def nullcontext() -> "Iterator[None]": yield + + +def deprecation_warning(msg: str) -> None: + """ + Emit a warnings.warn about a deprecation. + + For other types of warnings, use logger.warning(). + """ + warnings.warn(msg, stacklevel=3, category=DeprecationWarning) diff --git a/tests/test_client.py b/tests/test_client.py index ad08932690..64d7b90087 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1485,6 +1485,12 @@ def test_enable_tracing_deprecated(sentry_init, enable_tracing): sentry_init(enable_tracing=enable_tracing) +@pytest.mark.parametrize("send_default_pii", [True, False]) +def test_send_default_pii_deprecated(sentry_init, send_default_pii): + with pytest.warns(DeprecationWarning): + sentry_init(send_default_pii=send_default_pii) + + def test_ignore_spans_warns_without_streaming(sentry_init): with pytest.warns(UserWarning, match=r"`ignore_spans` parameter only works"): sentry_init(ignore_spans=["/health"], trace_lifecycle="static") From 2cee6be6b3dfd719a6bea1bb54868b76ceb089e6 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Thu, 24 Sep 2026 11:16:54 +0200 Subject: [PATCH 2/2] . --- sentry_sdk/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py index 26cebfa741..54c306b4b4 100644 --- a/sentry_sdk/client.py +++ b/sentry_sdk/client.py @@ -351,7 +351,7 @@ def _get_options(*args: "Optional[str]", **kwargs: "Any") -> "Dict[str, Any]": if rv["enable_tracing"] is True and rv["traces_sample_rate"] is None: rv["traces_sample_rate"] = 1.0 - if rv["send_default_pii"] is None: + if rv["send_default_pii"] is not None: deprecation_warning( "The send_default_pii option is deprecated. Use data_collection " "instead. "