Appsilon / shiny.telemetry

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

[Feature]: Track inputs exclusively via JS to optimize perfomance #171

Open averissimo opened 5 months ago

averissimo commented 5 months ago

Guidelines

Description

🏹 Goal: Add option to track inputs via JavaScript.

How?

$(document).on('shiny:inputchanged', function(event) {
  if (event.name === 'foo') {
    event.value *= 2;
  }
});

Benefits:

  1. Performance improvements as the Shiny R session wouldn't be monitoring the input changes

Taking one step further

🏹 Goal: Delegate write operations to external API via JS

In other words, bypass using the DataStorage backend on the current R Shiny session and send the data to a deployment of the existing PlumberAPI

In turn, the Plumber API would write to the correct backend (LogFile, SQLite, SQL, ...)

Benefits:

  1. Performance improvements as write operations would be done asynchronously in JS only
    • without blocking Shiny R session

Cons:

Additional work:

Diagram

image

Alternatives Considered

  1. Using a queue system that allows to group together multiple events #148
averissimo commented 5 months ago

Alternative:

note: Creating a future call has its own overhead. One way to minimize it is to define the globals argument manually and it might be as slow as the write operation.

A benchmark should be done to assess the performance benefits.