Commit c598b6de by Piotr Mitros

Logging has a timeout so it doesn't crash Chrome

parent f0786bbe
...@@ -3,12 +3,16 @@ ...@@ -3,12 +3,16 @@
var close_event_logged = false; var close_event_logged = false;
function log_close() { function log_close() {
var d=new Date();
var t=d.getTime();
close_event_logged = "waiting"; close_event_logged = "waiting";
log_event('page_close', {}); log_event('page_close', {});
// Google Chrome will close without letting the event go through. // Google Chrome will close without letting the event go through.
// This causes the page close to be delayed until we've hit the // This causes the page close to be delayed until we've hit the
// server. // server.
while(close_event_logged != "done") { // TODO: Check what happens with no network.
while((close_event_logged != "done") && (d.getTime() < t+500)) {
console.log(close_event_logged);
} }
} }
...@@ -220,8 +224,10 @@ function log_event(e, d) { ...@@ -220,8 +224,10 @@ function log_event(e, d) {
"page" : document.URL "page" : document.URL
}, },
function(data) { function(data) {
console.log("closing");
if (close_event_logged == "waiting") { if (close_event_logged == "waiting") {
close_event_logged == "done"; close_event_logged = "done";
console.log("closed");
} }
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment