Browse Source

feat(crons): Dismiss processing errors on monitor overview page (#72701)

Similar to https://github.com/getsentry/sentry/pull/72699

Adds dismiss behavior to monitor overview page 

<img width="1238" alt="image"
src="https://github.com/getsentry/sentry/assets/9372512/358b78a0-88e0-4a7d-8089-765f68d7c647">


depends on: 
- api changes: https://github.com/getsentry/sentry/pull/72623 
- ui changes: https://github.com/getsentry/sentry/pull/72626
David Wang 8 months ago
parent
commit
b48bd44bb0
2 changed files with 42 additions and 8 deletions
  1. 24 0
      static/app/actionCreators/monitors.tsx
  2. 18 8
      static/app/views/monitors/overview.tsx

+ 24 - 0
static/app/actionCreators/monitors.tsx

@@ -171,3 +171,27 @@ export async function deleteMonitorProcessingErrorByType(
     }
   }
 }
+
+export async function deleteProjectProcessingErrorByType(
+  api: Client,
+  orgId: string,
+  projectId: string,
+  errortype: ProcessingErrorType
+) {
+  addLoadingMessage();
+
+  try {
+    await api.requestPromise(`/projects/${orgId}/${projectId}/processing-errors/`, {
+      method: 'DELETE',
+      query: {errortype},
+    });
+    clearIndicators();
+  } catch (err) {
+    logException(err);
+    if (err.status === 403) {
+      addErrorMessage(t('You do not have permission to dismiss these processing errors'));
+    } else {
+      addErrorMessage(t('Unable to dismiss the processing errors'));
+    }
+  }
+}

+ 18 - 8
static/app/views/monitors/overview.tsx

@@ -3,6 +3,7 @@ import styled from '@emotion/styled';
 import * as qs from 'query-string';
 
 import {openBulkEditMonitorsModal} from 'sentry/actionCreators/modal';
+import {deleteProjectProcessingErrorByType} from 'sentry/actionCreators/monitors';
 import {Button} from 'sentry/components/button';
 import ButtonBar from 'sentry/components/buttonBar';
 import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton';
@@ -25,6 +26,7 @@ import {useApiQuery} from 'sentry/utils/queryClient';
 import {decodeList, decodeScalar} from 'sentry/utils/queryString';
 import useRouteAnalyticsEventNames from 'sentry/utils/routeAnalytics/useRouteAnalyticsEventNames';
 import useRouteAnalyticsParams from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams';
+import useApi from 'sentry/utils/useApi';
 import {useLocation} from 'sentry/utils/useLocation';
 import {useNavigate} from 'sentry/utils/useNavigate';
 import useOrganization from 'sentry/utils/useOrganization';
@@ -39,7 +41,7 @@ import {
 import {NewMonitorButton} from './components/newMonitorButton';
 import {OverviewTimeline} from './components/overviewTimeline';
 import {OwnerFilter} from './components/ownerFilter';
-import type {CheckinProcessingError, Monitor} from './types';
+import type {CheckinProcessingError, Monitor, ProcessingErrorType} from './types';
 import {makeMonitorListQueryKey} from './utils';
 
 const CronsListPageHeader = HookOrDefault({
@@ -47,6 +49,7 @@ const CronsListPageHeader = HookOrDefault({
 });
 
 export default function Monitors() {
+  const api = useApi();
   const organization = useOrganization();
   const navigate = useNavigate();
   const location = useLocation();
@@ -66,12 +69,11 @@ export default function Monitors() {
   });
 
   const processingErrorQueryKey = makeMonitorListErrorsQueryKey(organization, project);
-  const {data: processingErrors} = useApiQuery<CheckinProcessingError[]>(
-    processingErrorQueryKey,
-    {
-      staleTime: 0,
-    }
-  );
+  const {data: processingErrors, refetch: refetchErrors} = useApiQuery<
+    CheckinProcessingError[]
+  >(processingErrorQueryKey, {
+    staleTime: 0,
+  });
 
   useRouteAnalyticsEventNames('monitors.page_viewed', 'Monitors: Page Viewed');
   useRouteAnalyticsParams({empty_state: !monitorList || monitorList.length === 0});
@@ -86,6 +88,11 @@ export default function Monitors() {
     });
   };
 
+  function handleDismissError(errortype: ProcessingErrorType, projectId: string) {
+    deleteProjectProcessingErrorByType(api, organization.slug, projectId, errortype);
+    refetchErrors();
+  }
+
   const showAddMonitor = !isValidPlatform(platform) || !isValidGuide(guide);
 
   return (
@@ -155,7 +162,10 @@ export default function Monitors() {
               />
             </Filters>
             {!!processingErrors?.length && (
-              <MonitorProcessingErrors checkinErrors={processingErrors}>
+              <MonitorProcessingErrors
+                checkinErrors={processingErrors}
+                onDismiss={handleDismissError}
+              >
                 {t(
                   'Errors were encountered while ingesting check-ins for the selected projects'
                 )}