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-forwarder

v0.1.2

Published

Forwards analytics events to S3 via API Gateway and Firehose

Downloads

6

Readme

Analytics Forwarder

Forwards analytics events to S3 via API Gateway and Firehose. This repo includes the serverless lambda function for the endpoint, as well as the front-end Javascript SDK.


                                   .:+oooo+:.
                                ./oooooooooooo/
                            `-+oooooooooooooooo
                         .:+ooooooooooooooooooo
                     `-/ooooooooooooooooooooooo         .-`
                  .:+oooooooooooooooooooooooooo         -oo+:.
              `-/ooooooooooooooooooooo+//+ooooo         -oooooo/-`
            `/ooooooooooooooooooooo/-`    `-+oo         -ooooooooo/`
           `+ooooooooooooooooooo:.            .         -ooooooooooo`
           -oooooooooooooooo+:`                         -ooooooooooo-
           -ooooooooooooo/-                             -ooooooooooo-
           -ooooooooooo/                                -ooooooooooo-
           -ooooooooooo-             .:++/.             -ooooooooooo-
           -ooooooooooo-         `-/oooooooo/-`         -ooooooooooo-
           -ooooooooooo-         +oooooooooooo+         -ooooooooooo-
           -ooooooooooo-         +oooooooooooo+         -ooooooooooo-
           -ooooooooooo-         +oooooooooooo+         -ooooooooooo-
           -ooooooooooo-         +oooooooooooo+         -ooooooooooo-
           -ooooooooooo-         `-/oooooooo/-`         -ooooooooooo-
           -ooooooooooo-             .:++:.             -ooooooooooo-
           -ooooooooooo:                                /ooooooooooo-
           -oooooooooooo+:.                          .:ooooooooooooo-
           -oooooooooooooooo/-`                  `-/oooooooooooooooo-
           `+oooooooooooooooooo+:.            .:+ooooooooooooooooooo`
            `/oooooooooooooooooooo+/-`    `-/ooooooooooooooooooooo+`
              `-/+oooooooooooooooooooo+//+ooooooooooooooooooooo+:`
                  .:+ooooooooooooooooooooooooooooooooooooooo/-
                     `-/oooooooooooooooooooooooooooooooo+:.
                         .:+ooooooooooooooooooooooooo/-`
                            `-/oooooooooooooooooo+:.
                                .:+ooooooooooo/-`
                                   `-/oooo+:.

Lambda Installation (Experimental)

To deploy, after installing nvm:

nvm use
npm install -g [email protected]
npm install
./deploy [ENV]

SDK Usage

Client ID

const tracker = new AnalyticsForwarder({
  keyUrl: <URL_TO_GET_KEY>,
  analyticsUrl: <URL_TO_SEND_ANALYTICS>,
  clientId: <CLIENT_ID>,
  application: 'example',
});

tracker.setUser('1');
tracker.trackEvent('clicked_button', { button_text: 'help' });

Bearer Token

const tracker = new AnalyticsForwarder({
  keyUrl: <URL_TO_GET_KEY>,
  analyticsUrl: <URL_TO_SEND_ANALYTICS>,
  bearerToken: <BEARER_TOKEN>,
  application: 'example',
});

tracker.setUser('1', <BEARER_TOKEN>);
tracker.trackEvent('clicked_button', { button_text: 'help' });

Functions

getFingerprint() ⇒ Promise

Get a fingerprint for the user based on their IP address and user agent. Store the fingerprint as a cookie for when the user returns.

Kind: global function Returns: Promise - A promise with the fingerprint.

getKey() ⇒ Promise

Get a the tracking key for the user based on the authentication mode. If public is true, use a public client ID to get the key. If public is false, use a bearer token to get the key.

Kind: global function Returns: Promise - A promise with the tracking key.

setUser(id, bearerToken) ⇒ Promise

Set the current user to track and identify the user in the analytics.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | id | String | The id of the user to track. | | bearerToken | String | The bearer token for the user for non public tracking. |

trackEvent(event, properties) ⇒ Promise

Track an event with certain metadata and properties about the user.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | event | String | The name of the event to track. | | properties | Object | Metadata to track about the event. |

trackException(exception, fatal) ⇒ Promise

Track an exception event with the exception and whether or not it was fatal as properties.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | exception | String | The exception to track. | | fatal | Boolean | Whether or not the exceptionw as fatal. |

trackPage(page) ⇒ Promise

Track a page event with the name of the page as a property.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | page | String | The name of the page to track. |