details.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import {Fragment} from 'react';
  2. import type {RouteComponentProps} from 'react-router';
  3. import DetailedError from 'sentry/components/errors/detailedError';
  4. import NotFound from 'sentry/components/errors/notFound';
  5. import List from 'sentry/components/list';
  6. import {
  7. Provider as ReplayContextProvider,
  8. useReplayContext,
  9. } from 'sentry/components/replays/replayContext';
  10. import {t} from 'sentry/locale';
  11. import {PageContent} from 'sentry/styles/organization';
  12. import useReplayData from 'sentry/utils/replays/hooks/useReplayData';
  13. import useReplayLayout from 'sentry/utils/replays/hooks/useReplayLayout';
  14. import useReplayPageview from 'sentry/utils/replays/hooks/useReplayPageview';
  15. import Layout from 'sentry/views/replays/detail/layout';
  16. import Page from 'sentry/views/replays/detail/page';
  17. type Props = RouteComponentProps<
  18. {orgId: string; replaySlug: string},
  19. {},
  20. any,
  21. {t: number}
  22. >;
  23. function ReplayDetails({
  24. location: {
  25. query: {
  26. t: initialTimeOffset, // Time, in seconds, where the video should start
  27. },
  28. },
  29. params: {orgId: orgSlug, replaySlug},
  30. }: Props) {
  31. useReplayPageview();
  32. const {fetching, onRetry, replay, fetchError} = useReplayData({
  33. replaySlug,
  34. orgSlug,
  35. });
  36. if (!fetching && !replay && fetchError) {
  37. if (fetchError.statusText === 'Not Found') {
  38. return (
  39. <Page orgSlug={orgSlug}>
  40. <PageContent>
  41. <NotFound />
  42. </PageContent>
  43. </Page>
  44. );
  45. }
  46. const reasons = [
  47. t('The Replay is still processing and is on its way'),
  48. t('There is an internal systems error or active issue'),
  49. ];
  50. return (
  51. <Page orgSlug={orgSlug}>
  52. <PageContent>
  53. <DetailedError
  54. onRetry={onRetry}
  55. hideSupportLinks
  56. heading={t('There was an error while fetching this Replay')}
  57. message={
  58. <Fragment>
  59. <p>{t('This could be due to a couple of reasons:')}</p>
  60. <List symbol="bullet">
  61. {reasons.map((reason, i) => (
  62. <li key={i}>{reason}</li>
  63. ))}
  64. </List>
  65. </Fragment>
  66. }
  67. />
  68. </PageContent>
  69. </Page>
  70. );
  71. }
  72. if (!fetching && replay && replay.getRRWebEvents().length < 2) {
  73. return (
  74. <Page orgSlug={orgSlug} replayRecord={replay.getReplay()}>
  75. <DetailedError
  76. hideSupportLinks
  77. heading={t('Expected two or more replay events')}
  78. message={
  79. <Fragment>
  80. <p>{t('This Replay may not have captured any user actions.')}</p>
  81. <p>
  82. {t(
  83. 'Or there may be an issue loading the actions from the server, click to try loading the Replay again.'
  84. )}
  85. </p>
  86. </Fragment>
  87. }
  88. />
  89. </Page>
  90. );
  91. }
  92. return (
  93. <ReplayContextProvider replay={replay} initialTimeOffset={initialTimeOffset}>
  94. <LoadedDetails orgSlug={orgSlug} />
  95. </ReplayContextProvider>
  96. );
  97. }
  98. function LoadedDetails({orgSlug}: {orgSlug: string}) {
  99. const {getLayout} = useReplayLayout();
  100. const {replay} = useReplayContext();
  101. return (
  102. <Page
  103. orgSlug={orgSlug}
  104. crumbs={replay?.getRawCrumbs()}
  105. replayRecord={replay?.getReplay()}
  106. >
  107. <Layout layout={getLayout()} />
  108. </Page>
  109. );
  110. }
  111. export default ReplayDetails;