Browse Source

feat(issue-platform): Fix passing correct dataset for all events (#48705)

Includes changes from https://github.com/getsentry/sentry/pull/48288 and
also handles `isLoading` being permanently true when a query is
disabled.
Dameli Ushbayeva 1 year ago
parent
commit
6e3348d298

+ 8 - 2
static/app/views/issueDetails/actions/index.tsx

@@ -35,6 +35,7 @@ import {space} from 'sentry/styles/space';
 import {
   Group,
   GroupStatusResolution,
+  IssueCategory,
   Organization,
   Project,
   ResolutionStatus,
@@ -83,7 +84,6 @@ export function Actions(props: Props) {
   const bookmarkKey = isBookmarked ? 'unbookmark' : 'bookmark';
   const bookmarkTitle = isBookmarked ? t('Remove bookmark') : t('Bookmark');
   const hasRelease = !!project.features?.includes('releases');
-
   const isResolved = status === 'resolved';
   const isAutoResolved =
     group.status === 'resolved' ? group.statusDetails.autoResolved : undefined;
@@ -102,6 +102,9 @@ export function Actions(props: Props) {
   const getDiscoverUrl = () => {
     const {title, type, shortId} = group;
 
+    const groupIsOccurrenceBacked =
+      group.issueCategory === IssueCategory.PERFORMANCE && !!event?.occurrence;
+
     const config = getConfigForIssueType(group);
 
     const discoverQuery = {
@@ -113,7 +116,10 @@ export function Actions(props: Props) {
       projects: [Number(project.id)],
       version: 2 as SavedQueryVersions,
       range: '90d',
-      dataset: config.usesIssuePlatform ? DiscoverDatasets.ISSUE_PLATFORM : undefined,
+      dataset:
+        config.usesIssuePlatform || groupIsOccurrenceBacked
+          ? DiscoverDatasets.ISSUE_PLATFORM
+          : undefined,
     };
 
     const discoverView = EventView.fromSavedQuery(discoverQuery);

+ 31 - 5
static/app/views/issueDetails/allEventsTable.tsx

@@ -8,11 +8,12 @@ import {
   profiling as PROFILING_PLATFORMS,
 } from 'sentry/data/platformCategories';
 import {t} from 'sentry/locale';
-import {Group, IssueCategory, Organization} from 'sentry/types';
+import {EventTransaction, Group, IssueCategory, Organization} from 'sentry/types';
 import EventView, {decodeSorts} from 'sentry/utils/discover/eventView';
 import {DiscoverDatasets} from 'sentry/utils/discover/types';
 import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
 import {platformToCategory} from 'sentry/utils/platform';
+import {useApiQuery} from 'sentry/utils/queryClient';
 import {useRoutes} from 'sentry/utils/useRoutes';
 import EventsTable from 'sentry/views/performance/transactionSummary/transactionEvents/eventsTable';
 
@@ -24,6 +25,10 @@ export interface Props {
   excludedTags?: string[];
 }
 
+const makeGroupPreviewRequestUrl = ({groupId}: {groupId: string}) => {
+  return `/issues/${groupId}/events/latest/`;
+};
+
 function AllEventsTable(props: Props) {
   const {location, organization, issueId, excludedTags, group} = props;
   const config = getConfigForIssueType(props.group);
@@ -31,8 +36,26 @@ function AllEventsTable(props: Props) {
   const routes = useRoutes();
   const {fields, columnTitles} = getColumns(group, organization);
 
+  const endpointUrl = makeGroupPreviewRequestUrl({
+    groupId: group.id,
+  });
+
+  const queryEnabled = group.issueCategory === IssueCategory.PERFORMANCE;
+  const {data, isLoading, isLoadingError} = useApiQuery<EventTransaction>([endpointUrl], {
+    staleTime: 60000,
+    enabled: queryEnabled,
+  });
+
+  // TODO: this is a temporary way to check whether
+  // perf issue is backed by occurrences or transactions
+  // Once migration to the issue platform is complete a call to /latest should be removed
+  const groupIsOccurrenceBacked = !!data?.occurrence;
+
   const eventView: EventView = EventView.fromLocation(props.location);
-  if (config.usesIssuePlatform) {
+  if (
+    config.usesIssuePlatform ||
+    (group.issueCategory === IssueCategory.PERFORMANCE && groupIsOccurrenceBacked)
+  ) {
     eventView.dataset = DiscoverDatasets.ISSUE_PLATFORM;
   }
   eventView.fields = fields.map(fieldName => ({field: fieldName}));
@@ -48,15 +71,17 @@ function AllEventsTable(props: Props) {
   }
 
   const idQuery =
-    group.issueCategory === IssueCategory.PERFORMANCE
+    group.issueCategory === IssueCategory.PERFORMANCE && !groupIsOccurrenceBacked
       ? `performance.issue_ids:${issueId} event.type:transaction`
       : `issue.id:${issueId}`;
   eventView.project = [parseInt(group.project.id, 10)];
   eventView.query = `${idQuery} ${props.location.query.query || ''}`;
   eventView.statsPeriod = '90d';
 
-  if (error) {
-    return <LoadingError message={error} onRetry={() => setError('')} />;
+  if (error || isLoadingError) {
+    return (
+      <LoadingError message={error || isLoadingError} onRetry={() => setError('')} />
+    );
   }
 
   return (
@@ -73,6 +98,7 @@ function AllEventsTable(props: Props) {
       transactionName=""
       columnTitles={columnTitles.slice()}
       referrer="api.issues.issue_events"
+      isEventLoading={queryEnabled ? isLoading : false}
     />
   );
 }

+ 6 - 0
static/app/views/issueDetails/groupEvents.spec.tsx

@@ -109,6 +109,12 @@ describe('groupEvents', () => {
       url: '/organizations/org-slug/recent-searches/',
       body: [],
     });
+
+    requests.latestEvent = MockApiClient.addMockResponse({
+      method: 'GET',
+      url: '/issues/1/events/latest/',
+      body: {},
+    });
   });
 
   afterEach(() => {

+ 8 - 1
static/app/views/issueDetails/groupEvents.tsx

@@ -24,7 +24,14 @@ interface State {
   query: string;
 }
 
-const excludedTags = ['environment', 'issue', 'issue.id', 'performance.issue_ids'];
+const excludedTags = [
+  'environment',
+  'issue',
+  'issue.id',
+  'performance.issue_ids',
+  'transaction.op',
+  'transaction.status',
+];
 
 class GroupEvents extends Component<Props, State> {
   constructor(props: Props) {

+ 5 - 2
static/app/views/performance/transactionSummary/transactionEvents/eventsTable.tsx

@@ -72,6 +72,7 @@ type Props = {
   columnTitles?: string[];
   customColumns?: ('attachments' | 'minidump')[];
   excludedTags?: string[];
+  isEventLoading?: boolean;
   issueId?: string;
   projectSlug?: string;
   referrer?: string;
@@ -340,7 +341,8 @@ class EventsTable extends Component<Props, State> {
   };
 
   render() {
-    const {eventView, organization, location, setError, referrer} = this.props;
+    const {eventView, organization, location, setError, referrer, isEventLoading} =
+      this.props;
 
     const totalEventsView = eventView.clone();
     totalEventsView.sorts = [];
@@ -484,7 +486,8 @@ class EventsTable extends Component<Props, State> {
                           isLoading={
                             isTotalEventsLoading ||
                             isDiscoverQueryLoading ||
-                            shouldFetchAttachments
+                            shouldFetchAttachments ||
+                            isEventLoading
                           }
                           data={tableData?.data ?? []}
                           columnOrder={columnOrder}