Usage Statistics

General

When you bring multiple Shiny apps to your end users, it may be interesting to track usage of the different applications over time. It may a.o. help to understand your user base and to prioritize maintenance work for the different applications.

ShinyProxy has a general model on board that allows one to store Shiny app events and for different storage back-ends, different plug-ins are available. Currently, ShinyProxy ships with plug-ins that can store events in two back-ends:

Alternative plug-ins can easily be developed and are on the roadmap.

InfluxDB

installation

InfluxDB installation is very simple: on an Ubuntu 16.04 LTS system one just needs to download and install the package using something along

wget https://dl.influxdata.com/influxdb/releases/influxdb_1.0.2_amd64.deb'
sudo dpkg -i influxdb_1.0.2_amd64.deb

To start the database one can use

sudo service influxdb start

and querying its status can be done with

sudo service influxdb status

DB creation

In order to store the usage statistics, a specific database needs to be created on the influxDB instance. In this example we will give it the name shinyproxy_usagestats.

To do so one can use the CLI client:

influx

then, at the database prompt, enter

CREATE DATABASE shinyproxy_usagestats
quit

configuration

Once the database is created, we can configure ShinyProxy to post all usage events to the shinyproxy_usagestats database. It is sufficient to add a single property in the application.yml file under the shiny / proxy section:

shiny:
  proxy:

  [...]

    usage-stats-url: http://localhost:8086/write?db=shinyproxy_usagestats

[...]

As can be seen, influxDB has the advantage that the storage of usage events can be done on a separate server and should not necessarily happen on localhost i.e. the machine on which the ShinyProxy server itself is running.

Note:

If authentication on the shinyproxy_usagestats database is required, one can use the usage-stats-username and usage-stats-password properties.

More detailed information on configuring ShinyProxy can be found here

MonetDB

installation

On an Ubuntu 16.04 system MonetDB can be installed from the official Debian package repository that is available here.

DB creation

When posting events to a MonetDB database, it is assumed that an event table exists that can be created as follows:

create table event(
 event_time timestamp,
 username varchar(128),
 type varchar(128),
 data text
);

configuration

Once the database is created, we can configure ShinyProxy to post all usage events to the shinyproxy_usagestats database. It is sufficient to only add a JDBC url in the usage-stats-url field in the shiny / proxy section of the application.yml file:

shiny:
  proxy:

  [...]

    usage-stats-url: jdbc:monetdb://localhost:50000/usage_stats

[...]

Similarly to influxDB, MonetDB can be used to store events on a separate server and event logging should not necessarily happen on localhost i.e. the machine on which the ShinyProxy server itself is running.

Note:

The default login and password that will be used to log into MonetDB are monetdb and monetdb respectively. If other credentials have been set on the database, one can enter the usage-stats-username and usage-stats-password properties below the usage-stats-url field.

More detailed information on configuring ShinyProxy can be found here