feat: enhance getPlatform to detect additional Chromium browsers#39705
feat: enhance getPlatform to detect additional Chromium browsers#39705DDDDDanica merged 20 commits intomainfrom
Conversation
Add individual platform detection for Vivaldi, Yandex, Samsung Internet, Whale, Puffin, Silk, UCBrowser, Maxthon, Cốc Cốc, QQ Browser, and Chromium. Unknown browsers now return PLATFORM_OTHER instead of defaulting to Chrome. Co-authored-by: Cursor <cursoragent@cursor.com>
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
| if (getPlatform() !== PLATFORM_CHROME && getPlatform() !== PLATFORM_FIREFOX) { | ||
| const platform = getPlatform(); | ||
|
|
||
| if (platform !== PLATFORM_CHROME && platform !== PLATFORM_FIREFOX) { |
There was a problem hiding this comment.
It seems it was intentional here to send the ping message to other extensions only for PLATFORM_CHROME (which we were defaulting to) and PLATFORM_FIREFOX browsers, but not for PLATFORM_OPERA, PLATFORM_BRAVE or PLATFORM_EDGE.
I don't have the context on why it was like this, but I wanted to highlight it here just in case someone has more context, and also because the behavior will change for browsers that were previously defaulting to PLATFORM_CHROME and that will now fall into one of these buckets:
PLATFORM_CHROMIUMPLATFORM_COCCOCPLATFORM_MAXTHONPLATFORM_OTHERPLATFORM_PUFFINPLATFORM_QQBROWSERPLATFORM_SAMSUNGPLATFORM_SILKPLATFORM_UCBROWSERPLATFORM_VIVALDIPLATFORM_WHALEPLATFORM_YANDEX
There was a problem hiding this comment.
I don't think there is any reason to skip the check on other browsers
There was a problem hiding this comment.
Ok, it's now updated in this commit: 8268fba
Builds ready [eb5db0b]
UI Startup Metrics (1332 ± 116 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [0a7bc3a]
UI Startup Metrics (1320 ± 104 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [073ecb3]
UI Startup Metrics (1366 ± 93 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Update the PLATFORM object to include all new platform constants so the Platform type includes them for type safety. Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [ef69433]
UI Startup Metrics (1386 ± 104 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Add waitFor to ensure async localforage cache updates complete before asserting cache keys, fixing race condition in CI. Co-authored-by: Cursor <cursoragent@cursor.com>
Mock getPlatform() to return PLATFORM_CHROME in the _buildUserTraitsObject tests to ensure consistent behavior across test environments. Co-authored-by: Cursor <cursoragent@cursor.com>
…rands - Add BRAND_TO_PLATFORM_MAP for browsers detectable via userAgentData.brands - Split getPlatform into getPlatformFromUserAgent and getPlatformFromBrands - UA string detection takes priority; brands used as fallback - Enables detection of Lemur, Mises, Brave that hide identity in UA string - Consolidate browser UA tests using parameterized it.each Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [f31f0a3]
UI Startup Metrics (1508 ± 109 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
I tested browsers listed in the PR. Given that many have different ways to define the user agent and Firefox Chrome Brave Edge Opera Coc Coc Maxthon UC Vivaldi Whale Yandex EdgeAndroid Kiwi Lemur Mises Samsung Internet |
|
As @davidmurdoch recommended on Slack, I started looking at this new experimental API, i.e. For that reason, I started using a hybrid browser detection approach in commit 1feaaa5, using both user agent and
This new experimental API also allows us to know if the user is on mobile or not, which we could add to Segment user traits, but I'd rather do that in a different PR. |
- Add 'Google Chrome' to BRAND_TO_PLATFORM_MAP for correct Chrome detection - Filter out noise brands (Chromium, GREASE brands) case-insensitively - Return unknown meaningful brands for analytics discovery - Alphabetize BRAND_TO_PLATFORM_MAP keys for consistency Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [496644f]
UI Startup Metrics (1429 ± 108 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
- Group Brave/Lemur/Mises tests using parameterized it.each - Fix test title to reflect Google Chrome is now a known brand - Rename FutureBrowser to DiscoveredBrowser for clarity Co-authored-by: Cursor <cursoragent@cursor.com>
|
LGTM ! |
Description
This PR achieves the following:
Changelog
CHANGELOG entry: null
Related issues
NA
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Changes browser/platform detection used by analytics and conditional runtime behavior, so mis-detections could affect event tagging and platform-specific logic across the extension.
Overview
getPlatformis expanded from a small set of browsers to a hybrid detector that distinguishes many Chromium-based browsers (e.g., Vivaldi, Yandex, Samsung Internet, Whale, Puffin, Silk, UC Browser, Maxthon, Cốc Cốc, QQ Browser, Chromium, and Edge Android) and returnsPLATFORM_OTHERfor unknown user agents instead of defaulting to Chrome.Detection now prefers explicit User-Agent signatures and falls back to
navigator.userAgentData.brands(with noise filtering) to identify browsers that mask themselves as Chrome, returning unmapped meaningful brands for analytics discovery. Multiple-instance detection is adjusted to ping Firefox IDs only on Firefox and otherwise always use Chrome Web Store IDs, and tests are updated/added to cover the new platform constants and detection behavior (including stabilizing MetaMetrics platform trait tests by mockinggetPlatform).Written by Cursor Bugbot for commit a003612. This will update automatically on new commits. Configure here.