Browse Source

chore(insights): Remove Webvitals static weight feature check (#74500)

Removes unneeded feature check due to GA
edwardgou-sentry 7 months ago
parent
commit
0ee08a0e27

+ 1 - 36
static/app/views/insights/browser/webVitals/components/charts/performanceScoreBreakdownChart.spec.tsx

@@ -14,7 +14,7 @@ jest.mock('sentry/utils/usePageFilters');
 
 describe('PerformanceScoreBreakdownChart', function () {
   const organization = OrganizationFixture();
-  let eventsMock, eventsStatsMock;
+  let eventsStatsMock;
 
   beforeEach(function () {
     jest.mocked(useLocation).mockReturnValue({
@@ -43,12 +43,6 @@ describe('PerformanceScoreBreakdownChart', function () {
       },
     });
 
-    eventsMock = MockApiClient.addMockResponse({
-      url: `/organizations/${organization.slug}/events/`,
-      body: {
-        data: [],
-      },
-    });
     eventsStatsMock = MockApiClient.addMockResponse({
       url: `/organizations/${organization.slug}/events-stats/`,
       body: {},
@@ -71,35 +65,6 @@ describe('PerformanceScoreBreakdownChart', function () {
     });
     render(<PerformanceScoreBreakdownChart />, {organization});
     await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
-    expect(eventsMock).toHaveBeenCalledTimes(1);
-    expect(eventsMock).toHaveBeenCalledWith(
-      '/organizations/org-slug/events/',
-      expect.objectContaining({
-        method: 'GET',
-        query: expect.objectContaining({
-          field: [
-            'performance_score(measurements.score.lcp)',
-            'performance_score(measurements.score.fcp)',
-            'performance_score(measurements.score.cls)',
-            'performance_score(measurements.score.inp)',
-            'performance_score(measurements.score.ttfb)',
-            'avg(measurements.score.total)',
-            'avg(measurements.score.weight.lcp)',
-            'avg(measurements.score.weight.fcp)',
-            'avg(measurements.score.weight.cls)',
-            'avg(measurements.score.weight.inp)',
-            'avg(measurements.score.weight.ttfb)',
-            'count()',
-            'count_scores(measurements.score.total)',
-            'count_scores(measurements.score.lcp)',
-            'count_scores(measurements.score.fcp)',
-            'count_scores(measurements.score.cls)',
-            'count_scores(measurements.score.ttfb)',
-            'count_scores(measurements.score.inp)',
-          ],
-        }),
-      })
-    );
 
     expect(eventsStatsMock).toHaveBeenCalledWith(
       '/organizations/org-slug/events-stats/',

+ 3 - 26
static/app/views/insights/browser/webVitals/components/charts/performanceScoreBreakdownChart.tsx

@@ -7,8 +7,6 @@ import {space} from 'sentry/styles/space';
 import type {Series} from 'sentry/types/echarts';
 import usePageFilters from 'sentry/utils/usePageFilters';
 import {ORDER} from 'sentry/views/insights/browser/webVitals/components/charts/performanceScoreChart';
-import {calculatePerformanceScoreFromStoredTableDataRow} from 'sentry/views/insights/browser/webVitals/queries/storedScoreQueries/calculatePerformanceScoreFromStored';
-import {useProjectWebVitalsScoresQuery} from 'sentry/views/insights/browser/webVitals/queries/storedScoreQueries/useProjectWebVitalsScoresQuery';
 import {
   useProjectWebVitalsScoresTimeseriesQuery,
   type WebVitalsScoreBreakdown,
@@ -16,7 +14,6 @@ import {
 import {applyStaticWeightsToTimeseries} from 'sentry/views/insights/browser/webVitals/utils/applyStaticWeightsToTimeseries';
 import type {BrowserType} from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
 import {PERFORMANCE_SCORE_WEIGHTS} from 'sentry/views/insights/browser/webVitals/utils/scoreThresholds';
-import {useStaticWeightsSetting} from 'sentry/views/insights/browser/webVitals/utils/useStaticWeightsSetting';
 import Chart, {ChartType} from 'sentry/views/insights/common/components/chart';
 
 type Props = {
@@ -54,22 +51,12 @@ export function PerformanceScoreBreakdownChart({transaction, browserTypes}: Prop
 
   const {data: timeseriesData, isLoading: isTimeseriesLoading} =
     useProjectWebVitalsScoresTimeseriesQuery({transaction, browserTypes});
-  const {data: projectScores, isLoading: isProjectScoresLoading} =
-    useProjectWebVitalsScoresQuery({transaction, browserTypes});
-
-  const projectScore = isProjectScoresLoading
-    ? undefined
-    : calculatePerformanceScoreFromStoredTableDataRow(projectScores?.data?.[0]);
 
   const period = pageFilters.selection.datetime.period;
   const performanceScoreSubtext = (period && DEFAULT_RELATIVE_PERIODS[period]) ?? '';
   const chartSeriesOrder = ORDER;
 
-  const shouldUseStaticWeights = useStaticWeightsSetting();
-
-  const weightedTimeseriesData = shouldUseStaticWeights
-    ? applyStaticWeightsToTimeseries(timeseriesData)
-    : timeseriesData;
+  const weightedTimeseriesData = applyStaticWeightsToTimeseries(timeseriesData);
 
   const weightedTimeseries = formatTimeSeriesResultsToChartData(
     weightedTimeseriesData,
@@ -93,17 +80,7 @@ export function PerformanceScoreBreakdownChart({transaction, browserTypes}: Prop
   );
 
   const weightsSeries = weightedTimeseries[0].data.map(({name}) => {
-    const value = shouldUseStaticWeights
-      ? PERFORMANCE_SCORE_WEIGHTS
-      : projectScore !== undefined
-        ? {
-            lcp: projectScore.lcpWeight,
-            fcp: projectScore.fcpWeight,
-            inp: projectScore.inpWeight,
-            cls: projectScore.clsWeight,
-            ttfb: projectScore.ttfbWeight,
-          }
-        : undefined;
+    const value = PERFORMANCE_SCORE_WEIGHTS;
     return {name, value};
   });
 
@@ -117,7 +94,7 @@ export function PerformanceScoreBreakdownChart({transaction, browserTypes}: Prop
         height={180}
         data={isTimeseriesLoading ? [] : weightedTimeseries}
         disableXAxis
-        loading={isTimeseriesLoading || isProjectScoresLoading}
+        loading={isTimeseriesLoading}
         type={ChartType.AREA}
         grid={{
           left: 5,

+ 1 - 14
static/app/views/insights/browser/webVitals/components/performanceScoreRingWithTooltips.tsx

@@ -17,7 +17,6 @@ import type {
   WebVitals,
 } from 'sentry/views/insights/browser/webVitals/types';
 import {PERFORMANCE_SCORE_WEIGHTS} from 'sentry/views/insights/browser/webVitals/utils/scoreThresholds';
-import {useStaticWeightsSetting} from 'sentry/views/insights/browser/webVitals/utils/useStaticWeightsSetting';
 import {useModuleURL} from 'sentry/views/insights/common/utils/useModuleURL';
 
 import {getFormattedDuration} from './webVitalMeters';
@@ -163,19 +162,7 @@ function PerformanceScoreRingWithTooltips({
     });
   }
 
-  const shouldUseStaticWeights = useStaticWeightsSetting();
-  const weights =
-    ['lcpWeight', 'fcpWeight', 'inpWeight', 'clsWeight', 'ttfbWeight'].every(
-      key => projectScore[key] === 0
-    ) || shouldUseStaticWeights
-      ? PERFORMANCE_SCORE_WEIGHTS
-      : {
-          lcp: projectScore.lcpWeight,
-          fcp: projectScore.fcpWeight,
-          inp: projectScore.inpWeight,
-          cls: projectScore.clsWeight,
-          ttfb: projectScore.ttfbWeight,
-        };
+  const weights = PERFORMANCE_SCORE_WEIGHTS;
 
   const commonWebVitalLabelProps = {
     organization,

+ 2 - 2
static/app/views/insights/browser/webVitals/components/tables/pagePerformanceTable.spec.tsx

@@ -124,7 +124,7 @@ describe('PagePerformanceTable', function () {
     });
     render(<PagePerformanceTable />, {organization});
     await waitFor(() => {
-      expect(eventsMock).toHaveBeenCalledTimes(2);
+      expect(eventsMock).toHaveBeenCalledTimes(1);
       expect(eventsMock).toHaveBeenLastCalledWith(
         '/organizations/org-slug/events/',
         expect.objectContaining({
@@ -172,6 +172,6 @@ describe('PagePerformanceTable', function () {
     expect(screen.getByRole('cell', {name: '0.18'})).toBeInTheDocument();
     expect(screen.getByRole('cell', {name: '783ms'})).toBeInTheDocument();
     expect(screen.getByRole('cell', {name: 'Meh 85'})).toBeInTheDocument();
-    expect(screen.getByRole('cell', {name: '18.25'})).toBeInTheDocument();
+    expect(screen.getByRole('cell', {name: '0.01'})).toBeInTheDocument();
   });
 });

+ 3 - 14
static/app/views/insights/browser/webVitals/components/tables/pagePerformanceTable.tsx

@@ -25,13 +25,11 @@ import {escapeFilterValue} from 'sentry/utils/tokenizeSearch';
 import {useLocation} from 'sentry/utils/useLocation';
 import useOrganization from 'sentry/utils/useOrganization';
 import {PerformanceBadge} from 'sentry/views/insights/browser/webVitals/components/performanceBadge';
-import {useProjectWebVitalsScoresQuery} from 'sentry/views/insights/browser/webVitals/queries/storedScoreQueries/useProjectWebVitalsScoresQuery';
 import {useTransactionWebVitalsScoresQuery} from 'sentry/views/insights/browser/webVitals/queries/storedScoreQueries/useTransactionWebVitalsScoresQuery';
 import {MODULE_DOC_LINK} from 'sentry/views/insights/browser/webVitals/settings';
 import type {RowWithScoreAndOpportunity} from 'sentry/views/insights/browser/webVitals/types';
 import {SORTABLE_FIELDS} from 'sentry/views/insights/browser/webVitals/types';
 import decodeBrowserTypes from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
-import {useStaticWeightsSetting} from 'sentry/views/insights/browser/webVitals/utils/useStaticWeightsSetting';
 import {useWebVitalsSort} from 'sentry/views/insights/browser/webVitals/utils/useWebVitalsSort';
 import {ModuleName, SpanIndexedField} from 'sentry/views/insights/types';
 
@@ -64,7 +62,6 @@ const DEFAULT_SORT: Sort = {
 export function PagePerformanceTable() {
   const location = useLocation();
   const organization = useOrganization();
-  const shouldUseStaticWeights = useStaticWeightsSetting();
 
   const columnOrder = COLUMN_ORDER;
 
@@ -72,8 +69,6 @@ export function PagePerformanceTable() {
   const browserTypes = decodeBrowserTypes(location.query[SpanIndexedField.BROWSER_NAME]);
 
   const sort = useWebVitalsSort({defaultSort: DEFAULT_SORT});
-  const {data: projectScoresData, isLoading: isProjectScoresLoading} =
-    useProjectWebVitalsScoresQuery({browserTypes});
 
   const {
     data,
@@ -88,15 +83,9 @@ export function PagePerformanceTable() {
     browserTypes,
   });
 
-  const scoreCount = projectScoresData?.data?.[0]?.[
-    'count_scores(measurements.score.total)'
-  ] as number;
-
   const tableData: RowWithScoreAndOpportunity[] = data.map(row => ({
     ...row,
-    opportunity:
-      (((row as RowWithScoreAndOpportunity).opportunity ?? 0) * 100) /
-      (shouldUseStaticWeights ? 1 : scoreCount), // static weight keys are already normalized
+    opportunity: ((row as RowWithScoreAndOpportunity).opportunity ?? 0) * 100,
   }));
   const getFormattedDuration = (value: number) => {
     return getDuration(value, value < 1 ? 0 : 2, true);
@@ -310,7 +299,7 @@ export function PagePerformanceTable() {
         />
         <StyledPagination
           pageLinks={pageLinks}
-          disabled={isProjectScoresLoading || isTransactionWebVitalsQueryLoading}
+          disabled={isTransactionWebVitalsQueryLoading}
           size="md"
         />
         {/* The Pagination component disappears if pageLinks is not defined,
@@ -336,7 +325,7 @@ export function PagePerformanceTable() {
       <GridContainer>
         <GridEditable
           aria-label={t('Pages')}
-          isLoading={isProjectScoresLoading || isTransactionWebVitalsQueryLoading}
+          isLoading={isTransactionWebVitalsQueryLoading}
           columnOrder={columnOrder}
           columnSortBy={[]}
           data={tableData}

+ 2 - 2
static/app/views/insights/browser/webVitals/components/webVitalsDetailPanel.spec.tsx

@@ -100,7 +100,7 @@ describe('WebVitalsDetailPanel', function () {
             'performance_score(measurements.score.cls)',
             `performance_score(measurements.score.inp)`,
             'performance_score(measurements.score.ttfb)',
-            'avg(measurements.score.total)',
+            'performance_score(measurements.score.total)',
             'avg(measurements.score.weight.lcp)',
             'avg(measurements.score.weight.fcp)',
             'avg(measurements.score.weight.cls)',
@@ -138,7 +138,7 @@ describe('WebVitalsDetailPanel', function () {
             'p75(measurements.inp)',
             'performance_score(measurements.score.lcp)',
             'opportunity_score(measurements.score.lcp)',
-            'avg(measurements.score.total)',
+            'performance_score(measurements.score.total)',
             'count()',
             'count_scores(measurements.score.lcp)',
             'count_scores(measurements.score.fcp)',

+ 1 - 6
static/app/views/insights/browser/webVitals/queries/storedScoreQueries/useProjectWebVitalsScoresQuery.tsx

@@ -9,7 +9,6 @@ import usePageFilters from 'sentry/utils/usePageFilters';
 import {DEFAULT_QUERY_FILTER} from 'sentry/views/insights/browser/webVitals/settings';
 import type {WebVitals} from 'sentry/views/insights/browser/webVitals/types';
 import type {BrowserType} from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
-import {useStaticWeightsSetting} from 'sentry/views/insights/browser/webVitals/utils/useStaticWeightsSetting';
 import {SpanIndexedField} from 'sentry/views/insights/types';
 
 type Props = {
@@ -32,7 +31,6 @@ export const useProjectWebVitalsScoresQuery = ({
   const organization = useOrganization();
   const pageFilters = usePageFilters();
   const location = useLocation();
-  const shouldUseStaticWeights = useStaticWeightsSetting();
 
   const search = new MutableSearch([]);
   if (transaction) {
@@ -53,9 +51,7 @@ export const useProjectWebVitalsScoresQuery = ({
         'performance_score(measurements.score.cls)',
         `performance_score(measurements.score.inp)`,
         'performance_score(measurements.score.ttfb)',
-        ...(shouldUseStaticWeights
-          ? ['performance_score(measurements.score.total)']
-          : ['avg(measurements.score.total)']),
+        'performance_score(measurements.score.total)',
         'avg(measurements.score.weight.lcp)',
         'avg(measurements.score.weight.fcp)',
         'avg(measurements.score.weight.cls)',
@@ -96,7 +92,6 @@ export const useProjectWebVitalsScoresQuery = ({
 
   // Map performance_score(measurements.score.total) to avg(measurements.score.total) so we don't have to handle both keys in the UI
   if (
-    shouldUseStaticWeights &&
     result.data?.data?.[0]?.['performance_score(measurements.score.total)'] !== undefined
   ) {
     result.data.data[0]['avg(measurements.score.total)'] =

+ 4 - 11
static/app/views/insights/browser/webVitals/queries/storedScoreQueries/useTransactionWebVitalsScoresQuery.tsx

@@ -13,7 +13,6 @@ import type {
   WebVitals,
 } from 'sentry/views/insights/browser/webVitals/types';
 import type {BrowserType} from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
-import {useStaticWeightsSetting} from 'sentry/views/insights/browser/webVitals/utils/useStaticWeightsSetting';
 import {useWebVitalsSort} from 'sentry/views/insights/browser/webVitals/utils/useWebVitalsSort';
 import {SpanIndexedField} from 'sentry/views/insights/types';
 
@@ -43,10 +42,9 @@ export const useTransactionWebVitalsScoresQuery = ({
   const organization = useOrganization();
   const pageFilters = usePageFilters();
   const location = useLocation();
-  const shouldUseStaticWeights = useStaticWeightsSetting();
 
   const sort = useWebVitalsSort({sortName, defaultSort});
-  if (sort !== undefined && shouldUseStaticWeights) {
+  if (sort !== undefined) {
     if (sort.field === 'avg(measurements.score.total)') {
       sort.field = 'performance_score(measurements.score.total)';
     }
@@ -80,9 +78,7 @@ export const useTransactionWebVitalsScoresQuery = ({
           ? [`performance_score(measurements.score.${webVital})`]
           : []),
         `opportunity_score(measurements.score.${webVital})`,
-        ...(shouldUseStaticWeights
-          ? ['performance_score(measurements.score.total)']
-          : ['avg(measurements.score.total)']),
+        'performance_score(measurements.score.total)',
         'count()',
         `count_scores(measurements.score.lcp)`,
         `count_scores(measurements.score.fcp)`,
@@ -117,10 +113,7 @@ export const useTransactionWebVitalsScoresQuery = ({
     !isLoading && data?.data.length
       ? data.data.map(row => {
           // Map back performance score key so we don't have to handle both keys in the UI
-          if (
-            shouldUseStaticWeights &&
-            row['performance_score(measurements.score.total)'] !== undefined
-          ) {
+          if (row['performance_score(measurements.score.total)'] !== undefined) {
             row['avg(measurements.score.total)'] =
               row['performance_score(measurements.score.total)'];
           }
@@ -159,7 +152,7 @@ export const useTransactionWebVitalsScoresQuery = ({
             inpScore: inpScore ?? 0,
             // Map back opportunity score key so we don't have to handle both keys in the UI
             opportunity: row[
-              shouldUseStaticWeights && webVital === 'total'
+              webVital === 'total'
                 ? 'total_opportunity_score()'
                 : `opportunity_score(measurements.score.${webVital})`
             ] as number,

+ 0 - 6
static/app/views/insights/browser/webVitals/utils/useStaticWeightsSetting.tsx

@@ -1,6 +0,0 @@
-import useOrganization from 'sentry/utils/useOrganization';
-
-export function useStaticWeightsSetting(): boolean {
-  const organization = useOrganization();
-  return organization.features.includes('insights-browser-webvitals-static-weights');
-}

+ 1 - 1
static/app/views/insights/browser/webVitals/views/pageOverview.spec.tsx

@@ -103,7 +103,7 @@ describe('PageOverview', function () {
             'performance_score(measurements.score.cls)',
             `performance_score(measurements.score.inp)`,
             'performance_score(measurements.score.ttfb)',
-            'avg(measurements.score.total)',
+            'performance_score(measurements.score.total)',
             'avg(measurements.score.weight.lcp)',
             'avg(measurements.score.weight.fcp)',
             'avg(measurements.score.weight.cls)',

Some files were not shown because too many files changed in this diff