piwik/plugins/Live/API.php
/**
     * 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
     */
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
@param bool $filterNow If true, the visitors will be cleaned immediately
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 @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) {
            $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();
            $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('%time%');
                    $visitorDetailsArray['serverDatePretty'] = $dateTimeVisit->getLocalized(Piwik::translate('CoreHome_DateFormat'));
                }
                $dateTimeVisitFirstAction = Date::factory($visitorDetailsArray['firstActionTimestamp'], $timezone);
                $visitorDetailsArray['serverDatePrettyFirstAction'] = $dateTimeVisitFirstAction->getLocalized(Piwik::translate('CoreHome_DateFormat'));
                $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);
            }
        });
    }
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 ) { $ 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 ( ) ; $ 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 ( '%time%' ) ; $ visitorDetailsArray [ 'serverDatePretty' ] = $ dateTimeVisit -> getLocalized ( Piwik :: translate ( 'CoreHome_DateFormat' ) ) ; } $ dateTimeVisitFirstAction = Date :: factory ( $ visitorDetailsArray [ 'firstActionTimestamp' ] , $ timezone ) ; $ visitorDetailsArray [ 'serverDatePrettyFirstAction' ] = $ dateTimeVisitFirstAction -> getLocalized ( Piwik :: translate ( 'CoreHome_DateFormat' ) ) ; $ 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 ) ; } } ) ; }
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.
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 .
/** @var DataTable $table */ // live api is not summable, prevents errors like "Unexpected ECommerce status value"