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

@ruizrica/mako-sdk

v0.2.1

Published

Mako monitoring SDK for JavaScript and Node.js — capture errors, structured logs, and breadcrumbs to your self-hosted Mako ingestion API.

Readme

@ruizrica/mako-sdk

Mako monitoring SDK for JavaScript and Node.js — send errors (with stack traces), structured logs, and rich context to your self-hosted Mako ingestion API. Events are batched and delivered over HTTP with retries on transient failures.

Install

npm install @ruizrica/mako-sdk

What you can do

  • ErrorscaptureException() parses stack frames (filename, line, column, in-app vs node_modules) and attaches breadcrumbs, tags, extras, and user.
  • MessagescaptureMessage() for log-style events with optional level.
  • HTTP requestssetupFetchIntegration() patches fetch and XMLHttpRequest to emit a request item per call (method, url, status, duration, size).
  • PageviewssetupRouterIntegration() captures pushState / replaceState / popstate and emits a pageview item per route change, including the initial load.
  • BreadcrumbsaddBreadcrumb() keeps a ring buffer (size configurable) attached to the next error.
  • ContextsetUser(), setTag(), setExtra() apply to subsequent events until cleared.
  • Structured logging — named MakoLogger instances (debug / info / warn / error / fatal) send log envelopes with optional structured data.
  • Sampling & filteringsampleRate (0–1) and optional beforeSend hook to drop or rewrite events before they leave the process.
  • Global handlers — optional browser / Node integrations for uncaught errors and unhandled rejections.

Browser auto-instrumentation

import {
  Mako,
  setupBrowserIntegration,
  setupFetchIntegration,
  setupRouterIntegration,
} from '@ruizrica/mako-sdk';

Mako.init({ dsn: '<your DSN>' });
setupBrowserIntegration();   // window.onerror + unhandledrejection
setupFetchIntegration();     // fetch + XHR -> request items
setupRouterIntegration();    // pushState/popstate -> pageview items

The fetch integration filters out the SDK's own /api/v1/envelope requests so it never traces itself.

Quick start

import { Mako } from '@ruizrica/mako-sdk';

Mako.init({
  dsn: process.env.MAKO_DSN!, // see DSN format below
  environment: typeof process !== 'undefined' ? process.env.NODE_ENV : undefined,
  release: typeof process !== 'undefined' ? process.env.npm_package_version : undefined,
});

Mako is the MakoClient singleton. Call Mako.init({ dsn }) once before Mako.getInstance(), loggers, or integrations.

DSN

The DSN is a URL your Mako project gives you. It encodes the host, public key, and API path. The SDK posts JSON envelopes to /api/v1/envelope on that host with an Authorization header using the DSN scheme and the same DSN string you pass to Mako.init.

Shape (illustrative):

https://<public_key>@<your-mako-host>/api/v1/<project_id>

Typical practice:

  • NodeMAKO_DSN (or your own secret name) from environment or secrets manager.
  • Browser — only use a browser-safe key your server issues for the client; bundle tools often expose import.meta.env / process.env.NEXT_PUBLIC_* depending on your framework.

Never commit production DSNs to source control.

Configuration (MakoConfig)

| Option | Default | Description | |--------|---------|-------------| | dsn | — | Required for Mako.init. Ingestion URL / credential string. | | environment | '' | e.g. production, staging; sent on events. | | release | '' | App version or git SHA; sent on events. | | sampleRate | 1.0 | Random drop for all events before send (01). | | maxBreadcrumbs | 100 | Max breadcrumbs kept in memory. | | batchSize | 30 | Flush when this many items are queued. | | flushInterval | 5000 | Periodic flush interval in ms. | | debug | false | Logs redacted DSN and failed sends to the console. | | beforeSend | — | (event) => event \| null — return null to drop the event. | | tracesSampleRate | 0.0 | Present on the type for forward compatibility; not yet applied by the client. |

Browser and Node integrations

After Mako.init, optional helpers register global error handlers:

  • BrowsersetupBrowserIntegration() hooks window.onerror and unhandledrejection.
  • NodesetupNodeIntegration() hooks uncaughtException and unhandledRejection (fatal level for uncaught exceptions).
import { Mako, setupBrowserIntegration } from '@ruizrica/mako-sdk';

Mako.init({ dsn: '…' });
setupBrowserIntegration();
import { Mako, setupNodeIntegration } from '@ruizrica/mako-sdk';

Mako.init({ dsn: '…' });
setupNodeIntegration();

Remove hooks with teardownBrowserIntegration() / teardownNodeIntegration() when needed.

Manual capture and context

const client = Mako.getInstance();

client.setUser({ id: 'user-123', email: '[email protected]' });
client.setTag('region', 'eu-west');
client.setExtra('checkout_step', 2);

client.addBreadcrumb({
  category: 'navigation',
  message: 'Opened checkout',
  level: 'info',
});

try {
  // …
} catch (err) {
  client.captureException(err as Error, { step: 'payment' }, 'error');
}

client.captureMessage('Deployment finished', 'info');

captureException accepts optional context (merged into event context) and severity (error, fatal, etc.). Each capture returns an event id string.

Structured logging

const client = Mako.getInstance();
const authLog = client.getLogger('auth');

authLog.info('Session started', { sessionId: '…' });
authLog.error('Token refresh failed', { status: 401 });

// Shorthand for the unnamed logger
client.log.warn('Rate limit approaching');

Logger output respects sampleRate and beforeSend like other events.

Flush, close, and tests

  • await client.flush() — send queued items immediately (e.g. before exit in serverless).
  • client.close() — stop the batch timer and dispose the batcher.
  • Mako.resetInstance() — clear the singleton (useful in tests); call close() on the instance first if it was initialized.

Advanced: lower-level exports

The default client uses HttpTransport + Batcher internally. The package also exports BeaconTransport (unload-friendly sendBeacon / fetch with keepalive) and OfflineQueue / BreadcrumbBuffer if you build a custom pipeline. See dist/index.d.ts after install for signatures.

Requirements

  • JavaScript / TypeScript app with fetch available (modern browsers and Node 18+).
  • A running Mako stack that exposes the envelope ingestion route expected by your DSN.

For TypeScript, import types such as MakoConfig from @ruizrica/mako-sdk or rely on editor hints from dist/index.d.ts.