The statsv client maintains an in-memory queue of metrics to send to the server.
If the queue length is under 50 (an internally set maximum batch size), then the metrics are sent to the server/dequeued two seconds after the last metric was added to the queue (A). If the queue length is over 50, then a batch of metrics are sent to the server/dequeued every two seconds until either the queue is empty or the preconditions for A are met.
However, if the queue has metrics in it and the page unloads, then in principle those metrics aren't sent to the server and are lost.
=== AC
* When the page unloads, any metrics in the queue should be sent to the server
* When the page loses visibility, any metrics in the queue should be sent to the server
=== Notes
1. @phuedx: The AC around page visibility comes from a conversation with @Krinkle. IIRC, in some mobile browsers, the `unload` event doesn't fire before the JavaScript VM is torn down after a tab is closed. However, we can be more confident that the `visibilitychange` does fire.
@Krinkle: Please feel free to correct me where I'm wrong/add more detail about this 馃檪