if (session.getAttribute(WebKeys.CMS_USER) != null && clickstream.getUserId() == null) {
User user = (User) session.getAttribute(WebKeys.CMS_USER);
setClickStreamUser(user.getUserId(), request);
}
ClickstreamRequest cr = ClickstreamRequestFactory.getClickstreamRequest(request, clickstream.getLastRequest());
clickstream.setNumberOfRequests(clickstream.getNumberOfRequests() + 1);
cr.setRequestOrder(clickstream.getNumberOfRequests());
cr.setHostId(host.getIdentifier());
cr.setAssociatedIdentifier(associatedIdentifier);
// prevent dupe entries into the clickstream table - just retun if the user is on the same page
if(clickstream.getClickstreamRequests() != null &&clickstream.getClickstreamRequests().size()>0){
ClickstreamRequest last = clickstream.getClickstreamRequests().get(clickstream.getClickstreamRequests().size()-1);
if(last != null && cr.getAssociatedIdentifier().equals( last.getAssociatedIdentifier())){
return clickstream;
}
}
clickstream.addClickstreamRequest(cr);