mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 02:17:19 +00:00
report: Provide user information for browser-side errors.
b4dd118aa1 changed how the `user_info_str` parsed information out of
the events it received -- but only changed the server errors, not the
browser errors, though both use the same codepath. As a result, all
browser errors since then have been incorrectly marked as being for
anonymous users.
Build and pass in the expected `user` dict into the event.
This commit is contained in:
committed by
Tim Abbott
parent
ce5d13f9b2
commit
90b1e0b8b9
@@ -81,9 +81,8 @@ Deployed version: {version}
|
|||||||
|
|
||||||
|
|
||||||
def zulip_browser_error(report: Dict[str, Any], error_bot_email: str) -> None:
|
def zulip_browser_error(report: Dict[str, Any], error_bot_email: str) -> None:
|
||||||
email_subject = "JS error: {user_email}".format(**report)
|
|
||||||
|
|
||||||
user_info = user_info_str(report)
|
user_info = user_info_str(report)
|
||||||
|
email_subject = f"JS error: {user_info}"
|
||||||
|
|
||||||
body = f"User: {user_info}\n"
|
body = f"User: {user_info}\n"
|
||||||
body += "Message: {message}\n".format(**report)
|
body += "Message: {message}\n".format(**report)
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ class TestReport(ZulipTestCase):
|
|||||||
self.assertEqual(report[k], params[k])
|
self.assertEqual(report[k], params[k])
|
||||||
|
|
||||||
self.assertEqual(report["more_info"], dict(foo="bar", draft_content="'**xxxxx**'"))
|
self.assertEqual(report["more_info"], dict(foo="bar", draft_content="'**xxxxx**'"))
|
||||||
self.assertEqual(report["user_email"], user.delivery_email)
|
self.assertEqual(report["user"]["user_email"], user.delivery_email)
|
||||||
|
|
||||||
# Test with no more_info
|
# Test with no more_info
|
||||||
del params["more_info"]
|
del params["more_info"]
|
||||||
|
|||||||
@@ -157,11 +157,13 @@ def report_error(
|
|||||||
more_info["draft_content"] = privacy_clean_markdown(more_info["draft_content"])
|
more_info["draft_content"] = privacy_clean_markdown(more_info["draft_content"])
|
||||||
|
|
||||||
if maybe_user_profile.is_authenticated:
|
if maybe_user_profile.is_authenticated:
|
||||||
email = maybe_user_profile.delivery_email
|
user = {
|
||||||
full_name = maybe_user_profile.full_name
|
"user_email": maybe_user_profile.delivery_email,
|
||||||
|
"user_full_name": maybe_user_profile.full_name,
|
||||||
|
"user_role": maybe_user_profile.get_role_name(),
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
email = "unauthenticated@example.com"
|
user = None
|
||||||
full_name = "Anonymous User"
|
|
||||||
|
|
||||||
queue_json_publish(
|
queue_json_publish(
|
||||||
"error_reports",
|
"error_reports",
|
||||||
@@ -170,8 +172,7 @@ def report_error(
|
|||||||
report=dict(
|
report=dict(
|
||||||
host=SplitResult("", request.get_host(), "", "", "").hostname,
|
host=SplitResult("", request.get_host(), "", "", "").hostname,
|
||||||
ip_address=remote_ip,
|
ip_address=remote_ip,
|
||||||
user_email=email,
|
user=user,
|
||||||
user_full_name=full_name,
|
|
||||||
user_visible=ui_message,
|
user_visible=ui_message,
|
||||||
server_path=settings.DEPLOY_ROOT,
|
server_path=settings.DEPLOY_ROOT,
|
||||||
version=version,
|
version=version,
|
||||||
|
|||||||
Reference in New Issue
Block a user