Skip to content

Commit

Permalink
Fix async identification
Browse files Browse the repository at this point in the history
  • Loading branch information
bripkens committed May 6, 2019
1 parent 6e02baa commit ed176ce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions lib/hooks/XMLHttpRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/transmission/formEncoded.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions lib/vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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: [],
Expand Down

0 comments on commit ed176ce

Please sign in to comment.