@@ -8,7 +8,14 @@ import type * as Lantern from '../lantern/lantern.js';
88import * as Types from '../types/types.js' ;
99
1010import { getLogNormalScore } from './Statistics.js' ;
11- import type { InsightModels , InsightSet , InsightSetContext , MetricSavings , TraceInsightSets } from './types.js' ;
11+ import {
12+ InsightKeys ,
13+ type InsightModels ,
14+ type InsightSet ,
15+ type InsightSetContext ,
16+ type MetricSavings ,
17+ type TraceInsightSets
18+ } from './types.js' ;
1219
1320const GRAPH_SAVINGS_PRECISION = 50 ;
1421
@@ -34,7 +41,7 @@ export function getInsight<InsightName extends keyof InsightModels>(
3441
3542export function getLCP ( insights : TraceInsightSets | null , key : string | null ) :
3643 { value : Types . Timing . Micro , event : Types . Events . LargestContentfulPaintCandidate } | null {
37- const insight = getInsight ( 'LCPPhases' , insights , key ) ;
44+ const insight = getInsight ( InsightKeys . LCP_PHASES , insights , key ) ;
3845 if ( ! insight || ! insight . lcpMs || ! insight . lcpEvent ) {
3946 return null ;
4047 }
@@ -45,7 +52,7 @@ export function getLCP(insights: TraceInsightSets|null, key: string|null):
4552
4653export function getINP ( insights : TraceInsightSets | null , key : string | null ) :
4754 { value : Types . Timing . Micro , event : Types . Events . SyntheticInteractionPair } | null {
48- const insight = getInsight ( 'InteractionToNextPaint' , insights , key ) ;
55+ const insight = getInsight ( InsightKeys . INTERACTION_TO_NEXT_PAINT , insights , key ) ;
4956 if ( ! insight ?. longestInteractionEvent ?. dur ) {
5057 return null ;
5158 }
@@ -56,7 +63,7 @@ export function getINP(insights: TraceInsightSets|null, key: string|null):
5663
5764export function getCLS (
5865 insights : TraceInsightSets | null , key : string | null ) : { value : number , worstClusterEvent : Types . Events . Event | null } {
59- const insight = getInsight ( 'CLSCulprits' , insights , key ) ;
66+ const insight = getInsight ( InsightKeys . CLS_CULPRITS , insights , key ) ;
6067 if ( ! insight ) {
6168 // Unlike the other metrics, there is always a value for CLS even with no data.
6269 return { value : 0 , worstClusterEvent : null } ;
0 commit comments