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 🙏

© 2024 – Pkg Stats / Ryan Hefner

analytics-proxy

v0.2.0

Published

Proxy library to dispatch analytics to 3rd party providers in one single interface.

Downloads

1

Readme

analytics-proxy

A small analytics dispatching library that proxies common events to multiple providers. Currently includes Mixpanel, Intercom and Snowplow.

Installation

The package is hosted on Gemfury under @streemau/analytics-proxy. You will need to set up an Gemfury token via an environment variable, which can be found in your Gemfury account: export GEMFURY_TOKEN="..."

Then, you will need a .npmrc that contains the following, so you can install the private packages as well as public NPM packages:

@streemau:registry=https://npm.fury.io/streem/
//npm.fury.io/streem/:_authToken=${GEMFURY_TOKEN}
always-auth=true
registry="https://registry.npmjs.com/"

Usage

Ensure the script tags for each provider are loaded in the head of your app. Then simply import/require the analytics-proxy and configure with your analytics providers:

import AnalyticsProxy from 'analytics-proxy';

// configuration
const config = {
  // includes keys of the providers with their own config e.g. keys, settings, etc.
  mixpanel: { token: "<MIXPANEL_TOKEN>", ...other_config },
  intercom: { app_id: "<INTERCOM_APP_ID>", ...other_config },
  snowplow: { url: "<SNOWPLOW_URL>", options: <SNOWPLOW_OPTIONS> }
};

// create an instance to dispatch events
const analytics = new AnalyticsProxy(config);

// Initialize the providers to start tracking
analytics.init();

// track the currently logged in user, optionally with some metadata about the user
const userId = 123;
const metadata = { email: '[email protected]', first_name: 'Jackson' , last_name: 'Gross' };
analytics.identify(userId, metadata);

// stop tracking the user
analytics.reset();

// record a page view for the current page
analytics.pageView();

// record an event with some optional metadata describing the event
const event = 'Generated Report';
const eventMetadata = { type: 'pdf', title: 'My awesome report' };
analytics.trackEvent(event, eventMetadata);

Getting started

  1. Install dependencies
  • Run yarn install (recommended) or npm install to get the project's dependencies
  • Run yarn build or npm run build to produce minified version of the library.
  1. Development mode
  • Having all the dependencies installed run yarn dev or npm run dev. This command will generate an non-minified version of the library and will run a watcher so you get the compilation on file change.
  1. Running the tests
  • Run yarn test or npm run test. Can also run in watch mode with yarn test:watch or npm run test:watch

Releases

Ensure all new features have adequate test coverage before making a release. Once ready, ensure the package.json version number has been incremented following semver. Then authenticate to Gemfury through npm (see https://gemfury.com/help/npm-registry#npm-config) with npm login. Then simply run npm publish and the changes will be available from Gemfury!

Scripts

  • yarn build or npm run build - produces production version of the library under the lib folder
  • yarn dev or npm run dev - produces development version of the library and runs a watcher
  • yarn test or npm run test - runs the tests
  • yarn test:watch or npm run test:watch - same as above but in a watch mode
  • npm publish - publishes a new version of the package to Gemfury.