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

@incrowd/track-util

v2.0.0

Published

Generic event tracking module

Readme

Generic Event Tracking Module

A collection of JavaScript functions to track events such as page view and social sharing using Snowplow.

Motivation

To reuse the same collection of event tracking functions across all projects powered by FanScore.

Requirements

Snowplow must be set up using the following script:

// Snowplow script
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.0/sp.js","snowplow"));

// Create new tracker
snowplow('newTracker', 'TRACKER_NAME', 'COLLECTOR_ENDPOINT', {
    appId: 'com.example.app',
    platform: 'web',
    contexts: {webPage: true, geolocation: false}
})

Read more about loading Snowplow.

Getting Started

npm i @incrowd/track-util or yarn add @incrowd/track-util

then in JavaScript:

import trackUtil from '@incrowd/track-util'
const config = {
    // Optional, if omitted, calling trackPageView will not store view time
    setPageViewStartTime: time => {
        // Logic to store time
    },
    // Optional, if omitted, cannot call trackPageViewTiming
    pageViewStartTime: () => {
        // return pageViewStartTime
    },
    // Optional, if omitted, cannot call trackLogin, getUser will always return null and auth context will always be anonymous
    authObj: () => {
        // return authObj
    },
    // Optional, default is 'INCROWD'
    clientId: () => {
        // return clientId
    }
}
const icTrack = trackUtil(config)

API

trackPageView (pageName)

icTrack.trackPageView(pageName)

Track page view of given pageName and setPageViewStartTime for trackPageViewTiming.


trackPageViewTiming (pageName, pageDesc, contentId)

icTrack.trackPageViewTiming(pageName, pageDesc, contentId)

Track duration and start time of page view. pageDesc and contentId are optional.


trackLogin (source)

icTrack.trackLogin(source)

Track user login. source is the name given to indicate which application the user is logging into.


trackShare (name, target, contentId, contentDescription)

icTrack.trackShare(name, target, contentId, contentDescription)

Track social sharing of a particular social platform.


trackWebLink (url, name, contentId, contentDescription)

icTrack.trackWebLink(url, name, contentId, contentDescription)

Track navigation to external websites.


trackPollParticipation (data)

icTrack.trackPollParticipation(data)

Track poll participation. Read more about poll participation context


trackPredictorParticipation (data)

icTrack.trackPredictorParticipation(data)

Track predictor participation. Read more about predictor participation context


trackSelfDescribingEvent (schema, data)

icTrack.trackSelfDescribingEvent(schema, data)

Track self-describing event, mostly used by other methods within this library. Read more about self-describing event.


trackStructEvent (category, action, label, property, value)

icTrack.trackStructEvent(category, action, label, property, value)

Read more about structured event.


authContext ()

const context = icTrack.authContext()

Return authentication context base on authObj, mostly used by other methods within this library.


appContext ()

const context = icTrack.appContext()

Currently return clientId as versionName, mostly used by other methods within this library.


getUser ()

const user = icTrack.getUser()

Decode JWT token and return user object. null is returned if authentication object does not exist. Mostly used by other methods within this library.