eventEvidence.tsx 1.5 KB

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