Skip to content

A simple, comprehensive Elixir package for parsing user agent strings with the help of BrowserScope's UA database

Notifications You must be signed in to change notification settings

romul/uap-elixir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UserAgentParser

UserAgentParser is a simple Elixir package for parsing user agent strings. It uses BrowserScope's parsing patterns.

Installation

  1. Add user_agent_parser to your list of dependencies in mix.exs:

    def deps do [{:user_agent_parser, "~> 1.0"}] end

  2. Ensure user_agent_parser is started before your application:

    def application do [applications: [:user_agent_parser]] end

  3. Add worker(UA.Parser, []), to your supervisor tree

Usage example

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"}}

About

A simple, comprehensive Elixir package for parsing user agent strings with the help of BrowserScope's UA database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages