Skip to content

Commit 1433ec2

Browse files
authored
fix(logs): Don't gate user behind send_default_pii (#4453)
ref getsentry/sentry-docs#13974
1 parent 8ca298a commit 1433ec2

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

sentry_sdk/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ def _capture_experimental_log(self, log):
931931
log["trace_id"] = propagation_context.trace_id
932932

933933
# The user, if present, is always set on the isolation scope.
934-
if self.should_send_default_pii() and isolation_scope._user is not None:
934+
if isolation_scope._user is not None:
935935
for log_attribute, user_attribute in (
936936
("user.id", "id"),
937937
("user.name", "username"),

tests/test_logs.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,9 @@ def test_auto_flush_logs_after_100(sentry_init, capture_envelopes):
484484
raise AssertionError("200 logs were never flushed after five seconds")
485485

486486

487-
def test_user_attributes(sentry_init, capture_envelopes):
488-
"""User attributes are sent if send_default_pii is True."""
489-
sentry_init(send_default_pii=True, _experiments={"enable_logs": True})
487+
def test_log_user_attributes(sentry_init, capture_envelopes):
488+
"""User attributes are sent if enable_logs is True."""
489+
sentry_init(_experiments={"enable_logs": True})
490490

491491
sentry_sdk.set_user({"id": "1", "email": "[email protected]", "username": "test"})
492492
envelopes = capture_envelopes()
@@ -507,26 +507,6 @@ def test_user_attributes(sentry_init, capture_envelopes):
507507
}
508508

509509

510-
def test_user_attributes_no_pii(sentry_init, capture_envelopes):
511-
"""Ensure no user attributes are sent if send_default_pii is False."""
512-
sentry_init(_experiments={"enable_logs": True})
513-
514-
sentry_sdk.set_user({"id": "1", "email": "[email protected]", "username": "test"})
515-
envelopes = capture_envelopes()
516-
517-
python_logger = logging.Logger("test-logger")
518-
python_logger.warning("Hello, world!")
519-
520-
get_client().flush()
521-
522-
logs = envelopes_to_logs(envelopes)
523-
524-
(log,) = logs
525-
assert "user.id" not in log["attributes"]
526-
assert "user.email" not in log["attributes"]
527-
assert "user.name" not in log["attributes"]
528-
529-
530510
@minimum_python_37
531511
def test_auto_flush_logs_after_5s(sentry_init, capture_envelopes):
532512
"""

0 commit comments

Comments
 (0)