Skip to content

Commit

Permalink
Refactor xhr error log into function to save space on string
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-el committed Nov 15, 2023
1 parent 943afa6 commit 7b95fe6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libraries/browser-tracker-core/src/tracker/out_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ export function OutQueueManager(
});
};

const logXhrError = (xhr: XMLHttpRequest) => {
LOG.error(`Status ${xhr.status}, will not retry.`);
};

/**
* Send event as POST request right away without going to queue. Used when the request surpasses maxGetBytes or maxPostBytes
* @param body POST request body
Expand All @@ -229,7 +233,7 @@ export function OutQueueManager(
onRequestSuccess?.(batch);
} else {
if (!shouldRetryForStatusCode(xhr.status)) {
LOG.error(`Status ${xhr.status}, will not retry.`);
logXhrError(xhr);
tryOnRequestFailure(xhr.status, xhr.statusText, batch);
}
}
Expand Down Expand Up @@ -258,7 +262,7 @@ export function OutQueueManager(
executeQueue();
} else {
if (!shouldRetryForStatusCode(xhr.status)) {
LOG.error(`Status ${xhr.status}, will not retry.`);
logXhrError(xhr);
tryOnRequestFailure(xhr.status, xhr.statusText, batch);
removeEventsFromQueue(numberToSend);
}
Expand Down

0 comments on commit 7b95fe6

Please sign in to comment.