File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
front_end/models/trace/insights Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 33// found in the LICENSE file.
44
55import * as i18n from '../../../core/i18n/i18n.js' ;
6- import type * as Handlers from '../handlers/handlers.js' ;
6+ import * as Handlers from '../handlers/handlers.js' ;
77import * as Helpers from '../helpers/helpers.js' ;
88import type { SyntheticInteractionPair } from '../types/TraceEvents.js' ;
99import type * as Types from '../types/types.js' ;
@@ -67,13 +67,24 @@ export function isINPBreakdownInsight(insight: InsightModel): insight is INPBrea
6767}
6868
6969function finalize ( partialModel : PartialInsightModel < INPBreakdownInsightModel > ) : INPBreakdownInsightModel {
70+ let state : INPBreakdownInsightModel [ 'state' ] = 'pass' ;
71+ if ( partialModel . longestInteractionEvent ) {
72+ const classification = Handlers . ModelHandlers . UserInteractions . scoreClassificationForInteractionToNextPaint (
73+ partialModel . longestInteractionEvent . dur ) ;
74+ if ( classification === Handlers . ModelHandlers . PageLoadMetrics . ScoreClassification . GOOD ) {
75+ state = 'informative' ;
76+ } else {
77+ state = 'fail' ;
78+ }
79+ }
80+
7081 return {
7182 insightKey : InsightKeys . INP_BREAKDOWN ,
7283 strings : UIStrings ,
7384 title : i18nString ( UIStrings . title ) ,
7485 description : i18nString ( UIStrings . description ) ,
7586 category : InsightCategory . INP ,
76- state : partialModel . longestInteractionEvent ? 'informative' : 'pass' ,
87+ state,
7788 ...partialModel ,
7889 } ;
7990}
Original file line number Diff line number Diff line change @@ -180,13 +180,25 @@ function finalize(partialModel: PartialInsightModel<LCPBreakdownInsightModel>):
180180 if ( partialModel . lcpRequest ) {
181181 relatedEvents . push ( partialModel . lcpRequest ) ;
182182 }
183+
184+ let state : LCPBreakdownInsightModel [ 'state' ] = 'pass' ;
185+ if ( partialModel . lcpMs !== undefined ) {
186+ const classification = Handlers . ModelHandlers . PageLoadMetrics . scoreClassificationForLargestContentfulPaint (
187+ Helpers . Timing . milliToMicro ( partialModel . lcpMs ) ) ;
188+ if ( classification === Handlers . ModelHandlers . PageLoadMetrics . ScoreClassification . GOOD ) {
189+ state = 'informative' ;
190+ } else {
191+ state = 'fail' ;
192+ }
193+ }
194+
183195 return {
184196 insightKey : InsightKeys . LCP_BREAKDOWN ,
185197 strings : UIStrings ,
186198 title : i18nString ( UIStrings . title ) ,
187199 description : i18nString ( UIStrings . description ) ,
188200 category : InsightCategory . LCP ,
189- state : partialModel . lcpEvent || partialModel . lcpRequest ? 'informative' : 'pass' ,
201+ state,
190202 ...partialModel ,
191203 relatedEvents,
192204 } ;
You can’t perform that action at this time.
0 commit comments