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

errorsnap

v2.0.7

Published

A lightweight JavaScript error tracking library to capture and report runtime errors, unhandled promise rejections, and useful contextual breadcrumbs like user actions, navigation events, console logs, and network requests.

Downloads

25

Readme

ErrorSnap

A lightweight JavaScript error tracking library to capture and report runtime errors, unhandled promise rejections, and useful contextual breadcrumbs like user actions, navigation events, console logs, and network requests.

✨ Features

  • ✅ Global error capturing (window.onerror, unhandledrejection)
  • ✅ Breadcrumbs for user actions (clicks, navigation, console, fetch)
  • ✅ Manual error reporting
  • ✅ Custom user context
  • ✅ Local storage queue + background sending via navigator.sendBeacon
  • ✅ Simple API, framework-agnostic (vanilla JS)

🚀 Installation

Just import the library in your project.

npm install errorsnap
# or
yarn add errorsnap

Then in your code:

import ErrorSnap from 'errorsnap';

🛠️ Usage

1. Initialize ErrorSnap

ErrorSnap.init({
  endpoint: 'https://your-api.com/error-report', // required
  maxBreadcrumbs: 50, // optional (default: 30)
  env: 'DEVELOPMENT', // optional (default: PRODUCTION)
  consoleTypes: ['log', 'error'],  // optional (default: ['log', 'warn', 'error', 'info'])
  interval: 60    // optional (default: 60sec)
}, window);

2. Set user info (optional)

Attach user context to all error reports.

ErrorSnap.setUser({
  id: '12345',
  name: 'John Doe',
  email: '[email protected]',
});

3. Manually notify errors

Report manual or caught errors programmatically.

try {
  // your risky code
} catch (error) {
  ErrorSnap.notify(error);
}

4. Automatic breadcrumbs

ErrorSnap automatically tracks:

  • ✅ Click events
  • ✅ Navigation changes (pushState, popState)
  • ✅ Console errors and warnings
  • ✅ Network requests (fetch)

These breadcrumbs are included with every error report to give context.


🧩 Error Report Payload

Example payload sent to your API:

{
  "type": "error",
  "timestamp": "2025-04-15T04:41:06.708Z",
  "context": {
    "url": "http://localhost:3000/public/bui/user/dashboard",
    "timestamp": "2025-04-15T04:41:06.708Z",
    "userInfo": {
      "id": "12345",
      "name": "John Doe",
      "email": "[email protected]"
    },
    "errorMessage": "setShowVide is not defined",
    "simplifiedStackTrace": "",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36",
    "browserInfo": "Google Chrome",
    "operatingSystem": "Windows"
  }
  "breadcrumbs": [
    { "type": "click", "message": "Clicked on #submit-button" },
    { "type": "navigation", "message": "Navigated to /dashboard" },
    { "type": "console", "message": "Console error: Something went wrong" }
  ]
}

🧩 API

init(options)

Initialize ErrorSnap with configuration.

| Option | Type | Description | |--------------------|----------|-------------| | endpoint | string | Required. API endpoint to send error reports. | | maxBreadcrumbs | number | Optional. Max number of breadcrumbs to store (default: 20). | | env | string | Optional. if DEVELOPMENT, no sending error to server (default: PRODUCTION). | | consoleTypes | array | Optional. to send specific console type details to server ['log', 'warn', 'error', 'info']. | | interval | number | Optional. Time in seconds to batch+send errors (default: 60) |

setUser(userInfo)

Attach user information to error reports.

ErrorSnap.setUser({ id: '123', name: 'Jane', email: '[email protected]' });

notify(error)

Manually notify an error.

ErrorSnap.notify(new Error('Manual error'));

addBreadcrumb(breadcrumb)

Manually add a custom breadcrumb.

ErrorSnap.addBreadcrumb({ type: 'custom', message: 'User did something special' });

🏗️ Development

If you want to develop or test ErrorSnap locally:

  1. Clone the repo
  2. Install dependencies:
    npm install
  3. Run local test project:
    npm run dev

📄 License

MIT License — free to use and modify.


💡 Roadmap

  • [ ] Support batching of error reports
  • [ ] Support source maps for stack trace mapping
  • [ ] Session tracking
  • [ ] Replay user sessions (optional)

🤝 Contributions

Contributions are welcome!
Feel free to open issues or submit PRs 🚀