Skip to content

Conversation

jakubnowicki
Copy link

@jakubnowicki jakubnowicki commented Jun 17, 2025

Dashboard for presenting the adoption data for the content deployed on Posit Connect, created by Appsilon.

Standalone repository: https://github.com/Appsilon/ConnectUserMetrics

image

@dotNomad dotNomad self-requested a review June 17, 2025 16:20
Copy link
Collaborator

@dotNomad dotNomad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Howdy @jakubnowicki 👋

Thanks for submitting this PR to contribute to the Connect Gallery! I'm still working through this PR to give it a full review, but I figured I'd post my in progress comments and questions so we could start some back and forth while I work through it.

@@ -0,0 +1,55 @@
# Connect Insights Dashboard
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great README. I noticed you included a short description in the manifest.json, but it could be helpful to add a description here as well. Perhaps one even longer that gives an indication of what functionality to expect.

Additionally I see the "Connect Insights Dashboard" naming here, but the directory and manifest.json use "Connect User Metrics" I was curious about the difference in naming.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent idea! I will copy the content of the in-app "help button" here, so we have a better description of what the app really does.

About the naming convention: you are right, we will stick to "Connect User Metrics".

Confirm with your Posit Connect admin that instrumentation is enabled.

<!-- Links -->
[User Guide Vars]: https://docs.posit.com/connect/user/content-settings/#content-vars
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is a typo here.

Suggested change
[User Guide Vars]: https://docs.posit.com/connect/user/content-settings/#content-vars
[User Guide Vars]: https://docs.posit.co/connect/user/content-settings/#content-vars

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed there are some features not included in the README that are in the Appsilon/ConnectUsersMetrics repo README. That totally makes sense given how the READMEs will be consumed for Gallery content.

It makes me wonder if there should be a CONTRIBUTING guide here that includes some of those details so this file, for example, is a bit easier to understand.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This app here is a simplified version of the origina Connect User Metrics; some of the features only make sense in the complete app, where the user is able to modify some configuration files.

I will add a CONTRIBUTE file pointing to the original branch.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the js file is empty other than this one file. Is there a reason to keep it around that I'm missing?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! These files (together with Cypress testing) are automatically generated Rhino, the framework we used to make this app. I will delete it for the sake of simplicity.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the Cypress tests aren't used here and there isn't a package.json to setup Cypress with npm. Can we remove the Cypress config and this empty test file?

When Cypress tests are added in the future we can get them added back :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Same answer as above; I will delete the file).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is being generated from main.scss. but I'm curious how this is being generated. I don't see anything mentioned in the README here or over in https://github.com/Appsilon/ConnectUserMetrics

Forgive me this may be some of my own unfamiliarity with styling Shiny apps.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minified CSS is generated by running rhino::build_sass(); it is a common practice when using Rhino, but we probably can make that more clear in the main repository of Connect User Metrics.

@vituri
Copy link

vituri commented Jun 24, 2025

Hey, @dotNomad , thank for the quick review! Jakub is on vacation right now, so I will try to answer some of your comments. I made a PR-to-this-branch fixing the issues you pointed. As soon as Marcin approves it, we can make a new round of reviews.

Copy changes from main-connect-extension
Copy link
Collaborator

@toph-allen toph-allen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generally looks really cool, and thank you for submitting the PR! Not quite ready to approve yet. I have a few small comments in this review — not all are direct things that need to be changed, but a few are.

I'll sum a few things up here:

  • The file list in the manifest references at least one file that doesn't exist (app/js/index.js), so I couldn't test out the deploy as specified to a Connect server.
  • dependencies.R isn't needed any more (thanks @jonkeane for pointing that out).

Other things that I'll dig into more next week:

  • Running the app locally on my computer (with CONNECT_SERVER and CONNECT_API_KEY defined), I was unable to get the app to display data correctly. Like I said, I'll dig into this more at the start of next week to see if I can diagnose the issue.
  • I had trouble getting renv::restore() to run correctly. Some versions of certain packages recorded in renv.lock try to install from source from the Public Package Manager server, which results in compiler failures. I was able to get packages to install correctly with renv::install().

Again, thanks for submitting this, and looking forward to getting it in the Gallery!

