{"action":"created","comment":{"url":"https://api.github.com/repos/guardian/support-frontend/pulls/comments/227876573","pull_request_review_id":168017120,"id":227876573,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNzg3NjU3Mw==","diff_hunk":"@@ -0,0 +1,44 @@\n+package cookies\n+\n+import admin.ServersideAbTest\n+import admin.ServersideAbTest.Participation\n+import config.Configuration.GuardianDomain\n+import play.api.mvc.{Cookie, RequestHeader, Result}\n+\n+object ServersideAbTestCookie {\n+  val name = \"gu.serverside.ab.test\"\n+\n+  def create(domain: GuardianDomain, participation: ServersideAbTest.Participation): Cookie = Cookie(\n+    name = name,\n+    value = participation.toString,\n+    secure = true,\n+    httpOnly = false,\n+    domain = Some(s\"support${domain.value}\")\n+  )\n+\n+  def exists(implicit request: RequestHeader): Boolean = request.cookies.exists(_.name == name)\n+  def get(implicit request: RequestHeader): Option[Cookie] = request.cookies.get(name)\n+\n+  def addTo(result: Result)(implicit domain: GuardianDomain, participation: Participation): Result =\n+    result.withCookies(create(domain, participation))\n+}\n+\n+trait ServersideAbTestCookie {\n+\n+  implicit class ResultSyntax(result: Result)(","path":"app/cookies/ServersideAbTestCookie.scala","position":28,"original_position":28,"commit_id":"9842dab2f87f6587d23600d8950411f87b43a614","original_commit_id":"9842dab2f87f6587d23600d8950411f87b43a614","user":{"login":"johnduffell","id":7304387,"node_id":"MDQ6VXNlcjczMDQzODc=","avatar_url":"https://avatars1.githubusercontent.com/u/7304387?v=4","gravatar_id":"","url":"https://api.github.com/users/johnduffell","html_url":"https://github.com/johnduffell","followers_url":"https://api.github.com/users/johnduffell/followers","following_url":"https://api.github.com/users/johnduffell/following{/other_user}","gists_url":"https://api.github.com/users/johnduffell/gists{/gist_id}","starred_url":"https://api.github.com/users/johnduffell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnduffell/subscriptions","organizations_url":"https://api.github.com/users/johnduffell/orgs","repos_url":"https://api.github.com/users/johnduffell/repos","events_url":"https://api.github.com/users/johnduffell/events{/privacy}","received_events_url":"https://api.github.com/users/johnduffell/received_events","type":"User","site_admin":false},"body":"I also struggle with implicit classes - I do use them reluctantly a bit to move boilerplate to the end of for comprehensions (e.g. we have to lift various things into a EitherT[Future[Either[.]]] as part of a for comprehension) but on the whole, a normal function suffices for almost everything.","created_at":"2018-10-24T17:00:15Z","updated_at":"2018-10-24T17:00:15Z","html_url":"https://github.com/guardian/support-frontend/pull/1067#discussion_r227876573","pull_request_url":"https://api.github.com/repos/guardian/support-frontend/pulls/1067","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/guardian/support-frontend/pulls/comments/227876573"},"html":{"href":"https://github.com/guardian/support-frontend/pull/1067#discussion_r227876573"},"pull_request":{"href":"https://api.github.com/repos/guardian/support-frontend/pulls/1067"}}},"pull_request":{"url":"https://api.github.com/repos/guardian/support-frontend/pulls/1067","id":224988415,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI0OTg4NDE1","html_url":"https://github.com/guardian/support-frontend/pull/1067","diff_url":"https://github.com/guardian/support-frontend/pull/1067.diff","patch_url":"https://github.com/guardian/support-frontend/pull/1067.patch","issue_url":"https://api.github.com/repos/guardian/support-frontend/issues/1067","number":1067,"state":"open","locked":false,"title":"Serverside test for new payment flow","user":{"login":"joelochlann","id":5122968,"node_id":"MDQ6VXNlcjUxMjI5Njg=","avatar_url":"https://avatars3.githubusercontent.com/u/5122968?v=4","gravatar_id":"","url":"https://api.github.com/users/joelochlann","html_url":"https://github.com/joelochlann","followers_url":"https://api.github.com/users/joelochlann/followers","following_url":"https://api.github.com/users/joelochlann/following{/other_user}","gists_url":"https://api.github.com/users/joelochlann/gists{/gist_id}","starred_url":"https://api.github.com/users/joelochlann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelochlann/subscriptions","organizations_url":"https://api.github.com/users/joelochlann/orgs","repos_url":"https://api.github.com/users/joelochlann/repos","events_url":"https://api.github.com/users/joelochlann/events{/privacy}","received_events_url":"https://api.github.com/users/joelochlann/received_events","type":"User","site_admin":false},"body":"- `/$country<(uk|us|au|eu|int|nz|ca)>/contribute` => old or new flow\r\n- `/$country<(uk|us|au|eu|int|nz|ca)>/contribute.new` => new flow\r\n\r\nSince the top route is now uncached, I've added very basic serverside A/B test functionality to the backend. It only supports a single concurrent test, to 100% of the audience, in a 50/50 split. Based on a pseudorandom coin toss, it sets a cookie called `gu.serverside.ab.test` whose value is either `Control` or `Variant` that's about it.\r\n\r\nSo the top route will serve the new flow if the request has a `gu.serverside.ab.test` cookie with a value of `Variant`, or if the request is placed in that variant (in which the cookie will be set in the response).\r\n\r\nAs a result I've removed `segment` from the `ExperimentSwitch` type. So these are now just on/off switches, basically. (This switching functionality is still very useful for testing locally).\r\n\r\n**BEFORE THIS PR IS MERGED** I need to change the `experiments` part of `settings.json` in S3 from this:\r\n```\r\n    \"experiments\": {\r\n      \"newPaymentFlow\": {\r\n        \"name\": \"newPaymentFlow\",\r\n        \"description\": \"Redesign of the payment flow UI\",\r\n        \"segment\": \"Perc0\",\r\n        \"state\": \"On\"\r\n      }\r\n    },\r\n```\r\nto this:\r\n\r\n```\r\n    \"experiments\": {\r\n      \"newPaymentFlow\": {\r\n        \"name\": \"newPaymentFlow\",\r\n        \"description\": \"Redesign of the payment flow UI\",\r\n        \"state\": \"Off\"\r\n      }\r\n    },\r\n```\r\n\r\nso the test is not turned on by this PR. Then when we do release the test, we just change the state to \"On\"","created_at":"2018-10-23T10:48:18Z","updated_at":"2018-10-24T17:00:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c2c91c9643b8b6ea2d817f0ac774fadf0aff5709","assignee":null,"assignees":[],"requested_reviewers":[{"login":"tomrf1","id":1513454,"node_id":"MDQ6VXNlcjE1MTM0NTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1513454?v=4","gravatar_id":"","url":"https://api.github.com/users/tomrf1","html_url":"https://github.com/tomrf1","followers_url":"https://api.github.com/users/tomrf1/followers","following_url":"https://api.github.com/users/tomrf1/following{/other_user}","gists_url":"https://api.github.com/users/tomrf1/gists{/gist_id}","starred_url":"https://api.github.com/users/tomrf1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomrf1/subscriptions","organizations_url":"https://api.github.com/users/tomrf1/orgs","repos_url":"https://api.github.com/users/tomrf1/repos","events_url":"https://api.github.com/users/tomrf1/events{/privacy}","received_events_url":"https://api.github.com/users/tomrf1/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/guardian/support-frontend/pulls/1067/commits","review_comments_url":"https://api.github.com/repos/guardian/support-frontend/pulls/1067/comments","review_comment_url":"https://api.github.com/repos/guardian/support-frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/guardian/support-frontend/issues/1067/comments","statuses_url":"https://api.github.com/repos/guardian/support-frontend/statuses/9842dab2f87f6587d23600d8950411f87b43a614","head":{"label":"guardian:npf-serverside-test","ref":"npf-serverside-test","sha":"9842dab2f87f6587d23600d8950411f87b43a614","user":{"login":"guardian","id":164318,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NDMxOA==","avatar_url":"https://avatars0.githubusercontent.com/u/164318?v=4","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":87204582,"node_id":"MDEwOlJlcG9zaXRvcnk4NzIwNDU4Mg==","name":"support-frontend","full_name":"guardian/support-frontend","private":false,"owner":{"login":"guardian","id":164318,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NDMxOA==","avatar_url":"https://avatars0.githubusercontent.com/u/164318?v=4","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/guardian/support-frontend","description":"Frontend for the Supporter platform","fork":false,"url":"https://api.github.com/repos/guardian/support-frontend","forks_url":"https://api.github.com/repos/guardian/support-frontend/forks","keys_url":"https://api.github.com/repos/guardian/support-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/support-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/support-frontend/teams","hooks_url":"https://api.github.com/repos/guardian/support-frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/support-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/support-frontend/events","assignees_url":"https://api.github.com/repos/guardian/support-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/support-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/support-frontend/tags","blobs_url":"https://api.github.com/repos/guardian/support-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/support-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/support-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/support-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/support-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/support-frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/support-frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/support-frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/support-frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/support-frontend/subscription","commits_url":"https://api.github.com/repos/guardian/support-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/support-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/support-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/support-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/support-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/support-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/support-frontend/merges","archive_url":"https://api.github.com/repos/guardian/support-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/support-frontend/downloads","issues_url":"https://api.github.com/repos/guardian/support-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/support-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/support-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/support-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/support-frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/support-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/support-frontend/deployments","created_at":"2017-04-04T15:37:12Z","updated_at":"2018-10-24T16:32:49Z","pushed_at":"2018-10-24T16:52:18Z","git_url":"git://github.com/guardian/support-frontend.git","ssh_url":"git@github.com:guardian/support-frontend.git","clone_url":"https://github.com/guardian/support-frontend.git","svn_url":"https://github.com/guardian/support-frontend","homepage":"https://support.theguardian.com/","size":7070,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":8,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2,"open_issues":8,"watchers":4,"default_branch":"master"}},"base":{"label":"guardian:master","ref":"master","sha":"7a40b036ace87d8d3e5a733b06e420d9ef5a5bdc","user":{"login":"guardian","id":164318,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NDMxOA==","avatar_url":"https://avatars0.githubusercontent.com/u/164318?v=4","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":87204582,"node_id":"MDEwOlJlcG9zaXRvcnk4NzIwNDU4Mg==","name":"support-frontend","full_name":"guardian/support-frontend","private":false,"owner":{"login":"guardian","id":164318,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NDMxOA==","avatar_url":"https://avatars0.githubusercontent.com/u/164318?v=4","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/guardian/support-frontend","description":"Frontend for the Supporter platform","fork":false,"url":"https://api.github.com/repos/guardian/support-frontend","forks_url":"https://api.github.com/repos/guardian/support-frontend/forks","keys_url":"https://api.github.com/repos/guardian/support-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/support-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/support-frontend/teams","hooks_url":"https://api.github.com/repos/guardian/support-frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/support-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/support-frontend/events","assignees_url":"https://api.github.com/repos/guardian/support-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/support-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/support-frontend/tags","blobs_url":"https://api.github.com/repos/guardian/support-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/support-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/support-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/support-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/support-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/support-frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/support-frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/support-frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/support-frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/support-frontend/subscription","commits_url":"https://api.github.com/repos/guardian/support-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/support-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/support-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/support-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/support-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/support-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/support-frontend/merges","archive_url":"https://api.github.com/repos/guardian/support-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/support-frontend/downloads","issues_url":"https://api.github.com/repos/guardian/support-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/support-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/support-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/support-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/support-frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/support-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/support-frontend/deployments","created_at":"2017-04-04T15:37:12Z","updated_at":"2018-10-24T16:32:49Z","pushed_at":"2018-10-24T16:52:18Z","git_url":"git://github.com/guardian/support-frontend.git","ssh_url":"git@github.com:guardian/support-frontend.git","clone_url":"https://github.com/guardian/support-frontend.git","svn_url":"https://github.com/guardian/support-frontend","homepage":"https://support.theguardian.com/","size":7070,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":8,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2,"open_issues":8,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guardian/support-frontend/pulls/1067"},"html":{"href":"https://github.com/guardian/support-frontend/pull/1067"},"issue":{"href":"https://api.github.com/repos/guardian/support-frontend/issues/1067"},"comments":{"href":"https://api.github.com/repos/guardian/support-frontend/issues/1067/comments"},"review_comments":{"href":"https://api.github.com/repos/guardian/support-frontend/pulls/1067/comments"},"review_comment":{"href":"https://api.github.com/repos/guardian/support-frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/guardian/support-frontend/pulls/1067/commits"},"statuses":{"href":"https://api.github.com/repos/guardian/support-frontend/statuses/9842dab2f87f6587d23600d8950411f87b43a614"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"johnduffell"}}