Skip to content

Commit

Permalink
Record the google fonts exp when flushing CLS score (#36373)
Browse files Browse the repository at this point in the history
The new CLS metric uses a different path, and I forgot to check the Fonts experiment when it was calculated. We're probably missing all kinds of reports…. Gah.
  • Loading branch information
jridgewell committed Oct 15, 2021
1 parent 0e1956c commit 8e4c993
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/service/performance-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,26 +530,30 @@ export class Performance {
}
}

/** @private */
recordGoogleFontExp_() {
if (!this.googleFontExpRecorded_) {
this.googleFontExpRecorded_ = true;
const {win} = this;
const googleFontExp = parseInt(
computedStyle(win, win.document.body).getPropertyValue(
'--google-font-exp'
),
10
);
if (googleFontExp >= 0) {
this.addEnabledExperiment(`google-font-exp=${googleFontExp}`);
}
}
}

/**
* Tick the metrics whose values change over time.
* @private
*/
tickCumulativeMetrics_() {
if (this.supportsLayoutShift_) {
if (!this.googleFontExpRecorded_) {
this.googleFontExpRecorded_ = true;
const {win} = this;
const googleFontExp = parseInt(
computedStyle(win, win.document.body).getPropertyValue(
'--google-font-exp'
),
10
);
if (googleFontExp >= 0) {
this.addEnabledExperiment(`google-font-exp=${googleFontExp}`);
}
}

this.recordGoogleFontExp_();
this.tickCumulativeLayoutShiftScore_();
}
if (this.supportsLargestContentfulPaint_) {
Expand Down Expand Up @@ -613,6 +617,7 @@ export class Performance {
sum += entry.value;
}
entries.length = 0;
this.recordGoogleFontExp_();
if (old == null || sum > old) {
// We'll record the largest windowed CLS.
this.metrics_.reset(TickLabel.CUMULATIVE_LAYOUT_SHIFT);
Expand Down

0 comments on commit 8e4c993

Please sign in to comment.