feedbackReplay.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import ErrorBoundary from 'sentry/components/errorBoundary';
  2. import Section from 'sentry/components/feedback/feedbackItem/feedbackItemSection';
  3. import ReplayInlineCTAPanel from 'sentry/components/feedback/feedbackItem/replayInlineCTAPanel';
  4. import ReplaySection from 'sentry/components/feedback/feedbackItem/replaySection';
  5. import Placeholder from 'sentry/components/placeholder';
  6. import {replayPlatforms} from 'sentry/data/platformCategories';
  7. import {IconPlay} from 'sentry/icons';
  8. import {t} from 'sentry/locale';
  9. import type {Event, Organization, PlatformKey} from 'sentry/types';
  10. import type {FeedbackIssue} from 'sentry/utils/feedback/types';
  11. import useReplayCountForFeedbacks from 'sentry/utils/replayCount/useReplayCountForFeedbacks';
  12. import {useHaveSelectedProjectsSentAnyReplayEvents} from 'sentry/utils/replays/hooks/useReplayOnboarding';
  13. interface Props {
  14. eventData: Event | undefined;
  15. feedbackItem: FeedbackIssue;
  16. organization: Organization;
  17. }
  18. export default function FeedbackReplay({eventData, feedbackItem, organization}: Props) {
  19. const {feedbackHasReplay} = useReplayCountForFeedbacks();
  20. const hasReplayId = feedbackHasReplay(feedbackItem.id);
  21. // replay ID can be found in three places
  22. const replayId =
  23. eventData?.contexts?.feedback?.replay_id ??
  24. eventData?.contexts?.replay?.replay_id ??
  25. eventData?.tags?.find(({key}) => key === 'replayId')?.value;
  26. const {hasSentOneReplay, fetching: isFetchingSentOneReplay} =
  27. useHaveSelectedProjectsSentAnyReplayEvents();
  28. const platformSupported = replayPlatforms.includes(
  29. feedbackItem.project?.platform as PlatformKey
  30. );
  31. if (replayId && hasReplayId) {
  32. return (
  33. <Section icon={<IconPlay size="xs" />} title={t('Linked Replay')}>
  34. <ErrorBoundary mini>
  35. <ReplaySection
  36. eventTimestampMs={new Date(feedbackItem.firstSeen).getTime()}
  37. organization={organization}
  38. replayId={replayId}
  39. />
  40. </ErrorBoundary>
  41. </Section>
  42. );
  43. }
  44. if ((replayId && hasReplayId === undefined) || isFetchingSentOneReplay) {
  45. return (
  46. <Section icon={<IconPlay size="xs" />} title={t('Linked Replay')}>
  47. <Placeholder />
  48. </Section>
  49. );
  50. }
  51. if (!hasSentOneReplay && platformSupported) {
  52. return (
  53. <Section icon={<IconPlay size="xs" />} title={t('Linked Replay')}>
  54. <ReplayInlineCTAPanel />
  55. </Section>
  56. );
  57. }
  58. return null;
  59. }