8000 fix: Dont override custom user_info (#96) · etherscan-io/sentry-python@a6cb2d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit a6cb2d4

Browse files
authored
fix: Dont override custom user_info (getsentry#96)
1 parent 4593726 commit a6cb2d4

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

sentry_sdk/integrations/_wsgi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ def event_processor(event, hint):
216216

217217
if _should_send_default_pii():
218218
user_info = event.setdefault("user", {})
219-
user_info["ip_address"] = get_client_ip(environ)
219+
if "ip_address" not in user_info:
220+
user_info["ip_address"] = get_client_ip(environ)
220221

221222
if "query_string" not in request_info:
222223
request_info["query_string"] = environ.get("QUERY_STRING")

sentry_sdk/integrations/django.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,17 @@ def _set_user_info(request, event):
140140
if user is None or not is_authenticated(user):
141141
return
142142

143-
try:
144-
user_info["email"] = user.email
145-
except Exception:
146-
pass
143+
if "email" not in user_info:
144+
try:
145+
user_info["email"] = user.email
146+
except Exception:
147+
pass
147148

148-
try:
149-
user_info["username"] = user.get_username()
150-
except Exception:
151-
pass
149+
if "username" not in user_info:
150+
try:
151+
user_info["username"] = user.get_username()
152+
except Exception:
153+
pass
152154

153155

154156
class _FormatConverter(object):

sentry_sdk/integrations/flask.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def _add_user_to_event(event):
135135

136136
user_info = event.setdefault("user", {})
137137

138-
if user_info.get("id", None) is None:
138+
if "id" not in user_info:
139139
try:
140140
user_info["id"] = user.get_id()
141141
# TODO: more configurable user attrs here

0 commit comments

Comments
 (0)
0