eventReplay.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import styled from '@emotion/styled';
  2. import EventDataSection from 'sentry/components/events/eventDataSection';
  3. import Link from 'sentry/components/links/link';
  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. type Props = {
  12. orgSlug: string;
  13. projectSlug: string;
  14. replayId: string;
  15. };
  16. export default function EventReplay({replayId, orgSlug, projectSlug}: Props) {
  17. const {fetching, replay} = useReplayData({
  18. eventSlug: `${projectSlug}:${replayId}`,
  19. orgId: orgSlug,
  20. });
  21. const {ref: fullscreenRef, isFullscreen, toggle: toggleFullscreen} = useFullscreen();
  22. return (
  23. <EventDataSection type="replay" title={t('Replay')}>
  24. <Link to={`/organizations/${orgSlug}/replays/${projectSlug}:${replayId}`}>
  25. {replayId}
  26. </Link>
  27. <ReplayContextProvider replay={replay} initialTimeOffset={0}>
  28. <PlayerContainer ref={fullscreenRef}>
  29. {fetching ? (
  30. <Placeholder height="350px" width="100%" />
  31. ) : (
  32. replay && (
  33. <ReplayView
  34. toggleFullscreen={toggleFullscreen}
  35. isFullscreen={isFullscreen}
  36. />
  37. )
  38. )}
  39. </PlayerContainer>
  40. </ReplayContextProvider>
  41. </EventDataSection>
  42. );
  43. }
  44. const PlayerContainer = styled('div')`
  45. max-width: 420px;
  46. margin-top: ${space(2)};
  47. `;