{"action":"created","comment":{"url":"https://api.github.com/repos/Animatron/player/pulls/comments/39160622","id":39160622,"diff_hunk":"@@ -0,0 +1,77 @@\n+var engine = require('engine'),\n+    utils = require('./utils.js');\n+\n+var Analytics = function () {\n+    var self = this,\n+        supportSendBeacon = !!navigator.sendBeacon,\n+        timeout = supportSendBeacon ? 2000 : 1000,\n+        beacon = null,\n+        animatronUrl = utils.makeApiUrl('/analytics');\n+\n+    self.queue = [];\n+\n+    var event = function () {\n+        if (self.queue.length > 0) {\n+            var data = JSON.stringify(self.queue);\n+            self.queue = [];\n+\n+            if (supportSendBeacon) {\n+                navigator.sendBeacon(animatronUrl, data);\n+                setTimeout(event, timeout);\n+            } else {\n+                var trackUrl = animatronUrl + '?player=' + encodeURIComponent(data);\n+                sendViaGif(trackUrl);\n+            }\n+        } else {\n+            setTimeout(event, timeout);\n+        }\n+    };\n+\n+    var sendViaGif = function (trackUrl) {\n+        if (!beacon) {\n+            beacon = engine.createStatImg();\n+        }\n+        beacon.src = trackUrl;\n+        beacon.onerror = beacon.onload = function () {\n+            beacon.onerror = beacon.onload = null;\n+            setTimeout(event, timeout);\n+        }\n+    };\n+    event();","path":"src/anm/analytics.js","position":null,"original_position":40,"commit_id":"f6a61c65bb5621c1a285a77e5d0195a79e788864","original_commit_id":"d6de3f774afe8c3502338c687579b0eaa93150d8","user":{"login":"shamansir","id":110920,"avatar_url":"https://avatars.githubusercontent.com/u/110920?v=3","gravatar_id":"","url":"https://api.github.com/users/shamansir","html_url":"https://github.com/shamansir","followers_url":"https://api.github.com/users/shamansir/followers","following_url":"https://api.github.com/users/shamansir/following{/other_user}","gists_url":"https://api.github.com/users/shamansir/gists{/gist_id}","starred_url":"https://api.github.com/users/shamansir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shamansir/subscriptions","organizations_url":"https://api.github.com/users/shamansir/orgs","repos_url":"https://api.github.com/users/shamansir/repos","events_url":"https://api.github.com/users/shamansir/events{/privacy}","received_events_url":"https://api.github.com/users/shamansir/received_events","type":"User","site_admin":false},"body":"Don't call it at all, why? Call it just on `window.unload`, that's enough. ","created_at":"2015-09-10T13:42:13Z","updated_at":"2015-09-10T13:42:13Z","html_url":"https://github.com/Animatron/player/pull/327#discussion_r39160622","pull_request_url":"https://api.github.com/repos/Animatron/player/pulls/327","_links":{"self":{"href":"https://api.github.com/repos/Animatron/player/pulls/comments/39160622"},"html":{"href":"https://github.com/Animatron/player/pull/327#discussion_r39160622"},"pull_request":{"href":"https://api.github.com/repos/Animatron/player/pulls/327"}}},"pull_request":{"url":"https://api.github.com/repos/Animatron/player/pulls/327","id":44122295,"html_url":"https://github.com/Animatron/player/pull/327","diff_url":"https://github.com/Animatron/player/pull/327.diff","patch_url":"https://github.com/Animatron/player/pull/327.patch","issue_url":"https://api.github.com/repos/Animatron/player/issues/327","number":327,"state":"open","locked":false,"title":"WIP. Player analytics","user":{"login":"RobertoUa","id":1307169,"avatar_url":"https://avatars.githubusercontent.com/u/1307169?v=3","gravatar_id":"","url":"https://api.github.com/users/RobertoUa","html_url":"https://github.com/RobertoUa","followers_url":"https://api.github.com/users/RobertoUa/followers","following_url":"https://api.github.com/users/RobertoUa/following{/other_user}","gists_url":"https://api.github.com/users/RobertoUa/gists{/gist_id}","starred_url":"https://api.github.com/users/RobertoUa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RobertoUa/subscriptions","organizations_url":"https://api.github.com/users/RobertoUa/orgs","repos_url":"https://api.github.com/users/RobertoUa/repos","events_url":"https://api.github.com/users/RobertoUa/events{/privacy}","received_events_url":"https://api.github.com/users/RobertoUa/received_events","type":"User","site_admin":false},"body":"do not merge yet, WIP","created_at":"2015-09-03T15:37:23Z","updated_at":"2015-09-10T13:42:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d4c427815640e2ee9a88653deb2d1470bf8be8bf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Animatron/player/pulls/327/commits","review_comments_url":"https://api.github.com/repos/Animatron/player/pulls/327/comments","review_comment_url":"https://api.github.com/repos/Animatron/player/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Animatron/player/issues/327/comments","statuses_url":"https://api.github.com/repos/Animatron/player/statuses/f6a61c65bb5621c1a285a77e5d0195a79e788864","head":{"label":"RobertoUa:barna/analytics","ref":"barna/analytics","sha":"f6a61c65bb5621c1a285a77e5d0195a79e788864","user":{"login":"RobertoUa","id":1307169,"avatar_url":"https://avatars.githubusercontent.com/u/1307169?v=3","gravatar_id":"","url":"https://api.github.com/users/RobertoUa","html_url":"https://github.com/RobertoUa","followers_url":"https://api.github.com/users/RobertoUa/followers","following_url":"https://api.github.com/users/RobertoUa/following{/other_user}","gists_url":"https://api.github.com/users/RobertoUa/gists{/gist_id}","starred_url":"https://api.github.com/users/RobertoUa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RobertoUa/subscriptions","organizations_url":"https://api.github.com/users/RobertoUa/orgs","repos_url":"https://api.github.com/users/RobertoUa/repos","events_url":"https://api.github.com/users/RobertoUa/events{/privacy}","received_events_url":"https://api.github.com/users/RobertoUa/received_events","type":"User","site_admin":false},"repo":{"id":18397037,"name":"player","full_name":"RobertoUa/player","owner":{"login":"RobertoUa","id":1307169,"avatar_url":"https://avatars.githubusercontent.com/u/1307169?v=3","gravatar_id":"","url":"https://api.github.com/users/RobertoUa","html_url":"https://github.com/RobertoUa","followers_url":"https://api.github.com/users/RobertoUa/followers","following_url":"https://api.github.com/users/RobertoUa/following{/other_user}","gists_url":"https://api.github.com/users/RobertoUa/gists{/gist_id}","starred_url":"https://api.github.com/users/RobertoUa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RobertoUa/subscriptions","organizations_url":"https://api.github.com/users/RobertoUa/orgs","repos_url":"https://api.github.com/users/RobertoUa/repos","events_url":"https://api.github.com/users/RobertoUa/events{/privacy}","received_events_url":"https://api.github.com/users/RobertoUa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RobertoUa/player","description":"JavaScript player for Animatron Tool","fork":true,"url":"https://api.github.com/repos/RobertoUa/player","forks_url":"https://api.github.com/repos/RobertoUa/player/forks","keys_url":"https://api.github.com/repos/RobertoUa/player/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RobertoUa/player/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RobertoUa/player/teams","hooks_url":"https://api.github.com/repos/RobertoUa/player/hooks","issue_events_url":"https://api.github.com/repos/RobertoUa/player/issues/events{/number}","events_url":"https://api.github.com/repos/RobertoUa/player/events","assignees_url":"https://api.github.com/repos/RobertoUa/player/assignees{/user}","branches_url":"https://api.github.com/repos/RobertoUa/player/branches{/branch}","tags_url":"https://api.github.com/repos/RobertoUa/player/tags","blobs_url":"https://api.github.com/repos/RobertoUa/player/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RobertoUa/player/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RobertoUa/player/git/refs{/sha}","trees_url":"https://api.github.com/repos/RobertoUa/player/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RobertoUa/player/statuses/{sha}","languages_url":"https://api.github.com/repos/RobertoUa/player/languages","stargazers_url":"https://api.github.com/repos/RobertoUa/player/stargazers","contributors_url":"https://api.github.com/repos/RobertoUa/player/contributors","subscribers_url":"https://api.github.com/repos/RobertoUa/player/subscribers","subscription_url":"https://api.github.com/repos/RobertoUa/player/subscription","commits_url":"https://api.github.com/repos/RobertoUa/player/commits{/sha}","git_commits_url":"https://api.github.com/repos/RobertoUa/player/git/commits{/sha}","comments_url":"https://api.github.com/repos/RobertoUa/player/comments{/number}","issue_comment_url":"https://api.github.com/repos/RobertoUa/player/issues/comments{/number}","contents_url":"https://api.github.com/repos/RobertoUa/player/contents/{+path}","compare_url":"https://api.github.com/repos/RobertoUa/player/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RobertoUa/player/merges","archive_url":"https://api.github.com/repos/RobertoUa/player/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RobertoUa/player/downloads","issues_url":"https://api.github.com/repos/RobertoUa/player/issues{/number}","pulls_url":"https://api.github.com/repos/RobertoUa/player/pulls{/number}","milestones_url":"https://api.github.com/repos/RobertoUa/player/milestones{/number}","notifications_url":"https://api.github.com/repos/RobertoUa/player/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RobertoUa/player/labels{/name}","releases_url":"https://api.github.com/repos/RobertoUa/player/releases{/id}","created_at":"2014-04-03T09:00:30Z","updated_at":"2014-06-04T11:05:31Z","pushed_at":"2015-09-10T12:45:46Z","git_url":"git://github.com/RobertoUa/player.git","ssh_url":"git@github.com:RobertoUa/player.git","clone_url":"https://github.com/RobertoUa/player.git","svn_url":"https://github.com/RobertoUa/player","homepage":"http://animatron.com/player","size":29814,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Animatron:develop","ref":"develop","sha":"626a9b0bec38ac4f3eeffd2520cc4141071dcf29","user":{"login":"Animatron","id":1387673,"avatar_url":"https://avatars.githubusercontent.com/u/1387673?v=3","gravatar_id":"","url":"https://api.github.com/users/Animatron","html_url":"https://github.com/Animatron","followers_url":"https://api.github.com/users/Animatron/followers","following_url":"https://api.github.com/users/Animatron/following{/other_user}","gists_url":"https://api.github.com/users/Animatron/gists{/gist_id}","starred_url":"https://api.github.com/users/Animatron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Animatron/subscriptions","organizations_url":"https://api.github.com/users/Animatron/orgs","repos_url":"https://api.github.com/users/Animatron/repos","events_url":"https://api.github.com/users/Animatron/events{/privacy}","received_events_url":"https://api.github.com/users/Animatron/received_events","type":"Organization","site_admin":false},"repo":{"id":3326050,"name":"player","full_name":"Animatron/player","owner":{"login":"Animatron","id":1387673,"avatar_url":"https://avatars.githubusercontent.com/u/1387673?v=3","gravatar_id":"","url":"https://api.github.com/users/Animatron","html_url":"https://github.com/Animatron","followers_url":"https://api.github.com/users/Animatron/followers","following_url":"https://api.github.com/users/Animatron/following{/other_user}","gists_url":"https://api.github.com/users/Animatron/gists{/gist_id}","starred_url":"https://api.github.com/users/Animatron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Animatron/subscriptions","organizations_url":"https://api.github.com/users/Animatron/orgs","repos_url":"https://api.github.com/users/Animatron/repos","events_url":"https://api.github.com/users/Animatron/events{/privacy}","received_events_url":"https://api.github.com/users/Animatron/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Animatron/player","description":"JavaScript player for Animatron Tool","fork":false,"url":"https://api.github.com/repos/Animatron/player","forks_url":"https://api.github.com/repos/Animatron/player/forks","keys_url":"https://api.github.com/repos/Animatron/player/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Animatron/player/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Animatron/player/teams","hooks_url":"https://api.github.com/repos/Animatron/player/hooks","issue_events_url":"https://api.github.com/repos/Animatron/player/issues/events{/number}","events_url":"https://api.github.com/repos/Animatron/player/events","assignees_url":"https://api.github.com/repos/Animatron/player/assignees{/user}","branches_url":"https://api.github.com/repos/Animatron/player/branches{/branch}","tags_url":"https://api.github.com/repos/Animatron/player/tags","blobs_url":"https://api.github.com/repos/Animatron/player/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Animatron/player/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Animatron/player/git/refs{/sha}","trees_url":"https://api.github.com/repos/Animatron/player/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Animatron/player/statuses/{sha}","languages_url":"https://api.github.com/repos/Animatron/player/languages","stargazers_url":"https://api.github.com/repos/Animatron/player/stargazers","contributors_url":"https://api.github.com/repos/Animatron/player/contributors","subscribers_url":"https://api.github.com/repos/Animatron/player/subscribers","subscription_url":"https://api.github.com/repos/Animatron/player/subscription","commits_url":"https://api.github.com/repos/Animatron/player/commits{/sha}","git_commits_url":"https://api.github.com/repos/Animatron/player/git/commits{/sha}","comments_url":"https://api.github.com/repos/Animatron/player/comments{/number}","issue_comment_url":"https://api.github.com/repos/Animatron/player/issues/comments{/number}","contents_url":"https://api.github.com/repos/Animatron/player/contents/{+path}","compare_url":"https://api.github.com/repos/Animatron/player/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Animatron/player/merges","archive_url":"https://api.github.com/repos/Animatron/player/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Animatron/player/downloads","issues_url":"https://api.github.com/repos/Animatron/player/issues{/number}","pulls_url":"https://api.github.com/repos/Animatron/player/pulls{/number}","milestones_url":"https://api.github.com/repos/Animatron/player/milestones{/number}","notifications_url":"https://api.github.com/repos/Animatron/player/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Animatron/player/labels{/name}","releases_url":"https://api.github.com/repos/Animatron/player/releases{/id}","created_at":"2012-02-01T15:33:51Z","updated_at":"2015-08-23T05:30:21Z","pushed_at":"2015-09-10T12:45:47Z","git_url":"git://github.com/Animatron/player.git","ssh_url":"git@github.com:Animatron/player.git","clone_url":"https://github.com/Animatron/player.git","svn_url":"https://github.com/Animatron/player","homepage":"http://animatron.github.io/player","size":35867,"stargazers_count":43,"watchers_count":43,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":1,"forks":10,"open_issues":1,"watchers":43,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Animatron/player/pulls/327"},"html":{"href":"https://github.com/Animatron/player/pull/327"},"issue":{"href":"https://api.github.com/repos/Animatron/player/issues/327"},"comments":{"href":"https://api.github.com/repos/Animatron/player/issues/327/comments"},"review_comments":{"href":"https://api.github.com/repos/Animatron/player/pulls/327/comments"},"review_comment":{"href":"https://api.github.com/repos/Animatron/player/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Animatron/player/pulls/327/commits"},"statuses":{"href":"https://api.github.com/repos/Animatron/player/statuses/f6a61c65bb5621c1a285a77e5d0195a79e788864"}}}}