Refactor browser info collection to use User-Agent Client Hints API#21
Open
Refactor browser info collection to use User-Agent Client Hints API#21
Conversation
- Replace hardcoded browser info with navigator.userAgentData API to get real brand, full version (e.g. 122.0.6261.112), OS platform and version - Remove deprecated navigator.platform and raw userAgent dump - Add screen resolution, browser language, timezone and cookies to session data - Make getSystemInfo() async to support high-entropy API values - Update background.js to await getSystemInfo() and use brand for filenames - Update HTML report to display all 8 new fields with backwards compatibility for sessions stored with the old format (browser/browserVersion fields) - Update jest mocks and browserInfo.test.js to match new async API https://claude.ai/code/session_013y1QH2gkj8wg427JpzjdJe
The background.js service worker does not have access to the window screen object. Accessing screen.width threw a ReferenceError which silently prevented startSession() from completing and blocked all annotation saves. Added typeof screen !== 'undefined' guard so screenResolution falls back to 'N/A' when running in service worker context. https://claude.ai/code/session_013y1QH2gkj8wg427JpzjdJe
- Fix getFullSession handler to pass BrowserInfo directly instead of mapping to old format (this was causing all new fields to be lost) - Fix brand detection: match real browser by comparing major version against Chromium's version, avoiding randomized fake brand names - Remove screenResolution, language, timezone and cookies from getSystemInfo() — these cannot be obtained reliably from service worker - Update reportUI.js to display only: start date, browser, version, OS - Remove unnecessary screen/Intl mocks from jest.setup.js https://claude.ai/code/session_013y1QH2gkj8wg427JpzjdJe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR modernizes the browser and system information collection by migrating from deprecated APIs to the User-Agent Client Hints API (
navigator.userAgentData). The function is now async to support the asynchronousgetHighEntropyValues()method, and collects significantly more detailed system information.Key Changes
getSystemInfo()is now async to support the User-Agent Client Hints API's asynchronous high entropy values retrievaluserAgentData.fullVersionList)userAgentData.platformVersion)chrome.runtime.getManifest()userAgentData.brandsuserAgentData,screen, andIntlmocksbrowserand newbrandpropertiesImplementation Details
fullVersionListorbrandsarrayhttps://claude.ai/code/session_013y1QH2gkj8wg427JpzjdJe