Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Easy logging of users activity and session events of your Shiny App

NotificationsYou must be signed in to change notification settings

Appsilon/shiny.telemetry

Easy logging of users activity and session events of your Shiny App

CRANR CMD checkdownloads monthlydownloads totalLicense: LGPL-3.0

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

It provides developers with the tools to help understand how users interact with Shiny dashboardsand answer questions such as: which tabs/pages are more often visited,which inputs users are changing, what is the average length of a session, etc.

Install

Theshiny.telemetry package can be installed from GitHub by 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 to mandatory dependencies.

How to use in a Shiny Dashboard?

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

  • When session starts and ends
  • The browser version used by the client
  • Changes in the inputs(doesn't track values by default)

The code below runs a minimal example of a Shiny application that usesshiny.telemetry.The package will keep track of the session information and all changes to thenumericInput.

Note: When using the dashboard nothing is happening from the user's perspectiveas all operation run in the background(either in the 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 Shiny    numericInput("n","n",1),    plotOutput('plot')  ),server=function(input,output) {telemetry$start_session()# 3. Minimal setup to track eventsoutput$plot<- renderPlot({ hist(runif(input$n)) })  })

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

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

How to access the data?

The developers and administrators of the dashboard can access the data that is gathered byshiny.telemetry via a Telemetry object or directly fromDataStorage via the appropriate provider.

# 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 is located atinst/examples/app/analytics and it should be modifiedso that it references the correctDataStorage provider and configuration.

Data providers

There are 3 different types of data providersthat can range from local filesystem storage to a remote Plumber REST API instance.

  • Local file:
    • SQLite usingDataStorageSQLite class
    • Plain text file usingDataStorageLogFile class
  • Remote SQL database:
    • MariaDB usingDataStorageMariaDB class
    • PostgreSQL usingDataStoragePostgreSQL class
    • MS SQL Server usingDataStorageMSSQLServer class
  • Plumber REST API usingDataStoragePlumber class
    • In turn, the Plumber data provider will use one of the other classes aboveas the method of data storage.

The setup for plumber requires a valid Plumber instance running on the networkand the communication can be protected.See Plumber deployment documentation for more information.

Debugging the Telemetry calls

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

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

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

Contributing

SeeCONTRIBUTING.

Appsilon

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

Get in touchopensource@appsilon.com

Explore theRhinoverse - a family of R packages built aroundRhino!

We are hiring!

About

Easy logging of users activity and session events of your Shiny App

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors16

Languages


[8]ページ先頭

©2009-2025 Movatter.jp