hydrateFrames.tsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import type {
  2. OptionFrame,
  3. RawBreadcrumbFrame,
  4. RawSpanFrame,
  5. RecordingFrame,
  6. } from 'sentry/utils/replays/types';
  7. import {
  8. isBreadcrumbFrameEvent,
  9. isOptionFrameEvent,
  10. isRecordingFrame,
  11. isSpanFrameEvent,
  12. } from 'sentry/utils/replays/types';
  13. export default function hydrateFrames(attachments: unknown[]) {
  14. const rrwebFrames: RecordingFrame[] = [];
  15. const breadcrumbFrames: RawBreadcrumbFrame[] = [];
  16. const spanFrames: RawSpanFrame[] = [];
  17. let optionFrame = undefined as OptionFrame | undefined;
  18. attachments.forEach(attachment => {
  19. if (!attachment) {
  20. return;
  21. }
  22. if (isBreadcrumbFrameEvent(attachment)) {
  23. breadcrumbFrames.push(attachment.data.payload);
  24. } else if (isSpanFrameEvent(attachment)) {
  25. spanFrames.push(attachment.data.payload);
  26. } else if (isOptionFrameEvent(attachment)) {
  27. optionFrame = attachment.data.payload;
  28. } else if (isRecordingFrame(attachment)) {
  29. rrwebFrames.push(attachment);
  30. }
  31. });
  32. return {
  33. breadcrumbFrames,
  34. optionFrame,
  35. rrwebFrames,
  36. spanFrames,
  37. };
  38. }