Code Monkey home page Code Monkey logo

pixel-tracker's Issues

Requests from email clients are not logged

It appears that because the useragent for email clients is not recognized, requests from email clients are not logged.

I fixed this in my local installation by using the full useragent string if it doesn't match any of the pre-specified browser/version regex's.

pixel-tracker with express 4

Update example for use in epxress 4

var tracker = require('pixel-tracker');
var express       = require('express'),
    bodyParser    = require('body-parser'),
    cookieParser  = require('cookie-parser'),
    cookieSession = require('cookie-session'),
    session       = require('express-session'),
    compress      = require('compression'),
    morgan        = require('morgan'),
    methodOverride= require('method-override'),
    uri           = express.Router(),
    app           = express(),
    server        = require('http').createServer(app);
var Buffer = require('buffer').Buffer;

var objToBeTracked;
 app.use(cookieParser());
tracker.use(function (error, result) {
  objToBeTracked = result;
 console.log(objToBeTracked);

  /*
  {
    "cookies": { "_tracker": "58f911166e6d31041eba8d06e11e3f77" },
    "host": "localhost:3000",
    "cache": { "max-age": "0" },
    "referer": "direct",
    "params": [],
    "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.gif', tracker.middleware,function  (argument) {
  exports.data = new Buffer(42);
exports.data.write("GIF89a\u0001\u0000\u0001\u0000�\u0000\u0000\u0000\u0000\u0000ÿÿÿ!ù\u0004\u0001\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0001\u0000\u0001\u0000\u0000\u0002\u0001D\u0000;", 'binary');
exports.size = 42;

exports.headers = {
  'Content-Length': 42,
  'Content-Type':   "image/gif",
  'Pragma':         'no-cache',
  'Cache-Control':  "no-store, no-cache, must-revalidate, max-age=0,post-check=0,pre-check=0"
}
});

server.listen(80);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.