{"id":14067642,"url":"https://github.com/sol-eng/connect-usage","last_synced_at":"2026-03-11T12:05:41.153Z","repository":{"id":36020585,"uuid":"160751974","full_name":"sol-eng/connect-usage","owner":"sol-eng","description":"Report on RStudio Connect Usage","archived":false,"fork":false,"pushed_at":"2023-09-26T20:10:05.000Z","size":1750,"stargazers_count":38,"open_issues_count":5,"forks_count":24,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-12-04T08:36:17.251Z","etag":null,"topics":["easy-deploy","instrumentation","rmarkdown","rstudio-connect","usage"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sol-eng.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-12-07T01:03:38.000Z","updated_at":"2024-10-30T02:58:55.000Z","dependencies_parsed_at":"2024-02-19T19:15:59.799Z","dependency_job_id":"bb3d22ab-b8a4-4c70-940e-8177e7244a71","html_url":"https://github.com/sol-eng/connect-usage","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sol-eng/connect-usage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sol-eng%2Fconnect-usage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sol-eng%2Fconnect-usage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sol-eng%2Fconnect-usage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sol-eng%2Fconnect-usage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sol-eng","download_url":"https://codeload.github.com/sol-eng/connect-usage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sol-eng%2Fconnect-usage/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267798625,"owners_count":24145727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["easy-deploy","instrumentation","rmarkdown","rstudio-connect","usage"],"created_at":"2024-08-13T07:05:42.291Z","updated_at":"2026-03-11T12:05:41.102Z","avatar_url":"https://github.com/sol-eng.png","language":"R","readme":"---\noutput: github_document\n---\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)\n```\n\n# RStudio Connect Usage Data\n\nThis repository illustrates several examples for getting started with the\nRStudio Connect usage data. The examples:\n\n- [./examples/last_30_days](./examples/last_30_days)\n- [./examples/interactive_app](./examples/interactive_app)\n- [./examples/realtime](./examples/realtime)\n- [./examples/connectAnalytics](./examples/connectAnalytics)\n- [./examples/connectViz](./examples/connectViz)\n\nThe examples are generated using the [RStudio Connect Server\nAPI](https://docs.rstudio.com/connect/api). The API and data collection are both\navailable as of RStudio Connect 1.7.0. The API contains data to help answer\nquestions like:\n\n- What content is most visited?\n- Who is visiting my content?\n- What reports are most common?\n- Has viewership increased over time?\n- Did my CEO actually visit this app?\n\n**A data science team's time is precious, this data will help you focus and justify your efforts.**\n\n## Basic example\n\nThe following code should work as-is if copied into your R session. NOTE that it\nuses the [`connectapi`](https://github.com/rstudio/connectapi) package, which\ncan be installed from GitHub with\n`remotes::install_github(\"rstudio/connectapi\")`. You just need to replace the\nserver name, and have your API key ready.\n\n```{r connect_creds, eval=FALSE}\n## ACTION REQUIRED: Change the server URL below to your server's URL\nSys.setenv(\"CONNECT_SERVER\"  = \"https://connect.example.com/rsc\") \n## ACTION REQUIRED: Make sure to have your API key ready\nSys.setenv(\"CONNECT_API_KEY\" = rstudioapi::askForPassword(\"Enter Connect Token:\")) \n```\n\nThis will use the `get_usage_shiny()` function to pull the latest activity of\nthe Shiny apps you are allowed to see within your server.\n\n```{r shiny_usage}\nlibrary(ggplot2)\nlibrary(dplyr)\nlibrary(connectapi)\n\nclient \u003c- connect()\n\n# Get and clean the Shiny usage data\nshiny_rsc \u003c- get_usage_shiny(\n  client,\n  from = lubridate::today() - lubridate::ddays(7), \n  limit = Inf\n  ) %\u003e%\n  filter(!is.na(ended)) %\u003e%\n  mutate(session_duration = ended - started)\n\nglimpse(shiny_rsc)\n```\n\nThe identifiers used for the content in RStudio Connect are GUIDs. We can\nretrieve content names using the API. The API handles only one GUID at a time,\nso `purrr`'s `map_dfr()` is used to iterate through all of the unique GUIDs in\norder to get every Shiny app's title.\n\n```{r shiny_content_names}\n# Get the title of each Shiny app\nshiny_rsc_titles \u003c- shiny_rsc %\u003e%\n  count(content_guid) %\u003e% \n  pull(content_guid) %\u003e%\n  purrr::map_dfr(\n    ~tibble(content_guid = .x, content_name = content_title(client, .x))\n    )\n\nglimpse(shiny_rsc_titles)\n```\n\nThe new `shiny_rsc_titles` table, and the `shiny_rsc` can be joined to return\nthe \"user readable\" title. Using standard `dplyr` and `ggplot2` functions, we\ncan now determine things such as the top 10 apps based on how long their average\nsessions are.\n\n```{r analyze_data}\n# Calculate the average session duration and sort\napp_sessions \u003c- shiny_rsc %\u003e%\n  inner_join(shiny_rsc_titles, by = \"content_guid\") %\u003e%\n  group_by(content_name) %\u003e%\n  summarise(avg_session = mean(session_duration)) %\u003e%\n  ungroup() %\u003e%\n  arrange(desc(avg_session)) %\u003e%\n  head(10)\n  \n# Plot the top 10 used content\napp_sessions %\u003e%\n  ggplot(aes(content_name, avg_session)) +\n  geom_col() +\n  scale_y_continuous() +\n  geom_text(aes(y = (avg_session + 200), label = round(avg_session)), size = 3) +\n  coord_flip() +\n  theme_bw() +\n  labs(\n    title = \"RStudio Connect - Top 10\", \n    subtitle = \"Shiny Apps\", \n    x = \"\", \n    y = \"Average session time (seconds)\"\n    )\n```\n\nLearn more about programmatic deployments, calling the server API, and custom emails [here](https://docs.rstudio.com/user).\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsol-eng%2Fconnect-usage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsol-eng%2Fconnect-usage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsol-eng%2Fconnect-usage/lists"}