posit::conf(2023)
Shiny in Production: Tools & Techniques
β
Create app.R
in directory
β Take note of any custom environment variables
β
Ensure DESCRIPTION
is up-to-date with required packages
β Remove outdated functions / scripts
Deploy your application(s) to Posit Connect:
{rsconnect}
)πΌ Max Processes
πΌ Min Processes
Coming soon: Container support for Posit Connect
βHow many people used your app last year?β
βHow long are users on the app at a given time?β
βWhat is the return on investment (ROI) this app is bringing the company?β
{connectapi}
R client for the Posit Connect Server API as well as helpful functions that utilize the client
Checklist:
β Create API key for your Posit Connect account
β
Create .Renviron
with following variables: CONNECT_SERVER
, CONNECT_API_KEY
library(connectapi)
client <- connect(
server = Sys.getenv("CONNECT_SERVER"),
api_key = Sys.getenv("CONNECT_API_KEY")
)
client
Posit Connect API Client:
Posit Connect Server: https://rsc.training.rstudio.com
Posit Connect API Key: ***********FWxW
client
is an R6 object representing the API client[1] "47e1338f-54a8-4b0e-9b3c-e4380611b30f"
library(dplyr)
meta_df <- get_content(client) |>
filter(owner_guid == my_guid) |>
select(guid, name, title)
meta_df
# A tibble: 27 Γ 3
guid name title
<chr> <chr> <chr>
1 40dd2969-5d67-4940-89c4-08fe31fd1c74 brickapp brickapp
2 fba6896e-49e4-45c6-856f-03a3bc4f498f legobricksapp legobricks.app
3 626d6bb1-f36d-4c9b-bc9e-5cb44f46e698 hellogolem22 hellogolem2
4 6f8116dc-eabf-4a64-aacb-4aeffbb4eaa4 golembrochure2 golembrochure
5 a4e6809f-4858-4888-a848-94925d3df4a0 golembrochure golembrochure
6 f268d424-a286-41b9-91f1-ae458797e64a golemhellolocal golemhellolocal
7 4d9124a0-158b-4bd9-9b65-07b877db0906 test test
8 c60de16e-0b29-4267-a2c5-0eb6815d7999 hellogolem3 hellogolem
9 2aec4c5b-144f-4a6c-8abf-7d07a17d78b2 hellogolem hellogolem
10 344b9f1b-ddbe-4145-a1f0-eb6608662f08 hellogolem2 hellogolem
# βΉ 17 more rows
Session durations for the legobricksapp
:
app_guid <- "fba6896e-49e4-45c6-856f-03a3bc4f498f"
get_usage_shiny(
client,
content_guid = app_guid,
limit = 5
) |>
filter(!is.na(ended)) |>
mutate(session_duration = ended - started) |>
select(user_guid, session_duration)
# A tibble: 5 Γ 2
user_guid session_duration
<chr> <drtn>
1 47e1338f-54a8-4b0e-9b3c-e4380611b30f 10.933333 mins
2 47e1338f-54a8-4b0e-9b3c-e4380611b30f 1.216667 mins
3 47e1338f-54a8-4b0e-9b3c-e4380611b30f 4.733333 mins
4 47e1338f-54a8-4b0e-9b3c-e4380611b30f 6.766667 mins
5 47e1338f-54a8-4b0e-9b3c-e4380611b30f 1.183333 mins
How many users visited legobricksapp
in last 28 days?
Obtain metadata for your deployed application(s) on Posit Connect
05:00
Collection of interesting use cases available at github.com/sol-eng/connect-usage
{connectViz}
: Collection of customizable functions for visualizing content usage for an organization{golem}
{profvis}