Created
May 2, 2013 00:58
-
-
Save angrytoast/5499496 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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