CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-cra-template-typescript

The official TypeScript template for Create React App providing preconfigured TypeScript support and development environment setup.

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-5/

Core Web Performance Reporter

A lightweight entry point that wires optional collection of core web performance metrics and forwards them to callbacks or endpoints.

Capabilities

Optional setup

  • If called without a handler or endpoint, it performs no setup and avoids loading the measurement library. @test

Callback reporting

  • With a callback provided, it begins measuring CLS, FID, FCP, LCP, and TTFB and calls the callback once per metric with the library-provided metric object. @test

Network forwarding

  • When an endpoint URL is provided, it sends a POST request per metric using the metric object as JSON with a configurable fetch implementation. @test

Dual destinations

  • When both callback and endpoint are provided, each metric is delivered to both exactly once. @test

Implementation

@generates

API

export type CoreVitalName = 'CLS' | 'FID' | 'FCP' | 'LCP' | 'TTFB';

export interface VitalMetric {
  name: CoreVitalName;
  value: number;
  id: string;
  delta: number;
  rating: 'good' | 'needs-improvement' | 'poor';
  entries: PerformanceEntry[];
}

export interface ReporterOptions {
  onReport?: (metric: VitalMetric) => void;
  endpoint?: string;
  fetchImpl?: typeof fetch;
}

export function startWebPerformanceReporting(options?: ReporterOptions): void;

Dependencies { .dependencies }

web-vitals { .dependency }

Collects Core Web Vitals metrics on demand and supplies the measurement objects. @satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-cra-template-typescript

tile.json