Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
piwik.JS: devicePixelRatio detection covers only Apple devices #4663
The devicePixelRatio detection in https://github.com/piwik/piwik/blob/master/js/piwik.js#L2242 makes a simple assumption that only Apple Retina devices have a physical screen resolution that differs from the logical (CSS pixel) resolution.
That leads to the issue that e.g. most Android hi-res devices aren't correctly detected and neither Win8 ones.
You can find a list of real CSS Pixel ratios here: http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density Unfortunately not all Devices are configured on 1 1.5 2 2.5 3 etc... but some use in-between ratios.
My suggestion would be to use this (established) polyfill instead of the UA regexp:
but I would add a rounding to 0.5 precision to not spam the Data with random outliers.
did I miss something? I'm not sure how such a change affects backwards compatibility of the data. If backwards compatibility is an issue (have to think about retina displays on desktops, too!), An alternative would be to define "res" as CSS resolution and report devicePixelRatio separately (See my P.P.S. below).
Greets, interested to hear what you think.
P.S.: Concerning the devicesDetection Plugin: I think it would be a never-ending uphill battle to try to maintain an always-up-to-date mapping of UA strings to devicePixelRatios on the server, which would be inherently unreliable all the time as Vendors are starting to anonymize the UA strings of the devices more and more.
We only maintain regular expressions to detect devices, brands, models, etc. we don't maintain list of user agents, except of course in our extensive test suite which tests more than 1000 user agents after each commit. It will be a challenge to maintain this list for sure, but we call on the community to help us improve it over time and add new devices and models and brands and browsers and operating systems.
ok, I'll try to isolate the issue with the android resolutions tracked on a local installation.
Another possible cross-check whether this is actually a bug would be to take a real-world dataset (like the piwik forums and/or website) and segment some popular hi-res Android devices (from "device model" report, e.g. the
I unfotunately don't have such a dataset yet because we're not yet live with piwik.