Skip to contents

Implementation of the DataStorage R6 class to a JSON log file backend using a unified API for read/write operations

Super class

shiny.telemetry::DataStorage -> DataStorageLogFile

Active bindings

event_bucket

string that identifies the file path to store user related and action data

Methods

Inherited methods


Method new()

Initialize the data storage class

Usage

DataStorageLogFile$new(log_file_path)

Arguments

log_file_path

string with path to JSON log file user actions


Method clone()

The objects of this class are cloneable with this method.

Usage

DataStorageLogFile$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

log_file_path <- tempfile(fileext = ".txt")
data_storage <- DataStorageLogFile$new(log_file_path = log_file_path)

data_storage$insert("example", "test_event", "session1")
data_storage$insert("example", "input", "s1", list(id = "id"))
data_storage$insert("example", "input", "s1", list(id = "id2", value = 32))

data_storage$insert(
  "example", "test_event_3_days_ago", "session1",
  time = lubridate::as_datetime(lubridate::today() - 3)
)

data_storage$read_event_data()
#> # A tibble: 4 × 8
#>   app_name type      session time                id    value date       username
#>   <chr>    <chr>     <chr>   <dttm>              <chr> <chr> <date>     <chr>   
#> 1 example  test_eve… sessio… 2024-04-05 09:27:49 NA    NA    2024-04-05 NA      
#> 2 example  input     s1      2024-04-05 09:27:49 id    NA    2024-04-05 NA      
#> 3 example  input     s1      2024-04-05 09:27:49 id2   32    2024-04-05 NA      
#> 4 example  test_eve… sessio… 2024-04-02 00:00:00 NA    NA    2024-04-02 NA      
data_storage$read_event_data(Sys.Date() - 1, Sys.Date() + 1)
#> # A tibble: 3 × 8
#>   app_name type      session time                id    value date       username
#>   <chr>    <chr>     <chr>   <dttm>              <chr> <chr> <date>     <chr>   
#> 1 example  test_eve… sessio… 2024-04-05 09:27:49 NA    NA    2024-04-05 NA      
#> 2 example  input     s1      2024-04-05 09:27:49 id    NA    2024-04-05 NA      
#> 3 example  input     s1      2024-04-05 09:27:49 id2   32    2024-04-05 NA      

file.remove(log_file_path)
#> [1] TRUE