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

@trainerday/analytics-client

v1.3.5

Published

A lightweight JavaScript analytics client library with offline support for Hybrid and Progressive Web Apps

Readme

Analytics Client

Build Status

A lightweight (2.9k) JavaScript analytics client library with offline support for Hybrid and Progressive Web Apps.

This library provides a simple API for tracking events and user properties, compatible with popular analytics service endpoints. Events are written to localStorage first and are only removed once the analytics API confirms receipt, thus allowing the device to go offline without losing events.

Note: This client library can be used with self-hosted analytics APIs (like TrainerDay's analytics-api) or any compatible analytics service endpoint.

Self-Hosted Integration

To use with TrainerDay's analytics-api:

// Initialize with your self-hosted API endpoints
analytics.init('your-analytics-token', {
    trackingUrl: 'https://your-domain.com/track?data=',
    engageUrl: 'https://your-domain.com/engage?data='
});

// All existing code works unchanged
analytics.track('Event Name', { property: 'value' });
analytics.identify('[email protected]');

Demo: The analytics-api project includes a complete demo page at /demo/index.html showing integration examples.

Usage

NPM Installation (Recommended)

npm install @trainerday/analytics-client

CDN Installation

<script src="https://unpkg.com/@trainerday/analytics-client@latest/dist/analytics-client.min.js"></script>

Manual Installation

Download analytics-client.min.js and add to your project:

<script src="analytics-client.min.js"></script>

At present only the following methods are supported:

// Alias for cleaner code
var analytics = mixpanel;

// setup analytics client
analytics.init('your-token-here'); // pass { mute: true } to mute by default

// assign all future events to a user
analytics.identify('[email protected]');

// register 'Gender' as a super property
analytics.register({'Gender': 'Female'});

// assign user info
analytics.people.set({
    $email: '[email protected]' // only special properties need the $
});

// track an event
analytics.track('Your Event Name' {
    firstName: 'Optional event property 1',
    lastName: 'Optional event property 2'
});

// clear current identity
analytics.reset();

// stop sending data to analytics (calls to track, identify etc are ignored)
analytics.mute();

// resume sending data to analytics
analytics.unmute();

// check if analytics is muted
if (analytics.muted) {
    console.log('Analytics is disabled');
}

Contributing

Pull requests are welcomed:

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Dependencies

analytics-client uses window.localStorage and window.Promise which should exist in all modern browsers.

Update .min files

To generate a new analytics-client.min.js from source, tweak the version number in package.json and run:

npm run build

Star the repo

Star the repo if you find this useful as it helps me prioritize which bugs I should tackle first.

History

For change-log, check releases.

License

Licensed under MIT License © John Doherty