{"action":"created","comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/77934175","id":77934175,"diff_hunk":"@@ -36,8 +37,12 @@ import config from 'config';\n import userSettings from 'lib/user-settings';\n import AppPromo from 'components/app-promo';\n import { setNextLayoutFocus } from 'state/ui/layout-focus/actions';\n+import userUtils from 'lib/user/utils';\n+import * as userAgentUtils from 'lib/user-agent-utils';","path":"client/reader/sidebar/index.jsx","position":15,"original_position":15,"commit_id":"9382a92b323e3f4e17143483d7d3ac99ec59a457","original_commit_id":"9382a92b323e3f4e17143483d7d3ac99ec59a457","user":{"login":"sendhil","id":437043,"avatar_url":"https://avatars.githubusercontent.com/u/437043?v=3","gravatar_id":"","url":"https://api.github.com/users/sendhil","html_url":"https://github.com/sendhil","followers_url":"https://api.github.com/users/sendhil/followers","following_url":"https://api.github.com/users/sendhil/following{/other_user}","gists_url":"https://api.github.com/users/sendhil/gists{/gist_id}","starred_url":"https://api.github.com/users/sendhil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sendhil/subscriptions","organizations_url":"https://api.github.com/users/sendhil/orgs","repos_url":"https://api.github.com/users/sendhil/repos","events_url":"https://api.github.com/users/sendhil/events{/privacy}","received_events_url":"https://api.github.com/users/sendhil/received_events","type":"User","site_admin":false},"body":"I was getting a weird error with a previous version of the code by importing just isChromeOS... I'd have to rollback a few commits and see but I can change it as the structure is different now.","created_at":"2016-09-08T01:37:40Z","updated_at":"2016-09-08T01:37:40Z","html_url":"https://github.com/Automattic/wp-calypso/pull/7865#discussion_r77934175","pull_request_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/7865","_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/77934175"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/7865#discussion_r77934175"},"pull_request":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/7865"}}},"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/7865","id":84029283,"html_url":"https://github.com/Automattic/wp-calypso/pull/7865","diff_url":"https://github.com/Automattic/wp-calypso/pull/7865.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/7865.patch","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/7865","number":7865,"state":"open","locked":false,"title":"AppPromo:Add a promo for mobile apps and clean up code to add in unit testing","user":{"login":"sendhil","id":437043,"avatar_url":"https://avatars.githubusercontent.com/u/437043?v=3","gravatar_id":"","url":"https://api.github.com/users/sendhil","html_url":"https://github.com/sendhil","followers_url":"https://api.github.com/users/sendhil/followers","following_url":"https://api.github.com/users/sendhil/following{/other_user}","gists_url":"https://api.github.com/users/sendhil/gists{/gist_id}","starred_url":"https://api.github.com/users/sendhil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sendhil/subscriptions","organizations_url":"https://api.github.com/users/sendhil/orgs","repos_url":"https://api.github.com/users/sendhil/repos","events_url":"https://api.github.com/users/sendhil/events{/privacy}","received_events_url":"https://api.github.com/users/sendhil/received_events","type":"User","site_admin":false},"body":"@johnmaeda asked me to drop in a mobile promo to our current app promo that renders in the reader. The idea was to see this as an experiment to see if we could drive more mobile downloads. I was reluctant to drop the changes into the current code because the current code was untested so I cleaned it up and added some unit tests along the way.\r\n\r\nWhat the changes look like:\r\n<img width=\"923\" alt=\"screen shot 2016-09-05 at 10 42 42 am\" src=\"https://cloud.githubusercontent.com/assets/437043/18254714/83a818ce-7355-11e6-9539-d48b87e987fd.png\">\r\n\r\nNotable Changes:\r\n* Extracted promo code logic into it's own component (`./lib/promo-retriever`).\r\n* Extracted dependency on `navigator.userAgent` into it's own component(`/lib/user-agent-utils`). As a note I'll probably follow up with another PR expanding that module and pulling out direct dependencies on navigator.userAgent throughout the codebase.\r\n* I pulled out the direct dependency on analytics and instead attempted to follow the practices outlined [here](https://wpcalypso.wordpress.com/devdocs/client/state/analytics/README.md).\r\n* I extracted showing/hiding logic for the `AppPromo` class and put it into the `ReaderSidebar` which is the only place `AppPromo` renders. Note that I had to tweak the `ReaderSidebar` class a little bit to get it somewhat testable.\r\n\r\nTo test:\r\n* Unit tests can be run via `npm run test-client client/components/app-promo` and `npm run test-client client/lib/user-agent-utils`.\r\n* To test the component's rendering you'll need to modify `client/reader/sidebar/index.js` to have the `renderAppPromo` method skip all the checks and just return the `AppPromo` component. The promo generation text is random so you'll need to refresh a few times to see the mobile promo text and verify that the hyperlink points to `http://apps.wordpress.com/mobile...`. You'll also want to verify that the desktop links you see point to `http://apps.wordpress.com/desktop...`. If you click on the links you'll need to clear out the localStorage item `desktop_promo_dismissed` in order to see `AppPromo` render again. You can also cheat and just add `show_promo = true` towards the end of the components `getInitialState()`.\r\n\r\n**Update** - after chatting with @dmsnell for a little we thought it best to pull the logic for hiding/showing `AppPromo` out of that module and push it into the `ReaderSidebar` class.\r\n\r\np.s. - I haven't written Javascript in six years, anything that looks silly or head bang worthy is probably due to this fact ;).\r\n\r\ncc @dmsnell \r\n\r\nTest live: https://calypso.live/?branch=clean-up-app-promo","created_at":"2016-09-05T17:48:29Z","updated_at":"2016-09-08T01:37:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b9c9ed7a1be780fd4d7ba8e5e25a971a1a224ec","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/7865/commits","review_comments_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/7865/comments","review_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/7865/comments","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/9382a92b323e3f4e17143483d7d3ac99ec59a457","head":{"label":"Automattic:clean-up-app-promo","ref":"clean-up-app-promo","sha":"9382a92b323e3f4e17143483d7d3ac99ec59a457","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":45936895,"name":"wp-calypso","full_name":"Automattic/wp-calypso","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/wp-calypso","description":"The new JavaScript- and API-powered WordPress.com","fork":false,"url":"https://api.github.com/repos/Automattic/wp-calypso","forks_url":"https://api.github.com/repos/Automattic/wp-calypso/forks","keys_url":"https://api.github.com/repos/Automattic/wp-calypso/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/wp-calypso/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/wp-calypso/teams","hooks_url":"https://api.github.com/repos/Automattic/wp-calypso/hooks","issue_events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/wp-calypso/events","assignees_url":"https://api.github.com/repos/Automattic/wp-calypso/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/wp-calypso/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/wp-calypso/tags","blobs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/wp-calypso/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/wp-calypso/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/wp-calypso/languages","stargazers_url":"https://api.github.com/repos/Automattic/wp-calypso/stargazers","contributors_url":"https://api.github.com/repos/Automattic/wp-calypso/contributors","subscribers_url":"https://api.github.com/repos/Automattic/wp-calypso/subscribers","subscription_url":"https://api.github.com/repos/Automattic/wp-calypso/subscription","commits_url":"https://api.github.com/repos/Automattic/wp-calypso/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/wp-calypso/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/wp-calypso/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/wp-calypso/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/wp-calypso/merges","archive_url":"https://api.github.com/repos/Automattic/wp-calypso/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/wp-calypso/downloads","issues_url":"https://api.github.com/repos/Automattic/wp-calypso/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/wp-calypso/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/wp-calypso/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/wp-calypso/deployments","created_at":"2015-11-10T20:00:16Z","updated_at":"2016-09-07T19:16:45Z","pushed_at":"2016-09-08T01:15:15Z","git_url":"git://github.com/Automattic/wp-calypso.git","ssh_url":"git@github.com:Automattic/wp-calypso.git","clone_url":"https://github.com/Automattic/wp-calypso.git","svn_url":"https://github.com/Automattic/wp-calypso","homepage":"https://developer.wordpress.com/calypso/","size":108967,"stargazers_count":7798,"watchers_count":7798,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":972,"mirror_url":null,"open_issues_count":1472,"forks":972,"open_issues":1472,"watchers":7798,"default_branch":"master"}},"base":{"label":"Automattic:master","ref":"master","sha":"fbab1c5b952307a024f0f7a716187f548e874395","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":45936895,"name":"wp-calypso","full_name":"Automattic/wp-calypso","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/wp-calypso","description":"The new JavaScript- and API-powered WordPress.com","fork":false,"url":"https://api.github.com/repos/Automattic/wp-calypso","forks_url":"https://api.github.com/repos/Automattic/wp-calypso/forks","keys_url":"https://api.github.com/repos/Automattic/wp-calypso/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/wp-calypso/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/wp-calypso/teams","hooks_url":"https://api.github.com/repos/Automattic/wp-calypso/hooks","issue_events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/wp-calypso/events","assignees_url":"https://api.github.com/repos/Automattic/wp-calypso/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/wp-calypso/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/wp-calypso/tags","blobs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/wp-calypso/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/wp-calypso/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/wp-calypso/languages","stargazers_url":"https://api.github.com/repos/Automattic/wp-calypso/stargazers","contributors_url":"https://api.github.com/repos/Automattic/wp-calypso/contributors","subscribers_url":"https://api.github.com/repos/Automattic/wp-calypso/subscribers","subscription_url":"https://api.github.com/repos/Automattic/wp-calypso/subscription","commits_url":"https://api.github.com/repos/Automattic/wp-calypso/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/wp-calypso/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/wp-calypso/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/wp-calypso/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/wp-calypso/merges","archive_url":"https://api.github.com/repos/Automattic/wp-calypso/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/wp-calypso/downloads","issues_url":"https://api.github.com/repos/Automattic/wp-calypso/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/wp-calypso/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/wp-calypso/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/wp-calypso/deployments","created_at":"2015-11-10T20:00:16Z","updated_at":"2016-09-07T19:16:45Z","pushed_at":"2016-09-08T01:15:15Z","git_url":"git://github.com/Automattic/wp-calypso.git","ssh_url":"git@github.com:Automattic/wp-calypso.git","clone_url":"https://github.com/Automattic/wp-calypso.git","svn_url":"https://github.com/Automattic/wp-calypso","homepage":"https://developer.wordpress.com/calypso/","size":108967,"stargazers_count":7798,"watchers_count":7798,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":972,"mirror_url":null,"open_issues_count":1472,"forks":972,"open_issues":1472,"watchers":7798,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/7865"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/7865"},"issue":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/7865"},"comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/7865/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/7865/comments"},"review_comment":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/7865/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/wp-calypso/statuses/9382a92b323e3f4e17143483d7d3ac99ec59a457"}}}}
{"actor":{"display_login":"sendhil"}}