How do we track application closure time and how do we access events.log file in R Studio connect server

Hi Experts here. I have 2 points. Need your help.

below is the reprex for it. I have 2 points here

  1. In my application I am tracking my Login time by using log_value(Sys.time). Is there a way to track When my application ends?

  2. Everytime I close my application, events.log file is created. In my local system i am able to access it. But How do we access it when I am using the application in R Studio connect server

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"),verbatimTextOutput("last1"))
)

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(Sys.time())
    
    
    datasetInput <- reactive({
        switch(input$dataset,
               "iris" = iris,
               "mtcars" = mtcars)
    })
    
    output$table1 <- DT::renderDT({
        head(datasetInput(), n = 6)
    })
    
    as1 <- output$table2 <- DT::renderDT({
        if(is.null(input$table1_rows_selected)){
            
        } else {
            head(datasetInput()[input$table1_rows_selected,], n = 100)
        }
        
    })
    
    output$last <- renderPrint({
        input$.shinylogs_lastInput
    })
    
    output$last1 <- renderPrint({
        log_value(row.names(mtcars)[c(input$table1_rows_selected)])
    })
    
})

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