How can I get the names associated with the user guids
> ## ACTION REQUIRED: Change the server URL below to your server's URL
> Sys.setenv("CONNECT_SERVER" = "https://rstudio.xx.com/")
> ## ACTION REQUIRED: Make sure to have your API key ready
> Sys.setenv("CONNECT_API_KEY" = rstudioapi::askForPassword("Enter Connect Token:"))
> library(ggplot2)
> library(dplyr)
> library(connectapi)
> library(purrr)
> client <- connect()
Defining Connect with server: https://rstudio.hartvillegroup.com/
> # Get and clean the Shiny usage data
> shiny_rsc <- get_usage_shiny(
+ client,
+ from = lubridate::today() - lubridate::ddays(60),
+ limit = Inf
+ ) %>%
+ filter(!is.na(ended)) %>%
+ mutate(session_duration = ended - started)
>
> glimpse(shiny_rsc)
Observations: 129
Variables: 6
$ content_guid <chr> "a261edd3-fa51-4878-8afc-b7fe662a6c37", "a261edd3-fa51-4878...
$ user_guid <chr> "e96068bd-5e9f-4a5a-ab87-483f084f13fa", NA, NA, NA, NA, NA,...
$ started <dttm> 2021-07-06 14:39:24, 2021-07-06 15:08:47, 2021-07-06 21:40...
$ ended <dttm> 2021-07-06 14:49:17, 2021-07-06 16:15:44, 2021-07-06 22:20...
$ data_version <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
$ session_duration <drtn> 593 secs, 4017 secs, 2424 secs, 4329 secs, 2642 secs, 3286.
As you see the user_guid are identifiers. how do I link them with actual user names? or is that always encrypted.
It's not giving you and encrypted username, it's the GUID/UUID key from the user info table in RStudio's instrumentation API.
Using
connectapi
:where the last field is
"guid"
which should match theuser_guid
in your question. Note that you may need to extendlimit=...
to get all users. The output is the same as thehttr
-direct API call, below.If you (or somebody) is choosing to not use the
connectapi
package (it's not on CRAN yet, for instance), then the below function along with thehttr
package (anddata.table
for my personal use, but that dependency can be removed) will get you exactly the same data. (For reference, see https://docs.rstudio.com/connect/api/#get-/v1/users .)