Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -777,11 +777,16 @@ Raven.prototype = {
var xhrproto = XMLHttpRequest.prototype;
fill(xhrproto, 'open', function(origOpen) {
return function (method, url) { // preserve arity
this.__raven_xhr = {
method: method,
url: url,
status_code: null
};

// if Sentry key appears in URL, don't capture
if (url.indexOf(self._globalKey) === -1) {
this.__raven_xhr = {
method: method,
url: url,
status_code: null
};
}

return origOpen.apply(this, arguments);
};
});
Expand Down
29 changes: 28 additions & 1 deletion test/integration/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ describe('integration', function () {

iframeExecute(iframe, done,
function () {

// some browsers trigger onpopstate for load / reset breadcrumb state
Raven._breadcrumbs = [];

Expand Down Expand Up @@ -372,6 +371,34 @@ describe('integration', function () {
);
});

it('should NOT capture breadcrumbs from XMLHttpRequests to the Sentry store endpoint', function (done) {
var iframe = this.iframe;
iframeExecute(iframe, done,
function () {
// some browsers trigger onpopstate for load / reset breadcrumb state
Raven._breadcrumbs = [];

var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://example.com/api/1/store/?sentry_key=public');
xhr.setRequestHeader('Content-type', 'application/json');
xhr.onreadystatechange = function () {
// don't fire `done` handler until at least *one* onreadystatechange
// has occurred (doesn't actually need to finish)
if (xhr.readyState === 4) {
setTimeout(done);
}
};
xhr.send();
},
function () {
var Raven = iframe.contentWindow.Raven,
breadcrumbs = Raven._breadcrumbs;

assert.equal(breadcrumbs.length, 0);
}
);
});

it('should record a mouse click on element WITH click handler present', function (done) {
var iframe = this.iframe;

Expand Down