Skip to content

Commit 0ee08a0

Browse files
chore(insights): Remove Webvitals static weight feature check (#74500)
Removes unneeded feature check due to GA
1 parent 9a54412 commit 0ee08a0

13 files changed

+56
-162
lines changed

static/app/views/insights/browser/webVitals/components/charts/performanceScoreBreakdownChart.spec.tsx

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jest.mock('sentry/utils/usePageFilters');
1414

1515
describe('PerformanceScoreBreakdownChart', function () {
1616
const organization = OrganizationFixture();
17-
let eventsMock, eventsStatsMock;
17+
let eventsStatsMock;
1818

1919
beforeEach(function () {
2020
jest.mocked(useLocation).mockReturnValue({
@@ -43,12 +43,6 @@ describe('PerformanceScoreBreakdownChart', function () {
4343
},
4444
});
4545

46-
eventsMock = MockApiClient.addMockResponse({
47-
url: `/organizations/${organization.slug}/events/`,
48-
body: {
49-
data: [],
50-
},
51-
});
5246
eventsStatsMock = MockApiClient.addMockResponse({
5347
url: `/organizations/${organization.slug}/events-stats/`,
5448
body: {},
@@ -71,35 +65,6 @@ describe('PerformanceScoreBreakdownChart', function () {
7165
});
7266
render(<PerformanceScoreBreakdownChart />, {organization});
7367
await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
74-
expect(eventsMock).toHaveBeenCalledTimes(1);
75-
expect(eventsMock).toHaveBeenCalledWith(
76-
'/organizations/org-slug/events/',
77-
expect.objectContaining({
78-
method: 'GET',
79-
query: expect.objectContaining({
80-
field: [
81-
'performance_score(measurements.score.lcp)',
82-
'performance_score(measurements.score.fcp)',
83-
'performance_score(measurements.score.cls)',
84-
'performance_score(measurements.score.inp)',
85-
'performance_score(measurements.score.ttfb)',
86-
'avg(measurements.score.total)',
87-
'avg(measurements.score.weight.lcp)',
88-
'avg(measurements.score.weight.fcp)',
89-
'avg(measurements.score.weight.cls)',
90-
'avg(measurements.score.weight.inp)',
91-
'avg(measurements.score.weight.ttfb)',
92-
'count()',
93-
'count_scores(measurements.score.total)',
94-
'count_scores(measurements.score.lcp)',
95-
'count_scores(measurements.score.fcp)',
96-
'count_scores(measurements.score.cls)',
97-
'count_scores(measurements.score.ttfb)',
98-
'count_scores(measurements.score.inp)',
99-
],
100-
}),
101-
})
102-
);
10368

10469
expect(eventsStatsMock).toHaveBeenCalledWith(
10570
'/organizations/org-slug/events-stats/',

static/app/views/insights/browser/webVitals/components/charts/performanceScoreBreakdownChart.tsx

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@ import {space} from 'sentry/styles/space';
77
import type {Series} from 'sentry/types/echarts';
88
import usePageFilters from 'sentry/utils/usePageFilters';
99
import {ORDER} from 'sentry/views/insights/browser/webVitals/components/charts/performanceScoreChart';
10-
import {calculatePerformanceScoreFromStoredTableDataRow} from 'sentry/views/insights/browser/webVitals/queries/storedScoreQueries/calculatePerformanceScoreFromStored';
11-
import {useProjectWebVitalsScoresQuery} from 'sentry/views/insights/browser/webVitals/queries/storedScoreQueries/useProjectWebVitalsScoresQuery';
1210
import {
1311
useProjectWebVitalsScoresTimeseriesQuery,
1412
type WebVitalsScoreBreakdown,
1513
} from 'sentry/views/insights/browser/webVitals/queries/storedScoreQueries/useProjectWebVitalsScoresTimeseriesQuery';
1614
import {applyStaticWeightsToTimeseries} from 'sentry/views/insights/browser/webVitals/utils/applyStaticWeightsToTimeseries';
1715
import type {BrowserType} from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
1816
import {PERFORMANCE_SCORE_WEIGHTS} from 'sentry/views/insights/browser/webVitals/utils/scoreThresholds';
19-
import {useStaticWeightsSetting} from 'sentry/views/insights/browser/webVitals/utils/useStaticWeightsSetting';
2017
import Chart, {ChartType} from 'sentry/views/insights/common/components/chart';
2118

2219
type Props = {
@@ -54,22 +51,12 @@ export function PerformanceScoreBreakdownChart({transaction, browserTypes}: Prop
5451

5552
const {data: timeseriesData, isLoading: isTimeseriesLoading} =
5653
useProjectWebVitalsScoresTimeseriesQuery({transaction, browserTypes});
57-
const {data: projectScores, isLoading: isProjectScoresLoading} =
58-
useProjectWebVitalsScoresQuery({transaction, browserTypes});
59-
60-
const projectScore = isProjectScoresLoading
61-
? undefined
62-
: calculatePerformanceScoreFromStoredTableDataRow(projectScores?.data?.[0]);
6354

6455
const period = pageFilters.selection.datetime.period;
6556
const performanceScoreSubtext = (period && DEFAULT_RELATIVE_PERIODS[period]) ?? '';
6657
const chartSeriesOrder = ORDER;
6758

68-
const shouldUseStaticWeights = useStaticWeightsSetting();
69-
70-
const weightedTimeseriesData = shouldUseStaticWeights
71-
? applyStaticWeightsToTimeseries(timeseriesData)
72-
: timeseriesData;
59+
const weightedTimeseriesData = applyStaticWeightsToTimeseries(timeseriesData);
7360

7461
const weightedTimeseries = formatTimeSeriesResultsToChartData(
7562
weightedTimeseriesData,
@@ -93,17 +80,7 @@ export function PerformanceScoreBreakdownChart({transaction, browserTypes}: Prop
9380
);
9481

9582
const weightsSeries = weightedTimeseries[0].data.map(({name}) => {
96-
const value = shouldUseStaticWeights
97-
? PERFORMANCE_SCORE_WEIGHTS
98-
: projectScore !== undefined
99-
? {
100-
lcp: projectScore.lcpWeight,
101-
fcp: projectScore.fcpWeight,
102-
inp: projectScore.inpWeight,
103-
cls: projectScore.clsWeight,
104-
ttfb: projectScore.ttfbWeight,
105-
}
106-
: undefined;
83+
const value = PERFORMANCE_SCORE_WEIGHTS;
10784
return {name, value};
10885
});
10986

@@ -117,7 +94,7 @@ export function PerformanceScoreBreakdownChart({transaction, browserTypes}: Prop
11794
height={180}
11895
data={isTimeseriesLoading ? [] : weightedTimeseries}
11996
disableXAxis
120-
loading={isTimeseriesLoading || isProjectScoresLoading}
97+
loading={isTimeseriesLoading}
12198
type={ChartType.AREA}
12299
grid={{
123100
left: 5,

static/app/views/insights/browser/webVitals/components/performanceScoreRingWithTooltips.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import type {
1717
WebVitals,
1818
} from 'sentry/views/insights/browser/webVitals/types';
1919
import {PERFORMANCE_SCORE_WEIGHTS} from 'sentry/views/insights/browser/webVitals/utils/scoreThresholds';
20-
import {useStaticWeightsSetting} from 'sentry/views/insights/browser/webVitals/utils/useStaticWeightsSetting';
2120
import {useModuleURL} from 'sentry/views/insights/common/utils/useModuleURL';
2221

2322
import {getFormattedDuration} from './webVitalMeters';
@@ -163,19 +162,7 @@ function PerformanceScoreRingWithTooltips({
163162
});
164163
}
165164

166-
const shouldUseStaticWeights = useStaticWeightsSetting();
167-
const weights =
168-
['lcpWeight', 'fcpWeight', 'inpWeight', 'clsWeight', 'ttfbWeight'].every(
169-
key => projectScore[key] === 0
170-
) || shouldUseStaticWeights
171-
? PERFORMANCE_SCORE_WEIGHTS
172-
: {
173-
lcp: projectScore.lcpWeight,
174-
fcp: projectScore.fcpWeight,
175-
inp: projectScore.inpWeight,
176-
cls: projectScore.clsWeight,
177-
ttfb: projectScore.ttfbWeight,
178-
};
165+
const weights = PERFORMANCE_SCORE_WEIGHTS;
179166

180167
const commonWebVitalLabelProps = {
181168
organization,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('PagePerformanceTable', function () {
124124
});
125125
render(<PagePerformanceTable />, {organization});
126126
await waitFor(() => {
127-
expect(eventsMock).toHaveBeenCalledTimes(2);
127+
expect(eventsMock).toHaveBeenCalledTimes(1);
128128
expect(eventsMock).toHaveBeenLastCalledWith(
129129
'/organizations/org-slug/events/',
130130
expect.objectContaining({
@@ -172,6 +172,6 @@ describe('PagePerformanceTable', function () {
172172
expect(screen.getByRole('cell', {name: '0.18'})).toBeInTheDocument();
173173
expect(screen.getByRole('cell', {name: '783ms'})).toBeInTheDocument();
174174
expect(screen.getByRole('cell', {name: 'Meh 85'})).toBeInTheDocument();
175-
expect(screen.getByRole('cell', {name: '18.25'})).toBeInTheDocument();
175+
expect(screen.getByRole('cell', {name: '0.01'})).toBeInTheDocument();
176176
});
177177
});

static/app/views/insights/browser/webVitals/components/tables/pagePerformanceTable.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ import {escapeFilterValue} from 'sentry/utils/tokenizeSearch';
2525
import {useLocation} from 'sentry/utils/useLocation';
2626
import useOrganization from 'sentry/utils/useOrganization';
2727
import {PerformanceBadge} from 'sentry/views/insights/browser/webVitals/components/performanceBadge';
28-
import {useProjectWebVitalsScoresQuery} from 'sentry/views/insights/browser/webVitals/queries/storedScoreQueries/useProjectWebVitalsScoresQuery';
2928
import {useTransactionWebVitalsScoresQuery} from 'sentry/views/insights/browser/webVitals/queries/storedScoreQueries/useTransactionWebVitalsScoresQuery';
3029
import {MODULE_DOC_LINK} from 'sentry/views/insights/browser/webVitals/settings';
3130
import type {RowWithScoreAndOpportunity} from 'sentry/views/insights/browser/webVitals/types';
3231
import {SORTABLE_FIELDS} from 'sentry/views/insights/browser/webVitals/types';
3332
import decodeBrowserTypes from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
34-
import {useStaticWeightsSetting} from 'sentry/views/insights/browser/webVitals/utils/useStaticWeightsSetting';
3533
import {useWebVitalsSort} from 'sentry/views/insights/browser/webVitals/utils/useWebVitalsSort';
3634
import {ModuleName, SpanIndexedField} from 'sentry/views/insights/types';
3735

@@ -64,16 +62,13 @@ const DEFAULT_SORT: Sort = {
6462
export function PagePerformanceTable() {
6563
const location = useLocation();
6664
const organization = useOrganization();
67-
const shouldUseStaticWeights = useStaticWeightsSetting();
6865

6966
const columnOrder = COLUMN_ORDER;
7067

7168
const query = decodeScalar(location.query.query, '');
7269
const browserTypes = decodeBrowserTypes(location.query[SpanIndexedField.BROWSER_NAME]);
7370

7471
const sort = useWebVitalsSort({defaultSort: DEFAULT_SORT});
75-
const {data: projectScoresData, isLoading: isProjectScoresLoading} =
76-
useProjectWebVitalsScoresQuery({browserTypes});
7772

7873
const {
7974
data,
@@ -88,15 +83,9 @@ export function PagePerformanceTable() {
8883
browserTypes,
8984
});
9085

91-
const scoreCount = projectScoresData?.data?.[0]?.[
92-
'count_scores(measurements.score.total)'
93-
] as number;
94-
9586
const tableData: RowWithScoreAndOpportunity[] = data.map(row => ({
9687
...row,
97-
opportunity:
98-
(((row as RowWithScoreAndOpportunity).opportunity ?? 0) * 100) /
99-
(shouldUseStaticWeights ? 1 : scoreCount), // static weight keys are already normalized
88+
opportunity: ((row as RowWithScoreAndOpportunity).opportunity ?? 0) * 100,
10089
}));
10190
const getFormattedDuration = (value: number) => {
10291
return getDuration(value, value < 1 ? 0 : 2, true);
@@ -310,7 +299,7 @@ export function PagePerformanceTable() {
310299
/>
311300
<StyledPagination
312301
pageLinks={pageLinks}
313-
disabled={isProjectScoresLoading || isTransactionWebVitalsQueryLoading}
302+
disabled={isTransactionWebVitalsQueryLoading}
314303
size="md"
315304
/>
316305
{/* The Pagination component disappears if pageLinks is not defined,
@@ -336,7 +325,7 @@ export function PagePerformanceTable() {
336325
<GridContainer>
337326
<GridEditable
338327
aria-label={t('Pages')}
339-
isLoading={isProjectScoresLoading || isTransactionWebVitalsQueryLoading}
328+
isLoading={isTransactionWebVitalsQueryLoading}
340329
columnOrder={columnOrder}
341330
columnSortBy={[]}
342331
data={tableData}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ describe('WebVitalsDetailPanel', function () {
100100
'performance_score(measurements.score.cls)',
101101
`performance_score(measurements.score.inp)`,
102102
'performance_score(measurements.score.ttfb)',
103-
'avg(measurements.score.total)',
103+
'performance_score(measurements.score.total)',
104104
'avg(measurements.score.weight.lcp)',
105105
'avg(measurements.score.weight.fcp)',
106106
'avg(measurements.score.weight.cls)',
@@ -138,7 +138,7 @@ describe('WebVitalsDetailPanel', function () {
138138
'p75(measurements.inp)',
139139
'performance_score(measurements.score.lcp)',
140140
'opportunity_score(measurements.score.lcp)',
141-
'avg(measurements.score.total)',
141+
'performance_score(measurements.score.total)',
142142
'count()',
143143
'count_scores(measurements.score.lcp)',
144144
'count_scores(measurements.score.fcp)',

static/app/views/insights/browser/webVitals/queries/storedScoreQueries/useProjectWebVitalsScoresQuery.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import usePageFilters from 'sentry/utils/usePageFilters';
99
import {DEFAULT_QUERY_FILTER} from 'sentry/views/insights/browser/webVitals/settings';
1010
import type {WebVitals} from 'sentry/views/insights/browser/webVitals/types';
1111
import type {BrowserType} from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
12-
import {useStaticWeightsSetting} from 'sentry/views/insights/browser/webVitals/utils/useStaticWeightsSetting';
1312
import {SpanIndexedField} from 'sentry/views/insights/types';
1413

1514
type Props = {
@@ -32,7 +31,6 @@ export const useProjectWebVitalsScoresQuery = ({
3231
const organization = useOrganization();
3332
const pageFilters = usePageFilters();
3433
const location = useLocation();
35-
const shouldUseStaticWeights = useStaticWeightsSetting();
3634

3735
const search = new MutableSearch([]);
3836
if (transaction) {
@@ -53,9 +51,7 @@ export const useProjectWebVitalsScoresQuery = ({
5351
'performance_score(measurements.score.cls)',
5452
`performance_score(measurements.score.inp)`,
5553
'performance_score(measurements.score.ttfb)',
56-
...(shouldUseStaticWeights
57-
? ['performance_score(measurements.score.total)']
58-
: ['avg(measurements.score.total)']),
54+
'performance_score(measurements.score.total)',
5955
'avg(measurements.score.weight.lcp)',
6056
'avg(measurements.score.weight.fcp)',
6157
'avg(measurements.score.weight.cls)',
@@ -96,7 +92,6 @@ export const useProjectWebVitalsScoresQuery = ({
9692

9793
// Map performance_score(measurements.score.total) to avg(measurements.score.total) so we don't have to handle both keys in the UI
9894
if (
99-
shouldUseStaticWeights &&
10095
result.data?.data?.[0]?.['performance_score(measurements.score.total)'] !== undefined
10196
) {
10297
result.data.data[0]['avg(measurements.score.total)'] =

static/app/views/insights/browser/webVitals/queries/storedScoreQueries/useTransactionWebVitalsScoresQuery.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type {
1313
WebVitals,
1414
} from 'sentry/views/insights/browser/webVitals/types';
1515
import type {BrowserType} from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
16-
import {useStaticWeightsSetting} from 'sentry/views/insights/browser/webVitals/utils/useStaticWeightsSetting';
1716
import {useWebVitalsSort} from 'sentry/views/insights/browser/webVitals/utils/useWebVitalsSort';
1817
import {SpanIndexedField} from 'sentry/views/insights/types';
1918

@@ -43,10 +42,9 @@ export const useTransactionWebVitalsScoresQuery = ({
4342
const organization = useOrganization();
4443
const pageFilters = usePageFilters();
4544
const location = useLocation();
46-
const shouldUseStaticWeights = useStaticWeightsSetting();
4745

4846
const sort = useWebVitalsSort({sortName, defaultSort});
49-
if (sort !== undefined && shouldUseStaticWeights) {
47+
if (sort !== undefined) {
5048
if (sort.field === 'avg(measurements.score.total)') {
5149
sort.field = 'performance_score(measurements.score.total)';
5250
}
@@ -80,9 +78,7 @@ export const useTransactionWebVitalsScoresQuery = ({
8078
? [`performance_score(measurements.score.${webVital})`]
8179
: []),
8280
`opportunity_score(measurements.score.${webVital})`,
83-
...(shouldUseStaticWeights
84-
? ['performance_score(measurements.score.total)']
85-
: ['avg(measurements.score.total)']),
81+
'performance_score(measurements.score.total)',
8682
'count()',
8783
`count_scores(measurements.score.lcp)`,
8884
`count_scores(measurements.score.fcp)`,
@@ -117,10 +113,7 @@ export const useTransactionWebVitalsScoresQuery = ({
117113
!isLoading && data?.data.length
118114
? data.data.map(row => {
119115
// Map back performance score key so we don't have to handle both keys in the UI
120-
if (
121-
shouldUseStaticWeights &&
122-
row['performance_score(measurements.score.total)'] !== undefined
123-
) {
116+
if (row['performance_score(measurements.score.total)'] !== undefined) {
124117
row['avg(measurements.score.total)'] =
125118
row['performance_score(measurements.score.total)'];
126119
}
@@ -159,7 +152,7 @@ export const useTransactionWebVitalsScoresQuery = ({
159152
inpScore: inpScore ?? 0,
160153
// Map back opportunity score key so we don't have to handle both keys in the UI
161154
opportunity: row[
162-
shouldUseStaticWeights && webVital === 'total'
155+
webVital === 'total'
163156
? 'total_opportunity_score()'
164157
: `opportunity_score(measurements.score.${webVital})`
165158
] as number,

static/app/views/insights/browser/webVitals/utils/useStaticWeightsSetting.tsx

Lines changed: 0 additions & 6 deletions
This file was deleted.

static/app/views/insights/browser/webVitals/views/pageOverview.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe('PageOverview', function () {
103103
'performance_score(measurements.score.cls)',
104104
`performance_score(measurements.score.inp)`,
105105
'performance_score(measurements.score.ttfb)',
106-
'avg(measurements.score.total)',
106+
'performance_score(measurements.score.total)',
107107
'avg(measurements.score.weight.lcp)',
108108
'avg(measurements.score.weight.fcp)',
109109
'avg(measurements.score.weight.cls)',

0 commit comments

Comments
 (0)