Title: | Find Out Information About a User's Web Browser in 'Shiny' |
---|---|
Description: | Sometimes it's useful to know some information about your user in a 'Shiny' app. The available information is: browser name (such as 'Chrome' or 'Safari') and version, device type (mobile or desktop), operating system (such as 'Windows' or 'Mac' or 'Android') and version, and browser dimensions. |
Authors: | Dean Attali [aut, cre] |
Maintainer: | Dean Attali <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0.9001 |
Built: | 2025-02-14 03:10:11 UTC |
Source: | https://github.com/daattali/shinybrowser |
This function must be called somewhere in a Shiny app's UI in order to use any other {shinybrowser} functions.
detect()
detect()
HTML dependencies that are required to use shinybrowser.
It's important to understand there is no reliable way to detect the
information in {shinybrowser} with 100% accuracy.
{shinybrowser} makes
a best effort at identifying the most accurate information, but some
browser/operating system combinations may be difficult to identify. Users
can also use a variety of tools to deliberately spoof this information.
With that in mind, {shinybrowser} should detect the correct information in
most cases.
Only major browsers and operating systems are supported, which means that the
RStudio Viewer may result in an "UNKNOWN" browser, and unpopular operating systems
may also result in "UNKNOWN".
For a list of values that can be detected, see SUPPORTED_BROWSERS,
SUPPORTED_DEVICES, and SUPPORTED_OPERATING_SYSTEMS.
{shinybrowser} attempts to detect whether a device is "mobile" or "desktop".
The distinction between mobile and desktop is not always clear, so if what you
actually care about is the size of the device, it might be better to use
get_width()
.
Tablets return ambiguous results; some tablets self-report as mobile devices while
others as desktop.
The width and height of the browser window are only reported once, when the detect()
function is initially called.
If the user resizes the browser window, the new dimensions are not reported until
the page is refreshed.
get_all_info()
, get_browser()
, get_os()
, get_device()
, get_width()
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your browser information:", verbatimTextOutput("browser_info") ) server <- function(input, output, session) { output$browser_info <- renderPrint({ shinybrowser::get_all_info() }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your browser information:", verbatimTextOutput("browser_info") ) server <- function(input, output, session) { output$browser_info <- renderPrint({ shinybrowser::get_all_info() }) } shinyApp(ui, server) }
Get a list with all the information detected about the user's browser.
The list is reactive, therefore it must be accessed inside a reactive context
(such as an observe or reactive).
{shinybrowser} must be initialized with a call to detect()
in the app's ui.
get_all_info()
get_all_info()
List with all information detected about the user's browser: device
, browser
,
os
, dimensions
, user_agent
It's important to understand there is no reliable way to detect the
information in {shinybrowser} with 100% accuracy.
{shinybrowser} makes
a best effort at identifying the most accurate information, but some
browser/operating system combinations may be difficult to identify. Users
can also use a variety of tools to deliberately spoof this information.
With that in mind, {shinybrowser} should detect the correct information in
most cases.
Only major browsers and operating systems are supported, which means that the
RStudio Viewer may result in an "UNKNOWN" browser, and unpopular operating systems
may also result in "UNKNOWN".
For a list of values that can be detected, see SUPPORTED_BROWSERS,
SUPPORTED_DEVICES, and SUPPORTED_OPERATING_SYSTEMS.
{shinybrowser} attempts to detect whether a device is "mobile" or "desktop".
The distinction between mobile and desktop is not always clear, so if what you
actually care about is the size of the device, it might be better to use
get_width()
.
Tablets return ambiguous results; some tablets self-report as mobile devices while
others as desktop.
The width and height of the browser window are only reported once, when the detect()
function is initially called.
If the user resizes the browser window, the new dimensions are not reported until
the page is refreshed.
detect()
, get_browser()
, get_browser_version()
, get_os()
, get_os_version()
,
get_device()
, get_width()
, get_height()
, get_user_agent()
,
SUPPORTED_BROWSERS, SUPPORTED_DEVICES, SUPPORTED_OPERATING_SYSTEMS
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your browser information:", verbatimTextOutput("browser_info") ) server <- function(input, output, session) { output$browser_info <- renderPrint({ shinybrowser::get_all_info() }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your browser information:", verbatimTextOutput("browser_info") ) server <- function(input, output, session) { output$browser_info <- renderPrint({ shinybrowser::get_all_info() }) } shinyApp(ui, server) }
Get the user's browser name (such as "Chrome" or "Firefox") and version.
The value is reactive, therefore it must be accessed inside a reactive context
(such as an observe or reactive).
{shinybrowser} must be initialized with a call to detect()
in the app's ui.
get_browser() get_browser_version()
get_browser() get_browser_version()
User's detected browser type
User's detected browser version
It's important to understand there is no reliable way to detect the
information in {shinybrowser} with 100% accuracy.
{shinybrowser} makes
a best effort at identifying the most accurate information, but some
browser/operating system combinations may be difficult to identify. Users
can also use a variety of tools to deliberately spoof this information.
With that in mind, {shinybrowser} should detect the correct information in
most cases.
Only major browsers and operating systems are supported, which means that the
RStudio Viewer may result in an "UNKNOWN" browser, and unpopular operating systems
may also result in "UNKNOWN".
For a list of values that can be detected, see SUPPORTED_BROWSERS,
SUPPORTED_DEVICES, and SUPPORTED_OPERATING_SYSTEMS.
detect()
, get_all_info()
, is_browser_ie()
,
is_browser_chrome()
, is_browser_firefox()
, SUPPORTED_BROWSERS
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your browser:", textOutput("browser_info") ) server <- function(input, output, session) { output$browser_info <- renderText({ paste(shinybrowser::get_browser(), "version", shinybrowser::get_browser_version()) }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your browser:", textOutput("browser_info") ) server <- function(input, output, session) { output$browser_info <- renderText({ paste(shinybrowser::get_browser(), "version", shinybrowser::get_browser_version()) }) } shinyApp(ui, server) }
The value is reactive, therefore it must be accessed inside a reactive context
(such as an observe or reactive).
{shinybrowser} must be initialized with a call to detect()
in the app's ui.
get_device()
get_device()
User's detected decive type ("Mobile" or "Desktop")
It's important to understand there is no reliable way to detect the
information in {shinybrowser} with 100% accuracy.
{shinybrowser} makes
a best effort at identifying the most accurate information, but some
browser/operating system combinations may be difficult to identify. Users
can also use a variety of tools to deliberately spoof this information.
With that in mind, {shinybrowser} should detect the correct information in
most cases.
{shinybrowser} attempts to detect whether a device is "mobile" or "desktop".
The distinction between mobile and desktop is not always clear, so if what you
actually care about is the size of the device, it might be better to use
get_width()
.
Tablets return ambiguous results; some tablets self-report as mobile devices while
others as desktop.
detect()
, get_all_info()
, is_device_mobile()
, is_device_desktop()
,
get_width()
, get_height()
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your device:", textOutput("device_info") ) server <- function(input, output, session) { output$device_info <- renderText({ shinybrowser::get_device() }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your device:", textOutput("device_info") ) server <- function(input, output, session) { output$device_info <- renderText({ shinybrowser::get_device() }) } shinyApp(ui, server) }
Get the user's operating system (such as "Windows" or "Mac" or "Android") and version
(such as "10" for Windows or "OS X" for Mac).
The value is reactive, therefore it must be accessed inside a reactive context
(such as an observe or reactive).
{shinybrowser} must be initialized with a call to detect()
in the app's ui.
get_os() get_os_version()
get_os() get_os_version()
User's detected operating system
User's detected operating system version
It's important to understand there is no reliable way to detect the
information in {shinybrowser} with 100% accuracy.
{shinybrowser} makes
a best effort at identifying the most accurate information, but some
browser/operating system combinations may be difficult to identify. Users
can also use a variety of tools to deliberately spoof this information.
With that in mind, {shinybrowser} should detect the correct information in
most cases.
Only major browsers and operating systems are supported, which means that the
RStudio Viewer may result in an "UNKNOWN" browser, and unpopular operating systems
may also result in "UNKNOWN".
For a list of values that can be detected, see SUPPORTED_BROWSERS,
SUPPORTED_DEVICES, and SUPPORTED_OPERATING_SYSTEMS.
detect()
, get_all_info()
, is_os_windows()
,
is_os_mac()
, SUPPORTED_OPERATING_SYSTEMS
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your operating system:", textOutput("os_info") ) server <- function(input, output, session) { output$os_info <- renderText({ paste(shinybrowser::get_os(), "version", shinybrowser::get_os_version()) }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your operating system:", textOutput("os_info") ) server <- function(input, output, session) { output$os_info <- renderText({ paste(shinybrowser::get_os(), "version", shinybrowser::get_os_version()) }) } shinyApp(ui, server) }
This function exposes the user agent that is reported by the browser, but it
should only be used for troubleshooting purposes.
The value is reactive, therefore it must be accessed inside a reactive context
(such as an observe or reactive).
{shinybrowser} must be initialized with a call to detect()
in the app's ui.
get_user_agent()
get_user_agent()
User's user-agent string
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your user agent:", textOutput("ua_info") ) server <- function(input, output, session) { output$ua_info <- renderText({ shinybrowser::get_user_agent() }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your user agent:", textOutput("ua_info") ) server <- function(input, output, session) { output$ua_info <- renderText({ shinybrowser::get_user_agent() }) } shinyApp(ui, server) }
The value is reactive, therefore it must be accessed inside a reactive context
(such as an observe or reactive).
{shinybrowser} must be initialized with a call to detect()
in the app's ui.
get_width() get_height()
get_width() get_height()
User's detected browser width in pixels
User's detected browser height in pixels
The width and height of the browser window are only reported once, when the detect()
function is initially called.
If the user resizes the browser window, the new dimensions are not reported until
the page is refreshed.
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your browser dimensions:", textOutput("browser_dim") ) server <- function(input, output, session) { output$browser_dim <- renderText({ paste0(shinybrowser::get_width(), "x", shinybrowser::get_height()) }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Your browser dimensions:", textOutput("browser_dim") ) server <- function(input, output, session) { output$browser_dim <- renderText({ paste0(shinybrowser::get_width(), "x", shinybrowser::get_height()) }) } shinyApp(ui, server) }
Convenience function that checks if the user's browser is detected as Chrome.
See get_browser()
for details.
is_browser_chrome()
is_browser_chrome()
Whether or not this user using Chrome
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you using Chrome?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_browser_chrome() }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you using Chrome?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_browser_chrome() }) } shinyApp(ui, server) }
Convenience function that checks if the user's browser is detected as Firefox.
See get_browser()
for details.
is_browser_firefox()
is_browser_firefox()
Whether or not this user using Firefox
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you using Firefox?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_browser_firefox() }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you using Firefox?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_browser_firefox() }) } shinyApp(ui, server) }
Convenience function that checks if the user's browser is detected as Internet Explorer.
See get_browser()
for details.
is_browser_ie()
is_browser_ie()
Whether or not this user using Internet Explorer
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you using Internet Explorer?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_browser_ie() }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you using Internet Explorer?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_browser_ie() }) } shinyApp(ui, server) }
Convenience function that checks if the user's device is detected as desktop.
See get_device()
for details.
is_device_desktop()
is_device_desktop()
Whether or not this user is on desktop
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you on desktop?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_device_desktop() }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you on desktop?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_device_desktop() }) } shinyApp(ui, server) }
Convenience function that checks if the user's device is detected as mobile.
See get_device()
for details.
is_device_mobile()
is_device_mobile()
Whether or not this user is on mobile
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you on mobile?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_device_mobile() }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you on mobile?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_device_mobile() }) } shinyApp(ui, server) }
Convenience function that checks if the user's operating system is detected as Mac.
See get_os()
for details.
is_os_mac()
is_os_mac()
Whether or not this user using MacOS
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you on Mac?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_os_mac() }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you on Mac?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_os_mac() }) } shinyApp(ui, server) }
Convenience function that checks if the user's operating system is detected as Windows.
See get_os()
for details.
is_os_windows()
is_os_windows()
Whether or not this user using Windows
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you on Windows?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_os_windows() }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( shinybrowser::detect(), "Are you on Windows?", textOutput("result") ) server <- function(input, output, session) { output$result <- renderText({ shinybrowser::is_os_windows() }) } shinyApp(ui, server) }
Browsers that can be detected with {shinybrowser}
Devices that can be detected with {shinybrowser}
Operating systems that can be detected with {shinybrowser}