From 37aafc78bbfe001f8a965267f961fcffd724c9c2 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Thu, 1 Oct 2026 10:37:17 -0400 Subject: [PATCH] ref(django)!: Drop `send_default_pii` support in user info collection Gate user info on `data_collection["user_info"]` only, removing the `send_default_pii` fallback from the WSGI and ASGI request event processors and the post-response user lookup. Refs PY-2798 Refs #7566 --- sentry_sdk/integrations/django/__init__.py | 14 +++----------- sentry_sdk/integrations/django/asgi.py | 8 +------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/sentry_sdk/integrations/django/__init__.py b/sentry_sdk/integrations/django/__init__.py index f7a22a2fe8..d336c2ea2c 100644 --- a/sentry_sdk/integrations/django/__init__.py +++ b/sentry_sdk/integrations/django/__init__.py @@ -18,7 +18,7 @@ ) from sentry_sdk.integrations.logging import ignore_logger_for_events from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware -from sentry_sdk.scope import add_global_event_processor, should_send_default_pii +from sentry_sdk.scope import add_global_event_processor from sentry_sdk.serializer import add_global_repr_processor, add_repr_sequence_type from sentry_sdk.traces import SegmentNameSource from sentry_sdk.tracing_utils import ( @@ -31,7 +31,6 @@ capture_internal_exceptions, ensure_integration_enabled, event_from_exception, - has_data_collection_enabled, walk_exception_chain, ) @@ -512,10 +511,7 @@ def _after_get_response(request: "WSGIRequest") -> None: scope = sentry_sdk.get_current_scope() _attempt_resolve_again(request, scope) - if has_data_collection_enabled(client.options): - if client.options["data_collection"]["user_info"]: - _get_user_from_request_and_set_on_scope(request) - elif should_send_default_pii(): + if client.options["data_collection"]["user_info"]: _get_user_from_request_and_set_on_scope(request) @@ -563,11 +559,7 @@ def wsgi_request_event_processor(event: "Event", hint: "dict[str, Any]") -> "Eve DjangoRequestExtractor(request).extract_into_event(event) client_options = sentry_sdk.get_client().options - if has_data_collection_enabled(client_options): - if client_options["data_collection"]["user_info"]: - with capture_internal_exceptions(): - _set_user_info(request, event) - elif should_send_default_pii(): + if client_options["data_collection"]["user_info"]: with capture_internal_exceptions(): _set_user_info(request, event) diff --git a/sentry_sdk/integrations/django/asgi.py b/sentry_sdk/integrations/django/asgi.py index d237c4d946..0bea1355a8 100644 --- a/sentry_sdk/integrations/django/asgi.py +++ b/sentry_sdk/integrations/django/asgi.py @@ -16,12 +16,10 @@ import sentry_sdk from sentry_sdk.consts import OP from sentry_sdk.integrations.asgi import SentryAsgiMiddleware -from sentry_sdk.scope import should_send_default_pii from sentry_sdk.traces import Span from sentry_sdk.utils import ( capture_internal_exceptions, ensure_integration_enabled, - has_data_collection_enabled, ) if TYPE_CHECKING: @@ -71,11 +69,7 @@ def asgi_request_event_processor(event: "Event", hint: "dict[str, Any]") -> "Eve DjangoRequestExtractor(request).extract_into_event(event) client_options = sentry_sdk.get_client().options - if has_data_collection_enabled(client_options): - if client_options["data_collection"]["user_info"]: - with capture_internal_exceptions(): - _set_user_info(request, event) - elif should_send_default_pii(): + if client_options["data_collection"]["user_info"]: with capture_internal_exceptions(): _set_user_info(request, event)