0

BugSnag's documentation suggests this for custom fields:

def callback(notification):

    # if you return False, the notification will not be sent to
    # Bugsnag. (see ignore_classes for simple cases)
    if isinstance(notification.exception, KeyboardInterrupt):
        return False

    # You can set properties of the notification and
    # add your own custom meta-data.
    notification.user = {"id": current_user.id,
      "name": current_user.name,
      "email": current_user.email}
    notification.add_tab("account", {"paying": current_user.acccount.is_paying()})

# Call `callback` before every notification
bugsnag.before_notify(callback)

my application is JWT token based internl-api application server. Meaning, I don't have a current_user or any users "logged in" for that matter. Is there any way to get to the user of the current request? in views it's available as request.user after the JWT middleware parses out the token but how do I apply it here into this callback? I don't have access to the request object? notification.request doesn't exist.

Vikash Chauhan
  • 792
  • 2
  • 9
  • 18
JasonGenX
  • 4,952
  • 27
  • 106
  • 198

1 Answers1

0

So, if my POST was a flat list of keys and values, this is how I got the email value.

d = dict(notification.request_config.django_request.POST)
print(d['email'][0])
JasonGenX
  • 4,952
  • 27
  • 106
  • 198