Skip to content

Commit b97c649

Browse files
committed
Wrap XMLHttpRequest event handlers
1 parent 268fcf5 commit b97c649

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/raven.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,22 @@ Raven.prototype = {
606606
}
607607
});
608608

609+
var origSend;
610+
if ('XMLHttpRequest' in window) {
611+
origSend = XMLHttpRequest.prototype.send;
612+
XMLHttpRequest.prototype.send = function (data) { // preserve arity
613+
var xhr = this;
614+
'onreadystatechange onload onerror onprogress'.replace(/\w+/g, function (prop) {
615+
if (prop in xhr && Object.prototype.toString.call(xhr[prop]) === '[object Function]') {
616+
fill(xhr, prop, function (orig) {
617+
return self.wrap(orig);
618+
});
619+
}
620+
});
621+
origSend.apply(this, arguments);
622+
}
623+
}
624+
609625
},
610626

611627
_drainPlugins: function() {

0 commit comments

Comments
 (0)