subcollection
Version:
A collection of scripts to send Core Web Vital data to GA4
33 lines (26 loc) • 696 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getCLSRating = getCLSRating;
var _getConstants = require("./getConstants");
/**
* getCLSRating
* Determines whether a CLS score is good, average, or poor.
*
* @param {number} value value of the CLS metric
* @returns {string} the string value rating
*/
function getCLSRating(value) {
var accurate = value * 1000;
if (accurate < 0 || typeof accurate !== 'number') {
return _getConstants.NO_RATING;
}
if (accurate <= 100) {
return _getConstants.GOOD_SCORE;
}
if (accurate > 100 && accurate < 250) {
return _getConstants.AVERAGE_SCORE;
}
return _getConstants.POOR_SCORE;
}