replayContent.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import styled from '@emotion/styled';
  2. import DateTime from 'sentry/components/dateTime';
  3. import Duration from 'sentry/components/duration';
  4. import Placeholder from 'sentry/components/placeholder';
  5. import {Provider as ReplayContextProvider} from 'sentry/components/replays/replayContext';
  6. import ReplayView from 'sentry/components/replays/replayView';
  7. import {t} from 'sentry/locale';
  8. import space from 'sentry/styles/space';
  9. import useFullscreen from 'sentry/utils/replays/hooks/useFullscreen';
  10. import useReplayData from 'sentry/utils/replays/hooks/useReplayData';
  11. import FluidHeight from 'sentry/views/replays/detail/layout/fluidHeight';
  12. type Props = {
  13. orgSlug: string;
  14. replaySlug: string;
  15. };
  16. function ReplayContent({orgSlug, replaySlug}: Props) {
  17. const {fetching, replay, fetchError} = useReplayData({
  18. orgSlug,
  19. replaySlug,
  20. });
  21. const {ref: fullscreenRef, toggle: toggleFullscreen} = useFullscreen();
  22. const replayRecord = replay?.getReplay();
  23. const replayEvent = replay?.getEvent();
  24. if (fetchError) {
  25. throw new Error('Failed to load Replay');
  26. }
  27. if (fetching || !replayRecord || !replayEvent) {
  28. return <StyledPlaceholder height="400px" width="100%" />;
  29. }
  30. return (
  31. <table className="table key-value">
  32. <tbody>
  33. <tr key="replay">
  34. <td className="key">{t('Replay')}</td>
  35. <td className="value">
  36. <ReplayContextProvider replay={replay} initialTimeOffset={0}>
  37. <PlayerContainer ref={fullscreenRef}>
  38. <ReplayView toggleFullscreen={toggleFullscreen} showAddressBar={false} />
  39. </PlayerContainer>
  40. </ReplayContextProvider>
  41. </td>
  42. </tr>
  43. <tr key="id">
  44. <td className="key">{t('Id')}</td>
  45. <td className="value">
  46. <pre className="val-string">{replayRecord.replayId}</pre>
  47. </td>
  48. </tr>
  49. <tr key="url">
  50. <td className="key">{t('URL')}</td>
  51. <td className="value">
  52. <pre className="val-string">{replayEvent.culprit}</pre>
  53. </td>
  54. </tr>
  55. <tr key="timestamp">
  56. <td className="key">{t('Timestamp')}</td>
  57. <td className="value">
  58. <pre className="val-string">
  59. <DateTime year seconds utc date={replayRecord.startedAt} />
  60. </pre>
  61. </td>
  62. </tr>
  63. <tr key="duration">
  64. <td className="key">{t('Duration')}</td>
  65. <td className="value">
  66. <pre className="val-string">
  67. <Duration seconds={replayRecord.duration / 1000} fixedDigits={0} />
  68. </pre>
  69. </td>
  70. </tr>
  71. </tbody>
  72. </table>
  73. );
  74. }
  75. const PlayerContainer = styled(FluidHeight)`
  76. margin-bottom: ${space(2)};
  77. background: ${p => p.theme.background};
  78. `;
  79. const StyledPlaceholder = styled(Placeholder)`
  80. margin-top: ${space(2)};
  81. `;
  82. export default ReplayContent;