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

trk

v0.3.0

Published

lightning fast redis-powered event based stats

Downloads

9

Readme

trk

trk is an event based stats library for node.js that uses redis as a data store.

depending on the project, it can either be a total replacement for map/reduce routines, or, at the very least, a catalystic compliment that allows you to strike a performant balance between real-time data and hierarchical time bucket(y) reporting.

key concepts

  • events are recorded as objects (.record()), the only requirement is it has an event property
  • redis counters are modified on the fly into different areas as events come in
  • the time granularity supported is daily
  • there are 4 types of configurable properties for recording events
    1. bmp ("bitmap") counts unique values occurrences for this key
    2. add counts number of occurrences for each value of this key
    3. addv ("add value") sum of the values for all occurrences of this key
    4. top similar to add but returns the top occurrence values in order and limits the result set to 250
  • compound keys are supported by mapping them with a ~ delimiter
  • an interface to query data over date ranges is supplied (.query(),.query_days()), see examples
  • querying does not require a config and can be done from other machines, recording requires a map configuration

the data structure in redis ends up looks something like this

and for compound key combinations, if you choose to use them, like this

benefits

  • recording an event is :zap: fast and can be done in a fire-and-forget fashion
  • queries are :zap: fast and can be done in real-time with no need for caching in most cases

limitations

  • no regression. the raw event is never stored, it is broken down and digested into specific locations based on configuration and then is hair-flipped

install

using npm

npm i trk --save

usage

examples are located in src/examples

recording speed

build/examples/record-events.iced on a mbp i7(3.1)/16gb

$ node record-events.js
Finished recording 10000 events (series) in 7046ms
Series events digested/sec: 1419.244961680386
Finished recording 10000 events (parallel_limit) in 6449ms
Parallel events digested/sec: 1550.6280043417585

inspiration

todo

  • tests
  • map.bmp elaboration (support compound fields)
  • data inflation routine for compound key result sets
  • winston implementation for debug logging