Skip to content

Beacon tracking doesn't seem to flush OutQueue #708

Description

Hi again!

So it looks like because of the way the POST method is set up, the outQueue is "flushed" (events that were sent are removed/shift()ed from the queue) only in the onreadystatechange handler.

for (var deleteCount = 0; deleteCount < numberToSend; deleteCount++) {
    outQueue.shift();
}

Because the beacon API hands off control to the browser, there's no onreadystatechange or similar callback - you just make the sendBeacon() call, and get the true back, which is the browser telling you it queued the call.

As a result, I've had instances where the outQueue just increases to infinite length over time, since it's saved to localStorage and then picked back up

The solution seems to be break this out into logic that's called from both places - let me know if my solution (Pull Request #709) works for you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions