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

@vigilon/browser

v0.2.25

Published

Vigilon error monitoring for browser applications

Readme

@vigilon/browser

Error monitoring for browser applications. Captures uncaught errors and unhandled promise rejections, and errors you report yourself, and sends them to Vigilon, where they appear on the Errors page as Error Groups with origin browser.

Zero dependencies, about 7 KB gzipped, and no side effects on import.

Install

npm install @vigilon/browser

Or load the script-tag build, which exposes window.Vigilon:

<script src="https://unpkg.com/@vigilon/browser@0/dist/vigilon.min.js" crossorigin="anonymous"></script>

In production, replace @0 with the exact version you tested (npm view @vigilon/browser version prints the latest), so a release never changes your page without a deploy.

Quick start

In the Vigilon dashboard, open your project's Settings page, then the API Keys tab, and create a key of kind Browser.

Under Allowed origins, you can list the origins your app is served from, one per line, such as https://app.example.com. https://*.example.com covers every subdomain of example.com. Vigilon then answers requests from any other origin with HTTP 403, so a key copied into another site is refused. An empty list accepts any origin. To report from local development, add your dev server's origin, such as http://localhost:5173, or create a second key for it.

Call init once, as early as possible in your app's entry point:

import { init } from "@vigilon/browser";

init({
  apiKey: "your-api-key",
  appName: "dashboard",
  environment: "production",
  appVersion: "2026.10.26-1",
});

The key ships to every visitor's browser, so treat it as public: a Browser key can only send browser errors to its project, and Vigilon refuses it for traces and metrics. Never put a Server key in browser code.

If your entry point imports the rest of your app, put init in a module of its own and import that first: imports run before the importing module's own code, so errors thrown while they load would otherwise be missed.

init returns false and logs the reason when it cannot start. During server-side rendering there is no window, so init and every other function are safe no-ops; you can import the package from code that runs on both sides.

Set appVersion to your release (a build number or commit SHA). Without it, Vigilon cannot tell which release introduced an error, and the SDK warns once.

Reporting errors yourself

import { captureException, setTag, setUser } from "@vigilon/browser";

try {
  await saveSettings();
} catch (error) {
  captureException(error); // returns the event ID, or null when it was not sent
}

setUser({ id: "user_8f2c" }); // an opaque ID; never an email address
setTag("plan", "pro");

captureException accepts any thrown value. Non-Error values are recorded with their string or JSON form as the message, and an error's cause chain is captured up to five levels.

Pages

Vigilon groups an error's affected pages by route template, such as /users/:id, so a page with IDs in its URL still counts as one page. Without a template it derives one from the URL path, replacing segments that look like IDs. If your router knows the template, set it on every navigation:

import { setRoute } from "@vigilon/browser";

setRoute("/users/:id"); // the template, never the URL; pass null to clear it

@vigilon/react does this for TanStack Router and React Router.

Breadcrumbs

Each error carries the breadcrumbs recorded before it, the 50 most recent, so you can see what led up to it:

  • navigation: path changes through the History API, as from and to paths;
  • click: the clicked element as a selector, such as button#save.btn.primary (tag, id, and up to two classes; never the element's text);
  • console: console.warn and console.error calls, as their first argument only (an object loses keys that look like a credential);
  • fetch and xhr: the method, the URL without its query string or fragment, the status (0 when the request failed), and the duration. Requests the SDK sends to Vigilon are never recorded.

Add your own steps with addBreadcrumb:

import { addBreadcrumb } from "@vigilon/browser";

addBreadcrumb({ message: "checkout started", data: { step: 1 } });

Turn sources off, or record more console levels, with the breadcrumbs option, and edit or drop single breadcrumbs with beforeBreadcrumb:

init({
  // ...
  breadcrumbs: { console: ["log", "warn", "error"], xhr: false },
  beforeBreadcrumb(breadcrumb) {
    return breadcrumb.category === "click" ? null : breadcrumb;
  },
});

Configuration

