device-detector icon indicating copy to clipboard operation
device-detector copied to clipboard

Librem phone is counted as an iOS device

Open programmin1 opened this issue 3 years ago • 13 comments

Expected Behavior

Logged visits should be the right OS.

Current Behavior

Visit any site with Matomo installed on the Librem 5 phone. Look in the "visits in real time" in the left of Matomo Analytics and it registers that as "iOS"?? Browser: Chrome webview 64 even though this is the default browser that comes on Librem5. It should show it is a Linux phone not "iOS".

Possible Solution

Check for Librem/pinephone or other Linux phones as these are going to be growing in use lately.

Steps to Reproduce (for Bugs)

Visit any site with Matomo installed on a Librem 5 phone. Look in the "visits in real time" in the left of Matomo Analytics and see that the pages you just visited register as iOS visits.

Context

There is no way to know just how many Librem phone users are using the site, counting as iOS would send developer effort in the wrong direction testing sites.

Your Environment

  • Matomo Version:4.7.1
  • PHP Version: 7.4.28
  • Server Operating System:Ubuntu
  • Additionally installed plugins: N/A
  • Browser: GNOME WEB 3.38.2 default browser
  • Operating System: Librem PureOS

programmin1 avatar Feb 19 '22 06:02 programmin1

Hi,

Can you share the user agent the phone sends to websites? e.g. by opening https://devicedetector.lw1.at on it.

Findus23 avatar Feb 19 '22 10:02 Findus23

I'll move this on to the device detector repo. If anything can be improved in the detection it needs to be done there.

sgiehl avatar Feb 19 '22 10:02 sgiehl

Did a quick search and seems Librem uses useragents like

Mozilla/5.0 (Librem 5, like iPhone; X11; Linux x86_64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15 Epiphany/605.1.15

sgiehl avatar Feb 19 '22 10:02 sgiehl

And indeed that user agent is detected incorrectly. I assume the like iPhone and Safari/605.1.15 trips it up. Is there a way to change the rules so that Librem 5 has a higher priority?

Findus23 avatar Feb 19 '22 10:02 Findus23

The same happens with Nintendo 3DS

Mozilla/5.0 (New Nintendo 3DS like iPhone) AppleWebKit/536.30 (KHTML, like Gecko) NX/3.0.0.5.22 Mobile NintendoBrowser/1.10.10166.JP

liviuconcioiu avatar Feb 19 '22 10:02 liviuconcioiu

oss.yml need added (?<!like )

- regex: '(?:Apple-)?(?<!like )(?:iPhone|iPad|iPod)(?:.*Mac OS X.*Version/(\d+\.\d+)|; Opera)?'
  name: 'iOS'
  version: '$1'

line 720

upd 2

user_agent: Mozilla/5.0 (Librem 5, like iPhone; X11; Linux x86_64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15 Epiphany/605.1.15
os:
  name: GNU/Linux
  version: ""
  platform: x64
client:
  type: browser
  name: GNOME Web
  version: 605.1.15
  engine: WebKit
  engine_version: 605.1.15
device:
  type: smartphone
  brand: Purism
  model: "Librem 5"
os_family: GNU/Linux
browser_family: Unknown
user_agent: Mozilla/5.0 (New Nintendo 3DS like iPhone) AppleWebKit/536.30 (KHTML, like Gecko) NX/3.0.0.5.22 Mobile NintendoBrowser/1.10.10166.JP
os:
  name: Nintendo Mobile
  version: 3DS
  platform: ""
client:
  type: browser
  name: NetFront
  version: ""
  engine: WebKit
  engine_version: "536.30"
device:
  type: console
  brand: Nintendo
  model: 3DS
os_family: Mobile Gaming Console
browser_family: NetFront

sanchezzzhak avatar Feb 19 '22 10:02 sanchezzzhak

I'll make a PR.

liviuconcioiu avatar Feb 19 '22 10:02 liviuconcioiu

I still see Librem phone counted as "iOS". Being a phone and not their Intel desktop, its user agent includes "Linux aarch64" not "Linux x86_64".

It looks like the match in the PR includes the full UA string and would break every update of the system?

programmin1 avatar Mar 09 '22 06:03 programmin1

https://devicedetector.lw1.at/ Create online test and send it to us.

sanchezzzhak avatar Mar 09 '22 07:03 sanchezzzhak

@programmin1 it will take a while until your Matomo detects that correctly. When something is changed here it needs to be included in a release of device detector. Once that was done the device detector needs to be updated in Matomo, which is done with every new release of Matomo. So it might be included in Matomo 4.8.

sgiehl avatar Mar 09 '22 07:03 sgiehl

Mozilla/5.0 (Librem 5, like iPhone; Linux aarch64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Chrome/64 Mobile/15E148 Safari/605.1.15

is the full useragent of Librem phone with updates.

programmin1 avatar Mar 09 '22 20:03 programmin1

The device is detected correctly. As @sgiehl said, it might take some time until 5.0.5 version of device detector (which includes this particular device) reaches the next release of Matomo. I'm not familiar with Matomo, but I suppose you can update manually very easy device detector. You can also automate a nightly build, by downloading from Github.

{
  "isBot": false,
  "clientInfo": {
    "type": "browser",
    "name": "Chrome Webview",
    "short_name": "CV",
    "version": "64",
    "engine": "Blink",
    "engine_version": "",
    "family": "Chrome"
  },
  "browserFamily": "Chrome",
  "isMobileOnlyBrowser": false,
  "osInfo": {
    "name": "PureOS",
    "short_name": "PUR",
    "version": "",
    "platform": "ARM",
    "family": "GNU/Linux"
  },
  "osFamily": "GNU/Linux",
  "device": 1,
  "deviceName": "smartphone",
  "deviceBrand": {
    "name": "Purism",
    "short_name": "UP"
  },
  "model": "Librem 5",
  "icons": {
    "browser": "/icons/browsers/CV.png",
    "os": "/icons/os/LIN.png",
    "device": "/icons/devices/smartphone.png",
    "brand": null
  },
  "clientHints": {
    "architecture": "",
    "bitness": "",
    "mobile": false,
    "model": "",
    "platform": "",
    "platformVersion": "",
    "uaFullVersion": "",
    "fullVersionList": {}
  },
  "headers": null
}

liviuconcioiu avatar Mar 09 '22 21:03 liviuconcioiu

It's not easily possible to update device detector within Matomo. Version 5.0.5 was not included in Matomo 4.8.0 but it will be in Matomo 4.9.0 which should be released in a couple of weeks

sgiehl avatar Mar 09 '22 22:03 sgiehl

@sgiehl can you close this issue since is fixed?

liviuconcioiu avatar Jan 09 '23 12:01 liviuconcioiu