Skip to content

Commit 3ef325a

Browse files
vianaswmatticbot
authored andcommitted
Forms: Add browser info to form responses detail view (#45674)
* Add get_browser_display_name method The method returns a browser pretty named parsed from the user agent string or the string 'other' in case it's an unknown browser to us. * changelog * Add browser name and platform to form responses I've added the browser name and platform to the detail view of the form responses. * Add Other as display name catch all * Move Browser info from div to table * Fix composer lock issue * changelog * Fix static analysis issue * Fix unit tests * Update phan baseline * Return `Unknown browser` translated string... ...when we don't know the specific browser. Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/18952224061 Upstream-Ref: Automattic/jetpack@758e77e
1 parent 2d6f224 commit 3ef325a

5 files changed

Lines changed: 40 additions & 11 deletions

File tree

composer.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/automattic/jetpack-device-detection/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
This is an alpha version! The changes listed here are not final.
1111

12+
### Added
13+
- Device detection: added a method that returns the browser display name.
14+
1215
### Changed
1316
- Device detection: update bot detection list to include new AI and LLM crawler oriented bots.
1417

vendor/automattic/jetpack-device-detection/src/class-user-agent-info.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@ class User_Agent_Info {
9595
const BROWSER_SILK = 'silk';
9696
const OTHER = 'other';
9797

98+
const BROWSER_DISPLAY_NAME_MAP = array(
99+
self::BROWSER_CHROME => 'Chrome',
100+
self::BROWSER_FIREFOX => 'Firefox',
101+
self::BROWSER_SAFARI => 'Safari',
102+
self::BROWSER_EDGE => 'Edge',
103+
self::BROWSER_OPERA => 'Opera',
104+
self::BROWSER_IE => 'Internet Explorer',
105+
self::BROWSER_SAMSUNG => 'Samsung Browser',
106+
self::BROWSER_UC => 'UC Browser',
107+
self::BROWSER_YANDEX => 'Yandex Browser',
108+
self::BROWSER_VIVALDI => 'Vivaldi',
109+
self::BROWSER_MIUI => 'MIUI Browser',
110+
self::BROWSER_SILK => 'Amazon Silk',
111+
self::OTHER => 'Other',
112+
);
113+
98114
/**
99115
* A list of dumb-phone user agent parts.
100116
*
@@ -362,6 +378,16 @@ public function get_browser() {
362378
return self::OTHER;
363379
}
364380

381+
/**
382+
* Get the display name of the browser.
383+
*
384+
* @return string
385+
*/
386+
public function get_browser_display_name() {
387+
$browser = $this->get_browser();
388+
return self::BROWSER_DISPLAY_NAME_MAP[ $browser ] ?? $browser;
389+
}
390+
365391
/**
366392
* This method detects for UA which can display iPhone-optimized web content.
367393
* Includes iPhone, iPod Touch, Android, WebOS, Fennec (Firefox mobile), etc.

vendor/composer/installed.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"packages": [
33
{
44
"name": "automattic/jetpack-device-detection",
5-
"version": "3.3.0-alpha.1761816539",
6-
"version_normalized": "3.3.0.0-alpha1761816539",
5+
"version": "3.3.0-alpha.1761851286",
6+
"version_normalized": "3.3.0.0-alpha1761851286",
77
"dist": {
88
"type": "path",
99
"url": "/tmp/jetpack-build/Automattic/jetpack-device-detection",
10-
"reference": "c4f5eb315b8b4d956bf7b3ee388e4e5a6b2d2766"
10+
"reference": "ce6219932c8bf1132842a842d059cefcdb969d29"
1111
},
1212
"require": {
1313
"php": ">=7.2"

vendor/composer/installed.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
),
1212
'versions' => array(
1313
'automattic/jetpack-device-detection' => array(
14-
'pretty_version' => '3.3.0-alpha.1761816539',
15-
'version' => '3.3.0.0-alpha1761816539',
16-
'reference' => 'c4f5eb315b8b4d956bf7b3ee388e4e5a6b2d2766',
14+
'pretty_version' => '3.3.0-alpha.1761851286',
15+
'version' => '3.3.0.0-alpha1761851286',
16+
'reference' => 'ce6219932c8bf1132842a842d059cefcdb969d29',
1717
'type' => 'jetpack-library',
1818
'install_path' => __DIR__ . '/../automattic/jetpack-device-detection',
1919
'aliases' => array(),

0 commit comments

Comments
 (0)