Hi,
I would like to add a label to all the pages which did not get any view in the past year. I intend to use scriptrunner to automate that process, which lets me access Confluence through the groovy API.
I have been digging in the javadoc to find out how to access the page views for a given page, but I have not been successful.
It seems, however, that this data would be available through the rest API, but I do not know how to invoke it from groovy (and I am afraid of the potential performance issues).
How can I achieve my goal? Is there a way to access the number of views through the groovy API? Is there a different, simpler way way to label those pages automatically?
Thank you!
Unfortunately, view page data is not captured by Confluence itself, let alone is it available through the REST API.
You'd have to start capturing page views.
You can turn on Analytics, get another plugin, or do some fancy coding with database table updates.
If you've got Confluence capturing the page view data somehow, then:
Analytics has this Java API. You could start with that. Not sure if it'll give you all you need.
If you go to the Developer Tools Console in your web browser (hit F12) and visit a space's Activity page, you'll see a whole lot of mess. Perhaps you can interpret it, but good luck with that. There doesn't seem to be an easy, obvious API or code call there, other than this:
<myconfluence>/spaces/usage/report.action?key=ABC&period=week
which returns HTML and not even the data you want.
If you go the plugin route, it might have a REST API.
If you're doing fancy coding, then hats off to you.
One other thing you can try is the Confluence REST API Browser and see if you see anything analytic in there. Unfortunately, the version never seems to be the right fit for our instance, so I can't check for you. If you see CONFSERVER-76071, the REST API Browser does show the analytics REST API calls.
PS That REST API you linked to is for Cloud.
One more thing (promise), if you're a digger, you may want to explore this Java API: com.atlassian.confluence.api.impl.service.event.mau. Although the Impl one is, I think, only for Atlassian internal use, and it's a stretch at best, but that's what captures user activity and sends it to analytics.
Thank you for the extensive answer. It is a bit disappointing to discover that this data is not exposed to the api user... I will report here if I find a solution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After digging down the rabbit hole, I have an idea that could work: Leverage scriptrunner to write my own page tracking.
I know it sounds crazy, but with a Custom Event Listener, it does not look too complicated: basically, one can listen for the PageViewEvent. The modified Page should be available through this event, and pages happen to be instances of ContentEntityObject, which Confluence lets you associate with arbitrary content. So I should be able to store the date of the latest view for a page directly in Confluence, the same way a regular plugin developer does.
Then I am unsure how to proceed yet:
I will post here if I implement anything.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.