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

bugwatch

v0.20.0

Published

Error tracking SDK for Bugwatch: browser and Node.js

Readme

Bugwatch SDK

Small, dependency-free SDK that sends errors to Bugwatch: from the browser (bugwatch) and, since 0.5.0, from Node.js servers (bugwatch/node, see Node.js).

  • Zero runtime dependencies
  • Installs passive error / unhandledrejection listeners
  • Manual capture and user context
  • Breadcrumbs: clicks, navigation, network calls, and console messages before each error
  • Never throws into the host app
  • Under 5 KB gzipped (the browser bundle)

Install

Adding a project from GitHub in Bugwatch? Run the command it shows (npx bugwatch-cli@latest init --setup bws_…): it installs the SDK and writes the code below for you. See Set up a project from GitHub.

npm install bugwatch
import { Bugwatch } from "bugwatch";

Bugwatch.init({
  apiKey: "bw_…",
});

Bugwatch.init is safe to call more than once. It only installs the browser listeners once; a later call replaces the options.

Options

| Option | Required | Description | | ---------- | -------- | ------------------------------------------------------------------- | | apiKey | yes | Project API key from the project's Settings page. | | endpoint | no | Ingest endpoint. Defaults to https://sentry-like.vercel.app/api/ingest. | | release | no | Version of your app, e.g. "1.4.2" or a git SHA. Sent with every event. | | environment | no | Where the app runs, e.g. "production" or "staging". Sent with every event. | | breadcrumbs | no | false to record no breadcrumbs, or an object to turn kinds off, e.g. { console: false }. All on by default. | | captureHttpErrors | no | true to report failed fetch / XHR calls (5xx) as errors, or an object to choose statuses, network errors, and URLs to skip. Off by default. | | sessions | no | 0.16.0: false to send no release health sessions. On when release is set. |

Use endpoint for a local backend or a self-hosted deployment:

Bugwatch.init({
  apiKey: "bw_…",
  endpoint: "http://localhost:4000/api/ingest",
});

Release and environment

Tag every event with your app's version and where it runs. The dashboard can then show which release an error first appeared in and filter issues by environment.

Bugwatch.init({
  apiKey: "bw_…",
  release: "1.4.2", // e.g. from your build: process.env.APP_VERSION
  environment: "production",
});
  • release: 1–200 characters, no spaces or control characters, not . or ... Case-sensitive.
  • environment: letters, digits, _, ., - only, up to 64 characters. Case-sensitive (Production and production are different).
  • Values are trimmed; an empty value means "not set".
  • An invalid value is never thrown: the SDK logs one console.warn and sends events without it.

Breadcrumbs

The SDK records what happened before an error and sends the last 50 with every event (oldest first):

| Kind | Recorded | | --- | --- | | click | The clicked element: tag, id, up to 2 classes, and its text or aria-label (max 50 chars), e.g. button#checkout.primary "Pay now". For input, textarea, and select only tag, id, name, and type — never the value | | navigation | history.pushState / replaceState and popstate: { from, to } | | http | fetch and XMLHttpRequest: method, URL, status (0 on a network error), duration. 5xx and network errors are error, 4xx warning. Requests to the Bugwatch endpoint are skipped | | console | console.debug / log / info / warn / error as levels debug / info / info / warning / error; arguments joined, objects shown one level deep |

Add your own steps with addBreadcrumb:

Bugwatch.addBreadcrumb({ message: "Checkout started" });
Bugwatch.addBreadcrumb({ message: "Coupon rejected", level: "warning" });

Turn breadcrumbs off, completely or per kind:

Bugwatch.init({ apiKey: "bw_…", breadcrumbs: false });
Bugwatch.init({ apiKey: "bw_…", breadcrumbs: { console: false, http: false } });
  • The wrappers never change your app's behavior: fetch, XHR, history, and console get the same arguments and return the same values and errors.
  • Each kind is installed the first time it is enabled; turning it off later only stops recording.
  • Messages are cut to 300 characters and URLs to 500. The list sent with an event stays under 20 KB (oldest dropped), so a full stack trace still fits.
  • The SDK's API key is filtered out of breadcrumbs, and Bugwatch's own warnings are not recorded.

Failed API requests

Every request is a breadcrumb, but a failed one only becomes an issue when your code does not handle it. Turn on captureHttpErrors to report failed requests even when your code handles them:

