2

How do you configure the user data sent when using send_default_pii=True with flask-login for the Sentry Unified Python SDK?

The docs say:

If you use flask-login and have set send_default_pii=True in your call to init, user data (current user id, email address, username) is attached to the event.

However, doing so only passes along the id and email. How can I configure more attributes to be sent?

In the previous version of the SDK (raven-python), this could be configured with SENTRY_USER_ATTRS

Markus Unterwaditzer
  • 7,992
  • 32
  • 60
craigmichaelmartin
  • 6,091
  • 1
  • 21
  • 25

1 Answers1

3

Use before_send:

def before_send(event, hint):
    try:
        user = flask_login.current_user
        user_info = event.setdefault("user", {})
        user_info["myattribute"] = user.myattribute
    except Exception:
        pass
    return event


init(..., before_send=before_send)

More info: https://docs.sentry.io/learn/filtering/?platform=python#before-send

Markus Unterwaditzer
  • 7,992
  • 32
  • 60