groupReplays.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import {useEffect, useMemo} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Location} from 'history';
  4. import * as Layout from 'sentry/components/layouts/thirds';
  5. import type {Group, Organization} from 'sentry/types';
  6. import {trackAnalytics} from 'sentry/utils/analytics';
  7. import EventView from 'sentry/utils/discover/eventView';
  8. import useReplayList from 'sentry/utils/replays/hooks/useReplayList';
  9. import {useLocation} from 'sentry/utils/useLocation';
  10. import useOrganization from 'sentry/utils/useOrganization';
  11. import useReplaysFromIssue from 'sentry/views/issueDetails/groupReplays/useReplaysFromIssue';
  12. import ReplayTable from 'sentry/views/replays/replayTable';
  13. import {ReplayColumn} from 'sentry/views/replays/replayTable/types';
  14. import type {ReplayListLocationQuery} from 'sentry/views/replays/types';
  15. type Props = {
  16. group: Group;
  17. };
  18. const VISIBLE_COLUMNS = [
  19. ReplayColumn.REPLAY,
  20. ReplayColumn.OS,
  21. ReplayColumn.BROWSER,
  22. ReplayColumn.DURATION,
  23. ReplayColumn.COUNT_ERRORS,
  24. ReplayColumn.ACTIVITY,
  25. ];
  26. function GroupReplays({group}: Props) {
  27. const organization = useOrganization();
  28. const location = useLocation<ReplayListLocationQuery>();
  29. const {eventView, fetchError, pageLinks} = useReplaysFromIssue({
  30. group,
  31. location,
  32. organization,
  33. });
  34. useEffect(() => {
  35. trackAnalytics('replay.render-issues-group-list', {
  36. project_id: group.project.id,
  37. platform: group.project.platform,
  38. organization,
  39. });
  40. // we only want to fire this event once
  41. // eslint-disable-next-line react-hooks/exhaustive-deps
  42. }, []);
  43. if (!eventView) {
  44. return (
  45. <StyledLayoutPage withPadding>
  46. <ReplayTable
  47. fetchError={fetchError}
  48. isFetching
  49. replays={[]}
  50. sort={undefined}
  51. visibleColumns={VISIBLE_COLUMNS}
  52. />
  53. </StyledLayoutPage>
  54. );
  55. }
  56. return (
  57. <GroupReplaysTable
  58. eventView={eventView}
  59. organization={organization}
  60. pageLinks={pageLinks}
  61. visibleColumns={VISIBLE_COLUMNS}
  62. />
  63. );
  64. }
  65. function GroupReplaysTable({
  66. eventView,
  67. organization,
  68. visibleColumns,
  69. }: {
  70. eventView: EventView;
  71. organization: Organization;
  72. pageLinks: string | null;
  73. visibleColumns: ReplayColumn[];
  74. }) {
  75. const location = useMemo(() => ({query: {}} as Location<ReplayListLocationQuery>), []);
  76. const {replays, isFetching, fetchError} = useReplayList({
  77. eventView,
  78. location,
  79. organization,
  80. queryReferrer: 'issueReplays',
  81. });
  82. return (
  83. <StyledLayoutPage withPadding>
  84. <ReplayTable
  85. fetchError={fetchError}
  86. isFetching={isFetching}
  87. replays={replays}
  88. sort={undefined}
  89. visibleColumns={visibleColumns}
  90. />
  91. </StyledLayoutPage>
  92. );
  93. }
  94. const StyledLayoutPage = styled(Layout.Page)`
  95. box-shadow: 0px 0px 1px ${p => p.theme.gray200};
  96. background-color: ${p => p.theme.background};
  97. `;
  98. export default GroupReplays;