Bugwatch.init({ apiKey: "bw_…", captureHttpErrors: true }); // 500–599

Or choose what counts as failed:

Bugwatch.init({
  apiKey: "bw_…",
  captureHttpErrors: {
    statuses: [404, [500, 599]], // codes or [min, max] ranges
    networkErrors: true, // no response: offline, DNS, CORS, timeout
    ignoreUrls: ["/health", /analytics/],
  },
});
  • Each failure is an event of type HttpError (or NetworkError) with a message like HTTP 500: GET /api/orders/:id. Ids in the path (numbers, UUIDs, and hex ids like MongoDB ObjectIds) become :id, so one endpoint is one issue. The request is the event's last breadcrumb, with its real URL
  • The query string and hash are left out of the message, since they often hold tokens. The breadcrumb keeps the full URL, as for every request
  • The same request (method, URL, status) is reported at most once a minute, so a failing poll doesn't use up your quota
  • Cancelled requests (AbortController) are never reported, and neither are Bugwatch's own requests. Network errors are off by default because visitors who go offline would send many of them
  • It works with breadcrumbs off. Your app still gets the same response or error back

Tags

Add your own tags (0.6.0+) to every later event. Bugwatch shows how many of an issue's events had each value, next to its automatic tags (browser, OS, page, release, environment, level, and whether the error was handled):

Bugwatch.setTag("plan", "pro");
Bugwatch.setTags({ region: "eu", seats: 12 });
Bugwatch.removeTag("region");
  • Keys: 1–32 characters of a-z, 0-9, _, ., - (lower-case). Values: strings, numbers, or booleans, up to 200 characters
  • At most 20 tags; a tag that breaks a rule is ignored (it never throws). Automatic tag names (browser, os, url, route, server, platform, release, environment, level, handled) can't be set
  • Every event also says whether it was handled: false for uncaught errors and unhandled rejections, true for captureError and captureHttpErrors
  • And how it was caught (0.7.0+), as mechanism: onerror / onunhandledrejection in the browser, uncaught_exception / unhandled_rejection / express / nextjs in Node, and capture_error / http in both. The dashboard shows it on the stack trace
  • And (0.8.0+) contexts: in the browser, the page's language (navigator.language), time zone, screen size and pixel ratio, viewport, and the frameworks the page announces itself — Next.js (window.next.version), Angular (ng-version), and React / Vue only when loaded as page globals (a bundled React leaves no version on the page). In Node, the installed next and express versions (read once at init from the app's package.json files; Node 20.16+). A server's own locale and time zone are not sent: they describe the server, not your user

Feature flags

Record the feature flags your app evaluates (0.9.0+); every later event carries them, so the issue page shows which flags were on when the error happened:

const enabled = flags.isEnabled("new-checkout");
Bugwatch.addFeatureFlag("new-checkout", enabled); // boolean
Bugwatch.addFeatureFlag("pricing-test", "variant-b"); // or a short string
  • The last 100 flags are kept, one per flag name (a repeated flag keeps its latest result). Names: 1–100 characters; results: true / false or a string of 1–64 characters. Anything else is ignored (it never throws)
  • In Node, a flag recorded inside a request (or withScope) belongs to that request only, on top of the flags recorded outside any request — like setTag

Traces (0.10.0+)

Every event carries a trace id: one per page load (and per navigation to another path) in the browser, one per request in Node. The browser SDK sends it to your own server in the standard traceparent header on fetch and XMLHttpRequest calls, and the Node SDK picks it up, so the issue page shows the browser error and the server error its request caused together ("1 other issue in this trace").

  • By default the header goes only to the page's own origin, so requests to other sites never trigger a CORS preflight. If your API is on another origin, list it — and allow the traceparent header in that API's CORS settings:
Bugwatch.init({
  apiKey: "bw_…",
  tracePropagationTargets: ["https://api.example.com/", /^https:\/\/edge\./],
});
  • Strings match URLs that start with them; [] turns propagation off. A traceparent your app already sets is never replaced
  • In Node, install expressRequestHandler() (or use Next.js onRequestError) so each request reads the incoming header

Web Vitals (0.11.0+)

Browser errors carry the page's Web Vitals measured so far, so the issue page can show whether the page was slow when it failed:

