-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(insights): score ring and breakdown chart drop missing vital seg…
…ments (#82686) Currently in the Web Vitals module, if a specific vital is never reported in the organization or project, we just assume that the score of the vital is 0. However, this is misleading to the user, since the score is not actually 0. Instead, we want to handle missing vitals by excluding them from and score calculation. This means dropping missing vitals from the score ring and rebalancing the score breakdown timeseries in the frontend.
- Loading branch information
1 parent
14ff41f
commit 48932ae
Showing
15 changed files
with
128 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 0 additions & 102 deletions
102
...ghts/browser/webVitals/queries/storedScoreQueries/calculatePerformanceScoreFromStored.tsx
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
...sights/browser/webVitals/queries/storedScoreQueries/getWebVitalScoresFromTableDataRow.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import type {TableDataRow} from 'sentry/utils/discover/discoverQuery'; | ||
import type { | ||
ProjectScore, | ||
WebVitals, | ||
} from 'sentry/views/insights/browser/webVitals/types'; | ||
|
||
function getWebVitalScore(data: TableDataRow, webVital: WebVitals): number { | ||
return (data[`performance_score(measurements.score.${webVital})`] as number) * 100; | ||
} | ||
|
||
function getTotalScore(data: TableDataRow): number { | ||
return (data[`avg(measurements.score.total)`] as number) * 100; | ||
} | ||
|
||
function getWebVitalScoreCount( | ||
data: TableDataRow, | ||
webVital: WebVitals | 'total' | ||
): number { | ||
return data[`count_scores(measurements.score.${webVital})`] as number; | ||
} | ||
|
||
function hasWebVitalScore(data: TableDataRow, webVital: WebVitals): boolean { | ||
if (data.hasOwnProperty(`count_scores(measurements.score.${webVital})`)) { | ||
return getWebVitalScoreCount(data, webVital) > 0; | ||
} | ||
return false; | ||
} | ||
|
||
export function getWebVitalScoresFromTableDataRow(data?: TableDataRow): ProjectScore { | ||
if (!data) { | ||
return {}; | ||
} | ||
|
||
const [hasLcp, hasFcp, hasCls, hasTtfb, hasInp] = [ | ||
'lcp', | ||
'fcp', | ||
'cls', | ||
'ttfb', | ||
'inp', | ||
].map(webVital => hasWebVitalScore(data, webVital as WebVitals)); | ||
|
||
return { | ||
lcpScore: hasLcp ? Math.round(getWebVitalScore(data, 'lcp')) : undefined, | ||
fcpScore: hasFcp ? Math.round(getWebVitalScore(data, 'fcp')) : undefined, | ||
clsScore: hasCls ? Math.round(getWebVitalScore(data, 'cls')) : undefined, | ||
ttfbScore: hasTtfb ? Math.round(getWebVitalScore(data, 'ttfb')) : undefined, | ||
inpScore: hasInp ? Math.round(getWebVitalScore(data, 'inp')) : undefined, | ||
totalScore: Math.round(getTotalScore(data)), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 20 additions & 3 deletions
23
static/app/views/insights/browser/webVitals/utils/applyStaticWeightsToTimeseries.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
static/app/views/insights/browser/webVitals/utils/getWeights.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {ORDER} from 'sentry/views/insights/browser/webVitals/components/charts/performanceScoreChart'; | ||
import type {WebVitals} from 'sentry/views/insights/browser/webVitals/types'; | ||
import {PERFORMANCE_SCORE_WEIGHTS} from 'sentry/views/insights/browser/webVitals/utils/scoreThresholds'; | ||
|
||
export function getWeights(webVitals: WebVitals[] = []): Record<WebVitals, number> { | ||
const totalWeight = ORDER.filter(webVital => webVitals.includes(webVital)).reduce( | ||
(acc, webVital) => acc + PERFORMANCE_SCORE_WEIGHTS[webVital], | ||
0 | ||
); | ||
return Object.keys(PERFORMANCE_SCORE_WEIGHTS).reduce( | ||
(acc, webVital) => { | ||
acc[webVital] = | ||
(webVitals.includes(webVital as WebVitals) | ||
? PERFORMANCE_SCORE_WEIGHTS[webVital] * 100 | ||
: 0) / totalWeight; | ||
return acc; | ||
}, | ||
{} as Record<WebVitals, number> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.