diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py index 628db1a6d8..9d416780f9 100644 --- a/zerver/tests/test_decorators.py +++ b/zerver/tests/test_decorators.py @@ -1619,7 +1619,6 @@ class TestHumanUsersOnlyDecorator(ZulipTestCase): "/api/v1/users/me/hotspots", "/api/v1/users/me/presence", "/api/v1/users/me/tutorial_status", - "/api/v1/report/send_times", ] for endpoint in post_endpoints: result = self.api_post(default_bot, endpoint) diff --git a/zerver/tests/test_report.py b/zerver/tests/test_report.py index 12bd92ccb6..6db4b1d601 100644 --- a/zerver/tests/test_report.py +++ b/zerver/tests/test_report.py @@ -2,62 +2,6 @@ from zerver.lib.test_classes import ZulipTestCase class TestReport(ZulipTestCase): - def test_send_time(self) -> None: - self.login("hamlet") - - params = dict( - time=5, - received=6, - displayed=7, - locally_echoed="true", - rendered_content_disparity="true", - ) - - result = self.client_post("/json/report/send_times", params) - self.assert_json_success(result) - - def test_narrow_time(self) -> None: - self.login("hamlet") - - params = dict( - initial_core=5, - initial_free=6, - network=7, - ) - - result = self.client_post("/json/report/narrow_times", params) - self.assert_json_success(result) - - def test_anonymous_user_narrow_time(self) -> None: - params = dict( - initial_core=5, - initial_free=6, - network=7, - ) - - result = self.client_post("/json/report/narrow_times", params) - self.assert_json_success(result) - - def test_unnarrow_time(self) -> None: - self.login("hamlet") - - params = dict( - initial_core=5, - initial_free=6, - ) - - result = self.client_post("/json/report/unnarrow_times", params) - self.assert_json_success(result) - - def test_anonymous_user_unnarrow_time(self) -> None: - params = dict( - initial_core=5, - initial_free=6, - ) - - result = self.client_post("/json/report/unnarrow_times", params) - self.assert_json_success(result) - def test_report_csp_violations(self) -> None: fixture_data = self.fixture_data("csp_report.json") with self.assertLogs(level="WARNING") as warn_logs: diff --git a/zerver/views/report.py b/zerver/views/report.py index 38b358a2d1..4f7df6d89b 100644 --- a/zerver/views/report.py +++ b/zerver/views/report.py @@ -1,77 +1,17 @@ # System documented in https://zulip.readthedocs.io/en/latest/subsystems/logging.html import logging -from typing import Union -from django.contrib.auth.models import AnonymousUser from django.http import HttpRequest, HttpResponse from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST -from zerver.decorator import human_users_only -from zerver.lib.request import REQ, RequestNotes, has_request_variables +from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_success from zerver.lib.validator import ( WildValue, - check_bool, check_string, - to_non_negative_int, to_wild_value, ) -from zerver.models import UserProfile - - -@human_users_only -@has_request_variables -def report_send_times( - request: HttpRequest, - user_profile: UserProfile, - time: int = REQ(converter=to_non_negative_int), - received: int = REQ(converter=to_non_negative_int, default=-1), - displayed: int = REQ(converter=to_non_negative_int, default=-1), - locally_echoed: bool = REQ(json_validator=check_bool, default=False), - rendered_content_disparity: bool = REQ(json_validator=check_bool, default=False), -) -> HttpResponse: - received_str = "(unknown)" - if received > 0: - received_str = str(received) - displayed_str = "(unknown)" - if displayed > 0: - displayed_str = str(displayed) - - log_data = RequestNotes.get_notes(request).log_data - assert log_data is not None - log_data[ - "extra" - ] = f"[{time}ms/{received_str}ms/{displayed_str}ms/echo:{locally_echoed}/diff:{rendered_content_disparity}]" - - return json_success(request) - - -@has_request_variables -def report_narrow_times( - request: HttpRequest, - user_profile: Union[UserProfile, AnonymousUser], - initial_core: int = REQ(converter=to_non_negative_int), - initial_free: int = REQ(converter=to_non_negative_int), - network: int = REQ(converter=to_non_negative_int), -) -> HttpResponse: - log_data = RequestNotes.get_notes(request).log_data - assert log_data is not None - log_data["extra"] = f"[{initial_core}ms/{initial_free}ms/{network}ms]" - return json_success(request) - - -@has_request_variables -def report_unnarrow_times( - request: HttpRequest, - user_profile: Union[UserProfile, AnonymousUser], - initial_core: int = REQ(converter=to_non_negative_int), - initial_free: int = REQ(converter=to_non_negative_int), -) -> HttpResponse: - log_data = RequestNotes.get_notes(request).log_data - assert log_data is not None - log_data["extra"] = f"[{initial_core}ms/{initial_free}ms]" - return json_success(request) @csrf_exempt diff --git a/zproject/urls.py b/zproject/urls.py index b6fc3fa192..c77924e062 100644 --- a/zproject/urls.py +++ b/zproject/urls.py @@ -132,9 +132,6 @@ from zerver.views.registration import ( ) from zerver.views.report import ( report_csp_violations, - report_narrow_times, - report_send_times, - report_unnarrow_times, ) from zerver.views.scheduled_messages import ( delete_scheduled_messages, @@ -493,20 +490,6 @@ v1_api_and_json_patterns = [ rest_path("register", POST=(events_register_backend, {"allow_anonymous_user_web"})), # events -> zerver.tornado.views rest_path("events", GET=get_events, DELETE=cleanup_event_queue), - # report -> zerver.views.report - # - # These endpoints are for internal error/performance reporting - # from the browser to the web app, and we don't expect to ever - # include in our API documentation. - rest_path("report/send_times", POST=(report_send_times, {"intentionally_undocumented"})), - rest_path( - "report/narrow_times", - POST=(report_narrow_times, {"allow_anonymous_user_web", "intentionally_undocumented"}), - ), - rest_path( - "report/unnarrow_times", - POST=(report_unnarrow_times, {"allow_anonymous_user_web", "intentionally_undocumented"}), - ), # Used to generate a Zoom video call URL rest_path("calls/zoom/create", POST=make_zoom_video_call), # Used to generate a BigBlueButton video call URL