Closed summercms closed 2 years ago
I don't think we should classify WebPageTest as an application on its own. WebPageTest uses actual browsers on actual devices to load a webpage and measure loading speed. So the browser in the UA string is the browser that is being used.
Therefore change family
into using
Old:
headers: 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36 PTST 200730.21064'
readable: 'WebPageTest 200730.21064 on Linux'
result: { browser: { name: WebPageTest, family: { name: Chrome, version: 84 }, version: '200730.21064', type: app }, engine: { name: Blink }, os: { name: Linux }, device: { type: desktop } }
Into:
headers: 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36 PTST 200730.21064'
readable: 'WebPageTest 200730.21064 on Linux'
result: { browser: { name: WebPageTest, using: { name: Chrome, version: 84 }, version: '200730.21064', type: app }, engine: { name: Blink }, os: { name: Linux }, device: { type: desktop } }
Code to be moved in php section as well.
/* WebPageTest */
if (preg_match('/\sPTST(\s|\/)([0-9.]+)/u', $ua, $match)) {
$this->data->browser->name = 'WebPageTest';
$this->data->browser->version = new Version([ 'value' => $match[2], 'details' => 2 ]);
$this->data->browser->type = Constants\BrowserType::APP;
if ((isset($this->data->browser->family->name)) && (isset($this->data->browser->family->version))) {
$this->data->browser->using = $this->data->browser->family;
}
if (isset($this->data->browser->family)) {
$this->data->browser->family = null;
}
$this->data->device->reset();
$this->data->device->type = Constants\DeviceType::DESKTOP;
}
Cleaned version: https://github.com/summercms/sc-parser-module/pull/179/files
See github issue: https://github.com/WhichBrowser/Parser-PHP/issues/555