Browse Source

fix(replays): update archive row object to account for new fields (#53560)

Fixes #53269
Michelle Zhang 1 year ago
parent
commit
77554bd995

+ 1 - 0
.gitignore

@@ -58,3 +58,4 @@ import-graph.txt
 import-graph.dot
 import-graph.dot
 bin/rrweb-output
 bin/rrweb-output
 model-manifest.json
 model-manifest.json
+api-docs/dump.rdb

BIN
api-docs/dump.rdb


+ 14 - 1
src/sentry/replays/post_process.py

@@ -4,6 +4,8 @@ import collections
 from itertools import zip_longest
 from itertools import zip_longest
 from typing import Any, Generator, Iterable, Iterator, MutableMapping
 from typing import Any, Generator, Iterable, Iterator, MutableMapping
 
 
+from sentry.replays.validators import VALID_FIELD_SET
+
 
 
 def process_raw_response(response: list[dict[str, Any]], fields: list[str]) -> list[dict[str, Any]]:
 def process_raw_response(response: list[dict[str, Any]], fields: list[str]) -> list[dict[str, Any]]:
     """Process the response further into the expected output."""
     """Process the response further into the expected output."""
@@ -116,7 +118,7 @@ def dict_unique_list(items: Iterable[tuple[str, str]]) -> dict[str, list[str]]:
 
 
 
 
 def _archived_row(replay_id: str, project_id: int) -> dict[str, Any]:
 def _archived_row(replay_id: str, project_id: int) -> dict[str, Any]:
-    return {
+    archived_replay_response = {
         "id": _strip_dashes(replay_id),
         "id": _strip_dashes(replay_id),
         "project_id": str(project_id),
         "project_id": str(project_id),
         "trace_ids": [],
         "trace_ids": [],
@@ -137,7 +139,18 @@ def _archived_row(replay_id: str, project_id: int) -> dict[str, Any]:
         "finished_at": None,
         "finished_at": None,
         "started_at": None,
         "started_at": None,
         "is_archived": True,
         "is_archived": True,
+        "count_segments": None,
+        "count_urls": None,
+        "dist": None,
+        "platform": None,
+        "releases": None,
+        "clicks": None,
     }
     }
+    for field in VALID_FIELD_SET:
+        if field not in archived_replay_response:
+            archived_replay_response[field] = None
+
+    return archived_replay_response
 
 
 
 
 CLICK_FIELD_MAP = {
 CLICK_FIELD_MAP = {

+ 6 - 0
tests/sentry/replays/test_organization_replay_index.py

@@ -912,6 +912,12 @@ class OrganizationReplayIndexTest(APITestCase, ReplaysSnubaTestCase):
                     "finished_at": None,
                     "finished_at": None,
                     "duration": None,
                     "duration": None,
                     "is_archived": True,
                     "is_archived": True,
+                    "releases": None,
+                    "platform": None,
+                    "dist": None,
+                    "count_segments": None,
+                    "count_urls": None,
+                    "clicks": None,
                 }
                 }
             ]
             ]