From 4df4862c681c2090c28ad34d89dd828883f476bc Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 11 Feb 2009 17:11:24 -0800 Subject: [PATCH] Add an enable button, to disable Logging. Refactor out logging code into its own module for cleanliness. --- lib/WebGUI/Content/Asset.pm | 11 ++--------- lib/WebGUI/PassiveAnalytics/Flow.pm | 7 +++++++ lib/WebGUI/i18n/English/PassiveAnalytics.pm | 12 ++++++++++++ sbin/installPassiveAnalytics.pl | 3 ++- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/WebGUI/Content/Asset.pm b/lib/WebGUI/Content/Asset.pm index 064ffe411..64480777a 100644 --- a/lib/WebGUI/Content/Asset.pm +++ b/lib/WebGUI/Content/Asset.pm @@ -18,6 +18,7 @@ use strict; use LWP::MediaTypes qw(guess_media_type); use Time::HiRes; use WebGUI::Asset; +use WebGUI::PassiveAnalytics::Logging; use Apache2::Const -compile => qw(OK); @@ -171,15 +172,7 @@ sub page { } } ##Passive Analytics Logging - my $assetClass = $asset->get('className'); - $assetClass =~ s/^WebGUI::Asset:://; - if ( $assetClass ne 'Snippet' - && substr($assetClass,0,4) ne 'File') { - $session->db->write( - q|INSERT INTO `passiveLog` (userId, sessionId, assetId, timestamp, url) VALUES (?,?,?,?,?)|, - [ $session->user->userId, $session->getId, $asset->getId, time(), $session->request->unparsed_uri,] - ); - } + WebGUI::PassiveAnalytics::Logging::log($session, $asset); $output = tryAssetMethod($session,$asset,$method); $output = tryAssetMethod($session,$asset,"view") unless ($output || ($method eq "view")); diff --git a/lib/WebGUI/PassiveAnalytics/Flow.pm b/lib/WebGUI/PassiveAnalytics/Flow.pm index 10a4c33ea..6c9538d77 100644 --- a/lib/WebGUI/PassiveAnalytics/Flow.pm +++ b/lib/WebGUI/PassiveAnalytics/Flow.pm @@ -425,6 +425,12 @@ sub www_settings { label => $i18n->get('Delete Delta Table?'), hoverHelp => $i18n->get('Delete Delta Table? help'), ); + $f->yesNo( + name => 'enabled', + value => $session->form->get('enabled') || $session->setting->get('passiveAnalyticsEnabled') || 0, + label => $i18n->get('Enabled?'), + hoverHelp => $i18n->get('Enabled? help'), + ); $f->submit(); my $ac = WebGUI::AdminConsole->new($session,'passiveAnalytics'); $ac->addSubmenuItem($session->url->page('op=passiveAnalytics;func=editRuleflow'), $i18n->get('Passive Analytics')); @@ -445,6 +451,7 @@ sub www_settingsSave { my $form = $session->form; $session->setting->set('passiveAnalyticsInterval', $form->process('pauseInterval', 'integer')); $session->setting->set('passiveAnalyticsDeleteDelta', $form->process('deleteDelta', 'yesNo' )); + $session->setting->set('passiveAnalyticsEnabled', $form->process('enabled', 'yesNo' )); return www_settings($session); } diff --git a/lib/WebGUI/i18n/English/PassiveAnalytics.pm b/lib/WebGUI/i18n/English/PassiveAnalytics.pm index 1a0e9367e..4cca51390 100644 --- a/lib/WebGUI/i18n/English/PassiveAnalytics.pm +++ b/lib/WebGUI/i18n/English/PassiveAnalytics.pm @@ -123,6 +123,18 @@ home\?func=match, or
context => q|Button label to begin analyzing the logs.| }, + 'Enabled?' => { + message => q|Enable Passive Analytics?|, + lastUpdated => 0, + context => q|| + }, + + 'Enabled? help' => { + message => q|Passive Analytics will do no logging until enabled.|, + lastUpdated => 0, + context => q|| + }, + 'Regular Expression Error:' => { message => q|Regular Expression Error:|, lastUpdated => 0, diff --git a/sbin/installPassiveAnalytics.pl b/sbin/installPassiveAnalytics.pl index 82c819a35..cad304e45 100644 --- a/sbin/installPassiveAnalytics.pl +++ b/sbin/installPassiveAnalytics.pl @@ -95,13 +95,14 @@ sub installPassiveAnalyticsRule { } #---------------------------------------------------------------------------- -# Add the PassiveAnalytics Rule table +# Add the PassiveAnalytics Settings sub addPassiveAnalyticsSettings { my $session = shift; print "\tInstall Passive Analytics settings... "; # and here's our code $session->setting->add('passiveAnalyticsInterval', 300); $session->setting->add('passiveAnalyticsDeleteDelta', 0); + $session->setting->add('passiveAnalyticsEnabled', 0); print "DONE!\n"; }