|
4 | 4 | import uuid |
5 | 5 | from typing import Any |
6 | 6 |
|
7 | | -# import requests |
8 | | -# from rest_framework.exceptions import ParseError |
| 7 | +import requests |
| 8 | +from rest_framework.exceptions import ParseError |
9 | 9 | from rest_framework.request import Request |
10 | 10 | from rest_framework.response import Response |
11 | 11 |
|
12 | | -from sentry import features |
| 12 | +from sentry import features, options |
13 | 13 | from sentry.api.api_owners import ApiOwner |
14 | 14 | from sentry.api.api_publish_status import ApiPublishStatus |
15 | 15 | from sentry.api.base import region_silo_endpoint |
@@ -37,6 +37,13 @@ def get(self, request: Request, project: Project, replay_id: str) -> Response: |
37 | 37 | ): |
38 | 38 | return Response(status=404) |
39 | 39 |
|
| 40 | + if not features.has( |
| 41 | + "organizations:session-replay-accessibility-issues", |
| 42 | + project.organization, |
| 43 | + actor=request.user, |
| 44 | + ): |
| 45 | + return Response(status=404) |
| 46 | + |
40 | 47 | try: |
41 | 48 | replay_id = str(uuid.UUID(replay_id)) |
42 | 49 | except ValueError: |
@@ -78,53 +85,11 @@ def get_result(self, limit, cursor=None): |
78 | 85 |
|
79 | 86 |
|
80 | 87 | def request_accessibility_issues(filenames: list[str]) -> Any: |
81 | | - # TODO: Remove this once the service is ready. |
82 | | - return { |
83 | | - "meta": {"total": 1}, |
84 | | - "data": [ |
85 | | - { |
86 | | - "elements": [ |
87 | | - { |
88 | | - "alternatives": [ |
89 | | - { |
90 | | - "id": "button-has-visible-text", |
91 | | - "message": "Element does not have inner text that is visible to screen readers", |
92 | | - }, |
93 | | - { |
94 | | - "id": "aria-label", |
95 | | - "message": "aria-label attribute does not exist or is empty", |
96 | | - }, |
97 | | - { |
98 | | - "id": "aria-labelledby", |
99 | | - "message": "aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty", |
100 | | - }, |
101 | | - { |
102 | | - "id": "non-empty-title", |
103 | | - "message": "Element has no title attribute", |
104 | | - }, |
105 | | - { |
106 | | - "id": "presentational-role", |
107 | | - "message": 'Element\'s default semantics were not overridden with role="none" or role="presentation"', |
108 | | - }, |
109 | | - ], |
110 | | - "element": '<button class="svelte-19ke1iv">', |
111 | | - "target": ["button:nth-child(1)"], |
112 | | - } |
113 | | - ], |
114 | | - "help_url": "https://dequeuniversity.com/rules/axe/4.8/button-name?application=playwright", |
115 | | - "help": "Buttons must have discernible text", |
116 | | - "id": "button-name", |
117 | | - "impact": "critical", |
118 | | - "timestamp": 1695967678108, |
119 | | - } |
120 | | - ], |
121 | | - } |
122 | | - # TODO: When the service is deploy this should be the primary path. |
123 | | - # try: |
124 | | - # return requests.post( |
125 | | - # "/api/0/analyze/accessibility", |
126 | | - # json={"data": {"filenames": filenames}}, |
127 | | - # ).json() |
128 | | - # except Exception: |
129 | | - # logger.exception("replay accessibility analysis failed") |
130 | | - # raise ParseError("Could not analyze accessibility issues at this time.") |
| 88 | + try: |
| 89 | + return requests.post( |
| 90 | + f"{options.get('replay.analyzer_service_url')}/api/0/analyze/accessibility", |
| 91 | + json={"data": {"filenames": filenames}}, |
| 92 | + ).json() |
| 93 | + except Exception: |
| 94 | + logger.exception("replay accessibility analysis failed") |
| 95 | + raise ParseError("Could not analyze accessibility issues at this time.") |
0 commit comments