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

@elyochola/analytics-node

v0.1.0

Published

Node.js / Express analytics SDK for Pulse. Auto-captures API latency, errors, and custom events.

Readme

@elyochola/analytics-node

Node.js / Express SDK for Pulse analytics.

Installation

npm install @elyochola/analytics-node

Quick Start

import { createAnalytics } from '@elyochola/analytics-node';
import { createExpressMiddleware, wrapErrorHandler } from '@elyochola/analytics-node/express';

const analytics = createAnalytics({
  apiKey: process.env.PULSE_SECRET_KEY,   // sk_live_xxx
  endpoint: process.env.PULSE_ENDPOINT,    // https://ingest.example.com
});

// Track events
analytics.track('user_signup', { plan: 'pro' });
analytics.identify('user_123', { name: 'Ely' });

// Graceful shutdown
process.on('SIGTERM', () => analytics.shutdown());

Express Middleware

Automatically captures API request latency, route, method, status code, request ID, and tenant slug.

import { createExpressMiddleware, wrapErrorHandler } from '@elyochola/analytics-node/express';
import { errorHandler } from './middleware/errorHandler.js';

// Mount AFTER request ID middleware, body parsing, and gym-slug middleware
// Mount BEFORE route handlers
app.use(createExpressMiddleware(analytics, {
  ignoreRoutes: ['/api/health', '/api/test-logging', '/media'],
  tenantHeader: 'x-gym-slug',
  requestIdKey: 'id',              // req.id
  enrichContext: (req) => ({
    gymSlug: req.gymSlug,
    userId: req.user?.id,
  }),
}));

// Mount routes...
app.use('/api', routes);

// Wrap your existing error handler
app.use(wrapErrorHandler(analytics, errorHandler));

Middleware Options

| Option | Default | Description | |--------|---------|-------------| | ignoreRoutes | ['/health'] | Route prefixes to skip | | tenantHeader | 'x-gym-slug' | Header for tenant identification | | requestIdKey | 'id' | Property on req for request ID | | captureErrors | true | Auto-track 5xx responses as errors | | shouldCapture | () => true | Custom filter function | | enrichContext | () => ({}) | Add custom properties per request |

What's Captured Automatically

  • duration_ms — high-resolution request timing
  • route — Express route pattern (e.g., /api/member/:id)
  • method — HTTP method
  • status_code — response status code
  • request_id — from req.id or x-request-id header
  • tenant_id — from configured tenant header

API

createAnalytics(options)

| Option | Required | Default | Description | |--------|----------|---------|-------------| | apiKey | Yes | — | Secret API key (sk_live_xxx) | | endpoint | Yes | — | Ingestion API URL | | flushInterval | No | 5000 | Batch flush interval (ms) | | flushSize | No | 25 | Events per batch | | maxRetries | No | 3 | Retries per request | | onError | No | () => {} | Error callback |

Client Methods

| Method | Description | |--------|-------------| | track(eventName, properties?, context?) | Track a custom event | | identify(userId, traits?, context?) | Link user identity | | page(properties?, context?) | Track a page view | | error(err, context?) | Track an error/exception | | log(level, message, context?) | Forward a structured log | | performance(metricName, value, context?) | Track a performance metric | | flush() | Force flush queued events | | shutdown() | Flush and close (call on SIGTERM) |

Environment Variables

PULSE_SECRET_KEY=sk_live_xxxxxxxxxxxxx
PULSE_ENDPOINT=https://ingest.example.com