Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task
nelsonic opened this issue May 20, 2020 · 2 comments
Open
1 task

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

nelsonic opened this issue May 20, 2020 · 2 comments
Assignees
Labels
enhancement help wanted priority-1 T1h Time Estimate 1 Hour technical A technical issue that requires understanding of the code, infrastructure or dependencies

Comments

@nelsonic
Copy link
Member

nelsonic commented May 20, 2020

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 ...)

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

@nelsonic nelsonic added help wanted priority-1 T1h Time Estimate 1 Hour technical A technical issue that requires understanding of the code, infrastructure or dependencies labels Jul 7, 2023
@nelsonic nelsonic moved this to 🔖 Ready for Development in dwyl app kanban Jul 9, 2023
@nelsonic nelsonic self-assigned this Jul 9, 2023
@nelsonic nelsonic moved this from 🔖 Ready for Development to 🏗 In progress in dwyl app kanban Jul 10, 2023
@nelsonic
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted priority-1 T1h Time Estimate 1 Hour technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
Status: 🏗 In progress
Development

No branches or pull requests

1 participant