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 🙏

© 2026 – Pkg Stats / Ryan Hefner

error-monitor-core

v1.0.3

Published

Core module for error monitoring SDK - A powerful, flexible error tracking solution for JavaScript applications

Downloads

366

Readme

error-monitor-core

Core module for error monitoring SDK - A powerful, flexible error tracking solution for JavaScript applications.

Features

  • 🎯 Error Capture: Automatically capture JavaScript errors, Promise rejections, and custom errors
  • 🍞 Breadcrumbs: Track user actions and application events leading up to errors
  • 🔌 Plugin System: Extensible architecture with lifecycle hooks
  • 📊 Context Management: Rich context information including user data, tags, and custom metadata
  • 🎛️ Sampling: Configurable sampling rates for optimal performance
  • 🚫 Filtering: Filter out unwanted errors by pattern or URL
  • 📦 Zero Dependencies: Lightweight core with minimal footprint

Installation

npm install error-monitor-core
# or
pnpm install error-monitor-core
# or
yarn add error-monitor-core

Quick Start

import { ErrorMonitor } from 'error-monitor-core'

// Initialize the monitor
const monitor = new ErrorMonitor({
  appId: 'your-app-id',
  dsn: 'https://your-error-server.com/collect',
  enabled: true
})

// Start monitoring
monitor.init()

// Capture errors manually
try {
  // Your code
} catch (error) {
  monitor.captureError(error)
}

// Capture custom messages
monitor.captureMessage('User clicked button', 'info', {
  extra: { buttonId: 'submit' }
})

// Add breadcrumbs
monitor.addBreadcrumb({
  type: 'navigation',
  message: 'User navigated to /dashboard',
  data: { from: '/home' }
})

// Set user information
monitor.setUser({
  id: 'user-123',
  username: 'john_doe',
  email: '[email protected]'
})

// Add tags
monitor.setTags({ environment: 'production', version: '1.0.0' })

Configuration

interface Config {
  // Basic
  appId: string                    // Your application ID
  dsn: string                      // Error collection server URL
  environment?: string             // Environment name (development, production, etc.)
  release?: string                 // Release version
  userId?: string                  // User ID
  tags?: Record<string, string>    // Custom tags

  // Sampling
  sampleRate?: number              // Overall sampling rate (0-1)
  errorSampleRate?: number         // Error-specific sampling rate (0-1)

  // Auto-capture options
  autoCapture?: {
    js?: boolean                   // Auto-capture JavaScript errors
    promise?: boolean              // Auto-capture Promise rejections
    network?: boolean              // Auto-capture network errors
    resource?: boolean             // Auto-capture resource loading errors
    console?: boolean              // Auto-capture console errors
  }

  // Filtering
  filter?: {
    ignoreErrors?: RegExp[]        // Error message patterns to ignore
    ignoreUrls?: RegExp[]           // URL patterns to ignore
    minLevel?: LogLevel             // Minimum error level to capture
  }

  // Reporting
  report?: {
    delay?: number                  // Batch reporting delay (ms)
    batchSize?: number              // Batch reporting size
    customReporter?: (data: ErrorReport) => void | Promise<void>
  }

  // Debug
  debug?: boolean                  // Enable debug logging
  enabled?: boolean                // Enable/disable monitoring
}

API

Constructor

new ErrorMonitor(config: Config)

Methods

init(): void

Initialize the error monitor.

capture(error: ErrorType | Error, options?: CaptureOptions): void

Capture an error or custom message.

captureError(error: Error, options?: CaptureOptions): void

Convenience method for capturing Error objects.

captureMessage(message: string, level?: LogLevel, options?: CaptureOptions): void

Capture a custom message with optional level.

addBreadcrumb(crumb: Breadcrumb): void

Add a breadcrumb to the tracking timeline.

setUser(user: User): void

Set user information for all future error reports.

setTags(tags: Record<string, string>): void

Set tags for all future error reports.

setSampleRate(rate: number): void

Set the overall sampling rate (0-1).

setErrorSampleRate(rate: number): void

Set the error-specific sampling rate (0-1).

addFilter(pattern: RegExp): void

Add an error filter pattern.

enable(): void

Enable error monitoring.

disable(): void

Disable error monitoring.

use(plugin: Plugin): void

Register a plugin.

destroy(): void

Cleanup and destroy the monitor instance.

Error Report Format

interface ErrorReport {
  appId: string
  timestamp: number
  sessionId: string
  eventId: string

  type: string
  level: string
  message: string
  stack?: string

  context: {
    userAgent: string
    url: string
    viewport: { width: number; height: number }
    userId?: string
    tags?: Record<string, string>
  }

  breadcrumbs: Breadcrumb[]
  extra?: Record<string, any>
}

Plugins

Create custom plugins to extend functionality:

const myPlugin = {
  name: 'my-plugin',

  setup(core) {
    // Called when plugin is registered
  },

  beforeCapture(error) {
    // Modify error before capture
    // Return null to skip capturing
    return error
  },

  afterCapture(report) {
    // Modify report after capture
    return report
  },

  beforeReport(report) {
    // Modify report before sending to server
    return report
  },

  teardown() {
    // Cleanup when monitor is destroyed
  }
}

monitor.use(myPlugin)

License

MIT

Support

For issues and questions, please visit our GitHub repository.