details.tsx 3.6 KB

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