| Option | Default | | |---|---|---| | apiKey | required | A project API key of kind Browser. init returns false for a placeholder in square brackets, such as [YOUR_BROWSER_API_KEY]. | | appName | required | The name this app reports as, shown as its Service in Vigilon: 1 to 100 letters, digits, and . _ : / -. | | environment | required | The deployment environment, with the same character set. | | appVersion | none | The release. | | endpoint | https://ingest.vigilon.io | The ingest base URL. | | ignoreErrors | see below | More errors to drop, as strings (substring match) or regular expressions, matched against the message and against type: message. | | denyUrls | see below | More script URLs whose errors are dropped. | | beforeSend | none | (event) => event \| null. Edit or drop each event before it is sent. | | breadcrumbs | all on | false turns automatic breadcrumbs off (addBreadcrumb still works), or an object turning off navigation, click, fetch, or xhr. console takes true (every level), false, or a list of levels; the default is ["warn", "error"]. | | beforeBreadcrumb | none | (breadcrumb) => breadcrumb \| null. Edit or drop each breadcrumb as it is recorded. | | sampleRate | 1 | The fraction of errors to send. | | maxEventsPerPage | 100 | At most this many events per page load. | | debug | false | Log SDK diagnostics to the console. |

serviceName and serviceVersion were renamed to appName and appVersion. The old names still work until 0.3.0, and init warns for each one you pass. The values sent to Vigilon are unchanged, so the app keeps its Service and error groups when you rename.

Some noise is dropped by default: Script error. (an opaque error from a cross-origin script), failed and aborted network requests (Failed to fetch, NetworkError when attempting to fetch resource, Load failed, AbortError), ResizeObserver loop warnings, and errors thrown by browser extensions. The same error repeating within a minute is sent once, so an error loop cannot flood your project.

flush() sends queued events now and close() flushes and stops capturing. Both resolve true when everything was sent.

Readable stack traces

Production scripts are minified, so a raw stack trace points at minified code. @vigilon/bundler-plugins gives each script your build emits a debug ID that links it to its source map. The SDK sends the debug IDs of the scripts in an error's stack with the error, reading them from the runtime registries that build tools write: _vigilonDebugIds, then _sentryDebugIds and _debugIds. A build that already injects debug IDs for Sentry needs no second pass.

Privacy

The SDK removes the query string, the fragment, and any user:password@ from the page URL and from every URL in a stack trace. It drops tags whose key looks like a credential (password, token, secret, authorization, cookie, and similar), and a setUser ID that looks like an email address. The session ID is a random value in sessionStorage, one per tab; the SDK sets no cookies. In breadcrumbs it removes the query string, the fragment, and user:password@ from every URL and path, drops data keys that look like a credential, records clicks without the element's text, and keeps console breadcrumbs to the first argument of warnings and errors unless you ask for more levels. Vigilon applies the same rules again on its side.

Error messages are sent as they are, and so are console messages in breadcrumbs, apart from their URLs. A message is free text, so it can contain whatever your code put in it, and Vigilon cannot scrub it reliably. If your messages can carry personal data, scrub them in beforeSend (and console breadcrumbs in beforeBreadcrumb). The message is also the first line of the stack, and each entry of cause carries its own message and stack, so scrub all of them. Keep the pattern away from the stack's script URLs: Vigilon reads the frames from them.

// Email addresses, but not the @ in a script URL such as /@scope/[email protected]/.
const scrub = (text: string) =>
  text.replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g, "[email]");

init({
  // ...
  beforeSend(event) {
    const { exception } = event;
    exception.message = scrub(exception.message);
    if (exception.stack) exception.stack = scrub(exception.stack);
    for (const cause of exception.cause ?? []) {
      cause.message = scrub(cause.message);
      if (cause.stack) cause.stack = scrub(cause.stack);
    }
    return event;
  },
});

Delivery

Events are batched and sent with fetch. When the page is hidden or unloaded, queued events are sent with keepalive so they outlive the page. The SDK retries a request only when the endpoint is rate limiting (429), temporarily unavailable (503), or unreachable, and honours Retry-After by pausing all sends. It gives up on an event after five attempts or 30 minutes after its first attempt.

Delivery is at-least-once with duplicate suppression inside a one-hour window, not exactly-once: a retry after an ambiguous network failure is recognised and counted once if it arrives within an hour.

Support