Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

$dd->getDeviceName() empty #7829

Closed
jcerdan opened this issue Sep 16, 2024 · 7 comments · Fixed by #7830
Closed

$dd->getDeviceName() empty #7829

jcerdan opened this issue Sep 16, 2024 · 7 comments · Fixed by #7830

Comments

@jcerdan
Copy link

jcerdan commented Sep 16, 2024

Hello,

sometimes $dd->getDeviceName() returns an empty string.
DD detects it's not a bot, but device is empty.

What does that mean? Is it for real a human interaction?

I got the HTTP_USER_AGENT for one of those:

Mozilla/5.0 (iPhone; CPU iPhone OS 17_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/21G93 [FBAN/FBIOS;FBAV/479.1.0.33.109;FBBV/637241220;FBDV/iPhone15,2;FBMD/iPhone;FBSN/iOS;FBSV/17.6.1;FBSS/3;FBID/phone;FBLC/es_ES;FBOP/5;FBRV/639094949;IABMV/1]

Looks like FB app running on an iPhone...

regards

@liviuconcioiu
Copy link
Collaborator

HI @jcerdan! This is indeed the Facebook app running on iPhone 14 Pro, and is a human interaction.

In this case, device should have been a phablet. I think you are running an outdated version of Matomo or device-detector. Detection is working as expected:

-
  user_agent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/21G93 [FBAN/FBIOS;FBAV/479.1.0.33.109;FBBV/637241220;FBDV/iPhone15,2;FBMD/iPhone;FBSN/iOS;FBSV/17.6.1;FBSS/3;FBID/phone;FBLC/es_ES;FBOP/5;FBRV/639094949;IABMV/1]'
  os:
    name: iOS
    version: 17.6.1
    platform: ""
  client:
    type: mobile app
    name: Facebook
    version: 479.1.0.33.109
  device:
    type: phablet
    brand: Apple
    model: iPhone 14 Pro
  os_family: iOS
  browser_family: Unknown

@jcerdan
Copy link
Author

jcerdan commented Sep 16, 2024

Hi @liviuconcioiu ,

I'm running version 6.4.0.
I have tested the user agent there:
https://devicedetector.lw1.at

and I get

{
  "isBot": false,
  "clientInfo": {
    "type": "mobile app",
    "name": "Facebook",
    "version": "479.1.0.33.109"
  },
  "browserFamily": null,
  "isMobileOnlyBrowser": false,
  "osInfo": {
    "name": "iOS",
    "short_name": "IOS",
    "version": "17.6.1",
    "platform": "",
    "family": "iOS"
  },
  "osFamily": "iOS",
  "device": null,
  "deviceName": "",
  "deviceBrand": {
    "name": "Apple",
    "short_name": "AP"
  },
  "model": "",
  "icons": {
    "browser": null,
    "os": "/icons/os/IOS.png",
    "device": null,
    "brand": "/icons/brand/Apple.png"
  },
  "clientHints": {
    "architecture": "",
    "bitness": "",
    "mobile": false,
    "model": "",
    "platform": "",
    "platformVersion": "",
    "uaFullVersion": "",
    "fullVersionList": {}
  },
  "headers": null
}

How do you get the info for device=phablet?

@liviuconcioiu
Copy link
Collaborator

I'm running version 6.4.0. I have tested the user agent there: https://devicedetector.lw1.at

How do you get the info for device=phablet?

There's a bug on the website (user agent is wrongly encoded), reported in Findus23/devicedetector.net#4.

If you use the php code, detection works.

<?php

include_once 'path/to/spyc/Spyc.php';
include_once 'path/to/device-detector/autoload.php';

use DeviceDetector\ClientHints;
use DeviceDetector\DeviceDetector;
use DeviceDetector\Parser\Device\AbstractDeviceParser;

AbstractDeviceParser::setVersionTruncation(AbstractDeviceParser::VERSION_TRUNCATION_NONE);

$userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/21G93 [FBAN/FBIOS;FBAV/479.1.0.33.109;FBBV/637241220;FBDV/iPhone15,2;FBMD/iPhone;FBSN/iOS;FBSV/17.6.1;FBSS/3;FBID/phone;FBLC/es_ES;FBOP/5;FBRV/639094949;IABMV/1]';

$result = DeviceDetector::getInfoFromUserAgent($userAgent);

echo Spyc::YAMLDump($result, 2, 0);

@jcerdan
Copy link
Author

jcerdan commented Sep 17, 2024

I have checked commits. Looks like iOS improvement detection has been added after 6.4.0 release.
I'll try to get package until last commit and see if that solves the problem.
Thanks @liviuconcioiu

@jcerdan
Copy link
Author

jcerdan commented Sep 17, 2024

Hi,
I have detected that $dd->getDevice() returns null if Client Hints are passed to DeviceDetector.

So this code returns a null value:

$clientHints = ClientHints::factory($_SERVER);
$dd = new DeviceDetector($userAgent, $clientHints);
$dd->discardBotInformation();
$dd->parse();
dump($dd->getDevice());

while the same without ClientHints return the correct device name.

Is that a bug?

@liviuconcioiu
Copy link
Collaborator

Is that a bug?

Yes, it is a bug. It was introduced in #7807.

@sanchezzzhak can you look again at the code when you have time?

<?php

include_once 'path/to/spyc/Spyc.php';
include_once 'path/to/device-detector/autoload.php';

use DeviceDetector\ClientHints;
use DeviceDetector\DeviceDetector;
use DeviceDetector\Parser\Device\AbstractDeviceParser;

AbstractDeviceParser::setVersionTruncation(AbstractDeviceParser::VERSION_TRUNCATION_NONE);

$userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/21G93 [FBAN/FBIOS;FBAV/479.1.0.33.109;FBBV/637241220;FBDV/iPhone15,2;FBMD/iPhone;FBSN/iOS;FBSV/17.6.1;FBSS/3;FBID/phone;FBLC/es_ES;FBOP/5;FBRV/639094949;IABMV/1]';

$clientHints = ClientHints::factory([]);
$result = DeviceDetector::getInfoFromUserAgent($userAgent, $clientHints);

echo Spyc::YAMLDump($result, 2, 0);

This test should return

---
  user_agent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/21G93 [FBAN/FBIOS;FBAV/479.1.0.33.109;FBBV/637241220;FBDV/iPhone15,2;FBMD/iPhone;FBSN/iOS;FBSV/17.6.1;FBSS/3;FBID/phone;FBLC/es_ES;FBOP/5;FBRV/639094949;IABMV/1]'
  os:
    name: iOS
    version: 17.6.1
    platform: ""
  client:
    type: mobile app
    name: Facebook
    version: 479.1.0.33.109
  device:
    type: phablet
    brand: Apple
    model: iPhone 14 Pro
  os_family: iOS
  browser_family: Unknown

and not

---
user_agent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/21G93 [FBAN/FBIOS;FBAV/479.1.0.33.109;FBBV/637241220;FBDV/iPhone15,2;FBMD/iPhone;FBSN/iOS;FBSV/17.6.1;FBSS/3;FBID/phone;FBLC/es_ES;FBOP/5;FBRV/639094949;IABMV/1]'
os:
  name: iOS
  version: 17.6.1
  platform: ""
client:
  type: mobile app
  name: Facebook
  version: 479.1.0.33.109
device:
  type: ""
  brand: Apple
  model: ""
os_family: iOS
browser_family: Unknown

liviuconcioiu added a commit to liviuconcioiu/device-detector that referenced this issue Sep 17, 2024
@liviuconcioiu
Copy link
Collaborator

@jcerdan you can check with my change, if you need it working right away, until the commit is merged.

Also, fyi you need to request the headers from browser like this, if you want to fully benefit from client hints detection. Some browsers don't send full headers, if aren't requsted.

<?php

header('Accept-CH: Sec-CH-UA, Sec-CH-UA-Mobile, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version, Sec-CH-UA-Full-Version, Sec-CH-UA-Full-Version-List, Sec-CH-UA-Arch, Sec-CH-UA-Model, Sec-CH-UA-Form-Factors, Sec-CH-UA-Bitness, Sec-CH-UA-WoW64');

...code...

sanchezzzhak pushed a commit that referenced this issue Sep 18, 2024
* Fix client hints bug

ref #7829
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants