diff --git a/lib/hooks/XMLHttpRequest.js b/lib/hooks/XMLHttpRequest.js index b11ea4a40..e2d906b26 100644 --- a/lib/hooks/XMLHttpRequest.js +++ b/lib/hooks/XMLHttpRequest.js @@ -77,8 +77,8 @@ export function instrumentXMLHttpRequest() { return originalOpen.apply(xhr, arguments); } - const urlIgnored = state.ignored = isUrlIgnored(url); - if (urlIgnored) { + state.ignored = isUrlIgnored(url); + if (state.ignored) { if (DEBUG) { debug( 'Not generating XHR beacon because it should be ignored according to user configuration. URL: ' + url @@ -105,7 +105,7 @@ export function instrumentXMLHttpRequest() { 'l': win.location.href, 'm': method, 'u': normalizeUrl(url), - 'a': async ? 1 : 0, + 'a': async === undefined || async ? 1 : 0, 'st': 0, 'e': undefined, 'bc': state.setBackendCorrelationHeaders ? 1 : 0 @@ -158,6 +158,10 @@ export function instrumentXMLHttpRequest() { } function onError(e) { + if (state.ignored) { + return; + } + let message = e && ((e.error && e.error.message) || e.message); if (typeof message === 'string') { beacon['e'] = message.substring(0, 300); diff --git a/lib/transmission/formEncoded.js b/lib/transmission/formEncoded.js index 54e3a6d2a..dad5d1876 100644 --- a/lib/transmission/formEncoded.js +++ b/lib/transmission/formEncoded.js @@ -16,8 +16,8 @@ export function sendBeacon(data: Beacon) { if (XMLHttpRequest && str.length > maxLengthForImgRequest) { const xhr = new XMLHttpRequest(); - xhr.open('POST', String(vars.reportingUrl), true); disableMonitoringForXMLHttpRequest(xhr); + xhr.open('POST', String(vars.reportingUrl), true); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); // Ensure that browsers do not try to automatically parse the response. xhr.responseType = 'text'; diff --git a/lib/vars.js b/lib/vars.js index 70674a934..7150b5767 100644 --- a/lib/vars.js +++ b/lib/vars.js @@ -190,7 +190,7 @@ const defaultVars: { // eum('wrapTimers', true) wrapTimers: boolean, - // This key will be used by Weasel to privatelt store data ob objects. + // This key will be used by Weasel to privately store data on objects. // Make sure to change this key when deploying Weasel in production. secretPropertyKey: string, @@ -214,7 +214,7 @@ const defaultVars: { highResTimestampReference: performance && performance.now ? performance.now() : 0, initializerExecutionTimestamp: now(), reportingUrl: null, - beaconBatchingTime: 500, + beaconBatchingTime: 0, apiKey: null, meta: {}, ignoreUrls: [],