{"action":"opened","number":41,"pull_request":{"url":"https://api.github.com/repos/ai/browserslist/pulls/41","id":54907930,"html_url":"https://github.com/ai/browserslist/pull/41","diff_url":"https://github.com/ai/browserslist/pull/41.diff","patch_url":"https://github.com/ai/browserslist/pull/41.patch","issue_url":"https://api.github.com/repos/ai/browserslist/issues/41","number":41,"state":"open","locked":false,"title":"Added the possibility to query against custom browser usage data","user":{"login":"DanReyLop","id":1715800,"avatar_url":"https://avatars.githubusercontent.com/u/1715800?v=3","gravatar_id":"","url":"https://api.github.com/users/DanReyLop","html_url":"https://github.com/DanReyLop","followers_url":"https://api.github.com/users/DanReyLop/followers","following_url":"https://api.github.com/users/DanReyLop/following{/other_user}","gists_url":"https://api.github.com/users/DanReyLop/gists{/gist_id}","starred_url":"https://api.github.com/users/DanReyLop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanReyLop/subscriptions","organizations_url":"https://api.github.com/users/DanReyLop/orgs","repos_url":"https://api.github.com/users/DanReyLop/repos","events_url":"https://api.github.com/users/DanReyLop/events{/privacy}","received_events_url":"https://api.github.com/users/DanReyLop/received_events","type":"User","site_admin":false},"body":"See issue #4.\r\n\r\n**New query:**\r\n`>X% in my GA`\r\n\r\n**Usage:**\r\n``` js\r\nbrowserslist(\">5% in my GA\", {ga: \"path/to/usage_file.json\"})\r\n```\r\nAlso you can provide the usage info directly, like this:\r\n``` js\r\nvar usage = {\"ie\": {\"7\":0, \"8\":4.5, ...}, \"chrome\": {\"34\":23.7, ...}, ...}\r\nbrowserslist(\">5% in my GA\", {ga: usage})\r\n```\r\nThe expected file format is the same as `require('caniuse-db/region-usage-json/' + country).data`\r\n\r\nThe code used to parse the data directly from Google Analytics is over 1000 lines long and entangled with other parts of the caniuse.com JS code, so I just implemented a silly workaround:\r\n* Go to http://caniuse.com and import your custom Google Analytics data, as you would normally.\r\n* Paste this snippet into the navigation bar (tested in Chrome):\r\n```js\r\njavascript:(function(){var e=document.createElement('a');e.setAttribute('href', 'data:text/plain;charset=utf-8,'+encodeURIComponent(JSON.stringify(JSON.parse(localStorage['usage-data-by-id'])[localStorage['config-primary_usage']].dataByBrowser)));e.setAttribute('download','ga.json');document.body.appendChild(e);e.click();document.body.removeChild(e);})()\r\n```\r\n\r\nThat will give you the JSON file needed by browserslist.\r\n\r\nTell me if the functionality is OK and I'll write some tests for it and update the documentation. Maybe we should adapt the CLI script to support this functionality, or the use of an environment variable to specify the usage file.","created_at":"2016-01-02T15:55:33Z","updated_at":"2016-01-02T15:55:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ai/browserslist/pulls/41/commits","review_comments_url":"https://api.github.com/repos/ai/browserslist/pulls/41/comments","review_comment_url":"https://api.github.com/repos/ai/browserslist/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ai/browserslist/issues/41/comments","statuses_url":"https://api.github.com/repos/ai/browserslist/statuses/1bbafd87d2ec3e455fb0704e7bfe2c21a18baabd","head":{"label":"DanReyLop:custom-ga","ref":"custom-ga","sha":"1bbafd87d2ec3e455fb0704e7bfe2c21a18baabd","user":{"login":"DanReyLop","id":1715800,"avatar_url":"https://avatars.githubusercontent.com/u/1715800?v=3","gravatar_id":"","url":"https://api.github.com/users/DanReyLop","html_url":"https://github.com/DanReyLop","followers_url":"https://api.github.com/users/DanReyLop/followers","following_url":"https://api.github.com/users/DanReyLop/following{/other_user}","gists_url":"https://api.github.com/users/DanReyLop/gists{/gist_id}","starred_url":"https://api.github.com/users/DanReyLop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanReyLop/subscriptions","organizations_url":"https://api.github.com/users/DanReyLop/orgs","repos_url":"https://api.github.com/users/DanReyLop/repos","events_url":"https://api.github.com/users/DanReyLop/events{/privacy}","received_events_url":"https://api.github.com/users/DanReyLop/received_events","type":"User","site_admin":false},"repo":{"id":48883377,"name":"browserslist","full_name":"DanReyLop/browserslist","owner":{"login":"DanReyLop","id":1715800,"avatar_url":"https://avatars.githubusercontent.com/u/1715800?v=3","gravatar_id":"","url":"https://api.github.com/users/DanReyLop","html_url":"https://github.com/DanReyLop","followers_url":"https://api.github.com/users/DanReyLop/followers","following_url":"https://api.github.com/users/DanReyLop/following{/other_user}","gists_url":"https://api.github.com/users/DanReyLop/gists{/gist_id}","starred_url":"https://api.github.com/users/DanReyLop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanReyLop/subscriptions","organizations_url":"https://api.github.com/users/DanReyLop/orgs","repos_url":"https://api.github.com/users/DanReyLop/repos","events_url":"https://api.github.com/users/DanReyLop/events{/privacy}","received_events_url":"https://api.github.com/users/DanReyLop/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DanReyLop/browserslist","description":"Get browsers versions that matches given criterias like in Autoprefixer","fork":true,"url":"https://api.github.com/repos/DanReyLop/browserslist","forks_url":"https://api.github.com/repos/DanReyLop/browserslist/forks","keys_url":"https://api.github.com/repos/DanReyLop/browserslist/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DanReyLop/browserslist/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DanReyLop/browserslist/teams","hooks_url":"https://api.github.com/repos/DanReyLop/browserslist/hooks","issue_events_url":"https://api.github.com/repos/DanReyLop/browserslist/issues/events{/number}","events_url":"https://api.github.com/repos/DanReyLop/browserslist/events","assignees_url":"https://api.github.com/repos/DanReyLop/browserslist/assignees{/user}","branches_url":"https://api.github.com/repos/DanReyLop/browserslist/branches{/branch}","tags_url":"https://api.github.com/repos/DanReyLop/browserslist/tags","blobs_url":"https://api.github.com/repos/DanReyLop/browserslist/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DanReyLop/browserslist/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DanReyLop/browserslist/git/refs{/sha}","trees_url":"https://api.github.com/repos/DanReyLop/browserslist/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DanReyLop/browserslist/statuses/{sha}","languages_url":"https://api.github.com/repos/DanReyLop/browserslist/languages","stargazers_url":"https://api.github.com/repos/DanReyLop/browserslist/stargazers","contributors_url":"https://api.github.com/repos/DanReyLop/browserslist/contributors","subscribers_url":"https://api.github.com/repos/DanReyLop/browserslist/subscribers","subscription_url":"https://api.github.com/repos/DanReyLop/browserslist/subscription","commits_url":"https://api.github.com/repos/DanReyLop/browserslist/commits{/sha}","git_commits_url":"https://api.github.com/repos/DanReyLop/browserslist/git/commits{/sha}","comments_url":"https://api.github.com/repos/DanReyLop/browserslist/comments{/number}","issue_comment_url":"https://api.github.com/repos/DanReyLop/browserslist/issues/comments{/number}","contents_url":"https://api.github.com/repos/DanReyLop/browserslist/contents/{+path}","compare_url":"https://api.github.com/repos/DanReyLop/browserslist/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DanReyLop/browserslist/merges","archive_url":"https://api.github.com/repos/DanReyLop/browserslist/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DanReyLop/browserslist/downloads","issues_url":"https://api.github.com/repos/DanReyLop/browserslist/issues{/number}","pulls_url":"https://api.github.com/repos/DanReyLop/browserslist/pulls{/number}","milestones_url":"https://api.github.com/repos/DanReyLop/browserslist/milestones{/number}","notifications_url":"https://api.github.com/repos/DanReyLop/browserslist/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DanReyLop/browserslist/labels{/name}","releases_url":"https://api.github.com/repos/DanReyLop/browserslist/releases{/id}","created_at":"2016-01-01T16:41:04Z","updated_at":"2016-01-01T16:41:05Z","pushed_at":"2016-01-02T15:38:15Z","git_url":"git://github.com/DanReyLop/browserslist.git","ssh_url":"git@github.com:DanReyLop/browserslist.git","clone_url":"https://github.com/DanReyLop/browserslist.git","svn_url":"https://github.com/DanReyLop/browserslist","homepage":"","size":102,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ai:master","ref":"master","sha":"4b324989521c97186901c814be48d5d731a97086","user":{"login":"ai","id":19343,"avatar_url":"https://avatars.githubusercontent.com/u/19343?v=3","gravatar_id":"","url":"https://api.github.com/users/ai","html_url":"https://github.com/ai","followers_url":"https://api.github.com/users/ai/followers","following_url":"https://api.github.com/users/ai/following{/other_user}","gists_url":"https://api.github.com/users/ai/gists{/gist_id}","starred_url":"https://api.github.com/users/ai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ai/subscriptions","organizations_url":"https://api.github.com/users/ai/orgs","repos_url":"https://api.github.com/users/ai/repos","events_url":"https://api.github.com/users/ai/events{/privacy}","received_events_url":"https://api.github.com/users/ai/received_events","type":"User","site_admin":false},"repo":{"id":27971466,"name":"browserslist","full_name":"ai/browserslist","owner":{"login":"ai","id":19343,"avatar_url":"https://avatars.githubusercontent.com/u/19343?v=3","gravatar_id":"","url":"https://api.github.com/users/ai","html_url":"https://github.com/ai","followers_url":"https://api.github.com/users/ai/followers","following_url":"https://api.github.com/users/ai/following{/other_user}","gists_url":"https://api.github.com/users/ai/gists{/gist_id}","starred_url":"https://api.github.com/users/ai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ai/subscriptions","organizations_url":"https://api.github.com/users/ai/orgs","repos_url":"https://api.github.com/users/ai/repos","events_url":"https://api.github.com/users/ai/events{/privacy}","received_events_url":"https://api.github.com/users/ai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ai/browserslist","description":"Get browsers versions that matches given criterias like in Autoprefixer","fork":false,"url":"https://api.github.com/repos/ai/browserslist","forks_url":"https://api.github.com/repos/ai/browserslist/forks","keys_url":"https://api.github.com/repos/ai/browserslist/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ai/browserslist/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ai/browserslist/teams","hooks_url":"https://api.github.com/repos/ai/browserslist/hooks","issue_events_url":"https://api.github.com/repos/ai/browserslist/issues/events{/number}","events_url":"https://api.github.com/repos/ai/browserslist/events","assignees_url":"https://api.github.com/repos/ai/browserslist/assignees{/user}","branches_url":"https://api.github.com/repos/ai/browserslist/branches{/branch}","tags_url":"https://api.github.com/repos/ai/browserslist/tags","blobs_url":"https://api.github.com/repos/ai/browserslist/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ai/browserslist/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ai/browserslist/git/refs{/sha}","trees_url":"https://api.github.com/repos/ai/browserslist/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ai/browserslist/statuses/{sha}","languages_url":"https://api.github.com/repos/ai/browserslist/languages","stargazers_url":"https://api.github.com/repos/ai/browserslist/stargazers","contributors_url":"https://api.github.com/repos/ai/browserslist/contributors","subscribers_url":"https://api.github.com/repos/ai/browserslist/subscribers","subscription_url":"https://api.github.com/repos/ai/browserslist/subscription","commits_url":"https://api.github.com/repos/ai/browserslist/commits{/sha}","git_commits_url":"https://api.github.com/repos/ai/browserslist/git/commits{/sha}","comments_url":"https://api.github.com/repos/ai/browserslist/comments{/number}","issue_comment_url":"https://api.github.com/repos/ai/browserslist/issues/comments{/number}","contents_url":"https://api.github.com/repos/ai/browserslist/contents/{+path}","compare_url":"https://api.github.com/repos/ai/browserslist/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ai/browserslist/merges","archive_url":"https://api.github.com/repos/ai/browserslist/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ai/browserslist/downloads","issues_url":"https://api.github.com/repos/ai/browserslist/issues{/number}","pulls_url":"https://api.github.com/repos/ai/browserslist/pulls{/number}","milestones_url":"https://api.github.com/repos/ai/browserslist/milestones{/number}","notifications_url":"https://api.github.com/repos/ai/browserslist/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ai/browserslist/labels{/name}","releases_url":"https://api.github.com/repos/ai/browserslist/releases{/id}","created_at":"2014-12-13T19:35:45Z","updated_at":"2016-01-01T16:39:41Z","pushed_at":"2016-01-01T17:25:36Z","git_url":"git://github.com/ai/browserslist.git","ssh_url":"git@github.com:ai/browserslist.git","clone_url":"https://github.com/ai/browserslist.git","svn_url":"https://github.com/ai/browserslist","homepage":"","size":575,"stargazers_count":457,"watchers_count":457,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":2,"forks":26,"open_issues":2,"watchers":457,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ai/browserslist/pulls/41"},"html":{"href":"https://github.com/ai/browserslist/pull/41"},"issue":{"href":"https://api.github.com/repos/ai/browserslist/issues/41"},"comments":{"href":"https://api.github.com/repos/ai/browserslist/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/ai/browserslist/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/ai/browserslist/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ai/browserslist/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/ai/browserslist/statuses/1bbafd87d2ec3e455fb0704e7bfe2c21a18baabd"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":40,"deletions":1,"changed_files":1}}