Skip to content

Commit

Permalink
Improves version detection for Fire OS from client hints (matomo-org#…
Browse files Browse the repository at this point in the history
  • Loading branch information
liviuconcioiu authored Nov 1, 2024
1 parent 727ac23 commit 97f3c8e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Parser/OperatingSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,11 @@ public function parse(): ?array
$version = $osFromUserAgent['version'];
}

if ('Fire OS' === $osFromUserAgent['name']) {
$majorVersion = (int) (\explode('.', $version, 1)[0] ?? '0');
if ('Fire OS' === $name && !empty($osFromClientHints['version'])) {
$majorVersion = (int) (\explode('.', $version, 1)[0] ?? '0');

$version = $this->fireOsVersionMapping[$version]
?? $this->fireOsVersionMapping[$majorVersion] ?? '';
$version = $this->fireOsVersionMapping[$version]
?? $this->fireOsVersionMapping[$majorVersion] ?? '';
}
}

Expand Down
10 changes: 10 additions & 0 deletions Tests/Parser/fixtures/oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5699,3 +5699,13 @@
version: "18.2"
platform: ""
family: iOS
-
user_agent: Mozilla/5.0 (Linux; Android 11; AFTT) AppleWebKit/537.36 (KHTML, like Gecko) Silk/122.3.1 like Chrome/122.0.6261.160 Safari/537.36
os:
name: Fire OS
short_name: FIR
version: "8"
platform: ""
family: Android
headers:
Sec-CH-UA-Platform: Android

0 comments on commit 97f3c8e

Please sign in to comment.