browserslist / browserslist-ga

🦔 Target browsers tailored to your audience using Google Analytics
MIT License
303 stars 18 forks source link

Proposal: Map YaBrowser to corresponding chrome #2

Closed Vasfed closed 6 years ago

Vasfed commented 6 years ago

Yandex browser is relatively popular in russian-speaking countries. It is based on Blink engine thus in terms of rendering is equal to Chrome.

Until it becomes available on caniuse we may map it to chrome versions that are reported in user agent string and make stats coverage more useable.

dmfrancisco commented 6 years ago

This is great, thank you for your contribution 👏

Can you provide more context about how you got to that mapping? Right now all the browser version updates come from caniuse-lite but with this change we would have to manually keep this mapping file updated too, and so it's important to me to learn how easy that process is.

Vasfed commented 6 years ago

@dmfrancisco I have parsed that from my production system recent access logs (~6M hits), user agent strings look like Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 YaBrowser/14.8.1985.11875 Safari/537.36 (it's exactly Chrome user agent with addition of YaBrowser/[0-9.]+ (in this example we see YaBrowser 14.8 == Chrome 36, which gives [14, 8, 36] mapping, mappings are sorted for easier search. On iOS safari is used (thus other PR) and on android it looks like it uses either same version or newer

Mapping does not need to be 100% accurate - in worst case user will only get slightly elevated usage of middle-range chrome versions (closest known mapping is used). With this patch on my usage I managed to go from 83% stats coverage to 96% (npx browserslist --coverage="my stats" "cover 100% in my stats", browserslist >= 3.2)

dmfrancisco commented 6 years ago

This looks good 👍 Thank you again!

dmfrancisco commented 6 years ago

It seems it may be more appropriate to map "YaBrowser for Android" to "Chrome for Android", so I'll add that change too. The versions are the same so the mapping works for both. Because caniuse only tracks the latest version of Chrome for Android, the coverage may decrease a bit.

dmfrancisco commented 6 years ago

Ended up moving this code to a separate repository and followed the same approach for the Cốc Cốc Browser, a popular browser in Vietnam that I noticed frequently in the JS.coach analytics.

The repository is available here: https://github.com/dmfrancisco/map-to-chrome