|
@@ -1,9 +1,11 @@
|
|
|
|
+from __future__ import annotations
|
|
|
|
+
|
|
from io import BytesIO
|
|
from io import BytesIO
|
|
|
|
|
|
import sentry_sdk
|
|
import sentry_sdk
|
|
from django.http import StreamingHttpResponse
|
|
from django.http import StreamingHttpResponse
|
|
|
|
+from django.http.response import HttpResponseBase
|
|
from rest_framework.request import Request
|
|
from rest_framework.request import Request
|
|
-from rest_framework.response import Response
|
|
|
|
|
|
|
|
from sentry import features
|
|
from sentry import features
|
|
from sentry.api.base import region_silo_endpoint
|
|
from sentry.api.base import region_silo_endpoint
|
|
@@ -14,7 +16,7 @@ from sentry.replays.usecases.reader import download_segment, fetch_segment_metad
|
|
|
|
|
|
@region_silo_endpoint
|
|
@region_silo_endpoint
|
|
class ProjectReplayRecordingSegmentDetailsEndpoint(ProjectEndpoint):
|
|
class ProjectReplayRecordingSegmentDetailsEndpoint(ProjectEndpoint):
|
|
- def get(self, request: Request, project, replay_id, segment_id) -> Response:
|
|
|
|
|
|
+ def get(self, request: Request, project, replay_id, segment_id) -> HttpResponseBase:
|
|
if not features.has(
|
|
if not features.has(
|
|
"organizations:session-replay", project.organization, actor=request.user
|
|
"organizations:session-replay", project.organization, actor=request.user
|
|
):
|
|
):
|
|
@@ -33,7 +35,9 @@ class ProjectReplayRecordingSegmentDetailsEndpoint(ProjectEndpoint):
|
|
"replayId": segment.replay_id,
|
|
"replayId": segment.replay_id,
|
|
"segmentId": segment.segment_id,
|
|
"segmentId": segment.segment_id,
|
|
"projectId": str(segment.project_id),
|
|
"projectId": str(segment.project_id),
|
|
- "dateAdded": segment.date_added.replace(microsecond=0).isoformat(),
|
|
|
|
|
|
+ "dateAdded": segment.date_added.replace(microsecond=0).isoformat()
|
|
|
|
+ if segment.date_added
|
|
|
|
+ else None,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
)
|
|
)
|
|
@@ -46,6 +50,9 @@ class ProjectReplayRecordingSegmentDetailsEndpoint(ProjectEndpoint):
|
|
segment_bytes = download_segment(
|
|
segment_bytes = download_segment(
|
|
segment, transaction=transaction, current_hub=sentry_sdk.Hub.current
|
|
segment, transaction=transaction, current_hub=sentry_sdk.Hub.current
|
|
)
|
|
)
|
|
|
|
+ if segment_bytes is None:
|
|
|
|
+ segment_bytes = b"[]"
|
|
|
|
+
|
|
segment_reader = BytesIO(segment_bytes)
|
|
segment_reader = BytesIO(segment_bytes)
|
|
|
|
|
|
response = StreamingHttpResponse(
|
|
response = StreamingHttpResponse(
|