npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-monitoring-kit

v1.1.4

Published

React error monitoring library for capturing and tracking application errors

Readme

React Monitoring Kit

React library for capturing and monitoring application-breaking errors.

Installation

npm install react-monitoring-kit

Basic Usage

import { ErrorMonitoringProvider } from 'react-monitoring-kit';

function App() {
  return (
    <ErrorMonitoringProvider
      config={{
        onError: (errorDetails) => {
          // Send to your logging service
          console.log('Error captured:', errorDetails);
          
          // Example: send to API
          fetch('/api/log-error', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify(errorDetails),
          });
        },
      }}
    >
      <YourApp />
    </ErrorMonitoringProvider>
  );
}

Features

  • Captures errors that break React components
  • Extracts detailed information (stack trace, component, URL, line, file)
  • Customizable context
  • TypeScript first
  • Zero required dependencies (except React)
  • Optional React Router support

Advanced Usage

With React Router

import { ErrorMonitoringProvider, useRouteTracking } from 'react-monitoring-kit';
import { BrowserRouter } from 'react-router-dom';

function RouteTracker() {
  useRouteTracking();
  return null;
}

function App() {
  return (
    <ErrorMonitoringProvider
      config={{
        onError: (errorDetails) => {
          // errorDetails.additionalContext.route will have route information
          console.log('Error on route:', errorDetails.additionalContext?.route);
        },
      }}
    >
      <BrowserRouter>
        <RouteTracker />
        <YourApp />
      </BrowserRouter>
    </ErrorMonitoringProvider>
  );
}

Adding Custom Context

import { useErrorMonitoring } from 'react-monitoring-kit';

function UserProfile({ userId }) {
  const { addContext, removeContext } = useErrorMonitoring();

  useEffect(() => {
    addContext('userId', userId);
    return () => removeContext('userId');
  }, [userId]);

  return <div>Profile</div>;
}

Using ErrorBoundary Directly

import { ErrorBoundary } from 'react-monitoring-kit';

function App() {
  return (
    <ErrorBoundary
      onError={(errorDetails) => {
        console.log('Error:', errorDetails);
      }}
      fallback={<div>Something went wrong</div>}
    >
      <ComponentThatMightError />
    </ErrorBoundary>
  );
}

API

ErrorDetails

Object with detailed error information:

interface ErrorDetails {
  // Basic data
  message: string;              // Error message
  name: string;                 // Error name (e.g., TypeError)
  stack?: string;               // Complete stack trace
  componentStack: string;       // React component tree
  
  // Structured information
  sourceFile?: string;          // Exact file where the error occurred
  sourceLine?: number;          // Exact line of the error
  sourceColumn?: number;        // Exact column of the error
  componentName?: string;       // Name of the React component that failed
  userStack?: string[];         // Filtered stack (only user code, no node_modules)
  
  // Context
  timestamp: Date;              // When the error occurred
  url: string;                  // URL where the error happened
  userAgent: string;            // User's browser
  additionalContext?: {         // Customizable additional context
    route?: object;             // Route information (if using useRouteTracking)
    // ... other contexts added via addContext
  };
}

Example of captured error:

{
  message: "Cannot read property 'map' of undefined",
  name: "TypeError",
  sourceFile: "http://localhost:5173/src/components/UserList.tsx",
  sourceLine: 42,
  sourceColumn: 15,
  componentName: "UserList",
  userStack: [
    "UserList@http://localhost:5173/src/components/UserList.tsx:42:15",
    "Dashboard@http://localhost:5173/src/pages/Dashboard.tsx:28:10"
  ],
  url: "http://localhost:5173/dashboard",
  timestamp: "2025-10-17T14:54:18.123Z"
}

License

MIT