Dung (Donny) Nguyen

Senior Software Engineer

Monitoring

What Is Monitoring?

Monitoring is the practice of continuously observing a running application to understand its health, behavior, and performance in the real world. Once your React app is deployed, you can no longer see what happens on every user’s device — monitoring gives you that visibility by collecting errors, performance metrics, and usage data and surfacing them in dashboards and alerts.

In short: tests tell you the app works before release, and monitoring tells you how it behaves after release, in the hands of real users.

Why Monitoring Matters

What to Monitor

Monitoring for a frontend app generally falls into a few categories:

Error Tracking

Capturing JavaScript exceptions, unhandled promise rejections, and React render errors — along with the stack trace, browser, and steps that led to them.

Performance Monitoring

Measuring how fast pages load and respond. The key metrics are the Core Web Vitals:

Real User Monitoring (RUM)

Collecting performance and behavior data from actual users’ browsers, giving you a true picture across many devices, networks, and locations.

Session & Behavior Data

Recording user sessions, navigation paths, and interactions to reproduce bugs and understand how features are used.

Error Boundaries in React

React provides a built-in way to catch rendering errors so a single broken component doesn’t crash the whole app: an Error Boundary. It’s a component that catches errors in its child tree, displays a fallback UI, and gives you a hook to report the error to your monitoring service.

import { Component } from 'react';

class ErrorBoundary extends Component {
  state = { hasError: false };

  static getDerivedStateFromError() {
    return { hasError: true };
  }

  componentDidCatch(error, info) {
    // Send the error to your monitoring service
    reportError(error, info);
  }

  render() {
    if (this.state.hasError) {
      return <h2>Something went wrong.</h2>;
    }
    return this.props.children;
  }
}

export default ErrorBoundary;

Wrap parts of your app that should fail gracefully:

<ErrorBoundary>
  <Dashboard />
</ErrorBoundary>

Error boundaries catch errors during rendering, in lifecycle methods, and in constructors — but not in event handlers or async code, which you report manually with a try/catch.

Monitoring Tools

Sentry

Sentry is one of the most popular error and performance monitoring tools for React. It captures exceptions with full stack traces, tracks Core Web Vitals, and can record session replays.

import * as Sentry from '@sentry/react';

Sentry.init({
  dsn: 'https://your-dsn@sentry.io/project-id',
  integrations: [Sentry.browserTracingIntegration()],
  tracesSampleRate: 1.0,
});

Sentry also provides its own error boundary component that reports automatically:

<Sentry.ErrorBoundary fallback={<p>An error occurred</p>}>
  <App />
</Sentry.ErrorBoundary>

LogRocket

LogRocket focuses on session replay — it records a video-like playback of what the user saw and did, combined with console logs, network requests, and Redux state, making hard-to-reproduce bugs easy to diagnose.

Other Tools

Alerting

Collecting data is only useful if someone acts on it. Alerts notify your team when something crosses a threshold, for example:

Alerts are typically delivered to email, Slack, or on-call tools like PagerDuty so problems get attention quickly.

Best Practices

Summary

Monitoring closes the loop between deployment and the real world, showing you how your React app actually performs and where it fails for real users. Error tracking surfaces crashes, performance monitoring measures Core Web Vitals, and real user monitoring reveals the true experience across devices. React’s Error Boundaries let you fail gracefully and report problems, while tools like Sentry and LogRocket collect the data and alert your team — so you can fix issues before they affect more users.