1.0.1 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform
Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.
MIT - MIT LicenseUserAgentParser is a simple Elixir package for parsing user agent strings. It uses BrowserScope's parsing patterns.
Add user_agent_parser to your list of dependencies in mix.exs
:
def deps do [{:user_agent_parser, "~> 1.0"}] end
Ensure user_agent_parser is started before your application:
def application do [applications: [:user_agent_parser]] end
Add worker(UA.Parser, []),
to your supervisor tree
iex(1)> user_agent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; Microsoft; Lumia 640 XL)"
iex(2)> UserAgentParser.detect_browser(user_agent)
%UA.Browser{family: "IE Mobile", version: "10.0"}
iex(2)> UserAgentParser.detect_os(user_agent)
%UA.OS{family: "Windows Phone", version: "8.0"}
iex(3)> UserAgentParser.detect_device(user_agent)
%UA.Device{brand: "Microsoft", model: "Lumia 640 XL", name: "Microsoft Lumia 640 XL"}
iex(4)> UserAgentParser.parse(user_agent)
{%UA.Browser{family: "IE Mobile", version: "10.0"},
%UA.OS{family: "Windows Phone", version: "8.0"},
%UA.Device{brand: "Microsoft", model: "Lumia 640 XL",
name: "Microsoft Lumia 640 XL"}}