Skip to content

Commit 575b6b8

Browse files
committed
When a POST is successful, dequeue all sent events, not just the first (see snowplow#168)
1 parent f96bbe8 commit 575b6b8

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/js/out_queue.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,18 @@
163163
executingQueue = false;
164164
}, 5000);
165165

166+
// Keep track of number of events to delete from queue
167+
var eventCount = outQueue.length;
168+
166169
xhr.onreadystatechange = function () {
167170
if (xhr.readyState === 4 && xhr.status === 200) {
168-
clearTimeout(xhrTimeout);
169-
outQueue.shift();
171+
for (var deleteCount = 0; deleteCount < eventCount; deleteCount++) {
172+
outQueue.shift();
173+
}
170174
if (localStorageAccessible() && useLocalStorage) {
171175
localStorage.setItem(queueName, json2.stringify(outQueue));
172176
}
177+
clearTimeout(xhrTimeout);
173178
executeQueue();
174179
} else if (xhr.readyState === 4 && xhr.status === 404) {
175180
executingQueue = false;

0 commit comments

Comments
 (0)