Comment on lines +67 to +74
get_usage_from_client <- function(client, from = NULL, to = NULL, guids = NULL) {
usage <- get_usage_shiny(
client,
limit = Inf, content_guid = guids, from = from, to = to
)

usage
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a forthcoming get_usage() function in connectapi which will return usage from a newer endpoint which returns data in a slightly different format. Although the newer endpoint doesn't accept a guids argument, and so returns all hits between the provided dates, it isn't paginated, so it's almost always faster than the older usage endpoints.

This isn't an actionable change now, but it should be merged and released soon. (There is some code in the Usage Metrics Dashboard gallery app that calls this endpoint.

@@ -0,0 +1,24 @@
# This file allows packrat (used by rsconnect during deployment) to pick up dependencies.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rsconnect / packrat leverage renv for dependency detection now, so they pick up on box imports, so this file isn't needed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out! I have brought it up some time ago too in hopes we would move Rhino away from this approach, but we need to be considerate to not break too many things.

Bottom line is: it's fine to remove the file and I did so in 3363159.

Comment on lines 2733 to 5458
"Version": "0.9-40",
"Date": "2022-03-21",
"Authors@R": "c(person(given = \"Torsten\", family = \"Hothorn\", role = \"aut\", email = \"[email protected]\",\n comment = c(ORCID = \"0000-0001-8301-0471\")),\n person(given = \"Achim\", family = \"Zeileis\", role = c(\"aut\", \"cre\"), email = \"[email protected]\",\n comment = c(ORCID = \"0000-0003-0918-3766\")),\n person(given = c(\"Richard\", \"W.\"), family = \"Farebrother\", role = \"aut\", comment = \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file isn't present in the repo, so deployment via the manifest fails.

@toph-allen
Copy link
Collaborator

I wanted to add a bit more detail to my above reports of being unable to load data in the app. @dotNomad and I walked through these steps again today. Here are the steps we took:

  1. Clone this branch.

  2. Run renv::restore().

This failed, running on R 4.5.1 (for reference, the lockfile was generated under R 4.5.0), with a compile error from Matrix 1.7-2. The local R environment was configured to use the Posit Public Package Manager, which matches the lockfile.

  1. Run renv::install() to install detected dependencies.

Attaching the resulting renv.lock in case it's helpful: renv.lock.zip

  1. Ran the app with rhino::app().

We ran the app against two different Connect servers.

Against one server, users and applications appeared as GUIDs. Against another, users and applications show correctly in the filter lists but no data is loaded. We see errors in the browser's console like the following, and no output in the R console.

inputValidateDecorator.ts:16 Uncaught Error: Unexpected input value mode: 'undefined'
    at Oi (inputValidateDecorator.ts:16:13)
    at Ot.setInput (inputValidateDecorator.ts:37:21)
    at Co (bind.ts:42:12)
    at bind.ts:280:11
    at HTMLDivElement.<anonymous> (virtual-select.js:2:123801)
    at HTMLDivElement.dispatch (jquery.js:5145:27)
    at HTMLDivElement.<anonymous> (jquery.js:4949:28)
    at virtual-select.js:2:37123
    at Array.forEach (<anonymous>)
    at virtual-select.js:2:37100
Oi @ inputValidateDecorator.ts:16
setInput @ inputValidateDecorator.ts:37
Co @ bind.ts:42
(anonymous) @ bind.ts:280
(anonymous) @ virtual-select.js:2
dispatch @ jquery.js:5145
(anonymous) @ jquery.js:4949
(anonymous) @ virtual-select.js:2
(anonymous) @ virtual-select.js:2
setTimeout
value @ virtual-select.js:2
value @ virtual-select.js:2
value @ virtual-select.js:2
value @ virtual-select.js:2
receiveMessage @ virtual-select.js:2
(anonymous) @ shinyapp.ts:762
await in (anonymous)
_sendMessagesToHandlers @ shinyapp.ts:697
await in _sendMessagesToHandlers
dispatchMessage @ shinyapp.ts:672
(anonymous) @ shinyapp.ts:256
startActionQueueLoop @ shinyapp.ts:284
await in startActionQueueLoop
(anonymous) @ shinyapp.ts:253

Let us know if there’s something else we should try to get it working.

@toph-allen
Copy link
Collaborator

Hi @jakubnowicki — just wanted to ping you on this to see if there are any updates.

@toph-allen
Copy link
Collaborator

Hi @jakubnowicki — just following up again. We’re still interested in getting this app into the Connect Gallery, and happy to work with you to get it across the finish line!

@jakubnowicki
Copy link
Author

Hi @jakubnowicki — just following up again. We’re still interested in getting this app into the Connect Gallery, and happy to work with you to get it across the finish line!

Hi @toph-allen, apologies for the delay. We should be able to push some changes soon.

@TymekAppsilon
Copy link

@toph-allen, I also ran into the issues when running renv::restore(). It seems that some of the versions recorded in renv.lock were quite old and their binaries got dropped by P3M. As we don't really use anything specific there, I upgraded the dependencies (and renv.lock accordingly) which appears to have resolved the issues.

I updated the manifest too and tested the app against our internal Connect instance—the metrics seemed to work for me! Could you take a look if it works on your end too?

@toph-allen
Copy link
Collaborator

@jakubnowicki @TymekAppsilon Thanks for the updates; we'll take a look soon!

Copy link
Collaborator

@toph-allen toph-allen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @TymekAppsilon & others — thanks for the updates!

I successfully ran renv::restore() locally on my machine, and was able to deploy the app successfully to two internal Connect servers.

One issue I encountered: On one of the servers I tested against, both the applications and users appear as GUIDs (with no names) in the left-hand sidebar. Perhaps helpful for tracking down the issue: The names display correctly in the tables in the app's content area. I should note that this server has a lot of content deployed on it, and may have some malformed names in the data

Image

I'll bring this updated versio to team to figure out what we need to do to move the process forward and to see what other checks are required. (For example — I think most of our Gallery apps require R 4.3.0, so as part of the process of bringing this into the Gallery, we may try to bump the required version of R down.)

@TymekAppsilon
Copy link

@toph-allen I found the culprit. It's a mix of how we fill the missing title returned by connectapi::get_content and how shinyWidgets::virtualSelectInput handles NA in names of its choices arguments.

For the apps, an entry returned from get_content that has is missing both name and title makes virtualSelectInput fall back to displaying values for all its choices.

I will fix this on Thursday (August 21). For apps I will use GUID as the display name when both name and title are missing. I'll check what is the issue with users too.


Please let me know if you want me to downgrade to R 4.3 right away. I don't think we use anything in particular from later R versions.

@TymekAppsilon
Copy link

@toph-allen should be all sorted out!

@toph-allen
Copy link
Collaborator

Hey @TymekAppsilon! Thanks for the updates, and and for your patience — I just wanted to let you know that I'll be getting to this soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants