Coder Social home page Coder Social logo

appsilon / shiny.telemetry Goto Github PK

View Code? Open in Web Editor NEW
58.0 25.0 13.0 2.36 MB

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

Home Page: https://appsilon.github.io/shiny.telemetry/

R 99.49% CSS 0.51%
analytics r r-package shiny rhinoverse

shiny.telemetry's Introduction

shiny.telemetry shiny.telemetry logo

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

CRAN R CMD check downloads monthly downloads total License: LGPL-3.0

The shiny.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 dashboards and 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

The shiny.telemetry package can be installed from GitHub by using the remotes package:

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

With dependencies = 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 commands that 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 uses shiny.telemetry. The package will keep track of the session information and all changes to the numericInput.

Note: When using the dashboard nothing is happening from the user's perspective as 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 options

shinyApp(
  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 events
    output$plot <- renderPlot({ hist(runif(input$n)) })
  }
)

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

  1. Global Telemetry object that is used across the different sessions
  2. Add necessary Javascript to the UI by calling use_telemetry(). It is used to track browser version.
  3. Initialize the session-specific tracking by calling method start_session() of the Telemetry object.

How to access the data?

The developers and administrators of the dashboard can access the data that is gathered by shiny.telemetry via a Telemetry object or directly from DataStorage via the appropriate provider.

# After running the instrumented app
shiny.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 at inst/examples/app/analytics and it should be modified so that it references the correct DataStorage provider and configuration.

Data providers

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

  • Local file:
    • SQLite using DataStorageSQLite class
    • Logfile using DataStorageLogFile class
  • Remote SQL database:
    • MariaDB using DataStorageMariaDB class
    • PostgreSQL using DataStoragePostgreSQL class
    • MS SQL Server using DataStorageMSSQLServer class
  • Plumber REST API using DataStoragePlumber class
    • In turn, the Plumber data provider will use one of the other classes above as the method of data storage.

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

Debugging the Telemetry calls

The package uses the logger package internally with the shiny.telemetry namespace. To debug the shiny.telemetry calls in the dashboard, change the threshold of this namespace to DEBUG:

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

See CONTRIBUTING.

Appsilon

Appsilon is a Posit (formerly RStudio) Full Service Certified Partner.
Learn more at appsilon.com.

Get in touch [email protected]

Explore the Rhinoverse - a family of R packages built around Rhino!

We are hiring!

shiny.telemetry's People

Contributors

averissimo avatar capncodewash avatar jakubnowicki avatar kamilzyla avatar krystian8207 avatar marekrogala avatar mend-bolt-for-github[bot] avatar nbbn avatar przytu1 avatar renovate[bot] avatar tymekdev avatar vibalre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shiny.telemetry's Issues

Stats Panel dependencies

Dependencies for the analytics panels are all in Suggests (plotly, semantic.dashboard, ...)

Does it need to change and moved to Imports?

Input tracking improvement

Ideas:

  • track all inputs
  • add regex as inclusion/exclusion criteria for tracking
  • integrate namespace inclusion/exclusion criteria

Discussion

  • from a conversion in a PR that was not in the scope (see

I am really confused at first what is the purpose of matching_values, but I guess this will be useful in select inputs, e.g. when one of the option is "", then we only want to observe values inside matching_values. This makes me think if it is also worthwhile to have another argument, e.g. unmatch = FALSE, when users have a lot of select inputs, so they only list the one they do not want to match in matching_values and then log the rest of input values.

Prepare materials for release promotion

Goal

Bullet points or rough notes (will be edited by the Marketing Team) for a short announcement of a CRAN release (to be posted on Twitter / LinkedIn):

  1. What can the package do for you?
  2. Perhaps: a minimal example.
  3. How to learn more?

Inspiration

(Appsilon-internal) See some past bullet points for inspiration:

  1. Software engineering skills that Shiny Developers should know & how Rhino incorporates them
  2. Cypress vs shinytest2
  3. shiny.react & shiny.fluent feature overview

The end result can be a Twitter post like one of these:

  1. shiny.router 0.3.0
  2. Rhino 1.2

Track "dashboard name" and "version"

Needed if we plan a feature that tracks multiple dashboards in a central storage solution

For example, a client that has 4 dashboards and doesn't want 4 different analytics dashboards

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • chore(deps): update actions/cache action to v4
  • chore(deps): update actions/checkout action to v4
  • 🔐 Create all pending approval PRs at once 🔐

Detected dependencies

github-actions
.github/workflows/check_with_databases.yml
  • actions/checkout v3
  • r-lib/actions v2
  • r-lib/actions v2
  • r-lib/actions v2
.github/workflows/main.yml
  • actions/checkout v3
  • r-lib/actions v2
  • r-lib/actions v2
  • r-lib/actions v2
.github/workflows/pkgdown.yml
  • actions/checkout v3
  • r-lib/actions v2
  • r-lib/actions v2
  • r-lib/actions v2
.github/workflows/prepare_connect.yml
  • actions/checkout v3
  • r-lib/actions v2
  • actions/cache v3

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.