REST API that receives write and read requests for telemetry data from a Shiny Dashboard (using
shiny.telemetry
R 📦)
This plumber REST API serves as a middleware between a Shiny Application that is being monitored by shiny.telemetry
and a data backend that write the logging information to persistent storage.
The data backend is provided by the shiny.telemetry
R package.
Features:
shiny.telemetry
To get a minimal Plumber instance running locally it requires an R
environment (at least ≥v4.1
) and the renv
R package.
Start by downloading or cloning the source files in the repository and open an R session on the /plumber_rest_api
directory.
Install the required packages by calling renv::restore()
inside the R session.
> renv::restore()
Start the Plumber API by sourcing plumber.R
file or by calling plumber::plumb("plumber.R")
.
> # source("plumber.R")
> plumber::plumb("plumber.R")
The plumber instance is now running and the API documentation can be accessed via 127.0.0.1:8087/docs/. The /health_check
endpoint can be used without any parameters.
In order to test as a shiny.telemetry
data storage provider, you can run the code below in an R session.
The example will:
DataStoragePlumber
R6 class configured to use the local Plumber instancelibrary(shiny.telemetry)
data_storage <- DataStoragePlumber$new(
username = "test_user",
hostname = "127.0.0.1",
port = 8087,
protocol = "http"
)
log_login(data_storage)
log_click(data_storage, "an_id")
log_click(data_storage, "a_different_id")
data_storage$read_event_data("2020-01-01", "2035-01-01")
As a security feature, it is possible to sign the messages exchanged between shiny.telemetry
and this API so that we can guarantee that only un-modified information from known sources are stored.
The method uses a secret token that is defined as an environment variable on both the Shiny application and in the deployed API. The API can support multiple tokens and by default it uses no signature, so this feature is disabled.
In technical terms, the parameters of the requests are transmitted in plain text with the signature (of the parameters) and an unique identifier of the secret that is being used.
Note that, the data in the message being transmitted via the HTTP protocol is not encrypted (consider using https for this purpose).
To setup the message signature it is required to define:
SECRET_TOKENS="<string-token-a> <string-token-b>
shiny.telemetry
: PLUMBER_SECRET=<string-token-a>
ℹ️ Important: the different tokens defined in the API are separated by spaces.
Appsilon is a Posit (formerly RStudio) Full Service Certified Partner. Learn more at appsilon.com.
Get in touch opensource@appsilon.com
Check the Rhinoverse.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.