Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Send PII to Spotlight when no DSN is set #3804

Merged
merged 10 commits into from
Nov 21, 2024
7 changes: 6 additions & 1 deletion sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,12 @@ def should_send_default_pii(self):

Returns whether the client should send default PII (Personally Identifiable Information) data to Sentry.
"""
return self.options.get("send_default_pii", False)
result = self.options.get("send_default_pii", False)

if not self.options["dsn"] and self.spotlight is not None:
result = True

return result

@property
def dsn(self):
Expand Down
1 change: 1 addition & 0 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ class OP:
# This type exists to trick mypy and PyCharm into thinking `init` and `Client`
# take these arguments (even though they take opaque **kwargs)
class ClientConstructor:

def __init__(
self,
dsn=None, # type: Optional[str]
Expand Down
25 changes: 25 additions & 0 deletions tests/test_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,31 @@ def test_should_send_default_pii_false(sentry_init):
assert should_send_default_pii() is False


def test_should_send_default_pii_default_false(sentry_init):
sentry_init()

assert should_send_default_pii() is False


def test_should_send_default_pii_false_with_dsn_and_spotlight(sentry_init):
sentry_init(dsn="http://key@localhost/1", spotlight=True)

assert should_send_default_pii() is False


def test_should_send_default_pii_true_without_dsn_and_spotlight(sentry_init):
sentry_init(spotlight=True)

assert should_send_default_pii() is True


def test_should_send_default_pii_false_without_dsn_and_spotlight(sentry_init):
sentry_init(spotlight=True, send_default_pii=False)

# There is now now way to opt out of sending PII to spotlight
assert should_send_default_pii() is True

antonpirker marked this conversation as resolved.
Show resolved Hide resolved

def test_set_tags():
scope = Scope()
scope.set_tags({"tag1": "value1", "tag2": "value2"})
Expand Down
Loading