Browse Source

ref(metrics): Remove extrapolation ui (#76777)

Priscila Oliveira 6 months ago
parent
commit
d99c35e805

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

@@ -23,7 +23,6 @@ export type Project = {
   eventProcessing: {
     symbolicationDegraded: boolean;
   };
-  extrapolateMetrics: boolean;
   features: string[];
   firstEvent: string | null;
   firstTransactionEvent: boolean;

+ 0 - 4
static/app/utils/metrics/features.tsx

@@ -13,10 +13,6 @@ export function hasMetricAlertFeature(organization: Organization) {
   return organization.features.includes('incidents');
 }
 
-export function hasMetricsExtrapolationFeature(organization: Organization) {
-  return organization.features.includes('metrics-extrapolation');
-}
-
 export function hasMetricsNewInputs(organization: Organization) {
   return organization.features.includes('metrics-new-inputs');
 }

+ 0 - 76
static/app/views/settings/projectMetrics/extrapolationField.tsx

@@ -1,76 +0,0 @@
-import {useEffect, useState} from 'react';
-
-import {
-  addErrorMessage,
-  addLoadingMessage,
-  addSuccessMessage,
-} from 'sentry/actionCreators/indicator';
-import BooleanField from 'sentry/components/forms/fields/booleanField';
-import ExternalLink from 'sentry/components/links/externalLink';
-import Panel from 'sentry/components/panels/panel';
-import PanelBody from 'sentry/components/panels/panelBody';
-import {t, tct} from 'sentry/locale';
-import ProjectsStore from 'sentry/stores/projectsStore';
-import type {Project} from 'sentry/types/project';
-import {useMutation} from 'sentry/utils/queryClient';
-import type RequestError from 'sentry/utils/requestError/requestError';
-import useApi from 'sentry/utils/useApi';
-import useOrganization from 'sentry/utils/useOrganization';
-
-interface ExtrapolationFieldProps {
-  project: Project;
-}
-
-export function ExtrapolationField({project}: ExtrapolationFieldProps) {
-  const organization = useOrganization();
-  const api = useApi();
-
-  const [isToggleEnabled, setIsToggleEnabled] = useState(!project.extrapolateMetrics);
-
-  // Reload from props if new project state is received
-  useEffect(() => {
-    setIsToggleEnabled(!project.extrapolateMetrics);
-  }, [project.extrapolateMetrics]);
-
-  const {mutate: handleToggleChange} = useMutation<Project, RequestError, boolean>({
-    mutationFn: value => {
-      return api.requestPromise(`/projects/${organization.slug}/${project.slug}/`, {
-        method: 'PUT',
-        data: {
-          extrapolateMetrics: !value,
-        },
-      });
-    },
-    onMutate: () => {
-      addLoadingMessage(t('Toggling sampled mode'));
-    },
-    onSuccess: updatedProject => {
-      addSuccessMessage(t('Successfully toggled sampled mode'));
-      ProjectsStore.onUpdateSuccess(updatedProject);
-    },
-    onError: () => {
-      addErrorMessage(t('Failed to toggle sampled mode'));
-    },
-  });
-
-  return (
-    <Panel>
-      <PanelBody>
-        <BooleanField
-          onChange={handleToggleChange}
-          value={isToggleEnabled}
-          name="metrics-extrapolation-toggle"
-          disabled={!project.access.includes('project:write')} // admin, manager and owner of an organization will be able to edit this field
-          label={t('Sampled Mode')}
-          help={tct(
-            'Typically, Sentry uses weights to approximate original volume and correct sampling skew. Enable sampled mode to view raw event data, where sample rates are ignored in calculations. [link:Read the docs] to learn more.',
-            {
-              // TODO(telemetry-experience): Add link to metrics extrapolation docs when available
-              link: <ExternalLink href="https://docs.sentry.io/product/metrics/" />,
-            }
-          )}
-        />
-      </PanelBody>
-    </Panel>
-  );
-}

+ 0 - 8
static/app/views/settings/projectMetrics/projectMetrics.tsx

@@ -9,15 +9,12 @@ import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
 import type {Organization} from 'sentry/types/organization';
 import type {Project} from 'sentry/types/project';
 import {METRICS_DOCS_URL} from 'sentry/utils/metrics/constants';
-import {hasMetricsExtrapolationFeature} from 'sentry/utils/metrics/features';
 import routeTitleGen from 'sentry/utils/routeTitle';
-import useOrganization from 'sentry/utils/useOrganization';
 import {useMetricsOnboardingSidebar} from 'sentry/views/metrics/ddmOnboarding/useMetricsOnboardingSidebar';
 import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
 import TextBlock from 'sentry/views/settings/components/text/textBlock';
 import PermissionAlert from 'sentry/views/settings/project/permissionAlert';
 import {CustomMetricsTable} from 'sentry/views/settings/projectMetrics/customMetricsTable';
-import {ExtrapolationField} from 'sentry/views/settings/projectMetrics/extrapolationField';
 
 type Props = {
   organization: Organization;
@@ -25,7 +22,6 @@ type Props = {
 } & RouteComponentProps<{projectId: string}, {}>;
 
 function ProjectMetrics({project}: Props) {
-  const organization = useOrganization();
   const {activateSidebar} = useMetricsOnboardingSidebar();
 
   return (
@@ -62,10 +58,6 @@ function ProjectMetrics({project}: Props) {
 
       <PermissionAlert project={project} />
 
-      {hasMetricsExtrapolationFeature(organization) ? (
-        <ExtrapolationField project={project} />
-      ) : null}
-
       <CustomMetricsTable project={project} />
     </Fragment>
   );

+ 0 - 1
tests/js/fixtures/project.ts

@@ -58,7 +58,6 @@ export function ProjectFixture(params: Partial<Project> = {}): Project {
     sensitiveFields: [],
     subjectTemplate: '',
     verifySSL: false,
-    extrapolateMetrics: false,
     ...params,
   };
 }