details_v2.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import {Fragment} from 'react';
  2. import DetailedError from 'sentry/components/errors/detailedError';
  3. import NotFound from 'sentry/components/errors/notFound';
  4. import {Provider as ReplayContextProvider} from 'sentry/components/replays/replayContext';
  5. import {t} from 'sentry/locale';
  6. import {PageContent} from 'sentry/styles/organization';
  7. import useReplayData from 'sentry/utils/replays/hooks/useReplayData';
  8. import useUrlParam from 'sentry/utils/replays/hooks/useUrlParams';
  9. import {useRouteContext} from 'sentry/utils/useRouteContext';
  10. import Layout from 'sentry/views/replays/detail/layout';
  11. import Page from 'sentry/views/replays/detail/page';
  12. const LAYOUT_NAMES = ['topbar', 'sidebar', 'sidebar_left'];
  13. function ReplayDetails() {
  14. const {
  15. location,
  16. params: {eventSlug, orgId},
  17. } = useRouteContext();
  18. const {
  19. t: initialTimeOffset, // Time, in seconds, where the video should start
  20. } = location.query;
  21. const {getParamValue} = useUrlParam('l_page', 'topbar');
  22. const {fetching, onRetry, replay} = useReplayData({
  23. eventSlug,
  24. orgId,
  25. });
  26. if (!fetching && !replay) {
  27. return (
  28. <Page eventSlug={eventSlug} orgId={orgId}>
  29. <PageContent>
  30. <NotFound />
  31. </PageContent>
  32. </Page>
  33. );
  34. }
  35. if (!fetching && replay && replay.getRRWebEvents().length < 2) {
  36. return (
  37. <Page eventSlug={eventSlug} orgId={orgId} event={replay.getEvent()}>
  38. <DetailedError
  39. onRetry={onRetry}
  40. hideSupportLinks
  41. heading={t('Expected two or more replay events')}
  42. message={
  43. <Fragment>
  44. <p>{t('This Replay may not have captured any user actions.')}</p>
  45. <p>
  46. {t(
  47. 'Or there may be an issue loading the actions from the server, click to try loading the Replay again.'
  48. )}
  49. </p>
  50. </Fragment>
  51. }
  52. />
  53. </Page>
  54. );
  55. }
  56. return (
  57. <Page eventSlug={eventSlug} orgId={orgId} event={replay?.getEvent()}>
  58. <ReplayContextProvider replay={replay} initialTimeOffset={initialTimeOffset}>
  59. <Layout
  60. layout={
  61. // TODO(replay): If we end up keeping this, we'll fix up the typing
  62. LAYOUT_NAMES.includes(getParamValue()) ? (getParamValue() as any) : 'topbar'
  63. }
  64. />
  65. </ReplayContextProvider>
  66. </Page>
  67. );
  68. }
  69. export default ReplayDetails;