Skip to content

Commit ef64c9c

Browse files
authored
fix(trace-view): Web Vitals scores (#81945)
The previous formula was incorrect, we need to divide the score by the weight before multiplying by 100.
1 parent 0b51b12 commit ef64c9c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Diff for: static/app/views/performance/newTraceDetails/traceContextVitals.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ export function TraceContextVitals({tree}: Props) {
4242
}
4343

4444
const colors = theme.charts.getColorPalette(3);
45-
const score = Math.round(vital.score * 100);
4645

4746
return (
4847
<VitalMeter
4948
key={vital.key}
5049
webVital={vital.key as WebVitals}
51-
score={score}
50+
score={vital.score}
5251
meterValue={vital.measurement.value}
5352
showTooltip
5453
color={colors[index]}

Diff for: static/app/views/performance/newTraceDetails/traceModels/traceTree.measurements.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ export function collectTraceMeasurements(
125125
WEB_VITALS_LOOKUP.has(measurement) && vital_types.add('web');
126126
MOBILE_VITALS_LOOKUP.has(measurement) && vital_types.add('mobile');
127127

128-
const score = measurements[`score.${measurement}`]?.value;
128+
const score = Math.round(
129+
(measurements[`score.${measurement}`]?.value /
130+
measurements[`score.weight.${measurement}`]?.value) *
131+
100
132+
);
129133

130134
const vital = vitals.get(node)!;
131135
vital.push({

0 commit comments

Comments
 (0)