Inheritance: implements Piwik\Plugins\Live\VisitorInterface
Esempio n. 1
0
 /**
  * For an array of visits, query the list of pages for this visit
  * as well as make the data human readable
  * @param DataTable $dataTable
  * @param int $idSite
  * @param bool $flat whether to flatten the array (eg. 'customVariables' names/values will appear in the root array rather than in 'customVariables' key
  * @param bool $doNotFetchActions If set to true, we only fetch visit info and not actions (much faster)
  * @param bool $filterNow If true, the visitors will be cleaned immediately
  */
 private function addFilterToCleanVisitors(DataTable $dataTable, $idSite, $flat = false, $doNotFetchActions = false, $filterNow = false)
 {
     $filter = 'queueFilter';
     if ($filterNow) {
         $filter = 'filter';
     }
     $dataTable->{$filter}(function ($table) use($idSite, $flat, $doNotFetchActions) {
         /** @var DataTable $table */
         $actionsLimit = (int) Config::getInstance()->General['visitor_log_maximum_actions_per_visit'];
         $visitorFactory = new VisitorFactory();
         $website = new Site($idSite);
         $timezone = $website->getTimezone();
         $currency = $website->getCurrency();
         $currencies = APISitesManager::getInstance()->getCurrencySymbols();
         // live api is not summable, prevents errors like "Unexpected ECommerce status value"
         $table->deleteRow(DataTable::ID_SUMMARY_ROW);
         foreach ($table->getRows() as $visitorDetailRow) {
             $visitorDetailsArray = Visitor::cleanVisitorDetails($visitorDetailRow->getColumns());
             $visitor = $visitorFactory->create($visitorDetailsArray);
             $visitorDetailsArray = $visitor->getAllVisitorDetails();
             $visitorDetailsArray['siteCurrency'] = $currency;
             $visitorDetailsArray['siteCurrencySymbol'] = @$currencies[$visitorDetailsArray['siteCurrency']];
             $visitorDetailsArray['serverTimestamp'] = $visitorDetailsArray['lastActionTimestamp'];
             $dateTimeVisit = Date::factory($visitorDetailsArray['lastActionTimestamp'], $timezone);
             if ($dateTimeVisit) {
                 $visitorDetailsArray['serverTimePretty'] = $dateTimeVisit->getLocalized(Date::TIME_FORMAT);
                 $visitorDetailsArray['serverDatePretty'] = $dateTimeVisit->getLocalized(Date::DATE_FORMAT_LONG);
             }
             $dateTimeVisitFirstAction = Date::factory($visitorDetailsArray['firstActionTimestamp'], $timezone);
             $visitorDetailsArray['serverDatePrettyFirstAction'] = $dateTimeVisitFirstAction->getLocalized(Date::DATE_FORMAT_LONG);
             $visitorDetailsArray['serverTimePrettyFirstAction'] = $dateTimeVisitFirstAction->getLocalized(Date::TIME_FORMAT);
             $visitorDetailsArray['actionDetails'] = array();
             if (!$doNotFetchActions) {
                 $visitorDetailsArray = Visitor::enrichVisitorArrayWithActions($visitorDetailsArray, $actionsLimit, $timezone);
             }
             if ($flat) {
                 $visitorDetailsArray = Visitor::flattenVisitorDetailsArray($visitorDetailsArray);
             }
             $visitorDetailRow->setColumns($visitorDetailsArray);
         }
     });
 }
Esempio n. 2
0
 /**
  * For an array of visits, query the list of pages for this visit
  * as well as make the data human readable
  * @param DataTable $dataTable
  * @param int $idSite
  * @param bool $flat whether to flatten the array (eg. 'customVariables' names/values will appear in the root array rather than in 'customVariables' key
  * @param bool $doNotFetchActions If set to true, we only fetch visit info and not actions (much faster)
  * @param bool $filterNow If true, the visitors will be cleaned immediately
  */
 private function addFilterToCleanVisitors(DataTable $dataTable, $idSite, $flat = false, $doNotFetchActions = false, $filterNow = false)
 {
     $filter = 'queueFilter';
     if ($filterNow) {
         $filter = 'filter';
     }
     $dataTable->{$filter}(function ($table) use($idSite, $flat, $doNotFetchActions) {
         /** @var DataTable $table */
         $actionsLimit = (int) Config::getInstance()->General['visitor_log_maximum_actions_per_visit'];
         $site = new Site($idSite);
         $timezone = $site->getTimezone();
         $currencies = APISitesManager::getInstance()->getCurrencySymbols();
         foreach ($table->getRows() as $visitorDetailRow) {
             $visitorDetailsArray = Visitor::cleanVisitorDetails($visitorDetailRow->getColumns());
             $visitor = new Visitor($visitorDetailsArray);
             $visitorDetailsArray = $visitor->getAllVisitorDetails();
             $visitorDetailsArray['siteCurrency'] = $site->getCurrency();
             $visitorDetailsArray['siteCurrencySymbol'] = @$currencies[$site->getCurrency()];
             $visitorDetailsArray['serverTimestamp'] = $visitorDetailsArray['lastActionTimestamp'];
             $dateTimeVisit = Date::factory($visitorDetailsArray['lastActionTimestamp'], $timezone);
             $visitorDetailsArray['serverTimePretty'] = $dateTimeVisit->getLocalized('%time%');
             $visitorDetailsArray['serverDatePretty'] = $dateTimeVisit->getLocalized(Piwik::translate('CoreHome_ShortDateFormat'));
             $dateTimeVisitFirstAction = Date::factory($visitorDetailsArray['firstActionTimestamp'], $timezone);
             $visitorDetailsArray['serverDatePrettyFirstAction'] = $dateTimeVisitFirstAction->getLocalized(Piwik::translate('CoreHome_ShortDateFormat'));
             $visitorDetailsArray['serverTimePrettyFirstAction'] = $dateTimeVisitFirstAction->getLocalized('%time%');
             $visitorDetailsArray['actionDetails'] = array();
             if (!$doNotFetchActions) {
                 $visitorDetailsArray = Visitor::enrichVisitorArrayWithActions($visitorDetailsArray, $actionsLimit, $timezone);
             }
             if ($flat) {
                 $visitorDetailsArray = Visitor::flattenVisitorDetailsArray($visitorDetailsArray);
             }
             $visitorDetailRow->setColumns($visitorDetailsArray);
         }
     });
 }