error_notify: Add IP address to browser error reports.

This should make debugging a bit more convenient when we want to know
which of a user's clients was involved.
This commit is contained in:
Tim Abbott 2017-10-04 10:27:58 -07:00
parent 64795adef3
commit ce7ab0474d
2 changed files with 7 additions and 0 deletions

View File

@ -43,6 +43,7 @@ def email_browser_error(report):
body = ("User: %(user_full_name)s <%(user_email)s> on %(deployment)s\n\n" body = ("User: %(user_full_name)s <%(user_email)s> on %(deployment)s\n\n"
"Message:\n%(message)s\n\nStacktrace:\n%(stacktrace)s\n\n" "Message:\n%(message)s\n\nStacktrace:\n%(stacktrace)s\n\n"
"IP address: %(ip_address)s\n"
"User agent: %(user_agent)s\n" "User agent: %(user_agent)s\n"
"href: %(href)s\n" "href: %(href)s\n"
"Server path: %(server_path)s\n" "Server path: %(server_path)s\n"

View File

@ -101,10 +101,16 @@ def json_report_error(request, user_profile, message=REQ(), stacktrace=REQ(),
except Exception: except Exception:
version = None version = None
# Get the IP address of the request
remote_ip = request.META.get('HTTP_X_REAL_IP')
if remote_ip is None:
remote_ip = request.META['REMOTE_ADDR']
queue_json_publish('error_reports', dict( queue_json_publish('error_reports', dict(
type = "browser", type = "browser",
report = dict( report = dict(
host = request.get_host().split(":")[0], host = request.get_host().split(":")[0],
ip_address = remote_ip,
user_email = user_profile.email, user_email = user_profile.email,
user_full_name = user_profile.full_name, user_full_name = user_profile.full_name,
user_visible = ui_message, user_visible = ui_message,