From 0a47317ca1c9365913968d3046c35315a68f0553 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Mon, 18 Mar 2024 15:06:01 +0100 Subject: [PATCH] Moved should_send_default_pii into client (#2840) Moved functionality from `_should_send_default_pii()` in `hub` into `should_send_default_pii` on the `Client`. --- sentry_sdk/client.py | 9 +++++++++ sentry_sdk/hub.py | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py index 2bb00de11f..dc31e5ce1b 100644 --- a/sentry_sdk/client.py +++ b/sentry_sdk/client.py @@ -403,6 +403,15 @@ def is_active(self): """ return True + def should_send_default_pii(self): + # type: () -> bool + """ + .. versionadded:: 2.0.0 + + Returns whether the client should send default PII (Personally Identifiable Information) data to Sentry. + """ + return self.options.get("send_default_pii", False) + @property def dsn(self): # type: () -> Optional[str] diff --git a/sentry_sdk/hub.py b/sentry_sdk/hub.py index 045d2969fd..2af3091f5d 100644 --- a/sentry_sdk/hub.py +++ b/sentry_sdk/hub.py @@ -60,10 +60,12 @@ def overload(x): def _should_send_default_pii(): # type: () -> bool + # TODO: Migrate existing code to client.should_send_default_pii() and remove this function. + # New code should not use this function! client = Hub.current.client if not client: return False - return client.options["send_default_pii"] + return client.should_send_default_pii() class _InitGuard: