{"action":"created","comment":{"url":"https://api.github.com/repos/Robdel12/blog/pulls/comments/23386980","id":23386980,"diff_hunk":"@@ -0,0 +1,35 @@\n+require 'google/api_client'\n+require 'date'\n+class GoogleAnalytics\n+  def initialize\n+    @client  = Google::APIClient.new(:application_name => ENV[\"GA_APP_NAME\"], :application_version => '1.0')\n+    key_file = File.join('config', 'analytic_cert.p12')\n+    scope    = \"https://www.googleapis.com/auth/analytics.readonly\"\n+    key      = Google::APIClient::PKCS12.load_key(key_file, \"notasecret\")\n+    service_account = Google::APIClient::JWTAsserter.new(ENV[\"GA_EMAIL\"], scope, key)\n+    @client.authorization = service_account.authorize\n+    @analytics = @client.discovered_api('analytics', 'v3')\n+  end\n+\n+  def visitors(startDate, endDate)\n+    results = @client.execute(:api_method => @analytics.data.ga.get, :parameters => {\n+      'ids'         => ENV['GA_ID'],\n+      'start-date'  => startDate,\n+      'end-date'    => endDate,\n+      'metrics'     => \"ga:visits\",\n+      'dimensions'  => \"ga:year,ga:month,ga:day\",\n+      'sort'        => \"ga:year,ga:month,ga:day\"\n+    })\n+    if results.error?\n+      puts results.error_message","path":"rails/app/services/google_analytics.rb","position":24,"original_position":24,"commit_id":"789d803289d521baec8af1467ae9d68e1e29e575","original_commit_id":"789d803289d521baec8af1467ae9d68e1e29e575","user":{"login":"tracehelms","id":2370568,"avatar_url":"https://avatars.githubusercontent.com/u/2370568?v=3","gravatar_id":"","url":"https://api.github.com/users/tracehelms","html_url":"https://github.com/tracehelms","followers_url":"https://api.github.com/users/tracehelms/followers","following_url":"https://api.github.com/users/tracehelms/following{/other_user}","gists_url":"https://api.github.com/users/tracehelms/gists{/gist_id}","starred_url":"https://api.github.com/users/tracehelms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tracehelms/subscriptions","organizations_url":"https://api.github.com/users/tracehelms/orgs","repos_url":"https://api.github.com/users/tracehelms/repos","events_url":"https://api.github.com/users/tracehelms/events{/privacy}","received_events_url":"https://api.github.com/users/tracehelms/received_events","type":"User","site_admin":false},"body":"This will probably never be seen. If you want visibility I'd either raise a 500 or send an email to yourself, log to Airbrake, or whatever.","created_at":"2015-01-22T16:18:46Z","updated_at":"2015-01-22T16:18:46Z","html_url":"https://github.com/Robdel12/blog/pull/18#discussion_r23386980","pull_request_url":"https://api.github.com/repos/Robdel12/blog/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/Robdel12/blog/pulls/comments/23386980"},"html":{"href":"https://github.com/Robdel12/blog/pull/18#discussion_r23386980"},"pull_request":{"href":"https://api.github.com/repos/Robdel12/blog/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/Robdel12/blog/pulls/18","id":27816465,"html_url":"https://github.com/Robdel12/blog/pull/18","diff_url":"https://github.com/Robdel12/blog/pull/18.diff","patch_url":"https://github.com/Robdel12/blog/pull/18.patch","issue_url":"https://api.github.com/repos/Robdel12/blog/issues/18","number":18,"state":"open","locked":false,"title":"Feature/google analyitcs graphs","user":{"login":"Robdel12","id":2072894,"avatar_url":"https://avatars.githubusercontent.com/u/2072894?v=3","gravatar_id":"","url":"https://api.github.com/users/Robdel12","html_url":"https://github.com/Robdel12","followers_url":"https://api.github.com/users/Robdel12/followers","following_url":"https://api.github.com/users/Robdel12/following{/other_user}","gists_url":"https://api.github.com/users/Robdel12/gists{/gist_id}","starred_url":"https://api.github.com/users/Robdel12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Robdel12/subscriptions","organizations_url":"https://api.github.com/users/Robdel12/orgs","repos_url":"https://api.github.com/users/Robdel12/repos","events_url":"https://api.github.com/users/Robdel12/events{/privacy}","received_events_url":"https://api.github.com/users/Robdel12/received_events","type":"User","site_admin":false},"body":"# What is this?\r\nThis adds the ability to pull google analytics visitor info and show it on a little dashboard with c3.js charts.\r\n\r\n# Picture\r\n![screen shot 2015-01-19 at 10 45 45 pm](https://cloud.githubusercontent.com/assets/2072894/5850277/635dbbcc-a1c0-11e4-9b50-89c030872419.png)\r\n","created_at":"2015-01-22T03:54:22Z","updated_at":"2015-01-22T16:18:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0fc67c51e8c73d461667ed3182d2baf317f728a5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Robdel12/blog/pulls/18/commits","review_comments_url":"https://api.github.com/repos/Robdel12/blog/pulls/18/comments","review_comment_url":"https://api.github.com/repos/Robdel12/blog/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Robdel12/blog/issues/18/comments","statuses_url":"https://api.github.com/repos/Robdel12/blog/statuses/789d803289d521baec8af1467ae9d68e1e29e575","head":{"label":"Robdel12:feature/google-analyitcs-graphs","ref":"feature/google-analyitcs-graphs","sha":"789d803289d521baec8af1467ae9d68e1e29e575","user":{"login":"Robdel12","id":2072894,"avatar_url":"https://avatars.githubusercontent.com/u/2072894?v=3","gravatar_id":"","url":"https://api.github.com/users/Robdel12","html_url":"https://github.com/Robdel12","followers_url":"https://api.github.com/users/Robdel12/followers","following_url":"https://api.github.com/users/Robdel12/following{/other_user}","gists_url":"https://api.github.com/users/Robdel12/gists{/gist_id}","starred_url":"https://api.github.com/users/Robdel12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Robdel12/subscriptions","organizations_url":"https://api.github.com/users/Robdel12/orgs","repos_url":"https://api.github.com/users/Robdel12/repos","events_url":"https://api.github.com/users/Robdel12/events{/privacy}","received_events_url":"https://api.github.com/users/Robdel12/received_events","type":"User","site_admin":false},"repo":{"id":23009847,"name":"blog","full_name":"Robdel12/blog","owner":{"login":"Robdel12","id":2072894,"avatar_url":"https://avatars.githubusercontent.com/u/2072894?v=3","gravatar_id":"","url":"https://api.github.com/users/Robdel12","html_url":"https://github.com/Robdel12","followers_url":"https://api.github.com/users/Robdel12/followers","following_url":"https://api.github.com/users/Robdel12/following{/other_user}","gists_url":"https://api.github.com/users/Robdel12/gists{/gist_id}","starred_url":"https://api.github.com/users/Robdel12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Robdel12/subscriptions","organizations_url":"https://api.github.com/users/Robdel12/orgs","repos_url":"https://api.github.com/users/Robdel12/repos","events_url":"https://api.github.com/users/Robdel12/events{/privacy}","received_events_url":"https://api.github.com/users/Robdel12/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Robdel12/blog","description":"Ember front end and rails backend","fork":false,"url":"https://api.github.com/repos/Robdel12/blog","forks_url":"https://api.github.com/repos/Robdel12/blog/forks","keys_url":"https://api.github.com/repos/Robdel12/blog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Robdel12/blog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Robdel12/blog/teams","hooks_url":"https://api.github.com/repos/Robdel12/blog/hooks","issue_events_url":"https://api.github.com/repos/Robdel12/blog/issues/events{/number}","events_url":"https://api.github.com/repos/Robdel12/blog/events","assignees_url":"https://api.github.com/repos/Robdel12/blog/assignees{/user}","branches_url":"https://api.github.com/repos/Robdel12/blog/branches{/branch}","tags_url":"https://api.github.com/repos/Robdel12/blog/tags","blobs_url":"https://api.github.com/repos/Robdel12/blog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Robdel12/blog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Robdel12/blog/git/refs{/sha}","trees_url":"https://api.github.com/repos/Robdel12/blog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Robdel12/blog/statuses/{sha}","languages_url":"https://api.github.com/repos/Robdel12/blog/languages","stargazers_url":"https://api.github.com/repos/Robdel12/blog/stargazers","contributors_url":"https://api.github.com/repos/Robdel12/blog/contributors","subscribers_url":"https://api.github.com/repos/Robdel12/blog/subscribers","subscription_url":"https://api.github.com/repos/Robdel12/blog/subscription","commits_url":"https://api.github.com/repos/Robdel12/blog/commits{/sha}","git_commits_url":"https://api.github.com/repos/Robdel12/blog/git/commits{/sha}","comments_url":"https://api.github.com/repos/Robdel12/blog/comments{/number}","issue_comment_url":"https://api.github.com/repos/Robdel12/blog/issues/comments/{number}","contents_url":"https://api.github.com/repos/Robdel12/blog/contents/{+path}","compare_url":"https://api.github.com/repos/Robdel12/blog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Robdel12/blog/merges","archive_url":"https://api.github.com/repos/Robdel12/blog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Robdel12/blog/downloads","issues_url":"https://api.github.com/repos/Robdel12/blog/issues{/number}","pulls_url":"https://api.github.com/repos/Robdel12/blog/pulls{/number}","milestones_url":"https://api.github.com/repos/Robdel12/blog/milestones{/number}","notifications_url":"https://api.github.com/repos/Robdel12/blog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Robdel12/blog/labels{/name}","releases_url":"https://api.github.com/repos/Robdel12/blog/releases{/id}","created_at":"2014-08-16T03:34:34Z","updated_at":"2015-01-22T04:23:34Z","pushed_at":"2015-01-22T04:23:33Z","git_url":"git://github.com/Robdel12/blog.git","ssh_url":"git@github.com:Robdel12/blog.git","clone_url":"https://github.com/Robdel12/blog.git","svn_url":"https://github.com/Robdel12/blog","homepage":"http://robert-deluca.com","size":22539,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"Robdel12:master","ref":"master","sha":"e06ea3b6c02ef23046199027bd277e03fc4258d6","user":{"login":"Robdel12","id":2072894,"avatar_url":"https://avatars.githubusercontent.com/u/2072894?v=3","gravatar_id":"","url":"https://api.github.com/users/Robdel12","html_url":"https://github.com/Robdel12","followers_url":"https://api.github.com/users/Robdel12/followers","following_url":"https://api.github.com/users/Robdel12/following{/other_user}","gists_url":"https://api.github.com/users/Robdel12/gists{/gist_id}","starred_url":"https://api.github.com/users/Robdel12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Robdel12/subscriptions","organizations_url":"https://api.github.com/users/Robdel12/orgs","repos_url":"https://api.github.com/users/Robdel12/repos","events_url":"https://api.github.com/users/Robdel12/events{/privacy}","received_events_url":"https://api.github.com/users/Robdel12/received_events","type":"User","site_admin":false},"repo":{"id":23009847,"name":"blog","full_name":"Robdel12/blog","owner":{"login":"Robdel12","id":2072894,"avatar_url":"https://avatars.githubusercontent.com/u/2072894?v=3","gravatar_id":"","url":"https://api.github.com/users/Robdel12","html_url":"https://github.com/Robdel12","followers_url":"https://api.github.com/users/Robdel12/followers","following_url":"https://api.github.com/users/Robdel12/following{/other_user}","gists_url":"https://api.github.com/users/Robdel12/gists{/gist_id}","starred_url":"https://api.github.com/users/Robdel12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Robdel12/subscriptions","organizations_url":"https://api.github.com/users/Robdel12/orgs","repos_url":"https://api.github.com/users/Robdel12/repos","events_url":"https://api.github.com/users/Robdel12/events{/privacy}","received_events_url":"https://api.github.com/users/Robdel12/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Robdel12/blog","description":"Ember front end and rails backend","fork":false,"url":"https://api.github.com/repos/Robdel12/blog","forks_url":"https://api.github.com/repos/Robdel12/blog/forks","keys_url":"https://api.github.com/repos/Robdel12/blog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Robdel12/blog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Robdel12/blog/teams","hooks_url":"https://api.github.com/repos/Robdel12/blog/hooks","issue_events_url":"https://api.github.com/repos/Robdel12/blog/issues/events{/number}","events_url":"https://api.github.com/repos/Robdel12/blog/events","assignees_url":"https://api.github.com/repos/Robdel12/blog/assignees{/user}","branches_url":"https://api.github.com/repos/Robdel12/blog/branches{/branch}","tags_url":"https://api.github.com/repos/Robdel12/blog/tags","blobs_url":"https://api.github.com/repos/Robdel12/blog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Robdel12/blog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Robdel12/blog/git/refs{/sha}","trees_url":"https://api.github.com/repos/Robdel12/blog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Robdel12/blog/statuses/{sha}","languages_url":"https://api.github.com/repos/Robdel12/blog/languages","stargazers_url":"https://api.github.com/repos/Robdel12/blog/stargazers","contributors_url":"https://api.github.com/repos/Robdel12/blog/contributors","subscribers_url":"https://api.github.com/repos/Robdel12/blog/subscribers","subscription_url":"https://api.github.com/repos/Robdel12/blog/subscription","commits_url":"https://api.github.com/repos/Robdel12/blog/commits{/sha}","git_commits_url":"https://api.github.com/repos/Robdel12/blog/git/commits{/sha}","comments_url":"https://api.github.com/repos/Robdel12/blog/comments{/number}","issue_comment_url":"https://api.github.com/repos/Robdel12/blog/issues/comments/{number}","contents_url":"https://api.github.com/repos/Robdel12/blog/contents/{+path}","compare_url":"https://api.github.com/repos/Robdel12/blog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Robdel12/blog/merges","archive_url":"https://api.github.com/repos/Robdel12/blog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Robdel12/blog/downloads","issues_url":"https://api.github.com/repos/Robdel12/blog/issues{/number}","pulls_url":"https://api.github.com/repos/Robdel12/blog/pulls{/number}","milestones_url":"https://api.github.com/repos/Robdel12/blog/milestones{/number}","notifications_url":"https://api.github.com/repos/Robdel12/blog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Robdel12/blog/labels{/name}","releases_url":"https://api.github.com/repos/Robdel12/blog/releases{/id}","created_at":"2014-08-16T03:34:34Z","updated_at":"2015-01-22T04:23:34Z","pushed_at":"2015-01-22T04:23:33Z","git_url":"git://github.com/Robdel12/blog.git","ssh_url":"git@github.com:Robdel12/blog.git","clone_url":"https://github.com/Robdel12/blog.git","svn_url":"https://github.com/Robdel12/blog","homepage":"http://robert-deluca.com","size":22539,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Robdel12/blog/pulls/18"},"html":{"href":"https://github.com/Robdel12/blog/pull/18"},"issue":{"href":"https://api.github.com/repos/Robdel12/blog/issues/18"},"comments":{"href":"https://api.github.com/repos/Robdel12/blog/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/Robdel12/blog/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/Robdel12/blog/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Robdel12/blog/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/Robdel12/blog/statuses/789d803289d521baec8af1467ae9d68e1e29e575"}}}}