Movatterモバイル変換


[0]ホーム

URL:


shiny.telemetryshiny.telemetry logo

Easy logging of users activity and session events of your ShinyApp

CRANR CMD checkdownloads monthlydownloads totalLicense: LGPL-3.0

Theshiny.telemetry R package tracks events occurring ona user session, such as input changes and session duration, and storesthem in a local or remote database.

It provides developers with the tools to help understand how usersinteract with Shiny dashboards and answer questions such as: whichtabs/pages are more often visited, which inputs users are changing, whatis the average length of a session, etc.

Install

Theshiny.telemetry package can be installed from GitHubby using the remotes package:

remotes::install_github("Appsilon/shiny.telemetry",dependencies =TRUE)

Withdependencies = TRUE the suggested packages(required to run some examples) will be installed in addition tomandatory dependencies.

How to use in a ShinyDashboard?

shiny.telemetry allows for a minimal setup with only 3commands that can track some information about the session:

The code below runs a minimal example of a Shiny application thatusesshiny.telemetry. The package will keep track of thesession information and all changes to thenumericInput.

Note: When using the dashboard nothing is happening from theuser’s perspective as all operation run in the background(either inthe server or in Javascript).

library(shiny)library(shiny.telemetry)telemetry<- Telemetry$new()# 1. Initialize telemetry with default optionsshinyApp(ui =fluidPage(use_telemetry(),# 2. Add necessary javascript to ShinynumericInput("n","n",1),plotOutput('plot')  ),server =function(input, output) {    telemetry$start_session()# 3. Minimal setup to track events    output$plot<-renderPlot({hist(runif(input$n)) })  })

When inspecting the code above, we can breakdown the 3 lines of codeby:

  1. GlobalTelemetry object that is used across thedifferent sessions
  2. Add necessary Javascript to the UI by callinguse_telemetry(). It is used to track browser version.
  3. Initialize the session-specific tracking by calling methodstart_session() of theTelemetry object.

How to access the data?

The developers and administrators of the dashboard can access thedata that is gathered byshiny.telemetry via a Telemetryobject or directly fromDataStorage via the appropriateprovider.

# After running the instrumented appshiny.telemetry::Telemetry$new()$data_storage$read_event_data("2020-01-01","2050-01-01")# Default provider and path for Telemetry$new()shiny.telemetry::DataStorageSQLite$new(db_path ="telemetry.sqlite")$read_event_data("2020-01-01","2050-01-01")

The package includes an analytics dashboard to view the data. It islocated atinst/examples/app/analytics and it should bemodified so that it references the correctDataStorageprovider and configuration.

Data providers

There are 3 different types of data providers that can range fromlocal filesystem storage to a remote Plumber REST API instance.

The setup for plumber requires a valid Plumber instance running onthe network and the communication can be protected. See Plumberdeployment documentation for more information.

Debugging the Telemetrycalls

The package uses thelogger package internally with theshiny.telemetry namespace. To debug theshiny.telemetry calls in the dashboard, change thethreshold of this namespace toDEBUG:

logger::log_threshold("DEBUG",namespace ="shiny.telemetry")

note: This command can be run before the Shiny call or byadding it to the.Rprofile.

Contributing

SeeCONTRIBUTING.

Appsilon

Appsilon is aPosit (formerly RStudio) Full Service CertifiedPartner.
Learn more atappsilon.com.

Get in touchopensource@appsilon.com

Explore theRhinoverse - a family ofR packages built aroundRhino!

We are hiring!


[8]ページ先頭

©2009-2025 Movatter.jp