Browse Source

feat(profile-issues): Add function evidence section to discover pages (#45112)

Closes https://github.com/getsentry/sentry/issues/45111

- Adds `<EventEvidence />` to `<EventEntries />`
- Adds logic for converting the occurrence type ID to an issueCategory
so we can know what kind of customizations to apply
Malachi Willey 2 years ago
parent
commit
7218788669

+ 2 - 0
static/app/components/events/eventEntries.tsx

@@ -3,6 +3,7 @@ import styled from '@emotion/styled';
 import {Location} from 'history';
 
 import {CommitRow} from 'sentry/components/commitRow';
+import {EventEvidence} from 'sentry/components/events/eventEvidence';
 import {t} from 'sentry/locale';
 import {space} from 'sentry/styles/space';
 import {
@@ -101,6 +102,7 @@ const EventEntries = ({
           isShare={isShare}
         />
       )}
+      <EventEvidence event={event} projectSlug={project.slug} />
       <Entries
         definedEvent={event}
         projectSlug={projectSlug}

+ 1 - 0
static/app/components/events/eventEvidence.spec.tsx

@@ -26,6 +26,7 @@ describe('EventEvidence', () => {
   const defaultProps = {
     event,
     group: TestStubs.Group(),
+    projectSlug: 'project-slug',
   };
 
   it('renders nothing when evidence display is empty', () => {

+ 20 - 5
static/app/components/events/eventEvidence.tsx

@@ -1,16 +1,31 @@
 import {EventDataSection} from 'sentry/components/events/eventDataSection';
 import KeyValueList from 'sentry/components/events/interfaces/keyValueList';
-import {Event, Group} from 'sentry/types';
-import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
+import {ProfileEventEvidence} from 'sentry/components/events/profileEventEvidence';
+import {Event, Group, IssueCategory} from 'sentry/types';
+import {
+  getConfigForIssueType,
+  getIssueCategoryAndTypeFromOccurrenceType,
+} from 'sentry/utils/issueTypeConfig';
 
-type EvidenceProps = {event: Event; group: Group};
+type EvidenceProps = {event: Event; projectSlug: string; group?: Group};
 
 /**
  * This component is rendered whenever an `event.occurrence.evidenceDisplay` is
  * present and the issue type config is set up to use evidenceDisplay.
  */
-export const EventEvidence = ({event, group}: EvidenceProps) => {
-  const config = getConfigForIssueType(group).evidence;
+export const EventEvidence = ({event, group, projectSlug}: EvidenceProps) => {
+  if (!event.occurrence) {
+    return null;
+  }
+
+  const {issueCategory, issueType} =
+    group ?? getIssueCategoryAndTypeFromOccurrenceType(event.occurrence.type);
+
+  if (issueCategory === IssueCategory.PROFILE) {
+    return <ProfileEventEvidence event={event} projectSlug={projectSlug} />;
+  }
+
+  const config = getConfigForIssueType({issueCategory, issueType}).evidence;
   const evidenceDisplay = event.occurrence?.evidenceDisplay;
 
   if (!evidenceDisplay?.length || !config) {

+ 1 - 0
static/app/types/event.tsx

@@ -653,6 +653,7 @@ type EventOccurrence = {
   issueTitle: string;
   resourceId: string;
   subtitle: string;
+  type: number;
 };
 
 interface EventBase {

+ 31 - 7
static/app/utils/issueTypeConfig/index.tsx

@@ -10,6 +10,13 @@ import {
 
 type Config = Record<IssueCategory, IssueCategoryConfigMapping>;
 
+type IssueCategoryAndType = {
+  issueCategory: IssueCategory;
+  issueType?: IssueType;
+};
+
+type GetConfigForIssueTypeParams = {eventOccurrenceType: number} | IssueCategoryAndType;
+
 const BASE_CONFIG: IssueTypeConfig = {
   actions: {
     delete: {enabled: false},
@@ -35,18 +42,35 @@ const issueTypeConfig: Config = {
   [IssueCategory.PROFILE]: profileConfig,
 };
 
+const eventOccurrenceTypeToIssueCategory = (eventOccurrenceType: number) => {
+  if (eventOccurrenceType >= 2000) {
+    return IssueCategory.PROFILE;
+  }
+  if (eventOccurrenceType >= 1000) {
+    return IssueCategory.PERFORMANCE;
+  }
+  return IssueCategory.ERROR;
+};
+
+export const getIssueCategoryAndTypeFromOccurrenceType = (
+  eventOccurrenceType: number
+): IssueCategoryAndType => {
+  return {
+    issueCategory: eventOccurrenceTypeToIssueCategory(eventOccurrenceType),
+  };
+};
+
 /**
  * Given an issue category and optional issue type, returns the corresponding config.
  * If an entry is not found in the issue type config, it looks in the default category
  * configuration. If not found there, it takes from the base config.
  */
-export const getConfigForIssueType = ({
-  issueCategory,
-  issueType,
-}: {
-  issueCategory: IssueCategory;
-  issueType?: IssueType;
-}) => {
+export const getConfigForIssueType = (params: GetConfigForIssueTypeParams) => {
+  const {issueCategory, issueType} =
+    'eventOccurrenceType' in params
+      ? getIssueCategoryAndTypeFromOccurrenceType(params.eventOccurrenceType)
+      : params;
+
   const categoryMap = issueTypeConfig[issueCategory];
 
   if (!categoryMap) {

+ 5 - 0
static/app/views/issueDetails/groupEventDetails/groupEventDetails.spec.tsx

@@ -340,6 +340,11 @@ describe('groupEventDetails', () => {
     });
     const transaction = TestStubs.Event({
       entries: [],
+      occurrence: {
+        evidenceDisplay: [],
+        evidenceData: {},
+        type: 2000,
+      },
     });
 
     mockGroupApis(

+ 1 - 5
static/app/views/issueDetails/groupEventDetails/groupEventDetailsContent.tsx

@@ -18,7 +18,6 @@ import {EventGroupingInfo} from 'sentry/components/events/groupingInfo';
 import {Resources} from 'sentry/components/events/interfaces/performance/resources';
 import {SpanEvidenceSection} from 'sentry/components/events/interfaces/performance/spanEvidence';
 import {EventPackageData} from 'sentry/components/events/packageData';
-import {ProfileEventEvidence} from 'sentry/components/events/profileEventEvidence';
 import {EventRRWebIntegration} from 'sentry/components/events/rrwebIntegration';
 import {EventSdkUpdates} from 'sentry/components/events/sdkUpdates';
 import {EventUserFeedback} from 'sentry/components/events/userFeedback';
@@ -103,10 +102,7 @@ const GroupEventDetailsContent = ({
         projectSlug={project.slug}
         location={location}
       />
-      <EventEvidence event={event} group={group} />
-      {group.issueCategory === IssueCategory.PROFILE && (
-        <ProfileEventEvidence event={event} projectSlug={project.slug} />
-      )}
+      <EventEvidence event={event} group={group} projectSlug={project.slug} />
       <GroupEventEntry entryType={EntryType.MESSAGE} {...eventEntryProps} />
       <GroupEventEntry entryType={EntryType.EXCEPTION} {...eventEntryProps} />
       <GroupEventEntry entryType={EntryType.STACKTRACE} {...eventEntryProps} />