Tracking specific fields clicked by the user on Datatables using logging events

I have application where i am tracking all the user activity. But one major problem is there. I have a datatable in my application where when the user clicks on specific row (say " Datsun 710" under mtcars), this activity is not recorded in my log. I strongly believe that, this would be important as it captures in detail about the users.

I managed to get this below reprex

ui.R

library(shinydashboard)
library(readxl)
library(shiny)
library(shinylogs)
library(shinyEventLogger)
out <- data.frame(baseFns = ls('package:base'))

set_logging(r_console = TRUE,file = TRUE)


#Save and naigate log files 

if (is.null(interactive())) {
    tmp <- getwd()
    
    onStop(function(){
        browseURL(url = tmp)
    })
} else {
    tmp <- getwd()
    
    onStop(function(){
        browseURL(url = tmp)
    })
} 

# Define UI for application that draws a histogram
use_tracking()

dashboardPage(
    dashboardHeader(title = "Loading data"),
    dashboardSidebar(sidebarMenu(
        menuItem("Load Data", tabName = "Load_Data", icon = icon("balance-scale")),
        menuItem("Analysis", tabName = "Analysis", icon = icon("chart-bar"))
    )),
    dashboardBody(
        tabItems(tabItem(tabName = "Load_Data", selectInput("dataset",
                                                            "Select",choices = c("","iris","mtcars"), selected = "iris"),
                         DT::DTOutput('table1')),
                 tabItem(tabName = "Analysis",DT::DTOutput('table2'))
        ),verbatimTextOutput("last"))
)

server.R


library(shiny)
library(shinylogs)
library(DT)
source("ui.R")
library(shinyEventLogger)



# Define server logic required to draw a histogram
shinyServer(function(input, output) {
    
    set_logging_session()
    # log_value(rownames(table2()))
    
    track_usage(
        storage_mode = store_json(path = tmp)
    )
    
    datasetInput <- reactive({
        switch(input$dataset,
               "iris" = iris,
               "mtcars" = mtcars)
    })
    
    output$table1 <- DT::renderDT({
        head(datasetInput(), n = 6)
    })
    
    output$table2 <- DT::renderDT({
        if(is.null(log_value(input$table1_rows_selected))){
            
        } else {
            head(datasetInput()[input$table1_rows_selected,], n = 100)
        }
        
    })
    
    output$last <- renderPrint({
        input$.shinylogs_lastInput
    })
    
})

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.