Browse Source

feat(replays): Add rate-limits to accessibility issues (#60708)

Colton Allen 1 year ago
parent
commit
9c4a424285
1 changed files with 12 additions and 0 deletions
  1. 12 0
      src/sentry/replays/endpoints/project_replay_accessibility_issues.py

+ 12 - 0
src/sentry/replays/endpoints/project_replay_accessibility_issues.py

@@ -18,6 +18,7 @@ from sentry.api.bases.project import ProjectEndpoint
 from sentry.models.project import Project
 from sentry.replays.lib.storage import make_filename
 from sentry.replays.usecases.reader import fetch_direct_storage_segments_meta
+from sentry.types.ratelimit import RateLimit, RateLimitCategory
 from sentry.utils.cursors import Cursor, CursorResult
 
 REFERRER = "replays.query.query_replay_clicks_dataset"
@@ -27,11 +28,22 @@ logger = logging.getLogger()
 
 @region_silo_endpoint
 class ProjectReplayAccessibilityIssuesEndpoint(ProjectEndpoint):
+    # Internal API maintenance decoration.
     owner = ApiOwner.REPLAY
     publish_status = {
         "GET": ApiPublishStatus.EXPERIMENTAL,
     }
 
+    # Rate Limits
+    enforce_rate_limit = True
+    rate_limits = {
+        "GET": {
+            RateLimitCategory.IP: RateLimit(5, 1),
+            RateLimitCategory.USER: RateLimit(5, 1),
+            RateLimitCategory.ORGANIZATION: RateLimit(5, 1),
+        }
+    }
+
     def get(self, request: Request, project: Project, replay_id: str) -> Response:
         if not features.has(
             "organizations:session-replay", project.organization, actor=request.user