Browse Source

chore(metrics): remove metric stats (#72839)

Ogi 8 months ago
parent
commit
8364dfaeaf

+ 0 - 12
static/app/constants/index.tsx

@@ -334,18 +334,6 @@ export const DATA_CATEGORY_INFO = {
     titleName: t('Profile Hours'),
     uid: 17,
   },
-  /**
-   * Used to display metrics on the stats page
-   */
-  [DataCategoryExact.METRICS]: {
-    name: DataCategoryExact.METRICS,
-    apiName: 'metricOutcomes',
-    plural: 'metrics',
-    displayName: 'metrics',
-    titleName: t('Metrics'),
-    // Metrics has no uid, is only used on stats page
-    uid: -1,
-  },
   [DataCategoryExact.METRIC_SECOND]: {
     name: DataCategoryExact.METRIC_SECOND,
     apiName: 'metricSecond',

+ 0 - 5
static/app/types/core.tsx

@@ -100,11 +100,6 @@ export enum DataCategoryExact {
   MONITOR_SEAT = 'monitorSeat',
   PROFILE_DURATION = 'profileDuration',
   SPAN = 'span',
-  /**
-   * Metrics does not actually exist as a data category, but is used on the stats page.
-   * See metricSecond instead.
-   */
-  METRICS = 'metrics',
   METRIC_SECOND = 'metricSecond',
 }
 

+ 0 - 4
static/app/views/organizationStats/index.tsx

@@ -27,7 +27,6 @@ import {space} from 'sentry/styles/space';
 import type {DataCategoryInfo, DateString, PageFilters} from 'sentry/types/core';
 import type {Organization} from 'sentry/types/organization';
 import type {Project} from 'sentry/types/project';
-import {hasCustomMetrics} from 'sentry/utils/metrics/features';
 import withOrganization from 'sentry/utils/withOrganization';
 import withPageFilters from 'sentry/utils/withPageFilters';
 import HeaderTabs from 'sentry/views/organizationStats/header';
@@ -240,9 +239,6 @@ export class OrganizationStats extends Component<OrganizationStatsProps> {
       if (opt.value === DATA_CATEGORY_INFO.replay.plural) {
         return organization.features.includes('session-replay');
       }
-      if (opt.value === DATA_CATEGORY_INFO.metrics.plural) {
-        return hasCustomMetrics(organization);
-      }
       if (DATA_CATEGORY_INFO.span.plural === opt.value) {
         return organization.features.includes('spans-usage-tracking');
       }

+ 1 - 14
static/app/views/organizationStats/usageChart/index.tsx

@@ -1,4 +1,3 @@
-import {useMemo} from 'react';
 import {type Theme, useTheme} from '@emotion/react';
 import styled from '@emotion/styled';
 import Color from 'color';
@@ -24,9 +23,7 @@ import {space} from 'sentry/styles/space';
 import type {DataCategoryInfo, IntervalPeriod, SelectValue} from 'sentry/types/core';
 import {parsePeriodToHours} from 'sentry/utils/duration/parsePeriodToHours';
 import {statsPeriodToDays} from 'sentry/utils/duration/statsPeriodToDays';
-import {hasCustomMetrics} from 'sentry/utils/metrics/features';
 import commonTheme from 'sentry/utils/theme';
-import useOrganization from 'sentry/utils/useOrganization';
 
 import {formatUsageWithUnits} from '../utils';
 
@@ -363,16 +360,6 @@ function UsageChartBody({
   handleDataTransformation = cumulativeTotalDataTransformation,
 }: UsageChartProps) {
   const theme = useTheme();
-  const organization = useOrganization();
-
-  const filteredOptions = useMemo(() => {
-    return categoryOptions.filter(option => {
-      if (option.value !== DATA_CATEGORY_INFO.metrics.plural) {
-        return true;
-      }
-      return hasCustomMetrics(organization);
-    });
-  }, [organization, categoryOptions]);
 
   if (isLoading) {
     return (
@@ -404,7 +391,7 @@ function UsageChartBody({
     xAxisLabelInterval,
     yAxisMinInterval,
   } = chartMetadata({
-    categoryOptions: filteredOptions,
+    categoryOptions,
     dataCategory,
     handleDataTransformation: handleDataTransformation!,
     usageStats,

+ 12 - 88
static/app/views/organizationStats/usageStatsOrg.tsx

@@ -22,7 +22,6 @@ import {space} from 'sentry/styles/space';
 import type {DataCategoryInfo, IntervalPeriod, Organization} from 'sentry/types';
 import {Outcome} from 'sentry/types';
 import {parsePeriodToHours} from 'sentry/utils/duration/parsePeriodToHours';
-import {hasCustomMetrics} from 'sentry/utils/metrics/features';
 
 import {
   FORMAT_DATETIME_DAILY,
@@ -80,10 +79,7 @@ class UsageStatsOrganization<
   }
 
   getEndpoints(): ReturnType<DeprecatedAsyncComponent['getEndpoints']> {
-    return [
-      ['orgStats', this.endpointPath, {query: this.endpointQuery}],
-      ...this.metricsEndpoint,
-    ];
+    return [['orgStats', this.endpointPath, {query: this.endpointQuery}]];
   }
 
   /** List of components to render on single-project view */
@@ -125,51 +121,6 @@ class UsageStatsOrganization<
     };
   }
 
-  // Metric stats are not reported when grouping by category, so we make a separate request
-  // and combine the results
-  get metricsEndpoint(): ReturnType<DeprecatedAsyncComponent['getEndpoints']> {
-    if (hasCustomMetrics(this.props.organization)) {
-      return [
-        [
-          'metricOrgStats',
-          this.endpointPath,
-          {
-            query: {
-              ...this.endpointQuery,
-              category: DATA_CATEGORY_INFO.metrics.apiName,
-              groupBy: ['outcome'],
-            },
-          },
-        ],
-      ];
-    }
-    return [];
-  }
-
-  // Combines non-metric and metric stats
-  get orgStats() {
-    const {orgStats, metricOrgStats} = this.state;
-
-    if (!orgStats || !metricOrgStats) {
-      return orgStats;
-    }
-
-    const metricsGroups = metricOrgStats.groups.map(group => {
-      return {
-        ...group,
-        by: {
-          ...group.by,
-          category: DATA_CATEGORY_INFO.metrics.apiName,
-        },
-      };
-    });
-
-    return {
-      ...orgStats,
-      groups: [...orgStats.groups, ...metricsGroups],
-    };
-  }
-
   get chartData(): {
     cardStats: {
       accepted?: string;
@@ -189,7 +140,7 @@ class UsageStatsOrganization<
     dataError?: Error;
   } {
     return {
-      ...this.mapSeriesToChart(this.orgStats),
+      ...this.mapSeriesToChart(this.state.orgStats),
       ...this.chartDateRange,
       ...this.chartTransform,
     };
@@ -315,14 +266,6 @@ class UsageStatsOrganization<
       }
     };
 
-    const navigateToMetricsSettings = (event: ReactMouseEvent) => {
-      event.preventDefault();
-      const url = `/settings/${organization.slug}/projects/:projectId/metrics/`;
-      if (router) {
-        navigateTo(url, router);
-      }
-    };
-
     const cardMetadata: Record<string, ScoreCardProps> = {
       total: {
         title: tct('Total [dataCategory]', {dataCategory: dataCategoryName}),
@@ -344,29 +287,15 @@ class UsageStatsOrganization<
       },
       filtered: {
         title: tct('Filtered [dataCategory]', {dataCategory: dataCategoryName}),
-        help:
-          dataCategory === DATA_CATEGORY_INFO.metrics.plural
-            ? tct(
-                'Filtered metrics were blocked due to your disabled metrics [settings: settings]',
-                {
-                  dataCategory,
-                  settings: (
-                    <a href="#" onClick={event => navigateToMetricsSettings(event)} />
-                  ),
-                }
-              )
-            : tct(
-                'Filtered [dataCategory] were blocked due to your [filterSettings: inbound data filter] rules',
-                {
-                  dataCategory,
-                  filterSettings: (
-                    <a
-                      href="#"
-                      onClick={event => navigateToInboundFilterSettings(event)}
-                    />
-                  ),
-                }
-              ),
+        help: tct(
+          'Filtered [dataCategory] were blocked due to your [filterSettings: inbound data filter] rules',
+          {
+            dataCategory,
+            filterSettings: (
+              <a href="#" onClick={event => navigateToInboundFilterSettings(event)} />
+            ),
+          }
+        ),
         score: filtered,
       },
       dropped: {
@@ -437,12 +366,7 @@ class UsageStatsOrganization<
       };
 
       orgStats.groups.forEach(group => {
-        const {outcome} = group.by;
-        // TODO(metrics): remove this when metrics category name is updated
-        const category =
-          group.by.category === DATA_CATEGORY_INFO.metrics.apiName
-            ? DATA_CATEGORY_INFO.metrics.plural
-            : group.by.category;
+        const {outcome, category} = group.by;
 
         // HACK: The backend enum are singular, but the frontend enums are plural
         const fullDataCategory = Object.values(DATA_CATEGORY_INFO).find(

+ 0 - 6
static/app/views/organizationStats/usageStatsPerMin.tsx

@@ -1,6 +1,5 @@
 import styled from '@emotion/styled';
 
-import {DATA_CATEGORY_INFO} from 'sentry/constants';
 import {t} from 'sentry/locale';
 import type {DataCategoryInfo, Organization} from 'sentry/types';
 import {Outcome} from 'sentry/types';
@@ -77,11 +76,6 @@ function UsageStatsPerMin({dataCategory, organization, projectIds}: Props) {
     );
   };
 
-  // Metrics stats ingestion is delayed, so we can't show this for metrics right now
-  if (dataCategory === DATA_CATEGORY_INFO.metrics.plural) {
-    return null;
-  }
-
   return (
     <Wrapper>
       {minuteData()} {t('in last min')}