import com.opensymphony.clickstream.ClickstreamFilter import com.opensymphony.clickstream.ClickstreamListener import grails.plugins.clickstream.logger.ClickStreamLogger import javax.servlet.http.HttpSession import com.opensymphony.clickstream.Clickstream class ClickstreamGrailsPlugin { def version = "0.2.0" def grailsVersion = "1.1.1 > *" def dependsOn = [:] def pluginExcludes = [ "grails-app/views/error.gsp", "lib/**" ] def author = "Mihai Cazacu" def authorEmail = "cazacugmiha@gmail.com" def title = "Clickstream" def description = '''Utility to track the current users on your site, and\ where they've been in detail. Check this: http://www.opensymphony.com/clickstream/''' def documentation = "http://grails.org/Clickstream+Plugin" def doWithWebDescriptor = {xml -> def filters = xml.filter def filterMappings = xml.'filter-mapping' def listeners = xml.listener filters[filters.size() - 1] + { filter { 'filter-name'('clickstream') 'filter-class'(ClickstreamFilter.name) } } filterMappings[filterMappings.size() - 1] + { 'filter-mapping' { 'filter-name'('clickstream') 'url-pattern'("/*") } } listeners[listeners.size() - 1] + { listener { 'listener-class'(ClickstreamListener.name) } } } def doWithSpring = {} def doWithDynamicMethods = {ctx -> HttpSession.metaClass.getClickStreams = {showBots = 'both' -> def clickstreams = servletContext.getAttribute('clickstreams') if (['true', 'false'].contains(showBots)) { clickstreams = clickstreams?.findAll {key, Clickstream stream -> def testA = (showBots == 'false' && stream.isBot()) def testB = (showBots == 'true' && !stream.isBot()) !(testA || testB) } } clickstreams } } def doWithApplicationContext = {applicationContext ->} def onChange = {event ->} def onConfigChange = {event ->} }