Created
March 8, 2019 23:57
-
-
Save dougblackjr/b2dccddb526623333f15d3b5975896de to your computer and use it in GitHub Desktop.
SPY: Spies user interactions for sending back to server, or dumping to browser
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
var Spy = (function (register, undefined) { | |
var eventStore = [], | |
events = ['click']; | |
var store = function (type, data) { | |
eventStore.push({ | |
type: type, | |
data: data | |
}); | |
}; | |
events.forEach(function (event) { | |
register(event, function (data) { | |
store(event, data); | |
}, false); | |
}); | |
return { | |
dump: function () { | |
console.log(eventStore); | |
}, | |
store: function () { | |
// do whatever you wanna do here… | |
}, | |
send: function() { | |
// @TODO: Create websocket/server call to send back | |
} | |
}; | |
})(document.addEventListener); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment