dwyl / dwyl/atm

Parse User Agent String Into Relevant Parts (Device, OS, Version)

Open
#27 2 comments 0 reactions 1 assignee Claimed by @nelsonic View on GitHub
enhancement help wanted priority-1 T1h technical
Dominant language
Elixir
Stars
14
Forks
0
Avg merge
16h 28m
Merged PRs (30d)
6

Description

In order to provide valuable insights, we need to split our `user_agent.string`
into the relevant parts so that we can determine, Operating System, Device and version.
This looks promising: https://github.com/elixir-inspector/ua_inspector
(_based on https://github.com/matomo-org/device-detector ..._)

```elixir
iex(1)> UAInspector.parse("Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53")
%UAInspector.Result{
client: %UAInspector.Result.Client{
engine: "WebKit",
engine_version: "537.51.11",
name: "Mobile Safari",
type: "browser",
version: "7.0"
},
device: %UAInspector.Result.Device{
brand: "Apple",
model: "iPad",
type: "tablet"
},
os: %UAInspector.Result.OS{
name: "iOS",
platform: :unknown,
version: "7.0.4"
},
user_agent: "Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53"
}

iex(2)> UAInspector.parse("Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Safari/537.36")
%UAInspector.Result.Bot{
category: "Search bot",
name: "Googlebot",
producer: %UAInspector.Result.BotProducer{
name: "Google Inc.",
url: "http://www.google.com"
},
url: "http://www.google.com/bot.html",
user_agent: "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Safari/537.36"
}
```

# Todo

+ [ ] Borrow from: https://github.com/dwyl/auth/blob/83c286a24d47bd087ba41925a740d4030cf95e19/lib/auth/user_agent.ex
and extend the `user_agents` schema to include all the fields extracted by `UAInspector`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.