{"action":"created","comment":{"url":"https://api.github.com/repos/communityshare/communityshare/pulls/comments/78680068","id":78680068,"diff_hunk":"@@ -0,0 +1,31 @@\n+from http import HTTPStatus\n+\n+from flask import request\n+\n+from community_share.flask_helpers import needs_auth, with_store\n+from community_share.models.analytics import PageView\n+from community_share.routes.base_routes import make_bad_request_response\n+\n+\n+@needs_auth()\n+def endpoint(requester):\n+    data = request.get_json()\n+\n+    next_path = data.get('next_path')[:255]\n+    prev_path = data.get('prev_path')[:255]","path":"community_share/api/analytics/views/record_view.py","position":15,"original_position":15,"commit_id":"05f47c03d77d40e7a4f4f32671f04544ac42cfc2","original_commit_id":"05f47c03d77d40e7a4f4f32671f04544ac42cfc2","user":{"login":"seanastephens","id":5893305,"avatar_url":"https://avatars.githubusercontent.com/u/5893305?v=3","gravatar_id":"","url":"https://api.github.com/users/seanastephens","html_url":"https://github.com/seanastephens","followers_url":"https://api.github.com/users/seanastephens/followers","following_url":"https://api.github.com/users/seanastephens/following{/other_user}","gists_url":"https://api.github.com/users/seanastephens/gists{/gist_id}","starred_url":"https://api.github.com/users/seanastephens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanastephens/subscriptions","organizations_url":"https://api.github.com/users/seanastephens/orgs","repos_url":"https://api.github.com/users/seanastephens/repos","events_url":"https://api.github.com/users/seanastephens/events{/privacy}","received_events_url":"https://api.github.com/users/seanastephens/received_events","type":"User","site_admin":false},"body":"`prev_path` had better not be `None`...\r\n\r\nWe need to pass the check below before we do string slicing.","created_at":"2016-09-14T03:03:45Z","updated_at":"2016-09-14T03:03:45Z","html_url":"https://github.com/communityshare/communityshare/pull/183#discussion_r78680068","pull_request_url":"https://api.github.com/repos/communityshare/communityshare/pulls/183","_links":{"self":{"href":"https://api.github.com/repos/communityshare/communityshare/pulls/comments/78680068"},"html":{"href":"https://github.com/communityshare/communityshare/pull/183#discussion_r78680068"},"pull_request":{"href":"https://api.github.com/repos/communityshare/communityshare/pulls/183"}}},"pull_request":{"url":"https://api.github.com/repos/communityshare/communityshare/pulls/183","id":84993046,"html_url":"https://github.com/communityshare/communityshare/pull/183","diff_url":"https://github.com/communityshare/communityshare/pull/183.diff","patch_url":"https://github.com/communityshare/communityshare/pull/183.patch","issue_url":"https://api.github.com/repos/communityshare/communityshare/issues/183","number":183,"state":"open","locked":false,"title":"Create basic page tracking API","user":{"login":"dmsnell","id":5431237,"avatar_url":"https://avatars.githubusercontent.com/u/5431237?v=3","gravatar_id":"","url":"https://api.github.com/users/dmsnell","html_url":"https://github.com/dmsnell","followers_url":"https://api.github.com/users/dmsnell/followers","following_url":"https://api.github.com/users/dmsnell/following{/other_user}","gists_url":"https://api.github.com/users/dmsnell/gists{/gist_id}","starred_url":"https://api.github.com/users/dmsnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmsnell/subscriptions","organizations_url":"https://api.github.com/users/dmsnell/orgs","repos_url":"https://api.github.com/users/dmsnell/repos","events_url":"https://api.github.com/users/dmsnell/events{/privacy}","received_events_url":"https://api.github.com/users/dmsnell/received_events","type":"User","site_admin":false},"body":"Resolves #136 in that it brings us to a first step with analytics.\r\n\r\nWe currently have very little knowledge about how people use the\r\nCommunityshare website. This includes metrics such as visits and unique\r\nvisitors and it also includes broader information such as how people\r\nnavigate the site.\r\n\r\nThis patch creates a new API endpoint which we can hit to start tracking\r\ninformation about page views. It stores a user id and the paths the user\r\nroutes to from the path he or she left. With a timestamp logging this\r\ninformation, we can start to analyze the data to see which parts of the\r\npage are serving our users.\r\n\r\n**Remaining Work**\r\n\r\n - [x] <del>Create table if not exists: the table for this tracking doesn't exist in production. I have been able to manually add it in local dev running a manual operation, but I would like to find some saner way to synchronize the DB schema.</del> For simplicity's sake I copied the schema from the local database right into the production database, having used an export and SQL query to accomplish this.\r\n\r\n```bash\r\n# local database table dump -> to insert as SQL query in production\r\npg_dump -h localhost -d communityshare -U communityshare -t page_views --schema-only\r\n```\r\n\r\n**Testing**\r\n\r\nSend a `POST` to `/rest/analytics/views/` with a body of the JSON form below\r\n```json\r\n{\r\n\t\"prev_path\": \"/some/string\", \r\n\t\"next_path\": \"/some/other/string\"\r\n}\r\n```\r\n\r\nAfter the `POST`, check the `page_views` table to make sure that it inserted. Further, try sending unauthenticated API calls - they should fail. If either of the parameters are missing it should also fail with a message indicating an invalid request.\r\n\r\n@seanastephens ","created_at":"2016-09-13T06:42:53Z","updated_at":"2016-09-14T03:03:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"05d75d50fcec3862768f6705eefd1e1ccab219bb","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/communityshare/communityshare/pulls/183/commits","review_comments_url":"https://api.github.com/repos/communityshare/communityshare/pulls/183/comments","review_comment_url":"https://api.github.com/repos/communityshare/communityshare/pulls/comments{/number}","comments_url":"https://api.github.com/repos/communityshare/communityshare/issues/183/comments","statuses_url":"https://api.github.com/repos/communityshare/communityshare/statuses/05f47c03d77d40e7a4f4f32671f04544ac42cfc2","head":{"label":"communityshare:add/page-tracking-api","ref":"add/page-tracking-api","sha":"05f47c03d77d40e7a4f4f32671f04544ac42cfc2","user":{"login":"communityshare","id":17582499,"avatar_url":"https://avatars.githubusercontent.com/u/17582499?v=3","gravatar_id":"","url":"https://api.github.com/users/communityshare","html_url":"https://github.com/communityshare","followers_url":"https://api.github.com/users/communityshare/followers","following_url":"https://api.github.com/users/communityshare/following{/other_user}","gists_url":"https://api.github.com/users/communityshare/gists{/gist_id}","starred_url":"https://api.github.com/users/communityshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/communityshare/subscriptions","organizations_url":"https://api.github.com/users/communityshare/orgs","repos_url":"https://api.github.com/users/communityshare/repos","events_url":"https://api.github.com/users/communityshare/events{/privacy}","received_events_url":"https://api.github.com/users/communityshare/received_events","type":"Organization","site_admin":false},"repo":{"id":18902595,"name":"communityshare","full_name":"communityshare/communityshare","owner":{"login":"communityshare","id":17582499,"avatar_url":"https://avatars.githubusercontent.com/u/17582499?v=3","gravatar_id":"","url":"https://api.github.com/users/communityshare","html_url":"https://github.com/communityshare","followers_url":"https://api.github.com/users/communityshare/followers","following_url":"https://api.github.com/users/communityshare/following{/other_user}","gists_url":"https://api.github.com/users/communityshare/gists{/gist_id}","starred_url":"https://api.github.com/users/communityshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/communityshare/subscriptions","organizations_url":"https://api.github.com/users/communityshare/orgs","repos_url":"https://api.github.com/users/communityshare/repos","events_url":"https://api.github.com/users/communityshare/events{/privacy}","received_events_url":"https://api.github.com/users/communityshare/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/communityshare/communityshare","description":"An online network connecting educators with community partners","fork":false,"url":"https://api.github.com/repos/communityshare/communityshare","forks_url":"https://api.github.com/repos/communityshare/communityshare/forks","keys_url":"https://api.github.com/repos/communityshare/communityshare/keys{/key_id}","collaborators_url":"https://api.github.com/repos/communityshare/communityshare/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/communityshare/communityshare/teams","hooks_url":"https://api.github.com/repos/communityshare/communityshare/hooks","issue_events_url":"https://api.github.com/repos/communityshare/communityshare/issues/events{/number}","events_url":"https://api.github.com/repos/communityshare/communityshare/events","assignees_url":"https://api.github.com/repos/communityshare/communityshare/assignees{/user}","branches_url":"https://api.github.com/repos/communityshare/communityshare/branches{/branch}","tags_url":"https://api.github.com/repos/communityshare/communityshare/tags","blobs_url":"https://api.github.com/repos/communityshare/communityshare/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/communityshare/communityshare/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/communityshare/communityshare/git/refs{/sha}","trees_url":"https://api.github.com/repos/communityshare/communityshare/git/trees{/sha}","statuses_url":"https://api.github.com/repos/communityshare/communityshare/statuses/{sha}","languages_url":"https://api.github.com/repos/communityshare/communityshare/languages","stargazers_url":"https://api.github.com/repos/communityshare/communityshare/stargazers","contributors_url":"https://api.github.com/repos/communityshare/communityshare/contributors","subscribers_url":"https://api.github.com/repos/communityshare/communityshare/subscribers","subscription_url":"https://api.github.com/repos/communityshare/communityshare/subscription","commits_url":"https://api.github.com/repos/communityshare/communityshare/commits{/sha}","git_commits_url":"https://api.github.com/repos/communityshare/communityshare/git/commits{/sha}","comments_url":"https://api.github.com/repos/communityshare/communityshare/comments{/number}","issue_comment_url":"https://api.github.com/repos/communityshare/communityshare/issues/comments{/number}","contents_url":"https://api.github.com/repos/communityshare/communityshare/contents/{+path}","compare_url":"https://api.github.com/repos/communityshare/communityshare/compare/{base}...{head}","merges_url":"https://api.github.com/repos/communityshare/communityshare/merges","archive_url":"https://api.github.com/repos/communityshare/communityshare/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/communityshare/communityshare/downloads","issues_url":"https://api.github.com/repos/communityshare/communityshare/issues{/number}","pulls_url":"https://api.github.com/repos/communityshare/communityshare/pulls{/number}","milestones_url":"https://api.github.com/repos/communityshare/communityshare/milestones{/number}","notifications_url":"https://api.github.com/repos/communityshare/communityshare/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/communityshare/communityshare/labels{/name}","releases_url":"https://api.github.com/repos/communityshare/communityshare/releases{/id}","deployments_url":"https://api.github.com/repos/communityshare/communityshare/deployments","created_at":"2014-04-18T04:31:09Z","updated_at":"2016-07-06T02:44:36Z","pushed_at":"2016-09-14T01:35:21Z","git_url":"git://github.com/communityshare/communityshare.git","ssh_url":"git@github.com:communityshare/communityshare.git","clone_url":"https://github.com/communityshare/communityshare.git","svn_url":"https://github.com/communityshare/communityshare","homepage":null,"size":4321,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":49,"forks":10,"open_issues":49,"watchers":5,"default_branch":"master"}},"base":{"label":"communityshare:master","ref":"master","sha":"aacbd8612e2a8cdd1de81fc76b03bb091f752122","user":{"login":"communityshare","id":17582499,"avatar_url":"https://avatars.githubusercontent.com/u/17582499?v=3","gravatar_id":"","url":"https://api.github.com/users/communityshare","html_url":"https://github.com/communityshare","followers_url":"https://api.github.com/users/communityshare/followers","following_url":"https://api.github.com/users/communityshare/following{/other_user}","gists_url":"https://api.github.com/users/communityshare/gists{/gist_id}","starred_url":"https://api.github.com/users/communityshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/communityshare/subscriptions","organizations_url":"https://api.github.com/users/communityshare/orgs","repos_url":"https://api.github.com/users/communityshare/repos","events_url":"https://api.github.com/users/communityshare/events{/privacy}","received_events_url":"https://api.github.com/users/communityshare/received_events","type":"Organization","site_admin":false},"repo":{"id":18902595,"name":"communityshare","full_name":"communityshare/communityshare","owner":{"login":"communityshare","id":17582499,"avatar_url":"https://avatars.githubusercontent.com/u/17582499?v=3","gravatar_id":"","url":"https://api.github.com/users/communityshare","html_url":"https://github.com/communityshare","followers_url":"https://api.github.com/users/communityshare/followers","following_url":"https://api.github.com/users/communityshare/following{/other_user}","gists_url":"https://api.github.com/users/communityshare/gists{/gist_id}","starred_url":"https://api.github.com/users/communityshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/communityshare/subscriptions","organizations_url":"https://api.github.com/users/communityshare/orgs","repos_url":"https://api.github.com/users/communityshare/repos","events_url":"https://api.github.com/users/communityshare/events{/privacy}","received_events_url":"https://api.github.com/users/communityshare/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/communityshare/communityshare","description":"An online network connecting educators with community partners","fork":false,"url":"https://api.github.com/repos/communityshare/communityshare","forks_url":"https://api.github.com/repos/communityshare/communityshare/forks","keys_url":"https://api.github.com/repos/communityshare/communityshare/keys{/key_id}","collaborators_url":"https://api.github.com/repos/communityshare/communityshare/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/communityshare/communityshare/teams","hooks_url":"https://api.github.com/repos/communityshare/communityshare/hooks","issue_events_url":"https://api.github.com/repos/communityshare/communityshare/issues/events{/number}","events_url":"https://api.github.com/repos/communityshare/communityshare/events","assignees_url":"https://api.github.com/repos/communityshare/communityshare/assignees{/user}","branches_url":"https://api.github.com/repos/communityshare/communityshare/branches{/branch}","tags_url":"https://api.github.com/repos/communityshare/communityshare/tags","blobs_url":"https://api.github.com/repos/communityshare/communityshare/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/communityshare/communityshare/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/communityshare/communityshare/git/refs{/sha}","trees_url":"https://api.github.com/repos/communityshare/communityshare/git/trees{/sha}","statuses_url":"https://api.github.com/repos/communityshare/communityshare/statuses/{sha}","languages_url":"https://api.github.com/repos/communityshare/communityshare/languages","stargazers_url":"https://api.github.com/repos/communityshare/communityshare/stargazers","contributors_url":"https://api.github.com/repos/communityshare/communityshare/contributors","subscribers_url":"https://api.github.com/repos/communityshare/communityshare/subscribers","subscription_url":"https://api.github.com/repos/communityshare/communityshare/subscription","commits_url":"https://api.github.com/repos/communityshare/communityshare/commits{/sha}","git_commits_url":"https://api.github.com/repos/communityshare/communityshare/git/commits{/sha}","comments_url":"https://api.github.com/repos/communityshare/communityshare/comments{/number}","issue_comment_url":"https://api.github.com/repos/communityshare/communityshare/issues/comments{/number}","contents_url":"https://api.github.com/repos/communityshare/communityshare/contents/{+path}","compare_url":"https://api.github.com/repos/communityshare/communityshare/compare/{base}...{head}","merges_url":"https://api.github.com/repos/communityshare/communityshare/merges","archive_url":"https://api.github.com/repos/communityshare/communityshare/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/communityshare/communityshare/downloads","issues_url":"https://api.github.com/repos/communityshare/communityshare/issues{/number}","pulls_url":"https://api.github.com/repos/communityshare/communityshare/pulls{/number}","milestones_url":"https://api.github.com/repos/communityshare/communityshare/milestones{/number}","notifications_url":"https://api.github.com/repos/communityshare/communityshare/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/communityshare/communityshare/labels{/name}","releases_url":"https://api.github.com/repos/communityshare/communityshare/releases{/id}","deployments_url":"https://api.github.com/repos/communityshare/communityshare/deployments","created_at":"2014-04-18T04:31:09Z","updated_at":"2016-07-06T02:44:36Z","pushed_at":"2016-09-14T01:35:21Z","git_url":"git://github.com/communityshare/communityshare.git","ssh_url":"git@github.com:communityshare/communityshare.git","clone_url":"https://github.com/communityshare/communityshare.git","svn_url":"https://github.com/communityshare/communityshare","homepage":null,"size":4321,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":49,"forks":10,"open_issues":49,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/communityshare/communityshare/pulls/183"},"html":{"href":"https://github.com/communityshare/communityshare/pull/183"},"issue":{"href":"https://api.github.com/repos/communityshare/communityshare/issues/183"},"comments":{"href":"https://api.github.com/repos/communityshare/communityshare/issues/183/comments"},"review_comments":{"href":"https://api.github.com/repos/communityshare/communityshare/pulls/183/comments"},"review_comment":{"href":"https://api.github.com/repos/communityshare/communityshare/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/communityshare/communityshare/pulls/183/commits"},"statuses":{"href":"https://api.github.com/repos/communityshare/communityshare/statuses/05f47c03d77d40e7a4f4f32671f04544ac42cfc2"}}}}
{"actor":{"display_login":"seanastephens"}}