| Vital | What it measures | | --- | --- | | lcp Largest Contentful Paint | when the main content showed (ms) | | fcp First Contentful Paint | when anything showed (ms) | | cls Cumulative Layout Shift | how much the page jumped around (score) | | inp Interaction to Next Paint | the slowest click / key response so far (ms) | | ttfb Time to First Byte | how long the server took to start answering (ms) |

  • Measured with PerformanceObserver; a browser that lacks one of them simply does not send it. An early error carries only what was measured before it
  • inp is the slowest interaction so far, not Google's 98th percentile (they match on pages with fewer than 50 interactions)
  • Turn it off with Bugwatch.init({ …, vitals: false })

Per route (0.17.0+). Every page load also sends its vitals once, when the page is first hidden (switching tabs, closing it, navigating away), so Bugwatch can show each route's p75 and a performance score — not only the pages that had an error:

  • Pages are grouped by route: /products/8121 and /products/77 both count as /products/:id (numbers, UUIDs, hashes, and long tokens in the path become :id)
  • Name the route yourself when your router knows it: Bugwatch.setRoute("/products/[slug]") (call it on each route change; setRoute("") goes back to the path)
  • One small request per page load; it counts toward the same monthly session limit as release health, never the event limit
  • vitals: false turns these reports off too

Release health (0.16.0+)

With a release set, each page load is one session, so Bugwatch can show each release's crash-free sessions %, crash-free users %, and adoption (its share of the environment's sessions):

  • started is sent when init runs (a prerendered page waits until it is shown). A later init keeps the page's session
  • The page's first handled error (captureError, a failed request) sends errored; its first uncaught error or unhandled rejection sends crashed. Each at most once per page load, so a session is ok, errored, or crashed
  • An error counts even when the event itself is then dropped (a 429 pause, a server filter)
  • The user from setUser is sent with each request, so crash-free users counts the people behind the sessions; without one, Bugwatch counts the anonymous visitor by IP and browser (only a keyed hash is stored)
  • Sessions have their own monthly limit (they never use the event limit). At it, Bugwatch answers 429 and the page sends no more sessions
  • Turn it off with Bugwatch.init({ …, sessions: false }). The Node SDK sends no sessions

Logs (0.13.0+)

Send your app's own logs. Each log carries the current trace id, so the issue page shows the logs of the request that failed, from the browser and your server together.

Bugwatch.logger.info("Order validated", { orderId: 812, total: 49.9 });
Bugwatch.logger.warn("Payment retry", { attempt: 2 });
Bugwatch.logger.error("Payment provider timed out");
  • Levels: trace, debug, info, warn, error, fatal. The message is cut to 2,000 characters; up to 20 attributes with string, number, or boolean values (string values cut to 200)
  • Logs are sent in batches: every 5 seconds, at 50 logs, when the page is hidden, and (Node) on Bugwatch.flush(). At most 1,000 wait; the oldest are dropped
  • captureConsole: true in init also sends console.debug / log / info / warn / error output as logs. Off by default: console output is often noisy and can contain secrets
  • Logs are kept 7 days and have their own monthly limit (they never use your event limit). Over it, Bugwatch answers 429 and the SDK stops sending logs until Retry-After has passed; errors are not affected
  • Logs are scrubbed on the server like events; your API key is removed from messages in the SDK

Manual capture

try {
  checkout();
} catch (error) {
  Bugwatch.captureError(error);
}

User feedback (0.14.0+)

