Created
August 22, 2025 13:22
-
-
Save charliejhadley/88452cae463c7837308d57918cc95979 to your computer and use it in GitHub Desktop.
shiny.telemetry instructions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(shiny) | |
| library(shinyWidgets) | |
| library(shiny.telemetry) | |
| library(highcharter) | |
| telemetry <- Telemetry$new() | |
| ui <- fluidPage(selectInput("things", "things", choices = letters)) | |
| shinyApp( | |
| ui = fluidPage( | |
| use_telemetry(), # 2. Add necessary javascript to Shiny | |
| numericInput("n", "n", 1), | |
| plotOutput('plot'), | |
| actionButton("do_thing", "do_thing"), | |
| highchartOutput("bar_chart") | |
| ), | |
| server = function(input, output, session) { | |
| output$bar_chart <- renderHighchart({ | |
| highchart() %>% | |
| hc_add_series( | |
| data = count(gss_cat, marital), | |
| type = "bar", | |
| hcaes(y = n, | |
| x = marital)) | |
| }) | |
| observeEvent(input$do_thing, | |
| { | |
| telemetry$log_custom_event( | |
| "input", | |
| details = list( | |
| id = "iona", | |
| value = input$n | |
| ) | |
| ) | |
| }) | |
| telemetry$start_session(track_values = TRUE, | |
| track_inputs = TRUE) | |
| # Do not track inputs that contain "tbl_" while still tracking "tbl_row_selected" | |
| telemetry$log_all_inputs( | |
| excluded_inputs_regex = "tbl_" | |
| ) | |
| output$plot <- renderPlot({ hist(runif(input$n)) }) | |
| } | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| # This reads the data into a tibble | |
| telemetry_data <- shiny.telemetry::Telemetry$new()$data_storage$read_event_data("2020-01-01", "2050-01-01") | |
| # This gives the dashboard | |
| analytics_app(shiny.telemetry::DataStorageSQLite$new(db_path = "telemetry.sqlite")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment