Skip to main content
InterviewHubPRO
Section Overview
Q46

Question 46 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

92%
Web Vitals & Performance (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Real User Monitoring (RUM) with `PerformanceObserver`.

senior LevelCode ExampleFormsPerformanceSystem Design

In Simple Words: Collect user-centric Core Web Vitals directly from users' browsers and beacon metrics back to observability endpoints:

javascript
import { onCLS, onINP, onLCP } from 'web-vitals';

function sendToAnalytics(metric) {
  const body = JSON.stringify({ name: metric.name, value: metric.value, rating: metric.rating });
  // navigator.sendBeacon ensures data delivery even if user closes the tab immediately
  navigator.sendBeacon('/api/telemetry', body);
}

onCLS(sendToAnalytics);
onINP(sendToAnalytics);
onLCP(sendToAnalytics);