allEventsTable.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import {useState} from 'react';
  2. import {Location} from 'history';
  3. import LoadingError from 'sentry/components/loadingError';
  4. import {t} from 'sentry/locale';
  5. import {Organization} from 'sentry/types';
  6. import EventView, {decodeSorts} from 'sentry/utils/discover/eventView';
  7. import {useRoutes} from 'sentry/utils/useRoutes';
  8. import EventsTable from 'sentry/views/performance/transactionSummary/transactionEvents/eventsTable';
  9. export interface Props {
  10. isPerfIssue: boolean;
  11. issueId: string;
  12. location: Location;
  13. organization: Organization;
  14. projectId: string;
  15. excludedTags?: string[];
  16. totalEventCount?: string;
  17. }
  18. const AllEventsTable = (props: Props) => {
  19. const {
  20. location,
  21. organization,
  22. issueId,
  23. isPerfIssue,
  24. excludedTags,
  25. projectId,
  26. totalEventCount,
  27. } = props;
  28. const [error, setError] = useState<string>('');
  29. const routes = useRoutes();
  30. const isReplayEnabled = organization.features.includes('session-replay-ui');
  31. const fields: string[] = [
  32. 'id',
  33. 'transaction',
  34. 'trace',
  35. 'release',
  36. 'environment',
  37. 'user.display',
  38. ...(isPerfIssue ? ['transaction.duration'] : []),
  39. 'timestamp',
  40. ...(isReplayEnabled ? ['replayId'] : []),
  41. ];
  42. const eventView: EventView = EventView.fromLocation(props.location);
  43. eventView.fields = fields.map(fieldName => ({field: fieldName}));
  44. eventView.sorts = decodeSorts(location).filter(sort => fields.includes(sort.field));
  45. if (!eventView.sorts.length) {
  46. eventView.sorts = [{field: 'timestamp', kind: 'desc'}];
  47. }
  48. const idQuery = isPerfIssue
  49. ? `performance.issue_ids:${issueId} event.type:transaction`
  50. : `issue.id:${issueId}`;
  51. eventView.query = `${idQuery} ${props.location.query.query || ''}`;
  52. eventView.statsPeriod = '90d';
  53. const columnTitles: Readonly<string[]> = [
  54. t('event id'),
  55. t('transaction'),
  56. t('trace id'),
  57. t('release'),
  58. t('environment'),
  59. t('user'),
  60. ...(isPerfIssue ? [t('total duration')] : []),
  61. t('timestamp'),
  62. ...(isReplayEnabled ? [t('replay')] : []),
  63. t('minidump'),
  64. ];
  65. if (error) {
  66. return <LoadingError message={error} />;
  67. }
  68. return (
  69. <EventsTable
  70. eventView={eventView}
  71. location={location}
  72. issueId={issueId}
  73. organization={organization}
  74. routes={routes}
  75. excludedTags={excludedTags}
  76. projectId={projectId}
  77. totalEventCount={totalEventCount}
  78. customColumns={['minidump']}
  79. setError={(msg: string | undefined) => setError(msg ?? '')}
  80. transactionName=""
  81. columnTitles={columnTitles.slice()}
  82. referrer="api.issues.issue_events"
  83. />
  84. );
  85. };
  86. export default AllEventsTable;