Track Core Web Vitals and custom metrics

Performance Monitoring

Overseer automatically tracks Core Web Vitals and allows custom performance metrics.

Automatic Tracking

When enabled, Overseer tracks:

MetricDescription
LCPLargest Contentful Paint - loading performance
FIDFirst Input Delay - interactivity
CLSCumulative Layout Shift - visual stability
TTFBTime to First Byte - server response time
DOM LoadDOMContentLoaded event time
Page LoadFull page load time

Configuration

import { init } from '@codmir/sdk';

init({
  dsn: 'https://your-project.codmir.com/overseer',
  apiKey: 'osk_...',
  service: 'my-app',
  environment: 'production',
  
  // Enable performance tracking
  enablePerformance: true,
});

Custom Timings

@codmir/sdk times your own operations as spans. Set tracesSampleRate above 0 in init; spans are sent when the trace is sampled.

startSpan

Wrap any sync or async operation:

import { startSpan } from '@codmir/sdk/tracing';

// Time a database query
const users = await startSpan(
  { name: 'db.query.users', op: 'db' },
  () => prisma.user.findMany()
);

// Time an API call
const data = await startSpan(
  { name: 'api.external.weather', op: 'http' },
  () => fetch('https://api.weather.com/forecast')
);

Spans started inside another span become its children, so one request shows up as a single trace.

React Performance

Route Change Time

// Next.js App Router
'use client';

import { usePathname } from 'next/navigation';
import { addBreadcrumb } from '@codmir/sdk/nextjs';
import { useEffect, useRef } from 'react';

export function RouteTracker() {
  const pathname = usePathname();
  const startTime = useRef<number | null>(null);

  useEffect(() => {
    if (startTime.current) {
      const duration = performance.now() - startTime.current;
      addBreadcrumb({
        type: 'navigation',
        category: 'route.change',
        message: `to ${pathname}`,
        level: 'info',
        data: { durationMs: Math.round(duration) },
      });
    }
    startTime.current = performance.now();
  }, [pathname]);

  return null;
}

API Performance

Time API calls as spans:

import { addBreadcrumb } from '@codmir/sdk';
import { startSpan } from '@codmir/sdk/tracing';

async function apiCall(endpoint: string, options?: RequestInit) {
  addBreadcrumb({
    type: 'http',
    category: 'api.start',
    message: `${options?.method || 'GET'} ${endpoint}`,
    level: 'info',
  });

  return startSpan(
    { name: `api.${endpoint.replace(/\//g, '.')}`, op: 'http' },
    async () => {
      const response = await fetch(endpoint, options);
      return response.json();
    }
  );
}

Dashboard

View performance metrics in the Codmir dashboard:

  • Overview - Aggregate metrics across all users
  • Trends - Track performance over time
  • Breakdown - Filter by page, user, device
  • Alerts - Set thresholds for degradation alerts

Best Practices

  1. Track meaningful metrics - Focus on user-facing performance
  2. Use tags - Add context for filtering
  3. Set baselines - Establish performance budgets
  4. Monitor trends - Watch for regressions over time
  5. Correlate with errors - Slow performance often precedes errors