subcollection
Version:
A collection of scripts to send Core Web Vital data to GA4
46 lines (34 loc) • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getRating = getRating;
var _getFCPRating = require("../helpers/getFCPRating");
var _getCLSRating = require("../helpers/getCLSRating");
var _getLCPRating = require("../helpers/getLCPRating");
var _getTTFBRating = require("../helpers/getTTFBRating");
var _getFIDRating = require("../helpers/getFIDRating");
/**
* getRating
* Determines whether a FID score is good, average, or poor.
*
* @param {number} name name of the metric
* @param {number} value recorded value of the metric
* @returns {string} the accurate rating for each CWV metric
*/
function getRating(name, value) {
switch (name) {
case 'FCP':
return (0, _getFCPRating.getFCPRating)(value);
case 'CLS':
return (0, _getCLSRating.getCLSRating)(value);
case 'LCP':
return (0, _getLCPRating.getLCPRating)(value);
case 'TTFB':
return (0, _getTTFBRating.getTTFBRating)(value);
case 'FID':
return (0, _getFIDRating.getFIDRating)(value);
default:
return "".concat(name, " is not a valid rating");
}
}