Authors: Tyler Bradley
Working with Shiny more than 1 year
Abstract: Track content usage on an RStudio Connect Server using this shiny app. The app is designed to work with existing Rstudio Connect servers by interfacing with the server using the
connectapi package. Deploy this application to your connect server to easily track usage on your server.
The goal of
connectAnalytics is to provide an out of the box shiny app that will allow for RStudio Connect users to see analytics information about their deployed applications and documents.
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("tbradley1013/connectAnalytics")
Before you can get started using the
connectAnalytics dashboard for your organization, there are a few things that you need to do:
Configure the following environment variables:
CONNECT_SERVER- This variable should be the url of your connect server that you use to reach the base content page. NOTE: If your server's port is masked then you will need to add the actual port to the server URL
CONNECT_API_KEY- An API key generated from the Connect system. You can see how to generate an API key here
connectAnalyticspackage as shown above
Run the app
To run the application, you can simply run the
connectAnalytics wrapper function:
If you run it wittout specifying any arguments than it will automatically look for the two environment variables discussed above to connect to your RStudio Connect server. In addition, once the application connects to your server and loads you will see a modal pop up asking you to specify your connect username. By default, if a user is not specified than it looks for the
session$user variable, if
session$user is NULL (which it will be if running locally) than you will be asked for your username via the modal. It is designed like this because once deployed to your RStudio Connect system than whichever user access the application will see their usage information. See the deployment section below for more information.
There are several arguments that can be specified when running this app that can help the user customize the app to themselves or their organization:
host- If specified would override the
api_key- If specified would override the
user- The RStudio Connect User name to run the application as
FALSE; Allows the user to specify different user names within the app to see usage information for other users. This feature could be userful for managers or supervisors who are not admins on the server but would like to be able to see how the content the people under them have deployed is being used.
favicon- The path to a favicon icon to be used by your app. If
golemfavicon is used (this may be changed in the future)
title- The title for your dashboard header. Defaults to
window_title- The title to be displayed in the browser tab for your app. Defaults to the same value as the
If you want to deploy the application to your connect server so that publishers and admins can easily track their application usage data, you simply need to create an
app.R file that looks like:
library(connectAnalytics) library(shiny) # Leave a commented out line of `shinyApp()` so that RStudio recognizes the script # as a shiny application! # shinyApp() connectAnalytics()
app.R file can then be published to your connect server in any way you would normally publish an application. It is recommneded that this application be deployed by an administrator with an API key for the admin account. This will allow all publishers and admins to easily view their usage data. If it is published by a user with
publiser permissions than it will only be able to be used by that user due to API key restrictions. By default, API keys generated by an admin account are able to view usage for all users, while an API key associated with a publisher account can only see the data associated with their account. The application will parse through the content and only show publishers their data. If the user accessing the application is an admin, then an additional "Admin" tab will be created showing data for all users on the account.
Keywords: RStudio Connect, Analytics, Site Usage
Shiny app: https://connect.staging.soleng.rstudioservices.com/connect-analytics/
RStudio Cloud: https://rstudio.cloud/project/1098400