click here for details... Sakai Executive Director Position Search now open
Issue Details (XML | Word | Printable)

Key: SAK-8499
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Nuno Fernandes
Reporter: Nuno Fernandes
Votes: 3
Watchers: 5
Operations

If you were logged in you would be able to see more operations.
Sakai

Presence events are only logged if presence list is enabled

Created: 26-Feb-2007 03:47   Updated: 08-Feb-2010 09:08
Component/s: Presence
Affects Version/s: 1.0, 1.5.0, 1.5.1, 2.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.1.x, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.2.x, 2.3.0, 2.3.1, 2.3.x, 2.4.0, 2.4.1, 2.5.0, 2.5.2, 2.5.3
Fix Version/s: 2.6.0

Time Tracking:
Not Specified

File Attachments: 1. Text File presence.patch (1 kB)

Environment: MySQL

2.6.x Status: None
2.5.x Status: None
2.4.x Status: None


 Description  « Hide
Currently, if the presence list is disabled, no "pres.begin" and "pres.end" events are sent to the Sakai Event Tracking Service. This makes impossible for SisteStats and other data analysis tools to track user presences in sites.

Related STAT-26: Non-presence way of calculating site visits & unique visits
Related STAT-51: Visits related information should be hidden if presence display disabled (workaround for this jira)


 All   Comments   Work Log   Change History   Subversion Commits   git Commits      Sort Order: Ascending order - Click to sort in descending order
Mike Osterman added a comment - 07-Aug-2007 09:00
I would like to suggest a new sakai.properties setting, something to the effect of "users.presents.events.nodisplay" that would invoke the /presence servlet, but not actually list the users in the portal.

Our instructors who use stats like to know how often people are visiting the site, but we do not want display users present in the portal.

Right now, we're getting this functionality by:

1) Setting display.users.present=true
2) Setting "users = null;" before the presence tool iterates over users for display (currently on line 256 of presence-tool/tool/src/java/org/sakaiproject/presence/tool/PresenceTool.java)
3) Changing portal.css:
#presenceWrapper {
    display:none;
}

It would be nice if there were a built-in way to achieve this.

David Roldán Martínez added a comment - 26-May-2008 00:36
    I've finally undestood how pres.begin event is logged. When Sakai builds the page displayed to user, it includes an iframe with an invocation to presence tool (=servlet). This iframe is only displayed if display.users.present at sakai.properties is enabled. When this parameter is disabled, the invocation to the servlet is never done and, thus, pres.begin event is not registered. Presence tool servlet makes a call to PresenceService.setPresence which checks, for each user in the site, if pres.begin event has been stored at the ddbb and if don't, fires the event.

    We've solved this issue by modifying SiteHandler under portal folder and invoking method PresenceService,setPresence from SiteHandler.doSite so that when the user visits the site a pres.begin event is logged. What you have to add between includeWorksite and portalIncludeButton at doSite method is the following:

...
includeWorksite(rcontext, res, req, session, site, page, toolContextPath, "site");

//UPV - Generamos el evento de visita
try{
org.sakaiproject.presence.cover.PresenceService.setPresence(siteId + "-presence");
}catch(Exception e){}
//End - UPV


portal.includeBottom(rcontext);

...

     We are going to spend today (and tomorrow, if needed) checking performance. I'll let you know.

     What do you think about this solution?

David Roldán Martínez added a comment - 26-May-2008 04:04
I attach a patch for trunk version. I've tested it and found no performance problems.

I've added a new sakai property to configure if in an installation pres.begin events are needed to be logged or not. This new property is presence.events.log and is readed at SiteHandler.


David Roldán Martínez added a comment - 27-May-2008 00:26
Trunk version r46803

Peter A. Knoop added a comment - 27-May-2008 08:48
Ian, is this one you could review and merge, if appropriate? Thanks.

Ian Boston added a comment - 27-May-2008 14:02
This looks Ok

Ian Boston added a comment - 27-May-2008 14:20
Patch applied

Nuno Fernandes added a comment - 28-May-2008 03:03
I tested this feature on a local trunk instance and it is working properly. SiteStats was updated (trunk and 1.0.4 tagged) to look at this new property for enabling site visits (STAT-69).
Thanks.

Tom Kuipers added a comment - 29-May-2008 03:58
I'm happy the issue is fixed by this patch, but what strikes me is the introduction of an empty catch block. Either code can handle the exception, then the catch clause shouldn't been empty, or the code can not handle the exception, then there should not be a try/catch block at all.

Stephen Marquard added a comment - 29-May-2008 05:18
You might get a harmless exception here if you don't have the presence impl in the build (e.g. cafe builds).

David Roldán Martínez added a comment - 29-May-2008 05:21
If you don't include event logging inside a try/catch block if, for any reason, an exception was launched client request would be broken because of the exception. That's why I included it inside the try/catch. But the problem was, what to do with the exception, then? Just keep processing client request. Maybe it should be inserted some message in the log. What do you think about it?


Tom Kuipers added a comment - 29-May-2008 05:35
At least put a comment in for maintainability, this catch catches all exceptions which is very dangerous. See http://confluence.sakaiproject.org/confluence/display/SAKDEV/Best+Practices+for+High+Quality+Code#BestPracticesforHighQualityCode-Neverswallowexceptionsorleavecatchblocksempty
for sakai coding guidelines.

Nuno Fernandes added a comment - 08-Feb-2010 09:08
Should have been closed earlier - I have verified this on local instances: "presence.events.log = true" enables logging of presence events as expected.