{"action":"created","comment":{"url":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls/comments/28631615","id":28631615,"diff_hunk":"@@ -55,6 +63,34 @@ Userlike.prototype.initialize = function(page){\n  *\n  * @return {Boolean}\n  */\n+\n Userlike.prototype.loaded = function(){\n   return !! (window.userlikeConfig && window.userlikeData);\n };\n+\n+/**\n+ * Listen for chat events.\n+ */\n+\n+Userlike.prototype.attachListeners = function(){\n+  var self = this;\n+  window.userlikeTrackingEvent = function(event_name, global_ctx, session_ctx){\n+    if (event_name === 'chat_started') {\n+      self.analytics.track('Live Chat Conversation Started',\n+        { agentId: session_ctx.operator_id, agentName: session_ctx.operator_name },\n+        { context: { integration: integration }});\n+    } else if (event_name === 'message_operator_terminating') {\n+      self.analytics.track('Live Chat Message Sent',\n+        { agentId: session_ctx.operator_id, agentName: session_ctx.operator_name },\n+        { context: { integration: integration }}); // message not available\n+    } else if (event_name === 'message_client_terminating') {\n+      self.analytics.track('Live Chat Message Received',\n+        { agentId: session_ctx.operator_id, agentName: session_ctx.operator_name },\n+        { context: { integration: integration }}); // message not available\n+    } else if (event_name === 'chat_quit') {\n+      self.analytics.track('Live Chat Conversation Ended',","path":"lib/userlike/index.js","position":71,"original_position":71,"commit_id":"c2ebc1d6930a0d694e52153bc46dcce3296b7203","original_commit_id":"c2ebc1d6930a0d694e52153bc46dcce3296b7203","user":{"login":"ndhoule","id":1863990,"avatar_url":"https://avatars.githubusercontent.com/u/1863990?v=3","gravatar_id":"","url":"https://api.github.com/users/ndhoule","html_url":"https://github.com/ndhoule","followers_url":"https://api.github.com/users/ndhoule/followers","following_url":"https://api.github.com/users/ndhoule/following{/other_user}","gists_url":"https://api.github.com/users/ndhoule/gists{/gist_id}","starred_url":"https://api.github.com/users/ndhoule/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndhoule/subscriptions","organizations_url":"https://api.github.com/users/ndhoule/orgs","repos_url":"https://api.github.com/users/ndhoule/repos","events_url":"https://api.github.com/users/ndhoule/events{/privacy}","received_events_url":"https://api.github.com/users/ndhoule/received_events","type":"User","site_admin":false},"body":"newline after `(`, newline before closing paren","created_at":"2015-04-17T21:27:32Z","updated_at":"2015-04-17T21:27:32Z","html_url":"https://github.com/segmentio/analytics.js-integrations/pull/590#discussion_r28631615","pull_request_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls/590","_links":{"self":{"href":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls/comments/28631615"},"html":{"href":"https://github.com/segmentio/analytics.js-integrations/pull/590#discussion_r28631615"},"pull_request":{"href":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls/590"}}},"pull_request":{"url":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls/590","id":33228297,"html_url":"https://github.com/segmentio/analytics.js-integrations/pull/590","diff_url":"https://github.com/segmentio/analytics.js-integrations/pull/590.diff","patch_url":"https://github.com/segmentio/analytics.js-integrations/pull/590.patch","issue_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/issues/590","number":590,"state":"open","locked":false,"title":"adding livechat event listeners to olark, snapengage, livechat and userlike","user":{"login":"reinpk","id":658545,"avatar_url":"https://avatars.githubusercontent.com/u/658545?v=3","gravatar_id":"","url":"https://api.github.com/users/reinpk","html_url":"https://github.com/reinpk","followers_url":"https://api.github.com/users/reinpk/followers","following_url":"https://api.github.com/users/reinpk/following{/other_user}","gists_url":"https://api.github.com/users/reinpk/gists{/gist_id}","starred_url":"https://api.github.com/users/reinpk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reinpk/subscriptions","organizations_url":"https://api.github.com/users/reinpk/orgs","repos_url":"https://api.github.com/users/reinpk/repos","events_url":"https://api.github.com/users/reinpk/events{/privacy}","received_events_url":"https://api.github.com/users/reinpk/received_events","type":"User","site_admin":false},"body":"@segmentio/integrations this is a draft, please don't merge yet\r\n\r\nopen questions on implementation IMO:\r\n+ [x] where to put semantic event names... repeated string consts aren't DRY\r\n+ [x] semantic event names and properties are not yet confirmed\r\n+ [x] naming of the \"listen\" option is a strawman\r\n+ [x] very unsure how to test this, ideas?\r\n+ [x] where and how does context.integration get added?","created_at":"2015-04-14T05:55:50Z","updated_at":"2015-04-17T21:27:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6e068cacd0a50e58ca8c1289409595d20b2ebde8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls/590/commits","review_comments_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls/590/comments","review_comment_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls/comments{/number}","comments_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/issues/590/comments","statuses_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/statuses/c2ebc1d6930a0d694e52153bc46dcce3296b7203","head":{"label":"segmentio:add/livechat","ref":"add/livechat","sha":"c2ebc1d6930a0d694e52153bc46dcce3296b7203","user":{"login":"segmentio","id":819518,"avatar_url":"https://avatars.githubusercontent.com/u/819518?v=3","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"repo":{"id":14219761,"name":"analytics.js-integrations","full_name":"segmentio/analytics.js-integrations","owner":{"login":"segmentio","id":819518,"avatar_url":"https://avatars.githubusercontent.com/u/819518?v=3","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/segmentio/analytics.js-integrations","description":"All of the third-party analytics.js integrations.","fork":false,"url":"https://api.github.com/repos/segmentio/analytics.js-integrations","forks_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/forks","keys_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/teams","hooks_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/hooks","issue_events_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/events","assignees_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/tags","blobs_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/languages","stargazers_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/stargazers","contributors_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/contributors","subscribers_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/subscribers","subscription_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/subscription","commits_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/issues/comments{/number}","contents_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/merges","archive_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/downloads","issues_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/releases{/id}","created_at":"2013-11-08T00:09:00Z","updated_at":"2015-04-17T18:47:56Z","pushed_at":"2015-04-17T18:47:56Z","git_url":"git://github.com/segmentio/analytics.js-integrations.git","ssh_url":"git@github.com:segmentio/analytics.js-integrations.git","clone_url":"https://github.com/segmentio/analytics.js-integrations.git","svn_url":"https://github.com/segmentio/analytics.js-integrations","homepage":null,"size":11083,"stargazers_count":60,"watchers_count":60,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":122,"mirror_url":null,"open_issues_count":64,"forks":122,"open_issues":64,"watchers":60,"default_branch":"master"}},"base":{"label":"segmentio:master","ref":"master","sha":"014632674c79f52945287a56fe8e5067e76bb277","user":{"login":"segmentio","id":819518,"avatar_url":"https://avatars.githubusercontent.com/u/819518?v=3","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"repo":{"id":14219761,"name":"analytics.js-integrations","full_name":"segmentio/analytics.js-integrations","owner":{"login":"segmentio","id":819518,"avatar_url":"https://avatars.githubusercontent.com/u/819518?v=3","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/segmentio/analytics.js-integrations","description":"All of the third-party analytics.js integrations.","fork":false,"url":"https://api.github.com/repos/segmentio/analytics.js-integrations","forks_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/forks","keys_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/teams","hooks_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/hooks","issue_events_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/events","assignees_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/tags","blobs_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/languages","stargazers_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/stargazers","contributors_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/contributors","subscribers_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/subscribers","subscription_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/subscription","commits_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/issues/comments{/number}","contents_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/merges","archive_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/downloads","issues_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/analytics.js-integrations/releases{/id}","created_at":"2013-11-08T00:09:00Z","updated_at":"2015-04-17T18:47:56Z","pushed_at":"2015-04-17T18:47:56Z","git_url":"git://github.com/segmentio/analytics.js-integrations.git","ssh_url":"git@github.com:segmentio/analytics.js-integrations.git","clone_url":"https://github.com/segmentio/analytics.js-integrations.git","svn_url":"https://github.com/segmentio/analytics.js-integrations","homepage":null,"size":11083,"stargazers_count":60,"watchers_count":60,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":122,"mirror_url":null,"open_issues_count":64,"forks":122,"open_issues":64,"watchers":60,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls/590"},"html":{"href":"https://github.com/segmentio/analytics.js-integrations/pull/590"},"issue":{"href":"https://api.github.com/repos/segmentio/analytics.js-integrations/issues/590"},"comments":{"href":"https://api.github.com/repos/segmentio/analytics.js-integrations/issues/590/comments"},"review_comments":{"href":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls/590/comments"},"review_comment":{"href":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/segmentio/analytics.js-integrations/pulls/590/commits"},"statuses":{"href":"https://api.github.com/repos/segmentio/analytics.js-integrations/statuses/c2ebc1d6930a0d694e52153bc46dcce3296b7203"}}}}