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

@webwatch/sdk

v0.1.0

Published

Zero-config error capture SDK for WebWatch. Auto-captures uncaught errors and unhandled rejections, batches them, and sends them to your WebWatch ingest endpoint.

Readme

@webwatch/sdk

Zero-config error capture SDK for WebWatch — uncaught errors and unhandled rejections are auto-captured, batched in memory, and posted to your WebWatch ingest endpoint with retries. No agent, no per-route wrappers.

Instalasi

npm install @webwatch/sdk
# atau
bun add @webwatch/sdk

Quick start (zero-config)

Set two env vars, then import once anywhere on the boot path — that is the whole setup:

export WEBWATCH_KEY="ww_..."                       # per-site API key dari dashboard WebWatch
export WEBWATCH_URL="https://watch.example.id"     # deployment WebWatch kamu
// entrypoint (Node/Bun, Next.js, Express, Hono, Fastify, ...)
import "@webwatch/sdk";

Tanpa kedua env itu SDK diam (no-op) dan memberi peringatan sekali lewat console.warn saat ada event masuk — monitoring tidak pernah menghentikan aplikasimu.

Yang otomatis ditangkap

| Sumber | event_type | Catatan | | --------------------------------------- | ---------------- | ---------------------------------------------------------- | | process unhandledRejection | backend_error | Termasuk route async Express 4 yang gagal | | process uncaughtException | backend_error | Via uncaughtExceptionMonitor — proses tetap crash normal | | window error (browser) | frontend_error | Stack + URL halaman | | window unhandledrejection (browser) | backend_error | |

Untuk framework yang menelan error per-route (Express 4 async, Hono, Fastify), pakai middleware di bawah agar semuanya tercatat — plus ini jamin terkirim sebelum proses mati.

Framework helpers

Express

import express from "express";
import { expressErrorMiddleware, wrapAsync } from "@webwatch/sdk/express";

const app = express();
app.get(
  "/users",
  wrapAsync(async (req, res) => res.json({ ok: true })),
);
app.use(expressErrorMiddleware()); // setelah semua route

Hono

import { Hono } from "hono";
import { honoOnError } from "@webwatch/sdk/hono";

const app = new Hono();
app.onError(honoOnError());

Fastify

import { fastifyErrorHandler } from "@webwatch/sdk/fastify";

fastify.setErrorHandler(fastifyErrorHandler());

Next.js

// instrumentation.ts (di root proyek atau src/)
export async function register() {
  await import("@webwatch/sdk/next").then((m) => m.register());
}

API

| Ekspor | Fungsi | | ---------------------------------------------------- | ------------------------------------------------------- | | capture(type, message, stackTrace?, url?, method?) | Masukkan event manual (fire-and-forget) | | captureError(error, options?) | Tangkap Error/nilai apa pun lintas root Error.cause | | flush() | Paksa kirim seluruh buffer sekarang | | init(key, { endpoint }) | Konfigurasi eksplisit (path bundler browser) | | @webwatch/sdk/next → register() | Drop-in untuk instrumentation.ts |

Batching & retry

  • Queue di memori (maks 1000 event, yang paling tua dibuang saat penuh).
  • Flush per 50 event / interval 5 detik, kirim paralel maksimum 1 batch in-flight.
  • Retry eksponensial (3x) untuk 5xx/408/429 dan error jaringan; tidak di-retry untuk 400/401/403/404 (mis. kode invalid_key, site_not_verified) supaya tidak membabi-buta.
  • Event duplikat (type + pesan sama) di-throttle 5 detik anti-storm.

Catatan

  • Browser tanpa bundler: pakai script GET /api/public/sdk dari deployment WebWatch — satu file ES module, tidak butuh npm.
  • Event saat proses crash karena uncaught exception mungkin hilang (flush async tidak bisa menunggu exit); middleware framework menutup kasus itu.
  • environment diambil dari NODE_ENV (fallback production).