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