{"action":"opened","issue":{"url":"https://api.github.com/repos/npm/npm/issues/12529","repository_url":"https://api.github.com/repos/npm/npm","labels_url":"https://api.github.com/repos/npm/npm/issues/12529/labels{/name}","comments_url":"https://api.github.com/repos/npm/npm/issues/12529/comments","events_url":"https://api.github.com/repos/npm/npm/issues/12529/events","html_url":"https://github.com/npm/npm/issues/12529","id":151981138,"number":12529,"title":"Implement statistics tracking","user":{"login":"iarna","id":983798,"avatar_url":"https://avatars.githubusercontent.com/u/983798?v=3","gravatar_id":"","url":"https://api.github.com/users/iarna","html_url":"https://github.com/iarna","followers_url":"https://api.github.com/users/iarna/followers","following_url":"https://api.github.com/users/iarna/following{/other_user}","gists_url":"https://api.github.com/users/iarna/gists{/gist_id}","starred_url":"https://api.github.com/users/iarna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iarna/subscriptions","organizations_url":"https://api.github.com/users/iarna/orgs","repos_url":"https://api.github.com/users/iarna/repos","events_url":"https://api.github.com/users/iarna/events{/privacy}","received_events_url":"https://api.github.com/users/iarna/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-29T22:28:00Z","updated_at":"2016-04-29T22:28:00Z","closed_at":null,"body":"We don't know how people use npm. We don't know how well it works for them. Not really. Our ways of hear our users, here, twitter, the web, only reach a tiny fraction of our users. We don't know how fast or slow installs typically are, nor how big they are, nor how often folks see errors.\r\n\r\nIn order to work toward answering these questions so that we can make better decisions about the tool, we are going to start adding some metrics. Initially we will just track, on an opt-in basis, how often installs end in error. This is intentionally small, both so that implementation on our part will be easy, but also so that the privacy implications will be clear.\r\n\r\n### The work to be done on this project is:\r\n\r\n* [ ] For users who opt in (by adding a configuration option), start recording how many times installs succeed or end in an error in a file in the cache (eg, something like `CACHEDIR/stats.json`).\r\n  \r\n  When npm completes:\r\n    * If a stats file exists, increment the successful or failed installs.\r\n    * If a stats file does not exist, create a new stats file with a new `statPostId` associated with it.\r\n\r\n---\r\n* [ ] Add a new API to `npm-registry-client` and the registry itself for sending stats information to a registry.\r\n  \r\n  See the `npm-registry-client` issue for details:\r\n\r\n  And the registry issue: \r\n\r\n---\r\n\r\n* [ ] Using the new API, send stats data to the registry.\r\n  #### When starting a new install command:\r\n  * If the stats file exists: \r\n    * PUT to the stats URL for the configured registry using the contents of the stats file at the start of the command with unrefed sockets, so that npm won't wait if the PUT doesn't complete before the command does. PUTs that result in errors should be silently ignored.\r\n    * If the PUT completes, delete the local stats file.\r\n  We may not be able to support 0.8, as it can't `unref` sockets (AFAIK).\r\n"}}