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

litetics

v1.1.3

Published

Embeddable javascript analytics event tracking library

Readme

Litetics

npm version npm downloads

Embeddable JavaScript analytics event tracking library. Server handlers for any JS runtime. Browser tracker with SPA support, session management, and automatic event enrichment.

Packages

| Entry | Purpose | | ------------------ | ------------------------------------------------------------------------------------------------------------ | | litetics | Server-side event and ping handler. Parses user-agent, referrer, Accept-Language, UTM params. Bot filtering. | | litetics/tracker | Browser tracker. Pageview lifecycle, SPA navigation, custom events, session timeouts, unload beacons. |

Install

# ✨ Auto-detect
npx nypm install litetics

# npm
npm install litetics

# yarn
yarn add litetics

# pnpm
pnpm add litetics

# bun
bun install litetics

# deno
deno install npm:litetics

Quick Start

Server (Hono)

import { Hono } from 'hono';
import { serve } from '@hono/node-server';
import { createEventRequestHandler, createPingRequestHandler, createPingResponse } from 'litetics';

const events = [];

const eventHandler = createEventRequestHandler({
  persist: (data) => {
    events.push(data);
  },
  update: ({ bid, durationMs }) => {
    const event = events.find((e) => e.bid === bid);
    if (event) event.durationMs = durationMs;
  },
});
const pingHandler = createPingRequestHandler();

const app = new Hono();

app.get('/ping', (c) => pingHandler.handle(c.req.raw).then(createPingResponse));
app.post('/event', async (c) => {
  await eventHandler.handle(c.req.raw);
  return c.body(null, 204);
});

serve({ fetch: app.fetch, port: 3000 });

Client (Browser)

import { createTracker } from 'litetics/tracker';

const tracker = createTracker({
  apiEndpoint: {
    track: 'http://localhost:3000/event',
    ping: 'http://localhost:3000/ping',
  },
});

// Start tracking the current page
const stop = tracker.register();

// Track a custom event
await tracker.track('signup_button', {
  type: 'engagement',
  label: 'hero-cta',
});

// Track with duration
await tracker.track('video_play', { type: 'media' }, { withDuration: true });
// ... later
await tracker.trackEndOf('video_play');

API

litetics — Server Exports

| Export | Description | | ------------------------------------------------ | ---------------------------------------------------------------------- | | createEventRequestHandler(options) | Creates an event handler. Calls persist on load, update on unload. | | createPingRequestHandler(options?) | Creates a ping handler for visitor uniqueness. | | createPingResponse(result) | Converts a PingRequestHandlerResult into a Response. | | EventData (type) | The full enriched event data object (50+ fields). | | EventRequestHandlerOptions<TProperties> (type) | Options for createEventRequestHandler. | | EventRequestHandlerParsers (type) | Overridable parser functions. | | EventRequestHandlerLoadRequestBody (type) | Shape of the load event POST body. | | EventRequestHandlerUnloadRequestBody (type) | Shape of the unload event POST body. | | PingRequestHandlerResult (type) | Result of a ping request. | | PingRequestHandlerOptions (type) | Options for createPingRequestHandler. | | EventRequestHandlerTrackOptions (type) | Getter-based track input. | | EventRequestHandlerTrackPayload (type) | Pre-resolved track input. |

litetics/tracker — Client Exports

| Export | Description | | -------------------------------- | ------------------------------------------------------------------------ | | createTracker(options) | Creates a tracker instance with register(), track(), trackEndOf(). | | createBrowserAdapter(options?) | Creates a RuntimeAdapter backed by browser APIs. | | RuntimeAdapter (type) | Interface for custom runtime adapters. | | BrowserAdapterOptions (type) | Options for createBrowserAdapter (mode: 'history' \| 'hash'). | | CreateTrackerOptions (type) | Options for createTracker. | | AnalyticsEvent (const) | Event name constants: { LOAD: 'load', UNLOAD: 'unload' }. |

Tracker Instance

{
  register: () => () => void;                                   // Start tracking, returns cleanup fn
  track: (key: string, data: { type: string; [k: string]: Primitive }, options?: { withDuration?: boolean }) => Promise<void>;
  trackEndOf: (key: string) => Promise<void>;                  // End a timed event
}

What Gets Parsed

Every load event is automatically enriched with:

| Category | Source | Fields produced | | -------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Page | Body u | host, path, queryString, hash | | User-Agent | Header User-Agent | browserName, browserVersion, browserEngineName, browserEngineVersion, deviceType, deviceVendor, deviceModel, cpuArchitecture, osName, osVersion | | Referrer | Body r | referrerHost, referrerPath, referrerQueryString, referrerKnown, referrerMedium, referrerName, referrerSearchParameter, referrerSearchTerm | | Language | Header Accept-Language | languageCode, languageScript, languageRegion, secondaryLanguageCode, secondaryLanguageScript, secondaryLanguageRegion | | UTM | URL query params | utmCampaign, utmMedium, utmSource, utmTerm, utmContent, utmId, utmSourcePlatform | | Location | Body t | timeZonecountry (two-letter code) | | Custom | Body d | properties (arbitrary key-value data) |

Documentation

Full docs at litetics.hrdtr.dev — architecture, complete API reference, integration guides, and playground.

Development

pnpm install
pnpm dev       # interactive tests (vitest dev)
pnpm play      # playground server at localhost:3000
pnpm test      # lint + typecheck + tests (123 tests, 100% coverage)
pnpm lint      # oxlint
pnpm typecheck # tsc --noEmit
pnpm build     # unbuild

License

Published under the MIT license. Made by community 💛


🤖 auto updated with automd