Last Pages Viewed - Panel

Hello,

I’ve been recently working on creating a custom panel which, instead of showing the last 5 modified pages by the user, shows the last 5 viewed pages. So, in combination with that, I’ve been thinking of using the EventStream API and implementing some sort of Listener.

As I read through the source code provided in GitHub, the ActionExecutedEvent could be useful here, as it picks up that event.

Could someone here tell me if I’m on the right track or if there’s an easier, or alternative way to do that ?

There’s no event sent when a page is viewed, so you wouldn’t be able to use the Event Stream to find that info.

This is why the Last pages viewed panel was implemented as part of the old Statistics extension, which has now been deprecated.

The way to implement what you want is to set up Matomo (or equivalent), in front of your XWiki instance and then use the Matomo API to query the last pages viewed.

See https://extensions.xwiki.org/xwiki/bin/view/Extension/Piwiki%20Integration

1 Like

Hello,

so I’ve been looking into using Matomo, and have set up everything according to instructions including the tracker and all, however I still seem to run into problems here. The issue is, that Matomo on my Webserver apparently tracks all page - views - as should be. However, when I accordingly try to retrieve the last page visits of a user via URL, it doesn’t really do that. It does retrieve some visits, but these visits are already days old and I’ve been doing many more since that.

Retrieved via JSON Document and the URL :
https://wof-matomo.desy.de/piwik/index.php?module=API&method=Live.getLastVisitsDetails&idSite=430&period=day&date=today&filter_limit=600&format=json&token_auth=...mytoken...&segment=userId==xwiki:XWiki.eliasadm

In this JSON document, there are a set piece of 6 results returned for these page visits and related information, and it stays that way, no matter how many visits I do since then. These 6 results are indeed page views from me, but they were made 1-2 days ago … Reloading the URL for the JSON document does not work.

Another weird effect is that in a few of these entries, the information for the key “referrerUrl”, which usually contains the URL of the page the user visited, is null.

So I’m just wondering whether you’d know what the issue here is ?


Edit : I think I found what is causing this… it seems that the information almost always gets lost when saving or viewing as JSON-file. However viewing it as a XML file correctly displays the last page views.

So it isn’t necessarily an issue with XWiki, but rather an issue with Matomo that causes the information about recent page views to be lost when storing into a JSON - file.