From 95aee366c80b7315651e5c8a94a57a20da6c4ae5 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 11 Aug 2016 12:44:09 -0700 Subject: [PATCH] Enable local browser error reporting if ZILENCER_ENABLED. --- zerver/worker/queue_processors.py | 8 +++++--- zilencer/views.py | 8 ++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py index ff4036420f..f5e6309ed3 100644 --- a/zerver/worker/queue_processors.py +++ b/zerver/worker/queue_processors.py @@ -275,9 +275,11 @@ class ErrorReporter(QueueProcessingWorker): def consume(self, event): # type: (Mapping[str, Any]) -> None - if not settings.DEPLOYMENT_ROLE_KEY: - return - self.staging_client.forward_error(event['type'], event['report']) + if settings.DEPLOYMENT_ROLE_KEY: + self.staging_client.forward_error(event['type'], event['report']) + elif settings.ZILENCER_ENABLED: + from zilencer.views import do_report_error + do_report_error(settings.DEPLOYMENT_ROLE_NAME, event['type'], event['report']) @assign_queue('slow_queries') class SlowQueryWorker(QueueProcessingWorker): diff --git a/zilencer/views.py b/zilencer/views.py index bc32e2cd64..c595718179 100644 --- a/zilencer/views.py +++ b/zilencer/views.py @@ -84,8 +84,12 @@ def submit_feedback(request, deployment, message=REQ(validator=check_dict([]))): @has_request_variables def report_error(request, deployment, type=REQ(), report=REQ(validator=check_dict([]))): - # type: (HttpRequest, Deployment, str, Dict[str, Any]) -> HttpResponse - report['deployment'] = deployment.name + # type: (HttpRequest, Deployment, text_type, Dict[str, Any]) -> HttpResponse + return do_report_error(deployment.name, type, report) + +def do_report_error(deployment_name, type, report): + # type: (text_type, text_type, Dict[str, Any]) -> HttpResponse + report['deployment'] = deployment_name if type == 'browser': notify_browser_error(report) elif type == 'server':