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

telemetry.js

v1.1.5

Published

Privacy-friendly visit tracking

Readme

Telemetry.js

🎲 Privacy-friendly visit tracking for Node.js

NPM

GitHub file size in bytes npm npm GitHub

Highlights

  • <4kb visit tracking library without database
  • 100% server-side
  • 100% open-source
  • MongoDB support
  • Detects & ignores bots
  • Privacy-friendly at its core
  • GDPR-compliant

JavaScript Style Guide

Install

$ npm install telemetry.js

Usage

var telemetry = require('telemetry.js')
telemetry = telemetry({ enableMongo: false })

Track visits with:

telemetry.trackVisit(req)

That's it! Add this line of code before you respond to a request and it will track every request to the visits.json file.

How it works

Unlike other web analytics tools (e.g. Google Analytics), Telemetry does not work in the visitor's browser. Instead it parses the HTTP request header and works fully server-side.

When a user sends a request, your server processes the request header through the trackVisit() function.

Telemetry then reads the client user agent, including browser, operating system & device type, and saves the parsed information as a visit to the visits.json file.

For every request, Telemetry creates a visit with a lot of useful information.

  • traffic source - path and referer
  • technology - browser, OS, and device type
  • location - country, region, and city

This is how a visit usually looks like in your visits.json file:

{
      "path": "/products",
      "referer": "https://bitly.com/",
      "browser": {
        "name": "Safari",
        "version": "12.0.2"
      },
      "os": {
        "name": "macOS",
        "version": "10.14.2"
      },
      "device": "desktop",
      "country": "US",
      "region": "CA",
      "city": "San Francisco",
      "timestamp": 1554076800
    }

Privacy Fundamentals

Telemetry does not collect any personal information and thus it does not save client's IP addresses. Instead, it looks up the client's location (country, region & city) via the geoip-lite library without actually saving the IP address.

Many web browsers give users the option to signal their tracking preferences with the Do Not Track request header. Operators are not obliged to comply with that request, however Telemetry complies with DNT-requests and ignores those visitors.

Using MongoDB

Using the visits.json to keep track of visits might be enough for small-scale websites and applications. A single record usually takes 300B of storage and thus the log can grow very quickly, if you run an application with heavy traffic.

Telemetry offers the options to save tracked visits to a MongoDB database instead of the visits.json file. This option is much more scalable and easy to set up.

Initialize Telemetry:

var telemetry = require('telemetry.js')
telemetry = telemetry({ enableMongo: true, connection: 'mongodb://user:password@host:port' })

You can track visits as usual with:

telemetry.trackVisit(req)

What's Next?

  • [x] Alternative Storage
  • [x] Track referrers
  • [ ] Visual dashboard
  • [ ] Event tracking