Browse Source

fix(perf): Vital detail chart title should changed based on chosen web vital (#34117)

Alberto Leal 2 years ago
parent
commit
7ccfa5e4da

+ 7 - 0
static/app/views/performance/vitalDetail/utils.tsx

@@ -91,6 +91,13 @@ export function vitalNameFromLocation(location: Location): WebVital {
   return WebVital.LCP;
   return WebVital.LCP;
 }
 }
 
 
+export function getVitalChartTitle(webVital: WebVital): string {
+  if (webVital === WebVital.CLS) {
+    return t('CLS p75');
+  }
+  return t('Duration p75');
+}
+
 export function getVitalDetailTablePoorStatusFunction(vitalName: WebVital): string {
 export function getVitalDetailTablePoorStatusFunction(vitalName: WebVital): string {
   const vitalThreshold = webVitalPoor[vitalName];
   const vitalThreshold = webVitalPoor[vitalName];
   const statusFunction = `compare_numeric_aggregate(${getAggregateAlias(
   const statusFunction = `compare_numeric_aggregate(${getAggregateAlias(

+ 2 - 1
static/app/views/performance/vitalDetail/vitalChart.tsx

@@ -26,6 +26,7 @@ import {ViewProps} from '../types';
 import {
 import {
   getMaxOfSeries,
   getMaxOfSeries,
   getVitalChartDefinitions,
   getVitalChartDefinitions,
+  getVitalChartTitle,
   vitalNameFromLocation,
   vitalNameFromLocation,
   VitalState,
   VitalState,
   vitalStateColors,
   vitalStateColors,
@@ -86,7 +87,7 @@ function VitalChart({
     <Panel>
     <Panel>
       <ChartContainer>
       <ChartContainer>
         <HeaderTitleLegend>
         <HeaderTitleLegend>
-          {t('Duration p75')}
+          {getVitalChartTitle(vitalName)}
           <QuestionTooltip
           <QuestionTooltip
             size="sm"
             size="sm"
             position="top"
             position="top"

+ 2 - 2
static/app/views/performance/vitalDetail/vitalChartMetrics.tsx

@@ -21,7 +21,7 @@ import getDynamicText from 'sentry/utils/getDynamicText';
 import {replaceSeriesName, transformEventStatsSmoothed} from '../trends/utils';
 import {replaceSeriesName, transformEventStatsSmoothed} from '../trends/utils';
 import {ViewProps} from '../types';
 import {ViewProps} from '../types';
 
 
-import {getMaxOfSeries, getVitalChartDefinitions} from './utils';
+import {getMaxOfSeries, getVitalChartDefinitions, getVitalChartTitle} from './utils';
 
 
 type Props = WithRouterProps &
 type Props = WithRouterProps &
   Omit<ViewProps, 'query' | 'start' | 'end'> & {
   Omit<ViewProps, 'query' | 'start' | 'end'> & {
@@ -81,7 +81,7 @@ function VitalChartMetrics({
     <Panel>
     <Panel>
       <ChartContainer>
       <ChartContainer>
         <HeaderTitleLegend>
         <HeaderTitleLegend>
-          {t('Duration p75')}
+          {getVitalChartTitle(vital)}
           <QuestionTooltip
           <QuestionTooltip
             size="sm"
             size="sm"
             position="top"
             position="top"