Let people tell you what went wrong; their words show next to the error in Bugwatch (Feedback, and the issue's page). Feedback has its own daily limit and does not use the monthly event limit.

A "Report a problem" button and a crash-report dialog come from a separate import, so apps that don't use them download nothing extra:

import { Bugwatch } from "bugwatch";
import { feedbackWidget, showReportDialog } from "bugwatch/feedback";

Bugwatch.init({ apiKey: "YOUR_API_KEY" });

// A button in a corner of every page.
feedbackWidget({ buttonText: "Report a problem", position: "bottom-right", colorScheme: "system" });

// After an error, ask what happened (e.g. in a React error boundary).
try {
  checkout();
} catch (error) {
  Bugwatch.captureError(error);
  showReportDialog(); // sent with Bugwatch.lastEventId(), so it lands on that issue
}
  • feedbackWidget(options) → { open(), remove() }. Options: buttonText, position (bottom-right, bottom-left, top-right, top-left), colorScheme (system, light, dark), title
  • showReportDialog(options) → { close() }. Options: eventId (default: the last error's), title, subtitle, colorScheme
  • The form asks for a message (required), and a name and email (optional); the page address, release, and environment are sent with it. It works with the keyboard (Escape closes, focus stays inside) and screen readers, and the page's CSS can't change it (shadow DOM). About 2.5 KB gzipped; safe to import during server rendering (it does nothing without a page)

With your own form, send it yourself:

const ok = await Bugwatch.captureFeedback({
  message: "I clicked Pay twice and the page went blank",
  name: "Asha",                      // optional
  email: "[email protected]",         // optional
  eventId: Bugwatch.lastEventId(),   // optional: the error it is about
});

captureFeedback resolves to true when Bugwatch accepted it and never rejects (false before init, for an empty message, offline, or over the limit). Every event now has an id (eventId, 32 hex characters); Bugwatch.lastEventId() returns the last one sent. The script-tag build has Bugwatch.captureFeedback and Bugwatch.lastEventId (not the widget).

Tracing (0.18.0+)

Tracing shows where the time goes: each sampled page load and navigation becomes a transaction with spans for its fetch calls, the page's loading phases (DNS, connect, request, response, DOM), and resources slower than 50 ms. Bugwatch shows p50 / p95 per transaction and a waterfall of each trace — across your browser and server projects.

import { Bugwatch } from "bugwatch";
import { startTracing } from "bugwatch/tracing";

Bugwatch.init({ apiKey: "bw_…", release: "1.4.2", tracesSampleRate: 0.1 });
startTracing();
  • Off until you set tracesSampleRate (0–1: the share of page loads and navigations that record spans). Errors are never sampled
  • bugwatch/tracing is a separate import (~1.8 KB gzipped), so apps that don't trace don't download it
  • A transaction ends a second after its last request settles (at most 30 s), or when the page is hidden. It is named by setRoute, else by its path with ids as :id
  • The sampling decision travels in traceparent (-01 sampled, -00 not), so your Node server traces the same requests
  • Spans have their own monthly limit; at it, Bugwatch answers 429

Session replay (0.20.0+)

A replay shows what the person saw and did in the minute before an error: the page, their clicks, scrolls, and typing (masked). The SDK records into memory only; nothing leaves the browser unless an error happens. Then it uploads the last 30–60 seconds, keeps recording for up to 60 seconds more, and the error's event links to the replay.

import { Bugwatch } from "bugwatch";
import { startReplay } from "bugwatch/replay";

Bugwatch.init({ apiKey: "bw_…", release: "1.4.2" });
startReplay(); // or startReplay({ onErrorSampleRate: 0.5 })

Privacy, by default:

  • Every text node and input is masked (****, keeping its shape); images, video, <canvas>, and SVG become same-size placeholders
  • data-bw-unmask on an element shows its text (for labels and buttons you want readable); data-bw-mask masks text when you start with maskAllText: false; data-bw-block never records an element
  • Password and card fields (type="password", autocomplete="cc-*") are always masked, whatever the attributes say

Notes:

  • A separate import (~25 KB gzipped: it bundles rrweb's recorder, MIT); apps that don't use replay download nothing
  • onErrorSampleRate (0–1, default 1) is decided once per page load; an unsampled page records nothing at all
  • Replays have their own monthly limit and are kept 30 days; when Bugwatch refuses one, the page's replay stops

Rate limits (0.12.0+)

Bugwatch answers 429 when the project's key is over its rate limit (an optional limit per key, set by the project's owners and managers) or the org's monthly event limit is used up. The response's Retry-After header says how many seconds to wait. Browser and Node SDKs then send nothing until that time has passed: events captured in between are dropped (not queued), then sending starts again on its own. The wait is capped at 1 hour, and is 60 seconds when the header is missing or unreadable. With debug: true, the Node SDK logs each pause. A 413 (event over 100 KB) drops that event only. Calling init again clears a pause.

User context

Bugwatch.setUser({ id: "u_42", email: "[email protected]" });

// Later, e.g. on logout:
Bugwatch.setUser(null);

Script tag

<script
  src="https://unpkg.com/bugwatch"
  data-api-key="bw_…"
  data-endpoint="http://localhost:4000/api/ingest"
  data-release="1.4.2"
  data-environment="production"
></script>

The script tag build exposes window.Bugwatch and initializes itself from data-api-key. data-endpoint, data-release, and data-environment are optional, like the matching options. Add data-breadcrumbs="false" to turn breadcrumbs off, and data-capture-http-errors="true" to report 5xx responses.

Node.js

bugwatch/node (0.5.0+, Node.js 20+) reports errors from your server: uncaught exceptions, unhandled rejections, Express and Next.js request errors, and, if you turn it on, failed outgoing fetch calls. It is part of the same package.

import { Bugwatch } from "bugwatch/node";

Bugwatch.init({
  apiKey: process.env.BUGWATCH_API_KEY, // the same bw_ key as the browser
  release: process.env.RELEASE,
  environment: process.env.NODE_ENV,
});

apiKey, release, and environment also come from BUGWATCH_API_KEY, BUGWATCH_RELEASE, and BUGWATCH_ENVIRONMENT when you leave them out.

| Option | Default | Description | | ------ | ------- | ----------- | | apiKey | $BUGWATCH_API_KEY | Project API key. Without one, nothing is sent. | | endpoint | hosted ingest | As in the browser SDK. | | release / environment | $BUGWATCH_RELEASE / $BUGWATCH_ENVIRONMENT | Same rules as the browser SDK. | | serverName | the host name | Sent with every event; false leaves it out. | | root | process.cwd() | Removed from stack paths, so they read dist/server.js. | | captureHttpErrors | off | Report failed outgoing fetch calls (same options as the browser). | | onFatalError | "exit" | After an uncaught exception: send it, then exit with code 1 as Node would. "keep-running" only reports. | | debug | false | Log why an event was not sent. |

Express

import express from "express";
import { Bugwatch } from "bugwatch/node";

Bugwatch.init({ apiKey: process.env.BUGWATCH_API_KEY });

const app = express();
app.use(Bugwatch.expressRequestHandler()); // first
// ...your routes...
app.use(Bugwatch.expressErrorHandler()); // after the routes, before your own error handler

Errors without a status, or with a 5xx status / statusCode, are reported with the request (method, URL, route such as /api/orders/:id), the request's user, and the outgoing fetch calls made while handling it. 4xx errors are not reported. The error is passed on with next(err). Express 4 and 5.

Next.js

In instrumentation.ts at the project root (or in src/), next to your instrumentation-client.ts:

import { Bugwatch } from "bugwatch/node";

export function register() {
  if (process.env.NEXT_RUNTIME === "nodejs") {
    Bugwatch.init({ apiKey: process.env.BUGWATCH_API_KEY });
  }
}

export const onRequestError = Bugwatch.nextOnRequestError;

Errors from server components, route handlers, and server actions arrive with the route (/blog/[slug]). redirect() and notFound() are not reported. Next.js 15+. The Edge runtime is not supported yet: there the SDK does nothing.

Outgoing requests

The SDK wraps the global fetch. Inside a request (Express, or Bugwatch.withScope), every call is a breadcrumb. With captureHttpErrors, failed calls become issues, for example a CMS that rejects your token:

Bugwatch.init({
  apiKey: process.env.BUGWATCH_API_KEY,
  captureHttpErrors: { statuses: [401, 403, [500, 599]] },
});
// → HTTP 401: GET https://cms.example.com/api/content/landingpage

Users, scopes, and serverless

Bugwatch.setUser({ id: user.id }); // inside a request: that request only
Bugwatch.setTag("plan", user.plan); // the same: per request, 0.6.0+
Bugwatch.addFeatureFlag("new-checkout", true); // per request too, 0.9.0+
Bugwatch.captureError(error, { level: "warning" });
await Bugwatch.withScope(async () => { /* own user and breadcrumbs */ });
await Bugwatch.flush(2000); // before a script or serverless function ends
  • Each request keeps its own user and breadcrumbs, even when requests run at the same time
  • Stack paths are relative to root, so the same error from two servers is one issue, and no home folders or deploy paths are sent
  • Uncaught exceptions are reported as fatal. When the SDK's listener is the only one, the process still prints the error and exits with code 1, as it would without the SDK. Unhandled rejections behave as Node's --unhandled-rejections setting says (default: exit)
  • Events carry platform: "node", the Node.js version, the server name, and the request; the dashboard shows them as a "Server" issue
  • A 401 (wrong key) stops sending until the next init; a 429 (the key's rate limit or the monthly limit) pauses it for as long as the Retry-After header says (0.12.0+; see Rate limits)

Tracing (0.18.0+)

With tracesSampleRate (or a sampled traceparent from the browser), each request through expressRequestHandler is a transaction: an http.server span named by its route (GET /api/orders/:id), an http.client span per outgoing fetch (which also passes traceparent on to the services you call), and any work you time yourself:

Bugwatch.init({ tracesSampleRate: 0.1 });

const receipt = await Bugwatch.startSpan({ name: "charge card", op: "payment.charge" }, () => charge(order));
  • startSpan returns what your function returns and passes its errors through (the span is marked error); outside a sampled request it just runs the function
  • An incoming traceparent decides for the request (sampled or not); a request without one uses tracesSampleRate
  • Spans are sent when the response finishes. Errors in a span carry its id, so the waterfall shows where they happened
  • Outgoing fetch calls inside a request get traceparent even with tracing off (marked not sampled), so errors still link across services

Database spans (0.19.0+)

Hand Bugwatch the database drivers your app uses, and each query inside a sampled request becomes a db span. Bugwatch uses them to find slow queries and N+1 queries (a query inside a loop) and opens performance issues for them:

import * as mongodb from "mongodb"; // Mongoose uses it too
import pg from "pg";

Bugwatch.init({ tracesSampleRate: 0.1 });
Bugwatch.instrument({ mongodb, pg });
  • Spans are named without their values: orders.find {"status":"?"}, SELECT * FROM orders WHERE id = ?. No query data leaves your app
  • Results and errors pass through unchanged (a failed query marks its span error); queries outside sampled requests are not timed at all
  • Passing the modules works the same in ESM and CommonJS apps and with any bundler

Cron monitors (0.15.0+)

A monitor (create it on Bugwatch's Monitors page, with its schedule) expects your job to check in on time. When a run is missed, fails, or runs too long, Bugwatch opens an issue, and resolves it when the job recovers.

import { Bugwatch } from "bugwatch/node";

Bugwatch.init({ apiKey: process.env.BUGWATCH_API_KEY });

// One run: in_progress, then ok (or error, rethrown); waits for the check-ins.
await Bugwatch.withMonitor("nightly-backup", () => runBackup());

// Or by hand:
const checkInId = Bugwatch.captureCheckIn({ monitorSlug: "nightly-backup", status: "in_progress" });
// … the job …
Bugwatch.captureCheckIn({ monitorSlug: "nightly-backup", status: "ok", checkInId });
await Bugwatch.flush();

captureCheckIn returns the run's id and never throws; an unknown slug logs a warning once. For crontab lines without Node, use bugwatch-cli monitor run nightly-backup -- ./backup.sh.

Source maps

To see the original file, line, and code around each error instead of minified frames, upload your build's source maps for the same release with bugwatch-cli (a CLI and a Vite plugin, a separate package; the SDK itself stays dependency-free and small):

npm install --save-dev bugwatch-cli
npx bugwatch-cli sourcemaps upload dist --release 1.4.2 --delete-after-upload

Local development

npm install
npm run build      # library + script-tag bundles, then the 5 KB check
npm test           # unit tests against the built bundle
npm run typecheck

Test page

npm run test-page

Open the printed URL with a real project key:

http://localhost:5050/?key=bw_…&endpoint=http://localhost:4000/api/ingest

Add &release=1.4.2&environment=staging to send a release and environment. The Breadcrumbs section has buttons for a navigation, two fetches (200 and 404), a console warning, and a custom breadcrumb; throw an error afterwards to send them.

Use &mode=auto to verify script-tag auto-init. The page loads dist/bugwatch.global.js, so run npm run build first (npm run test-page does it for you).

Payload

Every event includes the API key, message, error type, stack, page URL, user agent, SDK name/version, and timestamp, plus release and environment when they are set, the recorded breadcrumbs, (0.9.0+) the recorded feature flags, (0.10.0+) the traceId, (0.11.0+) the page's vitals, and (0.14.0+) its own eventId. file, line, and column are included for uncaught error events. Failed API requests are reported only with captureHttpErrors (see Failed API requests).