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

nightgaunt

v1.1.3

Published

A lightweight, self-contained, vanilla JavaScript event tracking library.

Readme

Nightgaunt

A lightweight, self-contained, vanilla JavaScript event tracking library.

Features

  • Zero Dependencies: Pure vanilla JS.
  • Efficient: Batched event sending with retry logic.
  • Reliable: Handles network failures and retries automatically.
  • Privacy-Focused: Built-in support for consent management and anonymization.
  • Auto-Tracking: Optional automatic tracking for page views, clicks, form submissions, and page performance.
  • Session Management: Automatic session tracking with 30-minute inactivity timeout.

Installation

Direct Include (Browser)

Include the script directly in your HTML. You can use the minified version for production.

<script src="dist/nightgaunt.min.js"></script>

NPM / Bundlers

If you are using a bundler like Webpack, Rollup, or Vite:

npm install nightgaunt
import Nightgaunt from 'nightgaunt';

Usage

Initialization

Initialize the tracker with your configuration.

const tracker = new Nightgaunt({
    appId: 'my-app-id',
    namespace: 'marketing-site',
    endpoint: 'https://api.my-analytics.com/events',
    
    // Optional Configuration
    batchSize: 10,           // Flush after 10 events (default: 10)
    flushInterval: 5000,     // Flush every 5 seconds (default: 5000ms)
    consent: true,           // Start with consent granted (default: true)
    anonymize: false,        // Start in anonymous mode (default: false)
    
    // Auto-tracking configuration (default: all true)
    autoTrack: {
        pageView: true,
        buttonClick: true,
        linkClick: true,
        formSubmit: true,
        performance: true
    }
});

Tracking Custom Events

Track specific user actions with custom data.

tracker.track('signup_button_clicked', {
    plan: 'pro',
    source: 'homepage_banner'
});

Note: You can pass a string value instead of an object if needed, though an object is recommended for structured data.

tracker.track('search', 'query_string');

Privacy & Consent

Managing Consent

To comply with GDPR/CCPA, you can disable tracking until the user consents.

// Disable tracking (e.g., user declines cookies)
tracker.setConsent(false);

// Enable tracking (e.g., user accepts cookies)
tracker.setConsent(true);

When consent is revoked (false), the tracker stops processing events, clears the current queue, and will not send any data.

Anonymization

For users who want more privacy or for specific compliance modes, you can enable anonymization.

// Enable anonymous mode
tracker.setAnonymize(true);

In Anonymous Mode:

  • User IDs and Session IDs are stored in-memory only.
  • No cookies are set.
  • No localStorage is used.
  • All IDs are lost when the page is reloaded.

Auto-Tracking

Nightgaunt can automatically track common interactions. You can configure this during initialization.

const tracker = new Nightgaunt({
    /* ... other config ... */
    autoTrack: {
        pageView: true,      // Track page loads
        buttonClick: true,   // Track button clicks
        linkClick: true,     // Track link clicks
        formSubmit: true,    // Track form submissions
        performance: true    // Track page load performance metrics (see below)
    }
});

To disable auto-tracking entirely, pass autoTrack: false or omit the keys you don't want.

Performance Tracking

When performance: true, a page_performance event is sent after the page load event fires. The context object contains timing metrics (in milliseconds) derived from the Navigation Timing API:

| Field | Description | |---|---| | dns_lookup | DNS resolution time | | tcp_connect | TCP connection time | | tls_handshake | TLS handshake time (0 for HTTP) | | ttfb | Time to first byte | | content_download | Response body download time | | dom_interactive | Time until DOM is interactive | | dom_complete | Time until DOM is fully parsed | | page_load | Total page load time | | transfer_size | Total transfer size in bytes | | encoded_size | Encoded (compressed) body size in bytes | | decoded_size | Decoded (uncompressed) body size in bytes |

Event Schema

Every event sent to your endpoint will have the following JSON structure:

{
  "EventID": "uuid-v4",
  "CookieID": "uuid-v4",          // Persistent User ID (or memory ID if anonymous)
  "SessionID": "uuid-v4",         // Session ID (rotates after 30m inactivity)
  "DeviceCreated": "ISO-8601",    // Client timestamp when event occurred
  "DeviceSent": "ISO-8601",       // Client timestamp when batch was sent
  "DeviceTimezone": "String",     // e.g., "America/New_York"
  "EventGroup": "String",         // Namespace defined in config
  "EventLabel": "String",         // Event name
  "EventValue": "String",         // Optional primary value
  "ExtraContext": Boolean,        // True if ContextB64 is present
  "ContextB64": "String"          // Base64 encoded JSON context object
}

License

MIT