This task can be performed using UAParser.js
Abstracts Away the Hassle of User-Agent Detection
Best product for this task

UAParser.js
oss
UAParser.js simplifies user-agent detection by providing a structured approach, offering a clean alternative to the unstructured mess of real-world user-agent strings.
JavaScriptUser-AgentClient HintsWeb DevelopmentAnalyticsBrowser DetectionDevice DetectionOS DetectionOpen Source

What to expect from an ideal product
- Breaks down messy user-agent strings into clean, readable pieces of device info
- Maps browser names, versions, and operating systems to standardized formats
- Handles edge cases and weird user-agent patterns without breaking
- Returns results as simple JavaScript objects for easy integration
- Updates regularly to stay current with new browsers and devices