8000 fix: Store Flask username (#264) · etherscan-io/sentry-python@edbd748 · GitHub
[go: up one dir, main page]

Skip to content

Commit edbd748

Browse files
authored
fix: Store Flask username (getsentry#264)
1 parent 085f47e commit edbd748

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

sentry_sdk/integrations/flask.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,20 @@ def _add_user_to_event(event):
174174
# - flask_login is not configured
175175
# - no user is logged in
176176
pass
177+
178+
# The following attribute accesses are ineffective for the general
179+
# Flask-Login case, because the User interface of Flask-Login does not
180+
# care about anything but the ID. However, Flask-User (based on
181+
# Flask-Login) documents a few optional extra attributes.
182+
#
183+
# https://github.com/lingthio/Flask-User/blob/a379fa0a281789618c484b459cb41236779b95b1/docs/source/data_models.rst#fixed-data-model-property-names
184+
185+
try:
186+
user_info["email"] = user_info["username"] = user.email
187+
except Exception:
188+
pass
189+
190+
try:
191+
user_info["username"] = user.username
192+
except Exception:
193+
pass

0 commit comments

Comments
 (0)
0