diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py index 9f54088438..426734e385 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 not 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 a6420d84b2..4586ac5d5e 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 @@ -2253,3 +2254,12 @@ def _is_localhost( @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 7d42fc4446..7dc3922285 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_transaction_profiling_warns(sentry_init): with pytest.warns(DeprecationWarning, match="Transaction-based profiling"): sentry_init(profiles_sample_rate=1.0)