- Added the WebGUI stats system, which will allow site admins to submit

information about their site to a central repository on webgui.org which 
   help the developers make WebGUI better.
This commit is contained in:
JT Smith 2009-05-14 19:42:37 +00:00
parent 4e51bf02d9
commit b6da052e08
7 changed files with 226 additions and 13 deletions

View file

@ -9,6 +9,9 @@
- Added support for template attachments; scripts and stylesheets that will
be included using style->setScript and setLink instead of just using raw
head tags.
- Added the WebGUI stats system, which will allow site admins to submit
information about their site to a central repository on webgui.org which
help the developers make WebGUI better.
- fixed #10322: Dataform: wrong attr on script tag
- fixed #10336: postReceivedTemplateId not corrected in upgrade_7.6.0-7.6.1 (Jukka Raimovaara / Axxion Oy)
- fixed: Crud handling of Form fields with database types that cannot have default values.

View file

@ -22,6 +22,7 @@ use Getopt::Long;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset;
use WebGUI::Workflow;
use WebGUI::Utility;
my $toVersion = "7.7.6";
@ -36,6 +37,7 @@ fixDefaultPostReceived($session);
addEuVatDbColumns( $session );
addShippingDrivers( $session );
addTransactionTaxColumns( $session );
sendWebguiStats($session);
addDataFormColumns($session);
addListingsCacheTimeoutToMatrix( $session );
addSurveyFeedbackTemplateColumn( $session );
@ -54,13 +56,19 @@ finish($session);
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {
# my $session = shift;
# print "\tWe're doing some stuff here that you should know about... " unless $quiet;
# # and here's our code
# print "DONE!\n" unless $quiet;
#}
sub sendWebguiStats {
my $session = shift;
print "\tAdding a workflow to allow users to take part in the WebGUI stats project..." unless $quiet;
my $wf = WebGUI::Workflow->create($session, {
type => 'None',
mode => 'singleton',
title => 'Send WebGUI Stats',
description => 'This workflow sends some information about your site to the central WebGUI statistics repository. No personal information is sent. The information is used to help determine the future direction WebGUI should take.',
}, 'send_webgui_statistics');
my $act = $wf->addActivity('WebGUI::Workflow::Activity::SendWebguiStats','send_webgui_statistics');
$act->set('title', 'Send WebGUI Stats');
print "DONE!\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub addListingsCacheTimeoutToMatrix{

View file

@ -1137,7 +1137,7 @@ className='WebGUI::Asset::Sku::EMSTicket' and state='published' and revisionDate
# get a list of tickets already associated with the badge
my @existingTickets = $db->buildArray("select ticketAssetId from EMSRegistrantTicket where badgeId=?",[$badgeId]);
# get assets
my $counter = 0;
my $totalTickets = scalar(@ids);

View file

@ -186,6 +186,8 @@ sub getOperations {
'ssoViaSessionId' => 'SSO',
'disableSendWebguiStats' => 'Statistics',
'enableSendWebguiStats' => 'Statistics',
'viewStatistics' => 'Statistics',
'makePrintable' => 'Style',

View file

@ -14,7 +14,8 @@ use strict;
use WebGUI::AdminConsole;
use WebGUI::Cache;
use WebGUI::International;
use WebGUI::SQL;
use WebGUI::Workflow::Cron;
use WebGUI::DateTime;
=head1 NAME
@ -79,9 +80,54 @@ sub canView {
return $user->isInGroup( $session->setting->get("groupIdAdminStatistics") );
}
#-------------------------------------------------------------------
=head2 www_viewStatistics ( $session )
=head2 www_disableSendWebguiStats ()
Deletes the workflow schedule that sends WebGUI statistics to webgui.org.
=cut
sub www_disableSendWebguiStats {
my $session = shift;
my $task = WebGUI::Workflow::Cron->new($session, 'send_webgui_statistics');
$task->delete;
return www_viewStatistics($session);
}
#-------------------------------------------------------------------
=head2 www_enableSendWebguiStats ()
Creates the workflow schedule that sends WebGUI statistics to webgui.org.
=cut
sub www_enableSendWebguiStats {
my $session = shift;
# we set the current hour, minute, and day of week to send in the stats so we don't DOS webgui.org
# by having everybody sending it at the same time
my $dt = WebGUI::DateTime->new($session, time());
WebGUI::Workflow::Cron->create($session, {
enabled => 1,
workflowId => 'send_webgui_statistics',
minuteOfHour => $dt->minute,
hourOfDay => $dt->hour,
dayOfWeek => ($dt->dow % 7),
dayOfMonth => '*',
monthOfYear => '*',
priority => 3,
title => 'Send WebGUI Statistics',
}, 'send_webgui_statistics');
return www_viewStatistics($session);
}
#-------------------------------------------------------------------
=head2 www_viewStatistics ( $session, $sent )
Displays information to the user about WebGUI statistics if they are
in group Admin (3).
@ -128,8 +174,8 @@ Number of groups.
sub www_viewStatistics {
my $session = shift;
return $session->privilege->adminOnly() unless canView($session);
my ($output, $data);
return $session->privilege->adminOnly() unless canView($session);
my ($output, $data);
my $i18n = WebGUI::International->new($session);
my $url = "http://update.webgui.org/latest-version.txt";
my $cache = WebGUI::Cache->new($session,$url,"URL");
@ -159,7 +205,18 @@ sub www_viewStatistics {
($data) = $session->db->quickArray("select count(*) from groups");
$output .= '<tr><td align="right" class="tableHeader">'.$i18n->get(89).':</td><td class="tableData">'.$data.'</td></tr>';
$output .= '</table>';
return _submenu($session,$output);
$output .= q|<p>|.$i18n->get('why to send','Activity_SendWebguiStats').q|</p>|;
my $task = WebGUI::Workflow::Cron->new($session, 'send_webgui_statistics');
if (defined $task) {
$output .= q|<p><a href="|.$session->url->page("op=disableSendWebguiStats").q|">|.$i18n->get('disable','Activity_SendWebguiStats').q|</a></p>|;
}
else {
$output .= q|<p><a href="|.$session->url->page("op=enableSendWebguiStats").q|">|.$i18n->get('enable','Activity_SendWebguiStats').q|</a></p>|;
}
$output .= q|<p><a href="http://www.webgui.org/stats">http://www.webgui.org/stats</a></p>|;
return _submenu($session,$output);
}

View file

@ -0,0 +1,109 @@
package WebGUI::Workflow::Activity::SendWebguiStats;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2009 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Workflow::Activity';
use HTTP::Request;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
use Digest::MD5;
use Apache2::ServerUtil;
=head1 NAME
Package WebGUI::Workflow::Activity::SendWebguiStats
=head1 DESCRIPTION
This activity publishes information about your site to webgui.org. No private data is shared. The data is then rolled up on webgui.org/stats
=head1 SYNOPSIS
See WebGUI::Workflow::Activity for details on how to use any activity.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 definition ( session, definition )
See WebGUI::Workflow::Activity::defintion() for details.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session, "Activity_SendWebguiStats");
push(@{$definition}, {
name=>$i18n->get("topicName"),
properties=> {
}
});
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 execute ( [ object ] )
See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
my $object = shift;
my $instance = shift;
my $db = $self->session->db;
my $stats = {
webguiVersion => $WebGUI::VERSION,
perlVersion => sprintf "%vd", $^V,
apacheVersion => Apache2::ServerUtil::get_server_version(),
osType => $^O,
siteId => Digest::MD5::md5_base64($self->session->config->get("sitename")->[0]), # only here to identify the site if the user submits their info a second time
userCount => $db->quickScalar("select count(*) from users"),
groupCount => $db->quickScalar("select count(*) from groups"),
assetCount => $db->quickScalar("select count(*) from asset where state='published'"),
packageCount => $db->quickScalar("select count(distinct assetId) from assetData where isPackage=1"),
assetTypes => $db->buildArrayRefOfHashRefs("select count(*) as quantity,className from asset group by className"),
};
my $statsAsJson = JSON->new->encode($stats);
my $userAgent = new LWP::UserAgent;
$userAgent->env_proxy;
$userAgent->agent("WebGUI/".$WebGUI::VERSION);
$userAgent->timeout(30);
my $request = POST 'http://www.webgui.org/stats', [ func => 'receiveStats', stats => $statsAsJson ];
my $response = $userAgent->request($request);
if ($response->is_error) {
$self->session->errorHandler->error("WebGUI Stats could not be sent.");
}
return $self->COMPLETE;
}
1;
#vim:ft=perl

View file

@ -0,0 +1,34 @@
package WebGUI::i18n::English::Activity_SendWebguiStats;
use strict;
our $I18N = {
'why to send' => {
message => q|You can choose to send information about your WebGUI site to the central webgui.org stats repository. This helps the developers make WebGUI better by understanding the size of the sites out there, how quickly they grow, and what assets they use most. And you have nothing to worry about because no personally identifiable information is sent.|,
lastUpdated => 0,
context => q|A description of the stats program, what we're sending, and why it's important.|
},
'topicName' => {
message => q|Send WebGUI Statistics|,
lastUpdated => 0,
context => q|The title of the workflow activity.|
},
'enable' => {
message => q|Enable|,
lastUpdated => 0,
context => q|A link label to start the sending of stats.|
},
'disable' => {
message => q|Disable|,
lastUpdated => 0,
context => q|A link label to end the sending of stats.|
},
};
1;
#vim:ft=perl