dwyl / user_agent

😎 parse user agent strings and return flat data for web metrics.
GNU General Public License v2.0
1 stars 0 forks source link

Create Micro-package to Flatten/Format `user_agent` data for `ATM` #1

Open nelsonic opened 1 year ago

nelsonic commented 1 year ago

while reading the code: https://github.com/elixir-inspector/ua_inspector/blob/master/lib/ua_inspector.ex and tests: https://github.com/elixir-inspector/ua_inspector/blob/master/test/ua_inspector/database/init_test.exs

I decided to create a thin wrapper that flattens the user_agent data into the format that we need.

Spoiled for choice on package names:

https://hex.pm/packages/ua

image

https://hex.pm/packages/user_agent

image

Todo

P.S: Sponsoring https://github.com/mneudert for as long as we use the fine work he has done. #first

image

Just a way to say "thanks" for the code. 🙏

nelsonic commented 1 year ago

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent

mdn-advert-react-course

WTF!? 🤷‍♂️ 🤦‍♂️

frontend-masters-react

Don't want to see ads? Pay. Monthly! https://developer.mozilla.org/en-US/plus?ref=nope#subscribe

image
nelsonic commented 1 year ago

Sadly, getting the following:

UserAgent.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")
%{
  browser_family: :unknown,
  client: :unknown,
  device: :unknown,
  os: :unknown,
  os_family: :unknown,
  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"
}

I'd have thought this user_agent would be fairly straightforward to parse ... 💭

nelsonic commented 1 year ago

https://docs.rs/user-agent-parser/latest/user_agent_parser/ hmm ... 💭

nelsonic commented 1 year ago

Continue:

nelsonic commented 1 year ago

https://hexdocs.pm/ua_inspector/UAInspector.html https://hexdocs.pm/ua_inspector/UAInspector.Config.html https://hexdocs.pm/ua_inspector/UAInspector.Supervisor.html#summary

nelsonic commented 1 year ago

https://github.com/ikeikeikeike/common_device_detector/blob/master/lib/common_device_detector/download/database.ex