{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/activity-streams/pulls/comments/53183714","id":53183714,"diff_hunk":"@@ -0,0 +1,89 @@\n+const tabs = require(\"sdk/tabs\");\n+const ss = require(\"sdk/simple-storage\");\n+\n+const NEWTAB_URL = \"resource://activity-streams/data/content/activity-streams.html#/\";\n+\n+const TabTracker = {\n+  _openTabs: [],\n+\n+  init: function() {\n+    this.onOpen = this.onOpen.bind(this);\n+    tabs.on(\"open\", this.onOpen);\n+    if (!ss.storage.tabData) {\n+      ss.storage.tabData = {};\n+    }\n+  },\n+\n+  uninit: function() {\n+    for (let i in this._openTabs) {\n+      let tab = this._openTabs[i];\n+      tab.removeListener(\"pageshow\", this.logShow);\n+      tab.removeListener(\"activate\", this.logActivate);\n+      tab.removeListener(\"deactivate\", this.logDeactivate);\n+      tab.removeListener(\"close\", this.logClose);\n+    }\n+    tabs.removeListener(\"open\", TabTracker.onOpen);\n+  },\n+\n+  navigateAwayFromNewtab: function(tab) {\n+    if (!ss.storage.tabData[tab.id]) {\n+      // We're navigating away from a newtab that didn't even load yet.\n+      // Let's say it's been active for 0 seconds.\n+      ss.storage.tabData[tab.id] = {activations: [{startTime: Date.now(), totalTime: 0}]};\n+      return;\n+    }\n+    let activations = ss.storage.tabData[tab.id].activations;\n+    let lastElement = activations[activations.length - 1];\n+    if (lastElement.startTime && !lastElement.totalTime) {\n+      lastElement.totalTime = (Date.now() - lastElement.startTime) / 1000;\n+    }","path":"lib/TabTracker.js","position":39,"original_position":39,"commit_id":"ca37a7c41115c53c6d35191040e73d7a7937bb3d","original_commit_id":"ca37a7c41115c53c6d35191040e73d7a7937bb3d","user":{"login":"oyiptong","id":9365,"avatar_url":"https://avatars.githubusercontent.com/u/9365?v=3","gravatar_id":"","url":"https://api.github.com/users/oyiptong","html_url":"https://github.com/oyiptong","followers_url":"https://api.github.com/users/oyiptong/followers","following_url":"https://api.github.com/users/oyiptong/following{/other_user}","gists_url":"https://api.github.com/users/oyiptong/gists{/gist_id}","starred_url":"https://api.github.com/users/oyiptong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oyiptong/subscriptions","organizations_url":"https://api.github.com/users/oyiptong/orgs","repos_url":"https://api.github.com/users/oyiptong/repos","events_url":"https://api.github.com/users/oyiptong/events{/privacy}","received_events_url":"https://api.github.com/users/oyiptong/received_events","type":"User","site_admin":false},"body":"We also want to send out an observer notification, so that an eventual data uploader can respond to a finished interaction and send the data out.","created_at":"2016-02-17T15:51:37Z","updated_at":"2016-02-17T15:51:37Z","html_url":"https://github.com/mozilla/activity-streams/pull/127#discussion_r53183714","pull_request_url":"https://api.github.com/repos/mozilla/activity-streams/pulls/127","_links":{"self":{"href":"https://api.github.com/repos/mozilla/activity-streams/pulls/comments/53183714"},"html":{"href":"https://github.com/mozilla/activity-streams/pull/127#discussion_r53183714"},"pull_request":{"href":"https://api.github.com/repos/mozilla/activity-streams/pulls/127"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/activity-streams/pulls/127","id":59596942,"html_url":"https://github.com/mozilla/activity-streams/pull/127","diff_url":"https://github.com/mozilla/activity-streams/pull/127.diff","patch_url":"https://github.com/mozilla/activity-streams/pull/127.patch","issue_url":"https://api.github.com/repos/mozilla/activity-streams/issues/127","number":127,"state":"open","locked":false,"title":"feature(addon): #28 Tab open time data collection.","user":{"login":"emtwo","id":784781,"avatar_url":"https://avatars.githubusercontent.com/u/784781?v=3","gravatar_id":"","url":"https://api.github.com/users/emtwo","html_url":"https://github.com/emtwo","followers_url":"https://api.github.com/users/emtwo/followers","following_url":"https://api.github.com/users/emtwo/following{/other_user}","gists_url":"https://api.github.com/users/emtwo/gists{/gist_id}","starred_url":"https://api.github.com/users/emtwo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emtwo/subscriptions","organizations_url":"https://api.github.com/users/emtwo/orgs","repos_url":"https://api.github.com/users/emtwo/repos","events_url":"https://api.github.com/users/emtwo/events{/privacy}","received_events_url":"https://api.github.com/users/emtwo/received_events","type":"User","site_admin":false},"body":"r? @oyiptong @k88hudson ","created_at":"2016-02-17T05:04:55Z","updated_at":"2016-02-17T15:51:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"06d794c586011de39489a5c0c8ce7506c7843784","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/activity-streams/pulls/127/commits","review_comments_url":"https://api.github.com/repos/mozilla/activity-streams/pulls/127/comments","review_comment_url":"https://api.github.com/repos/mozilla/activity-streams/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/activity-streams/issues/127/comments","statuses_url":"https://api.github.com/repos/mozilla/activity-streams/statuses/ca37a7c41115c53c6d35191040e73d7a7937bb3d","head":{"label":"mozilla:emtwo/data_collection","ref":"emtwo/data_collection","sha":"ca37a7c41115c53c6d35191040e73d7a7937bb3d","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":50695589,"name":"activity-streams","full_name":"mozilla/activity-streams","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/activity-streams","description":" MVP prototype add-on for activity streams","fork":false,"url":"https://api.github.com/repos/mozilla/activity-streams","forks_url":"https://api.github.com/repos/mozilla/activity-streams/forks","keys_url":"https://api.github.com/repos/mozilla/activity-streams/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/activity-streams/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/activity-streams/teams","hooks_url":"https://api.github.com/repos/mozilla/activity-streams/hooks","issue_events_url":"https://api.github.com/repos/mozilla/activity-streams/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/activity-streams/events","assignees_url":"https://api.github.com/repos/mozilla/activity-streams/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/activity-streams/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/activity-streams/tags","blobs_url":"https://api.github.com/repos/mozilla/activity-streams/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/activity-streams/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/activity-streams/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/activity-streams/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/activity-streams/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/activity-streams/languages","stargazers_url":"https://api.github.com/repos/mozilla/activity-streams/stargazers","contributors_url":"https://api.github.com/repos/mozilla/activity-streams/contributors","subscribers_url":"https://api.github.com/repos/mozilla/activity-streams/subscribers","subscription_url":"https://api.github.com/repos/mozilla/activity-streams/subscription","commits_url":"https://api.github.com/repos/mozilla/activity-streams/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/activity-streams/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/activity-streams/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/activity-streams/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/activity-streams/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/activity-streams/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/activity-streams/merges","archive_url":"https://api.github.com/repos/mozilla/activity-streams/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/activity-streams/downloads","issues_url":"https://api.github.com/repos/mozilla/activity-streams/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/activity-streams/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/activity-streams/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/activity-streams/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/activity-streams/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/activity-streams/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/activity-streams/deployments","created_at":"2016-01-29T22:28:26Z","updated_at":"2016-02-09T22:33:34Z","pushed_at":"2016-02-17T15:46:07Z","git_url":"git://github.com/mozilla/activity-streams.git","ssh_url":"git@github.com:mozilla/activity-streams.git","clone_url":"https://github.com/mozilla/activity-streams.git","svn_url":"https://github.com/mozilla/activity-streams","homepage":"","size":326,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":49,"forks":2,"open_issues":49,"watchers":5,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"9a9b515d1371f95abe6185f58935eae1f3bc7fc3","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":50695589,"name":"activity-streams","full_name":"mozilla/activity-streams","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/activity-streams","description":" MVP prototype add-on for activity streams","fork":false,"url":"https://api.github.com/repos/mozilla/activity-streams","forks_url":"https://api.github.com/repos/mozilla/activity-streams/forks","keys_url":"https://api.github.com/repos/mozilla/activity-streams/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/activity-streams/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/activity-streams/teams","hooks_url":"https://api.github.com/repos/mozilla/activity-streams/hooks","issue_events_url":"https://api.github.com/repos/mozilla/activity-streams/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/activity-streams/events","assignees_url":"https://api.github.com/repos/mozilla/activity-streams/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/activity-streams/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/activity-streams/tags","blobs_url":"https://api.github.com/repos/mozilla/activity-streams/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/activity-streams/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/activity-streams/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/activity-streams/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/activity-streams/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/activity-streams/languages","stargazers_url":"https://api.github.com/repos/mozilla/activity-streams/stargazers","contributors_url":"https://api.github.com/repos/mozilla/activity-streams/contributors","subscribers_url":"https://api.github.com/repos/mozilla/activity-streams/subscribers","subscription_url":"https://api.github.com/repos/mozilla/activity-streams/subscription","commits_url":"https://api.github.com/repos/mozilla/activity-streams/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/activity-streams/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/activity-streams/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/activity-streams/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/activity-streams/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/activity-streams/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/activity-streams/merges","archive_url":"https://api.github.com/repos/mozilla/activity-streams/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/activity-streams/downloads","issues_url":"https://api.github.com/repos/mozilla/activity-streams/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/activity-streams/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/activity-streams/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/activity-streams/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/activity-streams/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/activity-streams/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/activity-streams/deployments","created_at":"2016-01-29T22:28:26Z","updated_at":"2016-02-09T22:33:34Z","pushed_at":"2016-02-17T15:46:07Z","git_url":"git://github.com/mozilla/activity-streams.git","ssh_url":"git@github.com:mozilla/activity-streams.git","clone_url":"https://github.com/mozilla/activity-streams.git","svn_url":"https://github.com/mozilla/activity-streams","homepage":"","size":326,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":49,"forks":2,"open_issues":49,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/activity-streams/pulls/127"},"html":{"href":"https://github.com/mozilla/activity-streams/pull/127"},"issue":{"href":"https://api.github.com/repos/mozilla/activity-streams/issues/127"},"comments":{"href":"https://api.github.com/repos/mozilla/activity-streams/issues/127/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/activity-streams/pulls/127/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/activity-streams/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/activity-streams/pulls/127/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/activity-streams/statuses/ca37a7c41115c53c6d35191040e73d7a7937bb3d"}}}}