library/core/class.statistics.php
public function Tick() {
      // Fire an event for plugins to track their own stats.
      // TODO: Make this analyze the path and throw a specific event (this event will change in future versions).
      $this->EventArguments['Path'] = Gdn::Request()->Post('Path');
      $this->FireEvent('Tick');
      
      // Store the view, using denormalization if enabled
      $ViewType = 'normal';
      if (preg_match('`discussion/embed`', Gdn::Request()->Post('ResolvedPath', '')))
         $ViewType = 'embed';
      
      $this->AddView($ViewType);
      
      if (!self::CheckIsEnabled())
         return;
      
      if (Gdn::Session()->CheckPermission('Garden.Settings.Manage')) {
         if (Gdn::Get('Garden.Analytics.Notify', FALSE) !== FALSE) {
            $CallMessage = Sprite('Bandaid', 'InformSprite');
            $CallMessage .= sprintf(T("There's a problem with Vanilla Analytics that needs your attention.<br/> Handle it <a href=\"%s\">here &raquo;</a>"), Url('dashboard/statistics'));
            Gdn::Controller()->InformMessage($CallMessage, array('CssClass' => 'HasSprite'));
         }
      }
      
      $InstallationID = Gdn::InstallationID();
      
      // Check if we're registered with the central server already. If not, this request is 
      // hijacked and used to perform that task instead of sending stats or recording a tick.
      if (is_null($InstallationID)) {
         // If the config file is not writable, gtfo
         $ConfFile = PATH_CONF . '/config.php';
         if (!is_writable($ConfFile)) {
            // Admins see a helpful notice
            if (Gdn::Session()->CheckPermission('Garden.Settings.Manage')) {
               $Warning = Sprite('Sliders', 'InformSprite');
               $Warning .= T('Your config.php file is not writable.<br/> Find out <a href="http://vanillaforums.org/docs/vanillastatistics">how to fix this &raquo;</a>');
               Gdn::Controller()->InformMessage($Warning, array('CssClass' => 'HasSprite'));
            }
            return;
         }
         
         $AttemptedRegistration = Gdn::Get('Garden.Analytics.Registering', FALSE);
         // If we last attempted to register less than 60 seconds ago, do nothing. Could still be working.
         if ($AttemptedRegistration !== FALSE && (time() - $AttemptedRegistration) < 60)
            return;

         return $this->Register();
      }
      
      // If we get here, the installation is registered and we can decide on whether or not to send stats now.
      $LastSentDate = self::LastSentDate();
      if (empty($LastSentDate) || $LastSentDate < date('Ymd', strtotime('-1 day')))
         return $this->Stats();
   }
public function Tick() {
      // Fire an event for plugins to track their own stats.
      // TODO: Make this analyze the path and throw a specific event (this event will change in future versions).
      $this->EventArguments['Path'] = Gdn::Request()->Post('Path');
      $this->FireEvent('Tick');
      
      // Store the view, using denormalization if enabled
      $ViewType = 'normal';
      if (preg_match('`discussion/embed`', Gdn::Request()->Post('ResolvedPath', '')))
         $ViewType = 'embed';
      
      $this->AddView($ViewType);
      
      if (!self::CheckIsEnabled())
         return;
      
      if (Gdn::Session()->CheckPermission('Garden.Settings.Manage')) {
         if (Gdn::Get('Garden.Analytics.Notify', FALSE) !== FALSE) {
            $CallMessage = Sprite('Bandaid', 'InformSprite');
            $CallMessage .= sprintf(T("There's a problem with Vanilla Analytics that needs your attention.<br/> Handle it <a href=\"%s\">here &raquo;</a>"), Url('dashboard/statistics'));
            Gdn::Controller()->InformMessage($CallMessage, array('CssClass' => 'HasSprite'));
         }
      }
      
      $InstallationID = Gdn::InstallationID();
      
      // Check if we're registered with the central server already. If not, this request is 
      // hijacked and used to perform that task instead of sending stats or recording a tick.
      if (is_null($InstallationID)) {
         // If the config file is not writable, gtfo
         $ConfFile = PATH_CONF . '/config.php';
         if (!is_writable($ConfFile)) {
            // Admins see a helpful notice
            if (Gdn::Session()->CheckPermission('Garden.Settings.Manage')) {
               $Warning = Sprite('Sliders', 'InformSprite');
               $Warning .= T('Your config.php file is not writable.<br/> Find out <a href="http://vanillaforums.org/docs/vanillastatistics">how to fix this &raquo;</a>');
               Gdn::Controller()->InformMessage($Warning, array('CssClass' => 'HasSprite'));
            }
            return;
         }
         
         $AttemptedRegistration = Gdn::Get('Garden.Analytics.Registering', FALSE);
         // If we last attempted to register less than 60 seconds ago, do nothing. Could still be working.
         if ($AttemptedRegistration !== FALSE && (time() - $AttemptedRegistration) < 60)
            return;

         return $this->Register();
      }
      
      // If we get here, the installation is registered and we can decide on whether or not to send stats now.
      $LastSentDate = self::LastSentDate();
      if (empty($LastSentDate) || $LastSentDate < date('Ymd', strtotime('-1 day')))
         return $this->Stats();
   }
public function Tick ( ) { // Fire an event for plugins to track their own stats. // TODO: Make this analyze the path and throw a specific event (this event will change in future versions). $ this -> EventArguments [ 'Path' ] = Gdn :: Request ( ) -> Post ( 'Path' ) ; $ this -> FireEvent ( 'Tick' ) ; // Store the view, using denormalization if enabled $ ViewType = 'normal' ; if ( preg_match ( '`discussion/embed`' , Gdn :: Request ( ) -> Post ( 'ResolvedPath' , '' ) ) ) $ ViewType = 'embed' ; $ this -> AddView ( $ ViewType ) ; if ( ! self :: CheckIsEnabled ( ) ) return ; if ( Gdn :: Session ( ) -> CheckPermission ( 'Garden.Settings.Manage' ) ) { if ( Gdn :: Get ( 'Garden.Analytics.Notify' , FALSE ) !== FALSE ) { $ CallMessage = Sprite ( 'Bandaid' , 'InformSprite' ) ; $ CallMessage .= sprintf ( T ( "There's a problem with Vanilla Analytics that needs your attention.<br/> Handle it <a href=\"%s\">here &raquo;</a>" ) , Url ( 'dashboard/statistics' ) ) ; Gdn :: Controller ( ) -> InformMessage ( $ CallMessage , array ( 'CssClass' => 'HasSprite' ) ) ; } } $ InstallationID = Gdn :: InstallationID ( ) ; // Check if we're registered with the central server already. If not, this request is  // hijacked and used to perform that task instead of sending stats or recording a tick. if ( is_null ( $ InstallationID ) ) { // If the config file is not writable, gtfo $ ConfFile = PATH_CONF . '/config.php' ; if ( ! is_writable ( $ ConfFile ) ) { // Admins see a helpful notice if ( Gdn :: Session ( ) -> CheckPermission ( 'Garden.Settings.Manage' ) ) { $ Warning = Sprite ( 'Sliders' , 'InformSprite' ) ; $ Warning .= T ( 'Your config.php file is not writable.<br/> Find out <a href="http://vanillaforums.org/docs/vanillastatistics">how to fix this &raquo;</a>' ) ; Gdn :: Controller ( ) -> InformMessage ( $ Warning , array ( 'CssClass' => 'HasSprite' ) ) ; } return ; } $ AttemptedRegistration = Gdn :: Get ( 'Garden.Analytics.Registering' , FALSE ) ; // If we last attempted to register less than 60 seconds ago, do nothing. Could still be working. if ( $ AttemptedRegistration !== FALSE && ( time ( ) - $ AttemptedRegistration ) < 60 ) return ; return $ this -> Register ( ) ; } // If we get here, the installation is registered and we can decide on whether or not to send stats now. $ LastSentDate = self :: LastSentDate ( ) ; if ( empty ( $ LastSentDate ) || $ LastSentDate < date ( 'Ymd' , strtotime ( '-1 day' ) ) ) return $ this -> Stats ( ) ; }
This is the asynchronous callback

This method is triggerd on every page request via a callback AJAX request
so that it may execute asychronously and reduce lag for users. It tracks
views, handles registration for new installations, and sends stats every
day as needed.

@return void;
This is the asynchronous callback