Appsilon / shiny.telemetry

Easy logging of users activity and session events of your Shiny App
https://appsilon.github.io/shiny.telemetry/
66 stars 13 forks source link

[Bug]: :New version disabling shiny.fluent inputs #146

Open erikrenz88 opened 1 year ago

erikrenz88 commented 1 year ago

Guidelines

Project Version

0.2.0

Platform and OS Version

Windows 10 19044.3570

Existing Issues

No response

What happened?

I installed the latest version of shiny.telemetry to update the package in my app. When this was done, the inputs I had previously ben tracking in version 0.1.0 became disabled. I was using Dropdown.shinyInput from the shiny.fluent package and had a telemetry object attached. The inputs rendered but when clicked, no dropdown menu appeared.

Steps to reproduce

  1. Updated shiny.telemetry
  2. Seemingly - objects with telemetry stopped working Apologies - I have not had time to investigate fully as I only just discovered that rolling back to version 0.1.0 resolved the input issue

Expected behavior

No change to inputs

Attachments

No response

Screenshots or Videos

No response

Additional Information

No response

erikrenz88 commented 1 year ago

Apologies again - I know this is not a lot of detail. I can share the snippets of the telemetry objects for reference

erikrenz88 commented 1 year ago

Okay - so here's what I've got:

In main.R above ui and server functions:

log_file_path <- 'selfserve_usage.txt'
enableBookmarking(store = 'url')
telemetry <- shiny.telemetry::Telemetry$new(
  app_name = 'EncounterSelfServe', #make this a variable dependent on selection of view
  data_storage = shiny.telemetry::DataStorageLogFile$new(
    log_file_path = log_file_path
  ))

in the ui of the main.R: shiny.telemetry::use_telemetry()

In the server of the main.R: telemetry$start_session( login = T, logout = T, browser_version = T, session = session )

which then gets passed to the data module here: data$server('data', vals = dat, view_cols, view_fils, telemetry = telemetry)

And the telemetry object inside the data module server function:

