integrations/webVitals/webVitalsRouteSummary
此内容尚不支持你的语言。
Variables
Section titled “Variables”scoring
Section titled “scoring”const scoring: { good: number; needs-improvement: number; poor: number;};
Defined in: studiocms/packages/studiocms/src/integrations/webVitals/webVitalsRouteSummary.ts:104^
Type Declaration
Section titled “Type Declaration”good: number = 1;
needs-improvement
Section titled “needs-improvement”needs-improvement: number = 0.5;
poor: number = 0;
weighting
Section titled “weighting”const weighting: { CLS: number; INP: number; LCP: number;};
Defined in: studiocms/packages/studiocms/src/integrations/webVitals/webVitalsRouteSummary.ts:103^
Scoring Function: Computes a weighted score for core web vitals
Type Declaration
Section titled “Type Declaration”CLS: number = 0.3;
INP: number = 0.3;
LCP: number = 0.4;
Functions
Section titled “Functions”processWebVitalsRouteSummary()
Section titled “processWebVitalsRouteSummary()”function processWebVitalsRouteSummary(data: WebVitalsResponseItem[]): WebVitalsRouteSummary[];
Defined in: studiocms/packages/studiocms/src/integrations/webVitals/webVitalsRouteSummary.ts:25^
Processes an array of Web Vitals response items and returns a summary of web vitals for each route.
Parameters
Section titled “Parameters”An array of WebVitalsResponseItem objects representing the web vitals data.
Returns
Section titled “Returns”An array of WebVitalsRouteSummary objects summarizing the web vitals for each route.
The function performs the following steps:
- Groups the data by route and name.
- Processes each group separately, ensuring the sample size is at least 4.
- Sorts the metrics within each group by rating and value.
- Assigns quartiles to the metrics using NTILE(4) logic.
- Identifies the end of each quartile.
- Selects only the metrics in quartile 3 where quartile_end is true.
- Converts the selected metrics into WebVitalsRouteSummary structures.
The resulting summaries include the route, whether the route passes core web vitals, the metrics for LCP, CLS, and INP, and a score.
simpleScore()
Section titled “simpleScore()”function simpleScore( lcpRating: "good" | "needs-improvement" | "poor", clsRating: "good" | "needs-improvement" | "poor", inpRating: "good" | "needs-improvement" | "poor"): number;
Defined in: studiocms/packages/studiocms/src/integrations/webVitals/webVitalsRouteSummary.ts:106^
Parameters
Section titled “Parameters”lcpRating
Section titled “lcpRating”"good"
| "needs-improvement"
| "poor"
clsRating
Section titled “clsRating”"good"
| "needs-improvement"
| "poor"
inpRating
Section titled “inpRating”"good"
| "needs-improvement"
| "poor"
Returns
Section titled “Returns”number