{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/15900","repository_url":"https://api.github.com/repos/Automattic/wp-calypso","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/15900/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/15900/comments","events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/15900/events","html_url":"https://github.com/Automattic/wp-calypso/pull/15900","id":240860207,"number":15900,"title":"Add impression tracking for individual purchase subscription issues","user":{"login":"markryall","id":1926,"avatar_url":"https://avatars0.githubusercontent.com/u/1926?v=3","gravatar_id":"","url":"https://api.github.com/users/markryall","html_url":"https://github.com/markryall","followers_url":"https://api.github.com/users/markryall/followers","following_url":"https://api.github.com/users/markryall/following{/other_user}","gists_url":"https://api.github.com/users/markryall/gists{/gist_id}","starred_url":"https://api.github.com/users/markryall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markryall/subscriptions","organizations_url":"https://api.github.com/users/markryall/orgs","repos_url":"https://api.github.com/users/markryall/repos","events_url":"https://api.github.com/users/markryall/events{/privacy}","received_events_url":"https://api.github.com/users/markryall/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-06T06:50:08Z","updated_at":"2017-07-06T06:50:09Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/15900","html_url":"https://github.com/Automattic/wp-calypso/pull/15900","diff_url":"https://github.com/Automattic/wp-calypso/pull/15900.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/15900.patch"},"body":"This is a continuation of the work from #15493 and #15813 to add tracks events for notices related to domain or purchase issues.\r\n\r\nThis PR adds tracking to the three kinds of notification that can appear on the purchase list page (http://calypso.localhost:3000/me/purchases).\r\n\r\n# Testing\r\n\r\nYou can enable debug logging of tracks events in the console by running `localStorage.setItem('debug', 'calypso:analytics:tracks');` and then reloading.\r\n\r\nIt is possible to simulate each of the three warning conditions for a purchase by modifying the data received from the server for purchases in `client/state/purchases/reducer.js:94`:\r\n\r\n```\r\n\tconsole.log( 'purchases', action.purchases );\r\n\tconst seconds = 1000;\r\n\tconst minutes = 60 * seconds;\r\n\tconst hours = 60 * minutes;\r\n\tconst days = 24 * hours;\r\n\tfor (let i = 0; i < action.purchases.length; i++) {\r\n\t\tconst purchase = action.purchases[i];\r\n\t\tif ( purchase.ID && purchase.ID === \"8358369\" ) {\r\n\t\t\tconst now = ( new Date() ).getTime();\r\n\t\t\tconst date = new Date( now - 3 * days );\r\n\t\t\tpurchase.expiry_date = date.toISOString();\r\n\t\t\tpurchase.expiry_status = 'expired'; // included, expired, expiring, auto-renewing\r\n\t\t\tpurchase.payment_card_id = \"12345\";\r\n\t\t\tpurchase.payment_type = \"credit_card\";\r\n\t\t\tpurchase.payment_expiry = \"07/17\";\r\n\t\t\tpurchase.payment_card_type = \"visa\";\r\n\t\t\tpurchase.payment_details = \"4321\";\r\n\t\t}\r\n\t}\r\n```\r\n\r\nThe subscription id (8358369 in this example) can be determined from the url for the individual purchase.\r\n\r\nThe three warnings are:\r\n\r\n* purchase expired\r\n* purchase expiring\r\n* credit card expiring\r\n\r\nThe first two cases can be simulated by changing `expiry_date` for a chosen purchase and setting `expiry_status` to `expired` and `expiring` respectively.  The notice is shown for expiry within 30 days.  The credit card expiry can be testing by changing `expiry_status` to `auto-renewing` and `expiry_date` to any time after `payment_expiry`.\r\n\r\nThere are no click events for these events - the CTA are all displayed on the individual purchase pages.\r\n\r\nThe expected tracks events are:\r\n\r\n* purchase expired impression - `calypso_subscription_warning_impression` with properies `{ position: 'purchase-list', warning: 'purchase-expired' }`\r\n* purchase expiring impression - `calypso_subscription_warning_impression` with properies `{ position: 'purchase-list', warning: 'purchase-expiring' }`\r\n* credit card expiring impression - `calypso_subscription_warning_impression` with properies `{ position: 'purchase-list', warning: 'credit-card-expiring' }`\r\n"},"comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments/313311377","html_url":"https://github.com/Automattic/wp-calypso/pull/15900#issuecomment-313311377","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/15900","id":313311377,"user":{"login":"matticbot","id":18333116,"avatar_url":"https://avatars1.githubusercontent.com/u/18333116?v=3","gravatar_id":"","url":"https://api.github.com/users/matticbot","html_url":"https://github.com/matticbot","followers_url":"https://api.github.com/users/matticbot/followers","following_url":"https://api.github.com/users/matticbot/following{/other_user}","gists_url":"https://api.github.com/users/matticbot/gists{/gist_id}","starred_url":"https://api.github.com/users/matticbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matticbot/subscriptions","organizations_url":"https://api.github.com/users/matticbot/orgs","repos_url":"https://api.github.com/users/matticbot/repos","events_url":"https://api.github.com/users/matticbot/events{/privacy}","received_events_url":"https://api.github.com/users/matticbot/received_events","type":"User","site_admin":false},"created_at":"2017-07-06T06:50:09Z","updated_at":"2017-07-06T06:50:09Z","body":"Test live: https://calypso.live/?branch=add/tracks-events-for-subscription-warnings-on-purchases-list"}}
{"actor":{"display_login":"matticbot"}}