server <- function(id, vals, view_cols, view_fils, telemetry) {
  moduleServer(id, function(input, output, session) {

    telemetry$log_input(
      'cols',
      track_value = TRUE,
      input_type = 'text',
      session = session
    )

Let me know if there's more I can provide

averissimo commented 11 months ago

Thanks for reporting this Erik!

I've been trying to replicate the problem without success, so we need more information.

The following example using Dropdown.shinyInput appears to work as intended.

Can you help us and give a bit more information on how to best replicate this? (without divulging any sensitive information)

Thanks a lot!

library(shiny)
library(shiny.fluent)
library(shiny.telemetry)

log_file_path <- "selfserve_usage.txt"
enableBookmarking(store = "url")
telemetry <- shiny.telemetry::Telemetry$new(
  app_name = "EncounterSelfServe",
  data_storage = shiny.telemetry::DataStorageLogFile$new(
    log_file_path = log_file_path
  )
)

# data module -----------------------------------------------------------------

data <- list(
  ui = function(id) {
    ns <- NS(id)

    options <- list(
      list(key = "A", text = "Option A"),
      list(key = "B", text = "Option B"),
      list(key = "C", text = "Option C")
    )

    div(
      Dropdown.shinyInput(ns("dropdown"), value = "B", options = options),
      reactOutput(ns("dropdownValue"))
    )
  },
  server = function(id, telemetry) {
    moduleServer(id, function(input, output, session) {
      telemetry$log_input(
        "dropdown",
        track_value = TRUE,
        input_type = "text",
        session = session
      )

      output$dropdownValue <- renderReact({
        shiny.fluent::Text(sprintf("Value: %s", input$dropdown))
      })
    })
  }
)

# ------------------------------------------------------------------------------

ui <- function(id) {
  ns <- NS(id)
  tagList(
    shiny.telemetry::use_telemetry(),
    #
    h2("A Title"),
    div(
      style = "display: flex; gap: .2em;",
      Label("A Checkbox:"),
      Checkbox.shinyInput(ns("checkbox"), value = FALSE),
      reactOutput(ns("checkboxValue"))
    ),
    hr(),
    data$ui(ns("first_choices")),
    hr(),
    span("the end")
  )
}

server <- function(id, telemetry) {
  moduleServer(id, function(input, output, session) {
    telemetry$log_input("checkbox", track_value = F, input_type = "text", session = session)

    output$checkboxValue <- renderReact({
      shiny.fluent::Text(sprintf("Value: %s", input$checkbox))
    })

    data$server("first_choices", telemetry)
  })
}

if (interactive()) {
  shinyApp(ui("app"), function(input, output, session) {
    telemetry$start_session(
      login = T,
      logout = T,
      browser_version = T
      , track_inputs = T
      # , track_values = F
      # , session = session
    )

    server("app", telemetry)
  })
}
Session Info ```r R version 4.3.2 (2023-10-31) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 23.10 Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.11.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.11.0 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_IE.UTF-8 [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_IE.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_IE.UTF-8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=en_IE.UTF-8 LC_IDENTIFICATION=C time zone: Europe/Lisbon tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices datasets utils methods base other attached packages: [1] shiny.telemetry_0.2.0 testthat_3.1.10 shiny.fluent_0.3.0 shiny_1.8.0 loaded via a namespace (and not attached): [1] bslib_0.5.1 httr2_0.2.3 remotes_2.4.2.1 htmlwidgets_1.6.2 [5] devtools_2.4.5 processx_3.8.2 callr_3.7.3 vctrs_0.6.5 [9] odbc_1.3.5 tools_4.3.2 ps_1.7.5 generics_0.1.3 [13] tibble_3.2.1 fansi_1.0.4 RSQLite_2.3.1 blob_1.2.4 [17] pkgconfig_2.0.3 checkmate_2.2.0 desc_1.4.2 lifecycle_1.0.3 [21] stringr_1.5.0 compiler_4.3.2 brio_1.1.3 httpuv_1.6.11 [25] usethis_2.2.2 htmltools_0.5.6 sass_0.4.7 urlchecker_1.0.1 [29] later_1.3.1 pillar_1.9.0 crayon_1.5.2 jquerylib_0.1.4 [33] tidyr_1.3.0 ellipsis_0.3.2 cachem_1.0.8 sessioninfo_1.2.2 [37] mime_0.12 tidyselect_1.2.0 digest_0.6.33 stringi_1.7.12 [41] dplyr_1.1.3 purrr_1.0.2 rprojroot_2.0.3 fastmap_1.1.1 [45] cli_3.6.1 logger_0.2.2 magrittr_2.0.3 pkgbuild_1.4.2 [49] utf8_1.2.3 withr_2.5.2 prettyunits_1.1.1 promises_1.2.1 [53] backports_1.4.1 rappdirs_0.3.3 bit64_4.0.5 lubridate_1.9.2 [57] timechange_0.2.0 bit_4.0.5 hms_1.1.3 memoise_2.0.1 [61] miniUI_0.1.1.1 profvis_0.3.8 rlang_1.1.2 shiny.react_0.3.0 [65] Rcpp_1.0.11 xtable_1.8-4 glue_1.6.2 DBI_1.1.3 [69] renv_1.0.2 pkgload_1.3.2.1 rstudioapi_0.15.0 jsonlite_1.8.8 [73] R6_2.5.1 fs_1.6.3 ```
averissimo commented 10 months ago

@erikrenz88 can you give some extra feedback? thanks :bow:

erikrenz88 commented 10 months ago

Apologies @averissimo - I will try and reproduce this week. I've been trying to deploy an app and managing the feedback. Sorry for the delay!

averissimo commented 8 months ago

@erikrenz88 I imagine isolating the problem on a live app might be a tad difficult 😅

Let me know if I can help out with something

erikrenz88 commented 8 months ago

Clearly this got lost in the weeds. In the elapsed time, I did get everything migrated to a preprod environment and have a stable version on the prod environment which I am working on this week so I will go back to the telemetry piece right after I finish some in demand bookmarking!