eventEvidence.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import {EventDataSection} from 'sentry/components/events/eventDataSection';
  2. import KeyValueList from 'sentry/components/events/interfaces/keyValueList';
  3. import {ProfileEventEvidence} from 'sentry/components/events/profileEventEvidence';
  4. import {Event, Group, IssueCategory} from 'sentry/types';
  5. import {
  6. getConfigForIssueType,
  7. getIssueCategoryAndTypeFromOccurrenceType,
  8. } from 'sentry/utils/issueTypeConfig';
  9. type EvidenceProps = {event: Event; projectSlug: string; group?: Group};
  10. /**
  11. * This component is rendered whenever an `event.occurrence.evidenceDisplay` is
  12. * present and the issue type config is set up to use evidenceDisplay.
  13. */
  14. export const EventEvidence = ({event, group, projectSlug}: EvidenceProps) => {
  15. if (!event.occurrence) {
  16. return null;
  17. }
  18. const {issueCategory, issueType} =
  19. group ?? getIssueCategoryAndTypeFromOccurrenceType(event.occurrence.type);
  20. if (issueCategory === IssueCategory.PROFILE) {
  21. return <ProfileEventEvidence event={event} projectSlug={projectSlug} />;
  22. }
  23. const config = getConfigForIssueType({issueCategory, issueType}).evidence;
  24. const evidenceDisplay = event.occurrence?.evidenceDisplay;
  25. if (!evidenceDisplay?.length || !config) {
  26. return null;
  27. }
  28. return (
  29. <EventDataSection title={config.title} type="evidence" help={config.helpText}>
  30. <KeyValueList
  31. data={evidenceDisplay.map(item => ({
  32. subject: item.name,
  33. key: item.name,
  34. value: item.value,
  35. }))}
  36. shouldSort={false}
  37. />
  38. </EventDataSection>
  39. );
  40. };