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: