"Fossies" - the Fresh Open Source Software Archive

Member "Open-Web-Analytics-1.7.0/modules/base/module.php" (16 Sep 2020, 82487 Bytes) of package /linux/www/Open-Web-Analytics-1.7.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "module.php" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.6.9_vs_1.7.0.

    1 <?php
    2 
    3 //
    4 // Open Web Analytics - An Open Source Web Analytics Framework
    5 //
    6 // Copyright 2006 Peter Adams. All rights reserved.
    7 //
    8 // Licensed under GPL v2.0 http://www.gnu.org/copyleft/gpl.html
    9 //
   10 // Unless required by applicable law or agreed to in writing, software
   11 // distributed under the License is distributed on an "AS IS" BASIS,
   12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13 // See the License for the specific language governing permissions and
   14 // limitations under the License.
   15 //
   16 // $Id$
   17 //
   18 
   19 require_once(OWA_BASE_DIR.'/owa_module.php');
   20 
   21 /**
   22  * Base Package Module
   23  * 
   24  * @author      Peter Adams <peter@openwebanalytics.com>
   25  * @copyright   Copyright &copy; 2006 Peter Adams <peter@openwebanalytics.com>
   26  * @license     http://www.gnu.org/copyleft/gpl.html GPL v2.0
   27  * @category    owa
   28  * @package     owa
   29  * @version        $Revision$
   30  * @since        owa 1.0.0
   31  */
   32 
   33 class owa_baseModule extends owa_module {
   34 
   35     /**
   36      * Constructor
   37      *
   38      */
   39     function __construct() {
   40 
   41         $this->name = 'base';
   42         $this->display_name = 'Open Web Analytics';
   43         $this->group = 'Base';
   44         $this->author = 'Peter Adams';
   45         $this->version = 10;
   46         $this->description = 'Base functionality for OWA.';
   47         $this->config_required = false;
   48         $this->required_schema_version = 10;
   49         return parent::__construct();
   50     }
   51 
   52     function init() {
   53 
   54         // create event queues
   55 
   56         // register queue type implementations
   57         $this->registerImplementation('event_queue_types', 'file', 'owa_fileEventQueue', 'classes/fileEventQueue.php');
   58         $this->registerImplementation('event_queue_types', 'database', 'owa_dbEventQueue', 'classes/dbEventQueue.php');
   59         $this->registerImplementation('event_queue_types', 'http', 'owa_httpEventQueue', 'classes/httpEventQueue.php');
   60 
   61         // register named queues
   62         $this->registerEventQueue( 'incoming_tracking_events', array(
   63 
   64             'queue_type'            =>     'file',
   65             'path'                    =>    owa_coreAPI::getSetting('base', 'async_log_dir'),
   66             'rotation_interval'        => 3600
   67         ));
   68 
   69         $this->registerEventQueue( 'processing', array(
   70 
   71             'queue_type'            => 'database',
   72             'server'                => owa_coreAPI::getSetting('base', 'db_host'),
   73             'port'                    => owa_coreAPI::getSetting('base', 'db_port'),
   74             'username'                => owa_coreAPI::getSetting('base', 'db_user'),
   75             'password'                => owa_coreAPI::getSetting('base', 'db_password')
   76         ));
   77 
   78         $this->setupTrackingProperties();
   79 
   80     }
   81 
   82     /**
   83      * Register Tracking Event Properties
   84      *
   85      *
   86      */
   87 
   88      public function setupTrackingProperties() {
   89 
   90          $environmental = array(
   91 
   92             'REMOTE_HOST'        => array(
   93                 'callbacks'            => array( 'owa_trackingEventHelpers::remoteHostDefault' ),
   94                 'default_value'        => '(not set)',
   95                 'required'            => true,
   96                 'data_type'            => 'string',
   97                 'filter'            => true
   98             ),
   99 
  100             'HTTP_USER_AGENT'    => array(
  101                 'callbacks'            => array( 'owa_trackingEventHelpers::userAgentDefault' ),
  102                 'default_value'        => '(not set)',
  103                 'required'            => true,
  104                 'data_type'            => 'string',
  105                 'filter'            => true
  106             ),
  107 
  108             'HTTP_HOST'            => array(
  109                 'callbacks'            => array( 'owa_trackingEventHelpers::httpHostDefault' ),
  110                 'default_value'        => '(not set)',
  111                 'required'            => true,
  112                 'data_type'            => 'string',
  113                 'filter'            => true
  114             ),
  115 
  116             'language'            => array(
  117                 'callbacks'            => array( 'owa_trackingEventHelpers::languageDefault' ),
  118                 'default_value'        => '(not set)',
  119                 'required'            => true,
  120                 'data_type'            => 'string',
  121                 'filter'            => true
  122             ),
  123 
  124             'ip_address'        => array(
  125                 'callbacks'            => array( 'owa_trackingEventHelpers::ipAddressDefault' ),
  126                 'default_value'        => '(not set)',
  127                 'required'            => true,
  128                 'data_type'            => 'string',
  129                 'filter'            => true
  130             ),
  131 
  132             'timestamp'            => array(
  133                 'callbacks'            => array( 'owa_trackingEventHelpers::timestampDefault' ),
  134                 'default_value'        => '(not set)',
  135                 'required'            => true,
  136                 'data_type'            => 'integer',
  137                 'filter'            => false
  138             ),
  139 
  140             'microtime'            => array(
  141                 'callbacks'            => array( 'owa_trackingEventHelpers::microtimeDefault' ),
  142                 'default_value'        => '(not set)',
  143                 'required'            => true,
  144                 'data_type'            => 'string',
  145                 'filter'            => false
  146             )
  147 
  148         );
  149 
  150         $this->registerTrackingProperties( 'environmental', $environmental );
  151 
  152         $regular = array(
  153 
  154             'page_type'                        => array(
  155                 'default_value'                    => '(not set)',
  156                 'required'                        => true,
  157                 'data_type'                        => 'string'
  158             ),
  159 
  160             'page_url'                        => array(
  161                 'default_value'                    => '(not set)',
  162                 'required'                        => true,
  163                 'data_type'                        => 'url',
  164                 'callbacks'                        => array( 'owa_trackingEventHelpers::makeUrlCanonical' )
  165             ),
  166 
  167             'page_title'                     => array(
  168                 'required'                        => true,
  169                 'callbacks'                        => array( 'owa_trackingEventHelpers::utfEncodeProperty' ),
  170                 'data_type'                        => 'string',
  171                 'default_value'                    => '(not set)'
  172             ),
  173 
  174             'days_since_first_session'         => array(
  175                 'required'                        => true,
  176                 'callbacks'                        => array( ),
  177                 'data_type'                        => 'integer',
  178                 'default_value'                    => false,
  179                 'alternative_key'                => 'dsfs'
  180             ),
  181 
  182             'days_since_prior_session'         => array(
  183                 'required'                        => true,
  184                 'callbacks'                        => array( ),
  185                 'data_type'                        => 'integer',
  186                 'default_value'                    => false,
  187                 'alternative_key'                => 'dsps'
  188             ),
  189 
  190             'num_prior_sessions'             => array(
  191                 'required'                        => true,
  192                 'callbacks'                        => array( ),
  193                 'data_type'                        => 'integer',
  194                 'default_value'                    => false,
  195                 'alternative_key'                => 'nps'
  196             ),
  197 
  198             'is_new_visitor'                => array (
  199                 'required'                        => true,
  200                 'data_type'                        => 'boolean',
  201                 ' default_value'                => false
  202             ),
  203 
  204             'user_name'                        => array(
  205                 'required'                        => true,
  206                 'callbacks'                        => array( 'owa_trackingEventHelpers::setUserName' ),
  207                 'default_value'                    => '(not set)'
  208             ),
  209 
  210             'user_email'                    => array(
  211                 'required'                        => true,
  212                 'callbacks'                        => array( 'owa_trackingEventHelpers::setEmailAddress' ),
  213                 'default_value'                    => '(not set)',
  214                 'alternative_key'                => 'email_address'
  215             ),
  216 
  217             'HTTP_REFERER'                    => array(
  218                 'required'                        => false,
  219                 'data_type'                        => 'url',
  220                 'callbacks'                        => array()
  221             ),
  222 
  223             'target_url'                    => array(
  224                 'required'                        => false,
  225                 'data_type'                        => 'url',
  226                 'callbacks'                        => array( 'owa_trackingEventHelpers::makeUrlCanonical' )
  227             ),
  228 
  229             'source'                        => array(
  230                 'required'                        => true,
  231                 'data_type'                        => 'string',
  232                 'callbacks'                        => array( 'owa_trackingEventHelpers::lowercaseString' ),
  233                 'default_value'                    => '(not set)'
  234             ),
  235 
  236             'medium'                        => array(
  237                 'required'                        => true,
  238                 'data_type'                        => 'string',
  239                 'callbacks'                        => array( 'owa_trackingEventHelpers::lowercaseString' ),
  240                 'default_value'                    => '(not set)'
  241             ),
  242 
  243             'session_referer'                => array(
  244                 'required'                        => false,
  245                 'data_type'                        => 'url',
  246                 'callbacks'                        => array()
  247             ),
  248             // @todo investigate if this should be a required property so that a proper join can occur.
  249             'search_terms'                    => array(
  250                 'required'                        => false,
  251                 'callbacks'                        => array( 'owa_trackingEventHelpers::setSearchTerms' ),
  252                 'default_value'                    => '(not set)'
  253 
  254             ),
  255 
  256             'feed_subscription_id'                    => array(
  257                 'required'                        => false,
  258                 'callbacks'                        => array( ),
  259                 'default_value'                    => null,
  260                 'alternative_key'                => 'sid'
  261             ),
  262 
  263             'attribs'                        => array(
  264                 'required'                        => false,
  265                 'data_type'                        => 'json',
  266                 'callbacks'                        => '',
  267                 'default_value'                    => ''
  268             )
  269 
  270         );
  271 
  272         $this->registerTrackingProperties( 'regular', $regular );
  273 
  274         $derived = array(
  275 
  276             'year'                 => array(
  277                 'required'            => true,
  278                 'callbacks'            => array('owa_trackingEventHelpers::deriveYear')
  279             ),
  280 
  281             'month'             => array(
  282                 'required'            => true,
  283                 'callbacks'            => array('owa_trackingEventHelpers::deriveMonth')
  284             ),
  285 
  286             'day'                 => array(
  287                 'required'            => true,
  288                 'callbacks'            => array('owa_trackingEventHelpers::deriveDay')
  289             ),
  290 
  291             'yyyymmdd'             => array(
  292                 'required'            => true,
  293                 'callbacks'            => array('owa_trackingEventHelpers::deriveYyyymmdd')
  294             ),
  295 
  296             'dayofweek'         => array(
  297                 'required'            => true,
  298                 'callbacks'            => array('owa_trackingEventHelpers::deriveDayOfWeek')
  299             ),
  300 
  301             'dayofyear'         => array(
  302                 'required'            => true,
  303                 'callbacks'            => array('owa_trackingEventHelpers::deriveDayOfYear')
  304             ),
  305 
  306             'weekofyear'         => array(
  307                 'required'            => true,
  308                 'callbacks'            => array('owa_trackingEventHelpers::deriveWeekOfYear')
  309             ),
  310 
  311             'hour'                 => array(
  312                 'required'            => true,
  313                 'callbacks'            => array('owa_trackingEventHelpers::deriveHour')
  314             ),
  315 
  316             'minute'             => array(
  317                 'required'            => true,
  318                 'callbacks'            => array('owa_trackingEventHelpers::deriveMinute')
  319             ),
  320 
  321             'second'             => array(
  322                 'required'            => true,
  323                 'callbacks'            => array('owa_trackingEventHelpers::deriveSecond')
  324             ),
  325 
  326             'sec'                 => array(
  327                 'required'            => true,
  328                 'callbacks'            => array('owa_trackingEventHelpers::deriveSec')
  329             ),
  330 
  331             'msec'                 => array(
  332                 'required'            => true,
  333                 'callbacks'            => array('owa_trackingEventHelpers::deriveMsec')
  334             ),
  335 
  336             'page_uri'             => array(
  337                 'required'            => true,
  338                 'callbacks'            => array('owa_trackingEventHelpers::derivePageUri')
  339             ),
  340 
  341             'is_repeat_visitor' => array(
  342                 'required'            => true,
  343                 'callbacks'            => array('owa_trackingEventHelpers::setRepeatVisitorFlag')
  344             ),
  345 
  346             'full_host'            => array(
  347                 'required'            => true,
  348                 'callbacks'            => array('owa_trackingEventHelpers::resolveFullHost'),
  349                 'default_value'        => '(not set)'
  350             ),
  351 
  352             'host'                => array(
  353                 'required'            => true,
  354                 'callbacks'            => array('owa_trackingEventHelpers::getHostDomain'),
  355                 'default_value'        => '(not set)'
  356             ),
  357 
  358             'browser_type'        => array(
  359                 'required'            => true,
  360                 'callbacks'            => array('owa_trackingEventHelpers::resolveBrowserType')
  361             ),
  362 
  363             'is_browser'        => array(
  364                 'required'            => true,
  365                 'callbacks'            => array('owa_trackingEventHelpers::isBrowser'),
  366                 'default_value'        => false
  367             ),
  368 
  369             'browser'            => array(
  370                 'required'            => true,
  371                 'callbacks'            => array('owa_trackingEventHelpers::resolveBrowserVersion'),
  372                 'default_value'        => '(unknown)'
  373             ),
  374 
  375             'is_robot'            => array(
  376                 'required'            => true,
  377                 'callbacks'            => array('owa_trackingEventHelpers::isRobot'),
  378                 'default_value'        => false
  379             ),
  380 
  381             'os'                => array(
  382                 'required'            => true,
  383                 'callbacks'            => array( 'owa_trackingEventHelpers::resolveOs' ),
  384                 'default_value'        => '(unknown)'
  385             ),
  386 
  387             'is_entry_page'        => array(
  388                 'required'            => true,
  389                 'callbacks'            => array( 'owa_trackingEventHelpers::resolveEntryPage' ),
  390                 'default_value'        => false
  391             ),
  392 
  393             'country'            => array(
  394                 'required'            => true,
  395                 'callbacks'            => array( 'owa_trackingEventHelpers::resolveCountry' ),
  396                 'default_value'        => false
  397             ),
  398 
  399             'city'                => array(
  400                 'required'            => true,
  401                 'callbacks'            => array( 'owa_trackingEventHelpers::resolveCity' ),
  402                 'default_value'        => false
  403             ),
  404 
  405             'state'                => array(
  406                 'required'            => true,
  407                 'callbacks'            => array( 'owa_trackingEventHelpers::resolveState' ),
  408                 'default_value'        => false
  409             ),
  410 
  411             'latitude'            => array(
  412                 'required'            => true,
  413                 'callbacks'            => array( 'owa_trackingEventHelpers::resolveLatitude' ),
  414                 'default_value'        => false
  415             ),
  416 
  417             'longitude'            => array(
  418                 'required'            => true,
  419                 'callbacks'            => array( 'owa_trackingEventHelpers::resolveLongitude' ),
  420                 'default_value'        => false
  421             ),
  422 
  423             'country_code'        => array(
  424                 'required'            => true,
  425                 'callbacks'            => array( 'owa_trackingEventHelpers::resolveCountryCode' ),
  426                 'default_value'        => false
  427             ),
  428 
  429             'prior_page'        => array(
  430                 'required'            => true,
  431                 'callbacks'            => array( 'owa_trackingEventHelpers::setPriorPage', 'owa_trackingEventHelpers::makeUrlCanonical' ),
  432                 'default_value'        => false
  433             ),
  434             //related object IDs
  435             /* @todo these should really be moved to handlers and logic encoded in entity objects.*/
  436 
  437             'document_id'         => array(
  438 
  439                 'alternative_key'    => 'page_url',
  440                 'callbacks'            => 'owa_trackingEventHelpers::generateDimensionId'
  441             ),
  442 
  443             'ua_id'             => array(
  444 
  445                 'alternative_key'    => 'HTTP_USER_AGENT',
  446                 'callbacks'            => 'owa_trackingEventHelpers::generateDimensionId'
  447             ),
  448 
  449             'location_id'         => array(
  450 
  451                 'alternative_key'    => 'country',
  452                 'callbacks'            => 'owa_trackingEventHelpers::generateLocationId'
  453             ),
  454 
  455             'host_id'             => array(
  456 
  457                 'alternative_key'    => 'host',
  458                 'callbacks'            => 'owa_trackingEventHelpers::generateDimensionId'
  459             ),
  460 
  461             'os_id'             => array(
  462 
  463                 'alternative_key'    => 'os',
  464                 'callbacks'            => 'owa_trackingEventHelpers::generateDimensionId'
  465             ),
  466 
  467             'campaign_id'         => array(
  468 
  469                 'alternative_key'    => 'campaign',
  470                 'callbacks'            => 'owa_trackingEventHelpers::generateDimensionId'
  471             ),
  472 
  473             'ad_id'             => array(
  474 
  475                 'alternative_key'    => 'ad',
  476                 'callbacks'            => 'owa_trackingEventHelpers::generateDimensionId'
  477             ),
  478 
  479             'source_id'         => array(
  480 
  481                 'alternative_key'    => 'source',
  482                 'callbacks'            => 'owa_trackingEventHelpers::generateDimensionId'
  483             ),
  484 
  485             'referer_id'         => array(
  486 
  487                 'alternative_key'    => 'session_referer',
  488                 'callbacks'            => 'owa_trackingEventHelpers::generateDimensionId'
  489             ),
  490 
  491             'referring_search_term_id' => array(
  492 
  493                 'alternative_key'    => 'search_terms',
  494                 'callbacks'            => 'owa_trackingEventHelpers::generateDimensionId'
  495             )
  496         );
  497 
  498         $this->registerTrackingProperties( 'derived', $derived );
  499 
  500      }
  501 
  502     /**
  503      * Register Filters
  504      *
  505      * The following lines register filter methods.
  506      */
  507     function registerFilters() {
  508 
  509         if ( defined( 'OWA_MAIL_EXCEPTIONS' ) ) {
  510 
  511             $this->registerFilter('post_processed_tracking_event', $this, 'checkEventForType');
  512         }
  513 
  514         $this->registerFilter('tracker_tag_cmds', $this, 'addTrackerCmds', 0);
  515     }
  516 
  517     function addTrackerCmds( $cmds ) {
  518 
  519         $cmds[] = "owa_cmds.push(['trackPageView']);";
  520         $cmds[] = "owa_cmds.push(['trackClicks']);";
  521 
  522         return $cmds;
  523     }
  524 
  525     /**
  526      * Register Background jobs
  527      *
  528      * The following lines register background jobs used by the
  529      * background daemon.
  530      */
  531     function registerBackgroundJobs() {
  532 
  533         // event procesing daemon jobs
  534         $this->registerBackgroundJob('process_event_queue', 'cli.php cmd=processEventQueue', owa_coreAPI::getSetting('base', 'processQueuesJobSchedule'), 10);
  535     }
  536 
  537     /**
  538      * Register CLI Commands
  539      *
  540      * The following lines register various command line interface (CLI) controller.
  541      */
  542     function registerCliCommands() {
  543 
  544         $this->registerCliCommand('update', 'base.updatesApplyCli');
  545         $this->registerCliCommand('build', 'base.build');
  546         $this->registerCliCommand('flush-cache', 'base.flushCacheCli');
  547         $this->registerCliCommand('processEventQueue', 'base.processEventQueue');
  548         $this->registerCliCommand('install', 'base.installCli');
  549         $this->registerCliCommand('activate', 'base.moduleActivateCli');
  550         $this->registerCliCommand('deactivate', 'base.moduleDeactivateCli');
  551         $this->registerCliCommand('install-module', 'base.moduleInstallCli');
  552         $this->registerCliCommand('add-site', 'base.sitesAddCli');
  553         $this->registerCliCommand('flush-processed-events', 'base.flushProcessedEventsCli');
  554         $this->registerCliCommand('prune-event-queue-archives', 'base.pruneEventQueueArchivesCli');
  555         $this->registerCliCommand('change-password', 'base.changeUserPasswordCli');
  556         $this->registerCliCommand('update-referral', 'base.crawlReferralCli');
  557         $this->registerCliCommand('update-document', 'base.crawlDocumentCli');
  558     }
  559 
  560     /**
  561      * Register API methods
  562      *
  563      * The following lines register various API methods.
  564      */
  565     function registerApiMethods() {
  566 
  567         $this->registerRestApiRoute( 'v1', 'sites', 'GET', 'owa_sitesRestController', 'controllers/sitesRestController.php' );
  568         $this->registerRestApiRoute( 'v1', 'sites', 'POST', 'owa_addSiteRestController', 'controllers/addSiteRestController.php' );
  569         $this->registerRestApiRoute( 'v1', 'users', 'GET', 'owa_usersRestController', 'controllers/usersRestController.php' );
  570         $this->registerRestApiRoute( 'v1', 'users', 'POST', 'owa_addUserRestController', 'controllers/addUserRestController.php' );
  571         $this->registerRestApiRoute( 'v1', 'users', 'DELETE', 'owa_deleteUserRestController', 'controllers/deleteUserRestController.php', [ 'params_order' => ['user_id'] ] );
  572         $this->registerRestApiRoute( 'v1', 'siteUsers', 'POST', 'owa_siteAddAllowedUserRestController', 'controllers/siteAddAllowedUserRestController.php' );
  573         $this->registerRestApiRoute( 'v1', 'reports', 'GET', 'owa_reportsRestController', 'controllers/reportsRestController.php', [ 'params_order' => ['report_name'] ] );
  574     }
  575 
  576     /**
  577      * Registers Admin panels
  578      *
  579      */
  580     function registerAdminPanels() {
  581 
  582         $this->addAdminPanel(array(
  583                 'do'             => 'base.optionsGeneral',
  584                 'priviledge'     => 'admin',
  585                 'anchortext'     => 'Main Configuration',
  586                 'group'            => 'General',
  587                 'order'            => 1)
  588         );
  589 
  590         $this->addAdminPanel(array(
  591                 'do'             => 'base.users',
  592                 'priviledge'     => 'admin',
  593                 'anchortext'     => 'User Management',
  594                 'group'            => 'General',
  595                 'order'            => 2)
  596         );
  597 
  598 
  599 
  600         $this->addAdminPanel(array(
  601                 'do'             => 'base.sites',
  602                 'priviledge'     => 'admin',
  603                 'anchortext'     => 'Tracked Sites',
  604                 'group'            => 'General',
  605                 'order'            => 3)
  606         );
  607 
  608         $this->addAdminPanel(array(
  609                 'do'             => 'base.optionsModules',
  610                 'priviledge'     => 'admin',
  611                 'anchortext'     => 'Modules',
  612                 'group'            => 'General',
  613                 'order'            => 3)
  614         );
  615 
  616         /*
  617         $this->addAdminPanel(array(
  618                 'do'             => 'base.optionsGoals',
  619                 'priviledge'     => 'admin',
  620                 'anchortext'     => 'Goal Settings',
  621                 'group'            => 'General',
  622                 'order'            => 3)
  623         );
  624         */
  625     }
  626 
  627 
  628     /**
  629      * Register Metrics
  630      *
  631      * The following lines register various data metrics.
  632      */
  633     function registerMetrics() {
  634 
  635         $fact_table_entities = array(
  636             'base.session',
  637             'base.request',
  638             'base.action_fact',
  639             'base.domstream',
  640             'base.click',
  641             'base.commerce_transaction_fact',
  642             'base.commerce_line_item_fact'
  643         );
  644 
  645         // page views
  646         $this->registerMetricDefinition(array(
  647             'name'            => 'pageViews',
  648             'label'            => 'Page Views',
  649             'description'    => 'The total number of pages viewed.',
  650             'group'            => 'Site Usage',
  651             'entity'        => 'base.request',
  652             'metric_type'    => 'count',
  653             'data_type'        => 'integer',
  654             'column'        => 'id'
  655 
  656         ));
  657 
  658         $this->registerMetricDefinition(array(
  659             'name'            => 'pageViews',
  660             'label'            => 'Page Views',
  661             'description'    => 'The total number of pages viewed.',
  662             'group'            => 'Site Usage',
  663             'entity'        => 'base.session',
  664             'metric_type'    => 'sum',
  665             'data_type'        => 'integer',
  666             'column'        => 'num_pageviews'
  667 
  668         ));
  669 
  670 
  671         // unique visitors
  672         foreach($fact_table_entities as $factEntity ) {
  673 
  674             $this->registerMetricDefinition(array(
  675                 'name'            => 'uniqueVisitors',
  676                 'label'            => 'Unique Visitors',
  677                 'description'    => 'The total number of unique visitors.',
  678                 'group'            => 'Site Usage',
  679                 'entity'        => $factEntity,
  680                 'metric_type'    => 'distinct_count',
  681                 'data_type'        => 'integer',
  682                 'column'        => 'visitor_id'
  683 
  684             ));
  685             
  686             $this->registerMetricDefinition(array(
  687                 'name'            => 'visitors',
  688                 'label'            => 'Visitors',
  689                 'description'    => 'The total number of visitors.',
  690                 'group'            => 'Site Usage',
  691                 'entity'        => $factEntity,
  692                 'metric_type'    => 'count',
  693                 'data_type'        => 'integer',
  694                 'column'        => 'visitor_id'
  695 
  696             ));
  697 
  698         }
  699 
  700         // visits
  701 
  702 
  703             // owa_session uses a different column name and has it's own metric registration above.
  704                 $this->registerMetricDefinition(array(
  705                     'name'            => 'visits',
  706                     'label'            => 'Visits',
  707                     'description'    => 'The total number of visits/sessions.',
  708                     'group'            => 'Site Usage',
  709                     'entity'        => 'base.session',
  710                     'metric_type'    => 'distinct_count', // 'count', 'distinct_count', 'sum', or 'calculated'
  711                     'data_type'        => 'integer', // 'integrer', 'currency'
  712                     'column'        => 'id'
  713 
  714                 ));
  715 
  716                 $this->registerMetricDefinition(array(
  717                     'name'            => 'visits',
  718                     'label'            => 'Visits',
  719                     'description'    => 'The total number of visits/sessions.',
  720                     'group'            => 'Site Usage',
  721                     'entity'        => 'base.request',
  722                     'metric_type'    => 'distinct_count', // 'count', 'distinct_count', 'sum', or 'calculated'
  723                     'data_type'        => 'integer', // 'integrer', 'currency'
  724                     'column'        => 'session_id'
  725 
  726                 ));
  727 
  728 /*
  729         $this->registerMetric(
  730             'visitors',
  731             array(
  732                 'base.visitors',
  733                 'base.visitorsFromRequestFact'
  734             ),
  735             '',
  736             'Visitors',
  737             'The total number of visitors',
  738             'Site Usage'
  739         );
  740 */
  741         $this->registerMetric(
  742             'newVisitors',
  743             'base.newVisitors',
  744             '',
  745             'New Visitors',
  746             'The total number of new visitors',
  747             'Site Usage'
  748         );
  749 
  750 
  751         $this->registerMetric(
  752             'repeatVisitors',
  753             'base.repeatVisitors',
  754             '',
  755             'Repeat Visitors',
  756             'The total number of repeat visitors',
  757             'Site Usage'
  758         );
  759 
  760         $this->registerMetric(
  761             'bounces',
  762             'base.bounces',
  763             '',
  764             'Bounces',
  765             'The total number of visits with a single page view',
  766             'Site Usage'
  767         );
  768 
  769         $this->registerMetric(
  770             'visitDuration',
  771             'base.visitDuration',
  772             '',
  773             'Visit Duration',
  774             'The average duration of visits.',
  775             'Site Usage'
  776         );
  777 
  778         $this->registerMetric(
  779             'uniquePageViews',
  780             'base.uniquePageViews',
  781             '',
  782             'Unique Page Views',
  783             'The total number of unique pages viewed.',
  784             'Site Usage'
  785         );
  786 
  787         $this->registerMetric(
  788             'bounceRate',
  789             'base.bounceRate',
  790             '',
  791             'Bounce Rate',
  792             'The percentage of visits that were bounces.',
  793             'Site Usage'
  794         );
  795 
  796         $this->registerMetric(
  797             'pagesPerVisit',
  798             'base.pagesPerVisit',
  799             '',
  800             'Pages Per Visit',
  801             'The average pages viewed per visit.',
  802             'Site Usage'
  803         );
  804 
  805         $this->registerMetric(
  806             'actions',
  807             'base.actions',
  808             '',
  809             'Actions',
  810             'The total number of action events.',
  811             'Actions'
  812         );
  813 
  814         $this->registerMetric(
  815             'uniqueActions',
  816             'base.uniqueActions',
  817             '',
  818             'Unique Actions',
  819             'Total number of unique action events.',
  820             'Actions'
  821         );
  822 
  823         $this->registerMetric(
  824             'actionsValue',
  825             'base.actionsValue',
  826             '',
  827             'Action Value',
  828             'Total value of all action events.',
  829             'Actions'
  830         );
  831 
  832         $this->registerMetric(
  833             'feedRequests',
  834             'base.feedRequests',
  835             '',
  836             'Feed Requests',
  837             'Total number of feed requests.',
  838             'Feeds'
  839         );
  840 
  841         $this->registerMetric(
  842             'feedReaders',
  843             'base.feedReaders',
  844             '',
  845             'Feed Readers',
  846             'Total number of feed readers.',
  847             'Feeds'
  848         );
  849 
  850         $this->registerMetric(
  851             'feedSubscriptions',
  852             'base.feedSubscriptions',
  853             '',
  854             'Feed Subscriptions',
  855             'Total number of feed subscribers.',
  856             'Feeds'
  857         );
  858 
  859         // goals
  860         $gcount = owa_coreAPI::getSetting('base', 'numGoals');
  861         for ($num = 1; $num <= $gcount;$num++) {
  862             $params = array('goal_number' => $num);
  863 
  864             $metric_name = 'goal'.$num.'Completions';
  865             $this->registerMetric(
  866                 $metric_name,
  867                 'base.goalNCompletions',
  868                 $params,
  869                 "Goal $num Completions",
  870                 "The total number of goal $num completions.",
  871                 'Goals'
  872             );
  873 
  874             $metric_name = 'goal'.$num.'Starts';
  875             $this->registerMetric(
  876                 $metric_name,
  877                 'base.goalNStarts',
  878                 $params,
  879                 "Goal $num Starts",
  880                 "The total number of goal $num starts.",
  881                 'Goals'
  882             );
  883 
  884             $metric_name = 'goal'.$num.'Value';
  885             $this->registerMetric(
  886                 $metric_name,
  887                 'base.goalNValue',
  888                 $params,
  889                 "Goal $num Value",
  890                 "The total value of goal $num achieved.",
  891                 'Goals'
  892             );
  893         }
  894 
  895         $this->registerMetric(
  896             'goalCompletionsAll',
  897             'base.goalCompletionsAll',
  898             '',
  899             'Goal Completions',
  900             'The total number of goal completions.',
  901             'Goals'
  902         );
  903 
  904         $this->registerMetric(
  905             'goalStartsAll',
  906             'base.goalStartsAll',
  907             '',
  908             'Goal Starts',
  909             'The total number of goal starts.',
  910             'Goals'
  911         );
  912 
  913         $this->registerMetric(
  914             'goalValueAll',
  915             'base.goalValueAll',
  916             '',
  917             'Goal Value',
  918             'The total value of all goals achieved.',
  919             'Goals'
  920         );
  921 
  922         $this->registerMetric(
  923             'goalConversionRateAll',
  924             'base.goalConversionRateAll',
  925             '',
  926             'Goal Conversion Rate',
  927             'The rate of goals achieved in all visits.',
  928             'Goals'
  929         );
  930 
  931         $this->registerMetric(
  932             'goalAbandonRateAll',
  933             'base.goalAbandonRateAll',
  934             '',
  935             'Goal Abandon Rate',
  936             'The rate of goal abandons in all visits.',
  937             'Goals'
  938         );
  939 
  940         // ecommerce metrics
  941         $this->registerMetric(
  942             'lineItemQuantity',
  943             array(
  944                 'base.lineItemQuantity',
  945                 'base.lineItemQuantityFromSessionFact'
  946             ),
  947             '',
  948             'Item Quantity',
  949             'The total umber of items purchased.',
  950             'E-commerce'
  951         );
  952 
  953         $this->registerMetric(
  954             'lineItemRevenue',
  955             array(
  956                 'base.lineItemRevenue',
  957                 'base.lineItemRevenueFromSessionFact'
  958             ),
  959             '',
  960             'Item Revenue',
  961             'Total revenue from items purchased.',
  962             'E-commerce'
  963         );
  964 
  965         $this->registerMetric(
  966             'transactions',
  967             array(
  968                 'base.transactions',
  969                 'base.transactionsFromSessionFact'
  970             ),
  971             '',
  972             'Transactions',
  973             'Total number of transactions.',
  974             'E-commerce'
  975         );
  976 
  977         $this->registerMetric(
  978             'transactionRevenue',
  979             array(
  980                 'base.transactionRevenue',
  981                 'base.transactionRevenueFromSessionFact'
  982             ),
  983             '',
  984             'Revenue',
  985             'Total revenue from all transactions.',
  986             'E-commerce'
  987         );
  988 
  989         $this->registerMetric(
  990             'taxRevenue',
  991             array(
  992                 'base.taxRevenue',
  993                 'base.taxRevenueFromSessionFact'
  994             ),
  995             '',
  996             'Tax Revenue',
  997             'Total revenue from taxes.',
  998             'E-commerce'
  999         );
 1000 
 1001         $this->registerMetric(
 1002             'shippingRevenue',
 1003             array(
 1004                 'base.shippingRevenue',
 1005                 'base.shippingRevenueFromSessionFact'
 1006             ),
 1007             '',
 1008             'Shipping Revenue',
 1009             'Total revenue from shipping.',
 1010             'E-commerce'
 1011         );
 1012 
 1013         $this->registerMetric(
 1014             'uniqueLineItems',
 1015             array(
 1016                 'base.uniqueLineItems',
 1017                 'base.uniqueLineItemsFromSessionFact'
 1018             ),
 1019             '',
 1020             'Unique Items',
 1021             'Total number of unique items purchased.',
 1022             'E-commerce'
 1023         );
 1024 
 1025         $this->registerMetric(
 1026             'revenuePerTransaction',
 1027             'base.revenuePerTransaction',
 1028             '',
 1029             'Revenue Per Transaction',
 1030             'Average revenue per transaction.',
 1031             'E-commerce'
 1032         );
 1033 
 1034         $this->registerMetric(
 1035             'revenuePerVisit',
 1036             'base.revenuePerVisit',
 1037             '',
 1038             'Revenue Per Visit',
 1039             'Average revenue generated per visit.',
 1040             'E-commerce'
 1041         );
 1042 
 1043         $this->registerMetric(
 1044             'ecommerceConversionRate',
 1045             'base.ecommerceConversionRate',
 1046             '',
 1047             'E-commerce Conversion Rate',
 1048             'The rate of visits that resulted in an e-commerce transaction.',
 1049             'E-commerce');
 1050 
 1051         $this->registerMetric(
 1052             'domClicks',
 1053             'base.domClicks',
 1054             '',
 1055             'Clicks',
 1056             'Total number of clicks on DOM elements.',
 1057             'Clicks'
 1058         );
 1059     }
 1060 
 1061     /**
 1062      * Register Dimensions
 1063      *
 1064      * The following lines register various data dimensions.
 1065      * To register a dimenison use the registerDimension method.
 1066      * See owa_module class for documentation on this method.
 1067      */
 1068     function registerDimensions() {
 1069 
 1070         // fact table entity names used by a number of dimensions.
 1071         $fact_table_entities = array(
 1072             'base.action_fact',
 1073             'base.request',
 1074             'base.session',
 1075             'base.domstream',
 1076             'base.click',
 1077             'base.commerce_transaction_fact',
 1078             'base.commerce_line_item_fact'
 1079         );
 1080 
 1081 
 1082         // Time Dimensions
 1083         $this->registerDimension(
 1084             'date',
 1085             $fact_table_entities,
 1086             'yyyymmdd',
 1087             'Date',
 1088             'time',
 1089             'The full date.',
 1090             '',
 1091             true,
 1092             'yyyymmdd'
 1093         );
 1094 
 1095         $this->registerDimension(
 1096             'day',
 1097             $fact_table_entities,
 1098             'day',
 1099             'Day',
 1100             'time',
 1101             'The day of the month (1-31).',
 1102             '',
 1103             true
 1104         );
 1105 
 1106         $this->registerDimension(
 1107             'month',
 1108             $fact_table_entities,
 1109             'month',
 1110             'Month',
 1111             'time',
 1112             'The month of the year (1-12).',
 1113             '',
 1114             true,
 1115             'yyyymm'
 1116         );
 1117 
 1118         $this->registerDimension(
 1119             'year',
 1120             $fact_table_entities,
 1121             'year',
 1122             'Year',
 1123             'time',
 1124             'The year.',
 1125             '',
 1126             true
 1127         );
 1128 
 1129         $this->registerDimension(
 1130             'dayofweek',
 1131             $fact_table_entities,
 1132             'dayofweek',
 1133             'Day of Week',
 1134             'time',
 1135             'The day of the week (1-7).',
 1136             '',
 1137             true);
 1138 
 1139         $this->registerDimension(
 1140             'dayofyear',
 1141             $fact_table_entities,
 1142             'dayofyear',
 1143             'Day of Year',
 1144             'time',
 1145             'The day of the year (1-365).',
 1146             '',
 1147             true
 1148         );
 1149 
 1150         $this->registerDimension(
 1151             'weekofyear',
 1152             $fact_table_entities,
 1153             'weekofyear',
 1154             'Week of Year',
 1155             'time',
 1156             'The week of the year (1-52).',
 1157             '',
 1158             true
 1159         );
 1160 
 1161         $this->registerDimension(
 1162             'date',
 1163             'base.feed_request',
 1164             'yyyymmdd',
 1165             'Date',
 1166             'time',
 1167             'The date.',
 1168             '',
 1169             true,
 1170             'yyyymmdd'
 1171         );
 1172 
 1173         $this->registerDimension(
 1174             'day',
 1175             'base.feed_request',
 1176             'day',
 1177             'Day',
 1178             'time',
 1179             'The day.',
 1180             '',
 1181             true
 1182         );
 1183 
 1184         $this->registerDimension(
 1185             'month',
 1186             'base.feed_request',
 1187             'month',
 1188             'Month',
 1189             'time',
 1190             'The month.',
 1191             '',
 1192             true
 1193         );
 1194 
 1195         $this->registerDimension(
 1196             'year',
 1197             'base.feed_request',
 1198             'year',
 1199             'Year',
 1200             'time',
 1201             'The year.',
 1202             '',
 1203             true
 1204         );
 1205 
 1206         $this->registerDimension(
 1207             'dayofweek',
 1208             'base.feed_request',
 1209             'dayofweek',
 1210             'Day of Week',
 1211             'time',
 1212             'The day of the week.',
 1213             '',
 1214             true
 1215         );
 1216 
 1217         $this->registerDimension(
 1218             'dayofyear',
 1219             'base.feed_request',
 1220             'dayofyear',
 1221             'Day of Year',
 1222             'time',
 1223             'The day of the year.',
 1224             '',
 1225             true
 1226         );
 1227 
 1228         $this->registerDimension(
 1229             'weekofyear',
 1230             'base.feed_request',
 1231             'weekofyear',
 1232             'Week of Year',
 1233             'date',
 1234             'The week of the year.',
 1235             '',
 1236             true
 1237         );
 1238 
 1239         // Site Dimensions
 1240         $this->registerDimension(
 1241             'siteId',
 1242             $fact_table_entities,
 1243             'site_id',
 1244             'Site ID',
 1245             'site',
 1246             'The ID of the the web site.',
 1247             '',
 1248             true
 1249         );
 1250 
 1251         $this->registerDimension(
 1252             'siteDomain',
 1253             'base.site',
 1254             'domain',
 1255             'Site Domain',
 1256             'site',
 1257             'The domain of the web site.'
 1258         );
 1259 
 1260         $this->registerDimension(
 1261             'siteName',
 1262             'base.site',
 1263             'name',
 1264             'Site Name',
 1265             'site',
 1266             'The name of the site.'
 1267         );
 1268 
 1269         $this->registerDimension(
 1270             'siteId',
 1271             'base.feed_request',
 1272             'site_id',
 1273             'Site ID',
 1274             'site',
 1275             'The ID of the the web site.',
 1276             '',
 1277             true
 1278         );
 1279 
 1280         // Visitor Dimensions
 1281         $this->registerDimension(
 1282             'visitorId',
 1283             'base.visitor',
 1284             'id',
 1285             'Visitor ID',
 1286             'visitor',
 1287             'The ID of the visitor.'
 1288         );
 1289 
 1290         $this->registerDimension(
 1291             'userName',
 1292             $fact_table_entities,
 1293             'user_name',
 1294             'User Name',
 1295             'visitor',
 1296             'The name or ID of the user.'
 1297         );
 1298 
 1299         $this->registerDimension(
 1300             'userEmail',
 1301             'base.visitor',
 1302             'user_email',
 1303             'Email Address',
 1304             'visitor',
 1305             'The email address of the user.'
 1306         );
 1307 
 1308         $this->registerDimension(
 1309             'isRepeatVisitor',
 1310             $fact_table_entities,
 1311             'is_repeat_visitor',
 1312             'Repeat Visitor',
 1313             'visitor',
 1314             'Repeat Site Visitor.',
 1315             '',
 1316             true
 1317         );
 1318 
 1319         $this->registerDimension(
 1320             'isNewVisitor',
 1321             $fact_table_entities,
 1322             'is_new_visitor',
 1323             'New Visitor',
 1324             'visitor',
 1325             'New Site Visitor.',
 1326             '',
 1327             true
 1328         );
 1329 
 1330         // Visit/Session Dimensions
 1331         $this->registerDimension(
 1332             'sessionId',
 1333             'base.session',
 1334             'id',
 1335             'Session ID',
 1336             'visit-special',
 1337             'The ID of the session/visit.'
 1338         );
 1339 
 1340         $this->registerDimension(
 1341             'entryPageUrl',
 1342             'base.document',
 1343             'url',
 1344             'Entry Page URL',
 1345             'visit',
 1346             'The URL of the entry page.',
 1347             'first_page_id'
 1348         );
 1349 
 1350         $this->registerDimension(
 1351             'entryPagePath',
 1352             'base.document',
 1353             'uri',
 1354             'Entry Page Path',
 1355             'visit',
 1356             'The URI of the entry page.',
 1357             'first_page_id'
 1358         );
 1359 
 1360         $this->registerDimension(
 1361             'entryPageTitle',
 1362             'base.document',
 1363             'page_title',
 1364             'Entry Page Title',
 1365             'visit',
 1366             'The title of the entry page.',
 1367             'first_page_id'
 1368         );
 1369 
 1370         $this->registerDimension(
 1371             'entryPageType',
 1372             'base.document',
 1373             'page_type',
 1374             'Entry Page Type',
 1375             'visit',
 1376             'The page type of the entry page.',
 1377             'first_page_id'
 1378         );
 1379 
 1380         $this->registerDimension(
 1381             'exitPageUrl',
 1382             'base.document',
 1383             'url',
 1384             'Exit Page URL',
 1385             'visit',
 1386             'The URL of the exit page.',
 1387             'last_page_id'
 1388         );
 1389 
 1390         $this->registerDimension(
 1391             'exitPagePath',
 1392             'base.document',
 1393             'uri',
 1394             'Exit Page Path',
 1395             'visit',
 1396             'The URI of the exit page.',
 1397             'last_page_id'
 1398         );
 1399 
 1400         $this->registerDimension(
 1401             'exitPageTitle',
 1402             'base.document',
 1403             'page_title',
 1404             'Exit Page Title',
 1405             'visit',
 1406             'The title of the exit page.',
 1407             'last_page_id'
 1408         );
 1409 
 1410         $this->registerDimension(
 1411             'exitPageType',
 1412             'base.document',
 1413             'page_type',
 1414             'Exit Page Type',
 1415             'visit',
 1416             'The page type of the exit page.',
 1417             'last_page_id'
 1418         );
 1419 
 1420         $this->registerDimension(
 1421             'timeSinceLastVisit',
 1422             'base.session',
 1423             'time_sinse_priorsession',
 1424             'Time Since Last Visit',
 1425             'visit-special',
 1426             'The time since the last visit.',
 1427             '',
 1428             true
 1429         );
 1430 
 1431         $this->registerDimension(
 1432             'daysSinceLastVisit',
 1433             $fact_table_entities,
 1434             'days_since_prior_session',
 1435             'Days Since Last Visit',
 1436             'visit',
 1437             'The number of days since the last visit.',
 1438             '',
 1439             true
 1440         );
 1441 
 1442         $this->registerDimension(
 1443             'daysSinceFirstVisit',
 1444             $fact_table_entities,
 1445             'days_since_first_session',
 1446             'Days Since First Visit',
 1447             'visit',
 1448             'The number of days since the first visit of the user.',
 1449             '',
 1450             true
 1451         );
 1452 
 1453         $this->registerDimension(
 1454             'priorVisitCount',
 1455             $fact_table_entities,
 1456             'num_prior_sessions',
 1457             'Prior Visits',
 1458             'visit',
 1459             'The number of prior visits, excluding the current one.',
 1460             '',
 1461             true
 1462         );
 1463 
 1464         $this->registerDimension(
 1465             'pagesViewsInVisit',
 1466             'base.session',
 1467             'num_pageviews',
 1468             'Pages Viewed In Visit',
 1469             'visit',
 1470             'The number of pages viewed in a visit.',
 1471             '',
 1472             true
 1473         );
 1474 
 1475         $this->registerDimension(
 1476             'revenueInVisit',
 1477             'base.session',
 1478             'commerce_trans_revenue',
 1479             'Revenue in Visit',
 1480             'visit',
 1481             'Revenue generate from e-commerce transactions in a visit.',
 1482             '',
 1483             true
 1484         );
 1485 
 1486         $this->registerDimension(
 1487             'itemRevenueInVisit',
 1488             'base.session',
 1489             'commerce_item_revenue',
 1490             'Item Revenue in Visit',
 1491             'visit',
 1492             'Revenue generate from e-commerce transaction items in a visit.',
 1493             '',
 1494             true
 1495         );
 1496 
 1497         $this->registerDimension(
 1498             'shippingRevenueInVisit',
 1499             'base.session',
 1500             'commerce_shipping_revenue',
 1501             'Shipping Revenue in Visit',
 1502             'visit',
 1503             'Revenue generate from e-commerce shipping in a visit.',
 1504             '',
 1505             true
 1506         );
 1507 
 1508         $this->registerDimension(
 1509             'taxRevenueInVisit',
 1510             'base.session',
 1511             'commerce_tax_revenue',
 1512             'Tax Revenue in Visit',
 1513             'visit',
 1514             'Revenue generate from e-commerce tax in a visit.',
 1515             '',
 1516             true
 1517         );
 1518 
 1519         $this->registerDimension(
 1520             'transactionsInVisit',
 1521             'base.session',
 1522             'commerce_trans_count',
 1523             'Transactions in Visit',
 1524             'visit',
 1525             'Number of e-commerce transactions completed in a visit.',
 1526             '',
 1527             true
 1528         );
 1529 
 1530         $this->registerDimension(
 1531             'itemQuantityInVisit',
 1532             'base.session',
 1533             'commerce_items_quantity',
 1534             'Item Quantity in Visit',
 1535             'visit',
 1536             'Number of e-commerce items purchased completed in a visit.',
 1537             '',
 1538             true
 1539         );
 1540 
 1541         $this->registerDimension(
 1542             'distinctItemsInVisit',
 1543             'base.session',
 1544             'commerce_items_count',
 1545             'Distinct Items in Visit',
 1546             'visit',
 1547             'Number of distinct items purchased in Visit.',
 1548             '',
 1549             true
 1550         );
 1551 
 1552         $this->registerDimension(
 1553             'goalsInVisit',
 1554             'base.session',
 1555             'num_goals',
 1556             'Goals in Visit',
 1557             'visit',
 1558             'Goals completed in a visit.',
 1559             '',
 1560             true
 1561         );
 1562 
 1563         $this->registerDimension(
 1564             'goalStartsInVisit',
 1565             'base.session',
 1566             'num_goal_starts',
 1567             'Goal Starts in Visit',
 1568             'visit',
 1569             'Goals started in a visit.',
 1570             '',
 1571             true
 1572         );
 1573 
 1574         $this->registerDimension(
 1575             'goalValueInVisit',
 1576             'base.session',
 1577             'goals_value',
 1578             'Goal Value in Visit',
 1579             'visit',
 1580             'Total value from all goals in a visit.',
 1581             '',
 1582             true
 1583         );
 1584 
 1585 
 1586 
 1587         // System/Technology Dimensions
 1588         $this->registerDimension(
 1589             'browserVersion',
 1590             'base.ua',
 1591             'browser',
 1592             'Browser Version',
 1593             'system',
 1594             'The browser version of the visitor.'
 1595         );
 1596 
 1597         $this->registerDimension(
 1598             'browserType',
 1599             'base.ua',
 1600             'browser_type',
 1601             'Browser Type',
 1602             'system',
 1603             'The browser type of the visitor.'
 1604         );
 1605 
 1606         $this->registerDimension(
 1607             'osType',
 1608             'base.os',
 1609             'name',
 1610             'Operating System',
 1611             'system',
 1612             'The operating System of the visitor.'
 1613         );
 1614 
 1615         $this->registerDimension(
 1616             'language',
 1617             $fact_table_entities,
 1618             'language',
 1619             'Language',
 1620             'system',
 1621             'The language of the visit.',
 1622             '',
 1623             true
 1624         );
 1625 
 1626         // Geo Dimensions
 1627         $this->registerDimension(
 1628             'city',
 1629             'base.location_dim',
 1630             'city',
 1631             'City',
 1632             'geo',
 1633             'The city of the visitor.'
 1634         );
 1635 
 1636         $this->registerDimension(
 1637             'country',
 1638             'base.location_dim',
 1639             'country',
 1640             'Country',
 1641             'geo',
 1642             'The country of the visitor.'
 1643         );
 1644 
 1645         $this->registerDimension(
 1646             'latitude',
 1647             'base.location_dim',
 1648             'latitude',
 1649             'Latitude',
 1650             'geo',
 1651             'The latitude of the visitor.'
 1652         );
 1653 
 1654         $this->registerDimension(
 1655             'longitude',
 1656             'base.location_dim',
 1657             'longitude',
 1658             'Longitude',
 1659             'geo',
 1660             'The longitude of the visitor.'
 1661         );
 1662 
 1663         $this->registerDimension(
 1664             'countryCode',
 1665             'base.location_dim',
 1666             'country_code',
 1667             'Country Code',
 1668             'geo',
 1669             'The ISO country code of the visitor.'
 1670         );
 1671 
 1672         $this->registerDimension(
 1673             'stateRegion',
 1674             'base.location_dim',
 1675             'state',
 1676             'State/Region',
 1677             'geo',
 1678             'The state or region of the visitor.'
 1679         );
 1680 
 1681         // Network Dimensions
 1682         $this->registerDimension(
 1683             'ipAddress',
 1684             $fact_table_entities,
 1685             'ip_address',
 1686             'IP Address',
 1687             'network',
 1688             'The IP address of the visitor.',
 1689             '',
 1690             true
 1691         );
 1692 
 1693         $this->registerDimension(
 1694             'hostName',
 1695             'base.host',
 1696             'host',
 1697             'Host Name',
 1698             'network',
 1699             'The host name of the network used by the visitor.'
 1700         );
 1701 
 1702         // Campaign Dimensions
 1703         $this->registerDimension(
 1704             'medium',
 1705             $fact_table_entities,
 1706             'medium',
 1707             'Medium',
 1708             'campaign',
 1709             'The medium where visit originated from.',
 1710             '',
 1711             true
 1712         );
 1713 
 1714         $this->registerDimension(
 1715             'source',
 1716             'base.source_dim',
 1717             'source_domain',
 1718             'Source',
 1719             'campaign',
 1720             'The traffic source of the visit.'
 1721         );
 1722 
 1723         $this->registerDimension(
 1724             'campaign',
 1725             'base.campaign_dim',
 1726             'name',
 1727             'Campaign',
 1728             'campaign',
 1729             'The campaign that originated the visit.'
 1730         );
 1731 
 1732         $this->registerDimension(
 1733             'ad',
 1734             'base.ad_dim',
 1735             'name',
 1736             'Ad',
 1737             'campaign',
 1738             'The name of the ad that originated the visit.'
 1739         );
 1740 
 1741         $this->registerDimension(
 1742             'adType',
 1743             'base.ad_dim',
 1744             'type',
 1745             'Ad Type',
 1746             'campaign',
 1747             'The type of ad that originated the visit.'
 1748         );
 1749 
 1750         $this->registerDimension(
 1751             'referralPageUrl',
 1752             'base.referer',
 1753             'url',
 1754             'Referral Page URL',
 1755             'campaign',
 1756             'The url of the referring web page.'
 1757         );
 1758 
 1759         $this->registerDimension(
 1760             'referralPageTitle',
 1761             'base.referer',
 1762             'page_title',
 1763             'Referral Page Title',
 1764             'campaign',
 1765             'The title of the referring web page.'
 1766         );
 1767 
 1768         $this->registerDimension(
 1769             'referralSearchTerms',
 1770             'base.search_term_dim',
 1771             'terms',
 1772             'Search Terms',
 1773             'campaign',
 1774             'The referring search terms.',
 1775             'referring_search_term_id'
 1776         );
 1777 
 1778         $this->registerDimension(
 1779             'referralLinkText',
 1780             'base.referer',
 1781             'refering_anchortext',
 1782             'Referral Link Text',
 1783             'campaign',
 1784             'The text of the referring link.'
 1785         );
 1786 
 1787         $this->registerDimension(
 1788             'isSearchEngine',
 1789             'base.referer',
 1790             'is_searchengine',
 1791             'Search Engine',
 1792             'campaign',
 1793             'Is traffic source a search engine.'
 1794         );
 1795 
 1796         $this->registerDimension(
 1797             'referralWebSite',
 1798             'base.referer',
 1799             'site',
 1800             'Referral Web Site',
 1801             'campaign',
 1802             'The full domain of the referring web site.'
 1803         );
 1804 
 1805         $this->registerDimension(
 1806             'latestAttributions',
 1807             'base.session',
 1808             'latest_attributions',
 1809             'Latest Attributions',
 1810             'campaign-special',
 1811             'The latest campaign attributions.',
 1812             '',
 1813             true
 1814         );
 1815 
 1816         // Page Content
 1817         $this->registerDimension(
 1818             'priorPageUrl',
 1819             'base.document',
 1820             'url',
 1821             'Prior Page URL',
 1822             'content',
 1823             'The URL of the prior page.',
 1824             'prior_document_id'
 1825         );
 1826 
 1827         $this->registerDimension(
 1828             'priorPagePath',
 1829             'base.document',
 1830             'uri',
 1831             'Prior Page Path',
 1832             'content',
 1833             'The URI of the prior page.',
 1834             'prior_document_id'
 1835         );
 1836 
 1837         $this->registerDimension(
 1838             'priorPageTitle',
 1839             'base.document',
 1840             'page_title',
 1841             'Prior Page Title',
 1842             'content',
 1843             'The title of the prior page.',
 1844             'prior_document_id'
 1845         );
 1846 
 1847         $this->registerDimension(
 1848             'priorPageType',
 1849             'base.document',
 1850             'page_type',
 1851             'Prior Page Type',
 1852             'content',
 1853             'The page type of the prior page.',
 1854             'prior_document_id'
 1855         );
 1856 
 1857         $this->registerDimension(
 1858             'pageUrl',
 1859             'base.document',
 1860             'url',
 1861             'Page URL',
 1862             'content',
 1863             'The URL of the web page.',
 1864             'document_id'
 1865         );
 1866 
 1867         $this->registerDimension(
 1868             'pagePath',
 1869             'base.document',
 1870             'uri',
 1871             'Page Path',
 1872             'content',
 1873             'The path of the web page.',
 1874             'document_id'
 1875         );
 1876 
 1877         $this->registerDimension(
 1878             'pageTitle',
 1879             'base.document',
 1880             'page_title',
 1881             'Page Title',
 1882             'content',
 1883             'The title of the web page.',
 1884             'document_id'
 1885         );
 1886 
 1887         $this->registerDimension(
 1888             'pageType',
 1889             'base.document',
 1890             'page_type',
 1891             'Page Type',
 1892             'content',
 1893             'The page type of the web page.',
 1894             'document_id'
 1895         );
 1896 
 1897         // Action Event Dimensions
 1898         $this->registerDimension(
 1899             'actionName',
 1900             'base.action_fact',
 1901             'action_name',
 1902             'Action Name',
 1903             'actions',
 1904             'The name of the action.',
 1905             '',
 1906             true
 1907         );
 1908 
 1909         $this->registerDimension(
 1910             'actionGroup',
 1911             'base.action_fact',
 1912             'action_group',
 1913             'Action Group',
 1914             'actions',
 1915             'The group that an action belongs to.',
 1916             '',
 1917             true
 1918         );
 1919 
 1920         $this->registerDimension(
 1921             'actionLabel',
 1922             'base.action_fact',
 1923             'action_label',
 1924             'Action Label',
 1925             'actions',
 1926             'The label associated with an action.',
 1927             '',
 1928             true
 1929         );
 1930 
 1931         // Ecommerce Dimensions
 1932         $this->registerDimension(
 1933             'productName',
 1934             'base.commerce_line_item_fact',
 1935             'product_name',
 1936             'Product Name',
 1937             'ecommerce',
 1938             'The name of the product purchased.',
 1939             '',
 1940             true
 1941         );
 1942 
 1943         $this->registerDimension(
 1944             'productSku',
 1945             'base.commerce_line_item_fact',
 1946             'sku',
 1947             'Product SKU',
 1948             'ecommerce',
 1949             'The SKU code of the product purchased.',
 1950             '',
 1951             true
 1952         );
 1953 
 1954         $this->registerDimension(
 1955             'productCategory',
 1956             'base.commerce_line_item_fact',
 1957             'category',
 1958             'Product Category',
 1959             'ecommerce',
 1960             'The category of product purchased.',
 1961             '',
 1962             true
 1963         );
 1964 
 1965         $this->registerDimension(
 1966             'transactionOriginator',
 1967             'base.commerce_transaction_fact',
 1968             'order_source',
 1969             'Originator',
 1970             'ecommerce',
 1971             'The store or location that originated the transaction.',
 1972             '',
 1973             true
 1974         );
 1975 
 1976         $this->registerDimension(
 1977             'transactionId',
 1978             'base.commerce_transaction_fact',
 1979             'order_id',
 1980             'Transaction ID',
 1981             'ecommerce',
 1982             'The id of the e-commerce transaction.',
 1983             '',
 1984             true
 1985         );
 1986 
 1987         $this->registerDimension(
 1988             'transactionGateway',
 1989             'base.commerce_transaction_fact',
 1990             'gateway',
 1991             'Payment Gateway',
 1992             'ecommerce',
 1993             'The payment gateway/provider used to clear the transaction.',
 1994             '',
 1995             true
 1996         );
 1997 
 1998         $this->registerDimension(
 1999             'daysToTransaction',
 2000             'base.commerce_transaction_fact',
 2001             'days_since_first_session',
 2002             'Days To Purchase',
 2003             'ecommerce',
 2004             'The number of days since the first visit and an e-commerce transaction.',
 2005             '',
 2006             true
 2007         );
 2008 
 2009         $this->registerDimension(
 2010             'daysToTransaction',
 2011             'base.commerce_transaction_fact',
 2012             'days_since_first_session',
 2013             'Days To Purchase',
 2014             'ecommerce',
 2015             'The number of days since the first visit and an e-commerce transaction.',
 2016             '',
 2017             true
 2018         );
 2019 
 2020         $this->registerDimension(
 2021             'visitsToTransaction',
 2022             'base.commerce_transaction_fact',
 2023             'num_prior_sessions',
 2024             'Visits To Purchase',
 2025             'ecommerce',
 2026             'The number of visits before the transaction occurred.',
 2027             '',
 2028             true
 2029         );
 2030 
 2031         $this->registerDimension(
 2032             'timestamp',
 2033             'base.commerce_transaction_fact',
 2034             'timestamp',
 2035             'Time',
 2036             'ecommerce-special',
 2037             'The timestamp of the transaction.',
 2038             '',
 2039             true
 2040         );
 2041 
 2042         // Click Dimensions
 2043         $this->registerDimension(
 2044             'domElementId',
 2045             'base.click',
 2046             'dom_element_id',
 2047             'Dom ID',
 2048             'dom',
 2049             'The id of the dom element.',
 2050             '',
 2051             true
 2052         );
 2053 
 2054         $this->registerDimension(
 2055             'domElementName',
 2056             'base.click',
 2057             'dom_element_name',
 2058             'Dom Name',
 2059             'dom',
 2060             'The name of the dom element.',
 2061             '',
 2062             true
 2063         );
 2064 
 2065         $this->registerDimension(
 2066             'domElementText',
 2067             'base.click',
 2068             'dom_element_text',
 2069             'Dom Text',
 2070             'dom',
 2071             'The text associated the dom element.',
 2072             '',
 2073             true
 2074         );
 2075 
 2076         $this->registerDimension(
 2077             'domElementValue',
 2078             'base.click',
 2079             'dom_element_value',
 2080             'Dom Value',
 2081             'dom',
 2082             'The value of the dom element.',
 2083             '',
 2084             true
 2085         );
 2086 
 2087         $this->registerDimension(
 2088             'domElementTag',
 2089             'base.click',
 2090             'dom_element_tag',
 2091             'Dom Tag',
 2092             'dom',
 2093             'The html tag of the dom element.',
 2094             '',
 2095             true
 2096         );
 2097 
 2098         $this->registerDimension(
 2099             'domElementClass',
 2100             'base.click',
 2101             'dom_element_class',
 2102             'Dom Class',
 2103             'dom',
 2104             'The class of the dom element.',
 2105             '',
 2106             true
 2107         );
 2108 
 2109         // Feed Dimensions
 2110         $this->registerDimension(
 2111             'feedType',
 2112             'base.feed_request',
 2113             'feed_format',
 2114             'Feed Type',
 2115             'feed',
 2116             'The type or format of the feed.',
 2117             '',
 2118             true
 2119         );
 2120 
 2121         // Custom variable Dimensions
 2122         $cv_max = owa_coreAPI::getSetting( 'base', 'maxCustomVars' );
 2123         for ($i = 1; $i <= $cv_max;$i++) {
 2124 
 2125             $cvar_name_col = 'cv'.$i.'_name';
 2126             $cvar_name_label = "Custom Var $i Name";
 2127             $cvar_name_description = "The name of custom variable $i.";
 2128             $this->registerDimension(
 2129                     'customVarName'.$i,
 2130                     array(
 2131                         'base.action_fact',
 2132                         'base.request',
 2133                         'base.session',
 2134                         'base.domstream',
 2135                         'base.click',
 2136                         'base.commerce_transaction_fact',
 2137                         'base.commerce_line_item_fact'
 2138                     ),
 2139                     $cvar_name_col,
 2140                     $cvar_name_label,
 2141                     'custom variables',
 2142                     $cvar_name_description,
 2143                     '',
 2144                     true,
 2145                     'string'
 2146             );
 2147 
 2148             $cvar_value_col = 'cv'.$i.'_value';
 2149             $cvar_value_label = "Custom Var $i Value";
 2150             $cvar_value_description = "The value of custom variable $i.";
 2151             $this->registerDimension(
 2152                     'customVarValue'.$i,
 2153                     array(
 2154                         'base.action_fact',
 2155                         'base.request',
 2156                         'base.session',
 2157                         'base.domstream',
 2158                         'base.click',
 2159                         'base.commerce_transaction_fact',
 2160                         'base.commerce_line_item_fact'
 2161                     ),
 2162                     $cvar_value_col,
 2163                     $cvar_value_label,
 2164                     'custom variables',
 2165                     $cvar_value_description,
 2166                     '',
 2167                     true,
 2168                     'string'
 2169             );
 2170         }
 2171     }
 2172 
 2173     function registerNavigation() {
 2174 
 2175         $this->addNavigationSubGroup('Dashboard', 'base.reportDashboard', 'Dashboard', 1, 'view_reports', 'Reports','fa fa-tachometer-alt');
 2176 
 2177         //Ecommerce
 2178         $this->addNavigationSubGroup('Ecommerce', 'base.reportEcommerce', 'Ecommerce', 5, 'view_reports_ecommerce', 'Reports','fa fa-shopping-cart');
 2179         $this->addNavigationLinkInSubGroup('Ecommerce', 'base.reportRevenue', 'Revenue', 2);
 2180         $this->addNavigationLinkInSubGroup('Ecommerce', 'base.reportTransactions', 'Transactions', 3);
 2181         $this->addNavigationLinkInSubGroup('Ecommerce', 'base.reportVisitsToPurchase', 'Visits To Purchase', 4);
 2182         $this->addNavigationLinkInSubGroup('Ecommerce', 'base.reportDaysToPurchase', 'Days To Purchase', 5);
 2183 
 2184         //Content
 2185         $this->addNavigationSubGroup('Content', 'base.reportContent', 'Content', 4, 'view_reports', 'Reports','fa fa-newspaper');
 2186         $this->addNavigationLinkInSubGroup( 'Content', 'base.reportPages', 'Top Pages', 1);
 2187         $this->addNavigationLinkInSubGroup( 'Content', 'base.reportPageTypes', 'Page Types', 2);
 2188         $this->addNavigationLinkInSubGroup( 'Content', 'base.reportFeeds', 'Feeds', 7);
 2189         $this->addNavigationLinkInSubGroup( 'Content', 'base.reportEntryPages', 'Entry Pages', 3);
 2190         $this->addNavigationLinkInSubGroup( 'Content', 'base.reportExitPages', 'Exit Pages', 4);
 2191 
 2192 
 2193         //Actions
 2194         $this->addNavigationSubGroup('Action Tracking', 'base.reportActionTracking', 'Action Tracking', 1, 'view_reports', 'Reports','fa fa-hand-pointer');
 2195         $this->addNavigationLinkInSubGroup('Action Tracking', 'base.reportActionGroups', 'Action Groups', 2);
 2196 
 2197         //Visitors
 2198         $this->addNavigationSubGroup( 'Visitors', 'base.reportVisitors', 'Visitors', 3, 'view_reports', 'Reports','fa fa-user-friends');
 2199         $this->addNavigationLinkInSubGroup( 'Visitors', 'base.reportGeolocation', 'Geo-location', 1);
 2200         $this->addNavigationLinkInSubGroup( 'Visitors', 'base.reportHosts', 'Domains', 2);
 2201         $this->addNavigationLinkInSubGroup( 'Visitors', 'base.reportVisitorsLoyalty', 'Visitor Loyalty', 3);
 2202         $this->addNavigationLinkInSubGroup( 'Visitors', 'base.reportVisitorsRecency', 'Visitor Recency', 4);
 2203         $this->addNavigationLinkInSubGroup( 'Visitors', 'base.reportVisitorsAge', 'Visitor Age', 5);
 2204         $this->addNavigationLinkInSubGroup( 'Visitors', 'base.reportBrowsers', 'Browser Types', 6);
 2205         $this->addNavigationLinkInSubGroup( 'Visitors', 'base.reportOs', 'Operating Systems', 7);
 2206 
 2207         //Traffic
 2208         $this->addNavigationSubGroup('Traffic', 'base.reportTraffic', 'Traffic', 2, 'view_reports', 'Reports','fa fa-random');
 2209         $this->addNavigationLinkInSubGroup( 'Traffic', 'base.reportKeywords', 'Search Terms', 1);
 2210         $this->addNavigationLinkInSubGroup( 'Traffic', 'base.reportAnchortext', 'Inbound Link Text', 2);
 2211         $this->addNavigationLinkInSubGroup( 'Traffic', 'base.reportSearchEngines', 'Search Engines', 3);
 2212         $this->addNavigationLinkInSubGroup( 'Traffic', 'base.reportReferringSites', 'Referring Web Sites', 4);
 2213         $this->addNavigationLinkInSubGroup( 'Traffic', 'base.reportCampaigns', 'Campaigns', 5);
 2214         $this->addNavigationLinkInSubGroup( 'Traffic', 'base.reportAds', 'Ad Performance', 6);
 2215         $this->addNavigationLinkInSubGroup( 'Traffic', 'base.reportAdTypes', 'Ad Types', 7);
 2216         $this->addNavigationLinkInSubGroup( 'Traffic', 'base.reportCreativePerformance', 'Creative Performance', 8);
 2217         $this->addNavigationLinkInSubGroup( 'Traffic', 'base.reportAttributionHistory', 'Attribution History', 8);
 2218 
 2219         //Goals
 2220         $this->addNavigationSubGroup('Goals', 'base.reportGoals', 'Goals', 5, 'view_reports', 'Reports','fa fa-bullseye');
 2221         $this->addNavigationLinkInSubGroup( 'Goals', 'base.reportGoalFunnel', 'Funnel Visualization', 1);
 2222 
 2223     }
 2224 
 2225     /**
 2226      * Registers Package Files To be Built
 2227      *
 2228      */
 2229     function registerBuildPackages() {
 2230 
 2231         $package = array(
 2232             'name'            => 'owa.tracker',
 2233             'output_dir'    => OWA_MODULES_DIR.'base/js/',
 2234             'type'            => 'js',
 2235             'files'            => array(
 2236 
 2237                     'owa'            => array(
 2238                                             'path'            =>    OWA_MODULES_DIR.'base/js/owa.js',
 2239                                             'compression'    => 'minify'
 2240                                         ),
 2241                     'owa.tracker'     => array(
 2242                                             'path'            => OWA_MODULES_DIR.'base/js/owa.tracker.js',
 2243                                             'compression'    => 'minify'
 2244                                         )
 2245             )
 2246         );
 2247 
 2248         $this->registerBuildPackage( $package );
 2249 
 2250         $package = array(
 2251             'name'            => 'owa.reporting',
 2252             'output_dir'    => OWA_MODULES_DIR.'base/js/',
 2253             'type'            => 'js',
 2254             'files'            => array(
 2255                 
 2256                     'jquery'                => array(
 2257                                                     'path'            => OWA_MODULES_DIR.'base/js/includes/jquery/jquery-1.6.4.min.js'
 2258                                                 ),
 2259                     'sprintf'                => array(
 2260                                                     'path'            => OWA_MODULES_DIR.'base/js/includes/jquery/jquery.sprintf.js'
 2261 
 2262                                                 ), // needed?
 2263                     'jquery-ui'             => array(
 2264                                                     'path'            => OWA_MODULES_DIR.'base/js/includes/jquery/jquery-ui-1.8.12.custom.min.js'
 2265                                                 ),
 2266                     'jquery-ui-selectmenu'     => array(
 2267                                                     'path'            => OWA_MODULES_DIR.'base/js/includes/jquery/jquery.ui.selectmenu.js'
 2268 
 2269                                                 ),
 2270                     'chosen'                 => array(
 2271                                                     'path'            => OWA_MODULES_DIR.'base/js/includes/jquery/chosen.jquery.js',
 2272                                                     'compression'    => 'minify'
 2273                                                 ),
 2274                     'sparkline'             => array(
 2275                                                     'path'            => OWA_MODULES_DIR.'base/js/includes/jquery/jquery.sparkline.min.js'
 2276                                                 ),
 2277                     'jqgrid'                 => array(
 2278                                                     'path'            => OWA_MODULES_DIR.'base/js/includes/jquery/jquery.jqGrid.min.js'
 2279                                                 ),
 2280                     'flot'                    => array(
 2281                                                     'path'            => OWA_MODULES_DIR.'base/js/includes/jquery/flot_v0.7/jquery.flot.min.js'
 2282                                                 ),
 2283                     'flot-resize'            => array(
 2284                                                     'path'            => OWA_MODULES_DIR.'base/js/includes/jquery/flot_v0.7/jquery.flot.resize.min.js'
 2285                                                 ),
 2286                     'flot-pie'                => array(
 2287                                                     'path'            => OWA_MODULES_DIR.'base/js/includes/jquery/flot_v0.7/jquery.flot.pie.min.js'
 2288                                                 ),
 2289                     'jqote'                    => array(
 2290                                                     'path'            => OWA_MODULES_DIR.'base/js/includes/jquery/jQote2/jquery.jqote2.min.js'
 2291                                                 ),
 2292                     'owa'                    => array(
 2293                                                     'path'            => OWA_MODULES_DIR.'base/js/owa.js',
 2294                                                     'compression'    => 'minify'
 2295                                                 ),
 2296                     'owa.report'            => array(
 2297                                                     'path'            => OWA_MODULES_DIR.'base/js/owa.report.js',
 2298                                                     'compression'    => 'minify'
 2299                                                 ),
 2300                     'owa.resultSetExplorer' => array(
 2301                                                     'path'            => OWA_MODULES_DIR.'base/js/owa.resultSetExplorer.js',
 2302                                                     'compression'    => 'minify'
 2303                                                 ),
 2304                     'owa.sparkline'            => array(
 2305                                                     'path'            => OWA_MODULES_DIR.'base/js/owa.sparkline.js',
 2306                                                     'compression'    => 'minify'
 2307                                                 ),
 2308                     'owa.areaChart'            => array(
 2309                                                     'path'            => OWA_MODULES_DIR.'base/js/owa.areachart.js',
 2310                                                     'compression'    => 'minify'
 2311                                                 ),
 2312                     'owa.pieChart'            => array(
 2313                                                     'path'            => OWA_MODULES_DIR.'base/js/owa.piechart.js',
 2314                                                     'compression'    => 'minify'
 2315                                                 ),
 2316                     'owa.kpibox'            => array(
 2317                                                     'path'            => OWA_MODULES_DIR.'base/js/owa.kpibox.js',
 2318                                                     'compression'    => 'minify'
 2319                                                 )
 2320                 )
 2321         );
 2322 
 2323         $this->registerBuildPackage( $package );
 2324 
 2325 
 2326         $package = array(
 2327             'name'            => 'owa.reporting-css',
 2328             'output_dir'    => OWA_MODULES_DIR.'base/css/',
 2329             'type'            => 'css',
 2330             'files'            => array(
 2331                     'jqueryui'         => array(
 2332                                             'path'     => OWA_MODULES_DIR.'base/css/jquery-ui.css'
 2333                                         ),
 2334                     'selectmenu'        => array(
 2335                                             'path'    =>    OWA_MODULES_DIR.'base/css/jquery.ui.selectmenu.css'
 2336                                         ),
 2337                     'jqgrid'            => array(
 2338                                             'path'    =>    OWA_MODULES_DIR.'base/css/ui.jqgrid.css'
 2339                                         ),
 2340                     'chosen'     => array(
 2341                                             'path'    => OWA_MODULES_DIR.'base/css/chosen.css'
 2342                                         ),
 2343 /*
 2344                     'font-awesome'     => array(
 2345                                             'path'    => OWA_MODULES_DIR.'base/css/fa-all.min.css'
 2346                                         ),
 2347 */
 2348 
 2349                     'owa.css'     => array(
 2350                                             'path'    => OWA_MODULES_DIR.'base/css/owa.css'
 2351                                         ),
 2352                     'owa.admin.css'     => array(
 2353                                             'path'    => OWA_MODULES_DIR.'base/css/owa.admin.css'
 2354                                         ),
 2355                     'owa.report.css'     => array(
 2356                                             'path'    => OWA_MODULES_DIR.'base/css/owa.report.css'
 2357                                         )
 2358             )
 2359         );
 2360 
 2361         $this->registerBuildPackage( $package );
 2362     }
 2363 
 2364     /**
 2365      * Registers Event Handlers with queue queue
 2366      *
 2367      */
 2368     function _registerEventHandlers() {
 2369 
 2370         // Page Requests
 2371         $this->registerEventHandler(array('base.page_request', 'base.first_page_request'), 'requestHandlers');
 2372         // Sessions
 2373         $this->registerEventHandler(array('base.page_request_logged', 'base.first_page_request_logged'), 'sessionHandlers');
 2374         // Clicks
 2375         $this->registerEventHandler('dom.click', 'clickHandlers');
 2376         // Feed requests
 2377         $this->registerEventHandler('base.feed_request', 'feedRequestHandlers');
 2378 
 2379         // actions
 2380         $this->registerEventHandler('track.action', 'actionHandler');
 2381 
 2382         // ecommerce
 2383 
 2384         // handles new ecommerce transactions
 2385         $this->registerEventHandler('ecommerce.transaction', 'commerceTransactionHandlers');
 2386 
 2387         // updates session once ecommerce transactions are persisted
 2388         $this->registerEventHandler(array(
 2389                 'ecommerce.transaction_persisted',
 2390                 'ecommerce.async_transaction_persisted'),
 2391             'sessionCommerceSummaryHandlers'
 2392         );
 2393 
 2394         $this->registerEventHandler('base.new_session', 'visitorUpdateHandlers');
 2395 
 2396 
 2397         // register standard dimension handlers to listen for events
 2398         // that populate fact tables.
 2399 
 2400         // Note: ecommerce.async_transaction_persisted events are ommited here
 2401         // because it the event gets alll non ecommerce dimensional properties
 2402         // from a previously persisted session entity
 2403         $fact_events = array(
 2404             'base.page_request_logged',
 2405             'base.first_page_request_logged',
 2406             'base.new_session',
 2407             'dom.stream_logged',
 2408             'dom.click_logged',
 2409             'track.action_logged',
 2410             'ecommerce.transaction_persisted'
 2411         );
 2412 
 2413         $standard_dimension_handlers = array(
 2414             'refererHandlers',
 2415             'searchTermHandlers',
 2416             'osHandlers',
 2417             'sourceHandlers',
 2418             'campaignHandlers',
 2419             'adHandlers',
 2420             'userAgentHandlers',
 2421             'hostHandlers',
 2422             'visitorHandlers',
 2423             'locationHandlers'
 2424         );
 2425 
 2426         foreach ($standard_dimension_handlers as $handler) {
 2427 
 2428             $this->registerEventHandler($fact_events, $handler);
 2429         }
 2430 
 2431         // Documents
 2432         $this->registerEventHandler(
 2433             array(
 2434                 'base.page_request_logged',
 2435                 'base.first_page_request_logged',
 2436                 'base.feed_request_logged',
 2437                 'track.action',
 2438                 'dom.stream',
 2439                 'dom.click',
 2440                 'ecommerce.transaction'
 2441             ),
 2442             'documentHandlers'
 2443         );
 2444 
 2445         // Goal Conversions
 2446         $this->registerEventHandler(
 2447             array(
 2448                 'base.new_session',
 2449                 'base.session_update',
 2450                 'ecommerce.transaction_persisted'
 2451             ),
 2452             'conversionHandlers'
 2453         );
 2454 
 2455         // Nofifcation handler
 2456         if ( owa_coreAPI::getSetting( 'base', 'announce_visitors' )
 2457             && owa_coreAPI::getSetting( 'base', 'notice_email' ) ) {
 2458 
 2459             $this->registerEventHandler( 'base.new_session', 'notifyHandlers' );
 2460         }
 2461 
 2462         // install complete handler
 2463         $this->registerEventHandler('install_complete', $this, 'installCompleteHandler');
 2464         // User management
 2465         $this->registerEventHandler(array('base.set_password', 'base.reset_password', 'base.new_user_account'), 'userHandlers');
 2466     }
 2467 
 2468     function _registerEventProcessors() {
 2469 
 2470         $this->addEventProcessor('base.page_request', 'base.processRequest');
 2471         $this->addEventProcessor('base.first_page_request', 'base.processFirstRequest');
 2472     }
 2473 
 2474     function _registerEntities() {
 2475 
 2476         $this->registerEntity(array(
 2477                 'request',
 2478                 'session',
 2479                 'document',
 2480                 'feed_request',
 2481                 'click',
 2482                 'ua',
 2483                 'referer',
 2484                 'site',
 2485                 'visitor',
 2486                 'host',
 2487                 'exit',
 2488                 'os',
 2489                 'impression',
 2490                 'configuration',
 2491                 'user',
 2492                 'domstream',
 2493                 'action_fact',
 2494                 'search_term_dim',
 2495                 'ad_dim',
 2496                 'source_dim',
 2497                 'campaign_dim',
 2498                 'location_dim',
 2499                 'commerce_transaction_fact',
 2500                 'commerce_line_item_fact',
 2501                 'queue_item',
 2502                 'site_user')
 2503             );
 2504 
 2505     }
 2506 
 2507     function installCompleteHandler($event) {
 2508 
 2509         //owa_coreAPI::debug('test handler: '.print_r($event, true));
 2510     }
 2511     
 2512     function checkEventForType( $event ) {
 2513 
 2514         $type = $event->getEventType();
 2515 
 2516         if ( $type === 'unknown_event_type' ) {
 2517 
 2518             $e = owa_coreAPI::errorSingleton();
 2519             $e->mailErrorMsg( print_r( $event->getProperties(), true ), 'Unknown Event Type' );
 2520         }
 2521 
 2522         return $event;
 2523     }
 2524 
 2525 }
 2526 
 2527 
 2528 ?>