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

onedollarstats

v0.0.15

Published

A lightweight, zero-dependency analytics tracker for frontend apps

Readme

What's onedollarstats package?

OneDollarStats is a lightweight, zero-dependency analytics library for client applications that automatically tracks pageviews, UTM parameters, and custom events with minimal setup. It supports hash-based navigation, automatically collects UTM parameters, tracks clicks on elements with data-s-event attributes, and integrates effortlessly.

Installation

npm i onedollarstats

Getting Started

Configure analytics

⚠️ Initialize analytics on every page for static sites, or at the root layout (app entrypoint) in SPA apps. Calling view or event before configure will automatically initialize the tracker with the default configuration.

import { configure } from "onedollarstats";

// Configure analytics
configure({
  collectorUrl: "https://collector.onedollarstats.com/events",
  autocollect: true, // automatically tracks pageviews & clicks
  hashRouting: true // track SPA hash route changes
});

Manual Tracking

Note: Any path or properties you pass to view or event take priority over values found on the page (like data-s-path, data-s-view-props, or meta tags).

Track Pageviews

By default, pageviews are tracked automatically. If you want to track them manually (for example, with autocollect: false), you can use the view function:

import { view } from "onedollarstats";

// Simple pageview
view("/homepage");

// Pageview with extra properties
view("/checkout", { step: 2, plan: "pro" });

Track Custom Events

The event function can accept different types of arguments depending on your needs:

import { event } from "onedollarstats";

// Simple event
event("Purchase");

// Event with a path
event("Purchase", "/product");

// Event with properties
event("Purchase", { amount: 1, color: "green" });

// Event with path + properties
event("Purchase", "/product", { amount: 1, color: "green" });

API

configure(config?: AnalyticsConfig) initializes the tracker with your configuration.

Config Options:

| Option | Type | Default | Description | | ------------------ | ---------------- | --------------------------------------------- | --------------------------------------------------------------------------------- | | collectorUrl | string | https://collector.onedollarstats.com/events | URL to send analytics events | | trackLocalhostAs | string \| null | null | Deprecated. Use hostname and devmode | | hostname | string \| null | null | Override event hostname(for server-side or desktop runtimes) Required for devmode | | devmode | boolean | false | For dev testing, requires hostname | | hashRouting | boolean | false | Track hash route changes as pageviews | | autocollect | boolean | true | Automatically track pageviews & clicks | | excludePages | string[] | [] | Pages to ignore for automatic tracking | | includePages | string[] | [] | Pages to explicitly include for tracking |

Notes:

  • Manual calls of view or event ignore excludePages/includePages.
  • By default, events from localhost are ignored. Use the hostname and devmode options to simulate a hostname for local development.

view(pathOrProps?: string | Record<string, string>, props?: Record<string, string>) sends a pageview event.

Parameters:

  • pathOrProps – Optional, string represents the path, object represents custom properties.
  • props – Optional, properties if the first argument is a path string.

event(eventName: string, pathOrProps?: string | Record<string, string>, props?: Record<string, string>) sends a custom event.

Parameters:

  • eventName – Name of the event.
  • pathOrProps – Optional, string represents the path, object represents custom properties.
  • props – Optional, properties if the second argument is a path string.

Autocapture

Page view events

List of attributes for tags that allow modifying the sent page view:

  • data-s-path – Optional. Specifies the path representing the page where the event occurred. This attribute should be set on the <body> tag.

  • data-s-view-props – Optional. Defines additional properties to include with the page view event. All properties from elements on the page with this attribute will be collected and sent together.

Click events

Automatically capture clicks on elements using these HTML attributes:

  • data-s-event– Name of the event
  • data-s-event-path Optional, the path representing the page where the event occurred
  • data-s-event-props – Optional, properties to send with the event

See full onedollarstats documentation.