Skip to content

Instantly share code, notes, and snippets.

@angrytoast
Created May 2, 2013 00:58
Show Gist options
  • Save angrytoast/5499496 to your computer and use it in GitHub Desktop.
Save angrytoast/5499496 to your computer and use it in GitHub Desktop.
// Base stream obj
var user_activity = {
'id' : new Date().getTime() + navigator.userAgent,
'uri' : document.location.pathname,
'stream' : {}
};
var INTERVAL = 2000; // check cursor every 2 secs
function log_activity(e){
var d = new Date();
ts = d.getTime(); // utc timestamp
user_activity.stream[ts] = {
't' : window.scrollY,
'x' : window.mouseX,
'y' : window.mouseY
}
}
document.onmousemove = function(e) {
var event = e || window.event;
window.mouseX = event.clientX;
window.mouseY = event.clientY;
}
setInterval(log_activity, INTERVAL);
window.onbeforeunload = function(){
jQuery.each(user_activity.stream, function(k,v){
console.log(k,v);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment