diff --git a/zerver/lib/error_notify.py b/zerver/lib/error_notify.py index be313904b5..5334612b98 100644 --- a/zerver/lib/error_notify.py +++ b/zerver/lib/error_notify.py @@ -43,6 +43,7 @@ def email_browser_error(report): 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" + "IP address: %(ip_address)s\n" "User agent: %(user_agent)s\n" "href: %(href)s\n" "Server path: %(server_path)s\n" diff --git a/zerver/views/report.py b/zerver/views/report.py index 009576d7ff..56b4586795 100644 --- a/zerver/views/report.py +++ b/zerver/views/report.py @@ -101,10 +101,16 @@ def json_report_error(request, user_profile, message=REQ(), stacktrace=REQ(), except Exception: 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( type = "browser", report = dict( host = request.get_host().split(":")[0], + ip_address = remote_ip, user_email = user_profile.email, user_full_name = user_profile.full_name, user_visible = ui_message,