factored out UA detection to use in context processor