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

node-pixel-tracker

v0.1.0

Published

a simple pixel tracker for node

Downloads

4

Readme

node-pixel-tracker

A simple pixel-tracker for node.js based on https://github.com/tblobaum/pixel-tracker

Build Status

Example

Collect some data with parameters, along with the defaults


var tracker = require('pixel-tracker')

tracker.use(function (error, result) {
  console.log(result)
  
  /*
  {
    "cookies": { "_tracker": "58f911166e6d31041eba8d06e11e3f77" },
    "host": "localhost:3000",
    "cache": { "max-age": "0" },
    "referer": "direct",
    "params": [],
    "path": '/pixel'
    "decay": 1342597993859,
    "useragent": { "browser": "Chrome", "version": "20.0" },
    "language": [ "en-US", "en", { "q": "0.8" } ],
    "geo": { "ip": "127.0.0.1" },
    "domain": "localhost"
  }
  */

})

// ..

app.all('/pixel', tracker.middleware)

app.listen()

Methods

var tracker = require('pixel-tracker')

tracker.use(callback)

The callback function is called with error, result. Multiple callbacks can be used.

tracker.configure(options)

pixel-tracker has a few configurable options.

disable_cookies defaults to false ip default to false, added to get req.ip if it is set cookieName defaults to '_tracker', set your own cookie name noRefreshPath default '', here you have the possebility to have a special path that won't set the cookie or extend its runtime, useful if you use it on foreign pages that should not refresh the pixel but track our data

tracker.middleware(request, response)

A function to be called for each http request which calls response.end with a 1x1 pixel for every request and then calls all the functions provided with tracker.use. This works out of the box with express and would also work with any vanilla http server as long as a cookies implementation is provided for the response object (or cookies are disabled)


var tracker = require('pixel-tracker')

tracker
  .use(function (error, result) {
    // do something with result
    // ...

  })
  .configure({ disable_cookies : true })

require('http').createServer(tracker.middleware).listen(3000)

Install

npm install pixel-tracker

Tests

npm install -g tap && npm test

License

MIT