measurement-framework
Version:
Collection of Javascript code to implement a browser based measurement system for websites. It uses a cookie to store a users action on a webpage and let you map thoose actions to a particular state in the user journey.
22 lines (19 loc) • 698 B
JavaScript
import isJson from "is-json"
function ajaxCompleteNative(callback) {
XMLHttpRequest.prototype.realSend = XMLHttpRequest.prototype.send
XMLHttpRequest.prototype.send = function (body) {
this.addEventListener("progress", function () {
console.log("Loading")
}, false)
this.addEventListener("load", function () {
if (isJson(this.responseText)) {
var responseJSON = JSON.parse(this.responseText)
console.log("responses", responseJSON)
}
console.log("xhr", this)
console.log("body", body)
}, false)
this.realSend(body)
}
}
export default ajaxCompleteNative