I couldn’t understand what is the context of Browser until I read the first usage example with the line “Mozilla/5.0…”. I immediately understood that this is a user-agent parsing library.
I would prefer user-agent which is a well understood term.
I know there's a PHP package of the same name. I wouldn't be surprised if there were other packages of the same name and maybe it's just a namesake that continues.
Just a note, this was a bit difficult to read with the amount of times you repeat the phrase “ browser, device, platform, or bot that was making a request to the application”
Not ideal. It is very slow. It takes 8 seconds for 3400 strings. That might be fine for occasional offline usage, but not for frequent usage, and certainly not for use in the backend (although I agree it should not be used there). I guess it matches all regexps against each string.
It also misses some really common user agents, basically all iOS 11 and 12. They may be rare nowadays, but they still occur.
If I had any nit to make, it's about browser.NewBrowser. It stutters, and even with just New(), at first I thought it was making a client. Not sure what I'd go with, maybe Parse like net/url?
Again, just a minor nit, not trying to take away what you've done here at all.
It lists Sputnik as one of the supported browsers but it's a dead project once developed by the Russian government, and now it seems to be abandoned (last updates in 2021). I'd just delete any mentions of it.
please stop doing stuff like this. its trivial to change the user-agent when making a request with a programming language, so any logic surrounding that should be non existent, or as simple as possible.
the user-agent string has an essentially arbitrary format, so its not really a good place to be reading data from, or worse serving a different response based on the value.
It's a (minor) necessary evil that gives useful information. Almost no-one spoofs their user agent. I use this to pin down problems on the user side. Our users have all kinds of weird devices (e.g. browsing with a PlayStation) and it can be hard to find where things go wrong. There was a case where we lost more users than usual, and it turned out to be something very subtle related to tab switching in Safari. Without the user agent, we would never have found out.
If you have a website, you want to collect statistical data on which browsers are accessing your website and test for the best experiences on the top browsers.
thangngoc89|1 year ago
I would prefer user-agent which is a well understood term.
jjice|1 year ago
dlopes7|1 year ago
dineshgowda24|1 year ago
floobertoober|1 year ago
fastest963|1 year ago
tgv|1 year ago
It also misses some really common user agents, basically all iOS 11 and 12. They may be rare nowadays, but they still occur.
mpcjanssen|1 year ago
silisili|1 year ago
If I had any nit to make, it's about browser.NewBrowser. It stutters, and even with just New(), at first I thought it was making a client. Not sure what I'd go with, maybe Parse like net/url?
Again, just a minor nit, not trying to take away what you've done here at all.
kevindamm|1 year ago
dineshgowda24|1 year ago
kgeist|1 year ago
llmblockchain|1 year ago
The correct name would be "useragent".
unknown|1 year ago
[deleted]
38|1 year ago
the user-agent string has an essentially arbitrary format, so its not really a good place to be reading data from, or worse serving a different response based on the value.
tgv|1 year ago
zuck_vs_musk|1 year ago
If you have a website, you want to collect statistical data on which browsers are accessing your website and test for the best experiences on the top browsers.
dblohm7|1 year ago
Agreed. Feature detection is the way, not UA sniffing.
MOARDONGZPLZ|1 year ago
cebert|1 year ago
richbell|1 year ago