original_string: 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 */
              $visitorFactory = new VisitorFactory();
  
              // live api is not summable, prevents errors like "Unexpected ECommerce status value"
              $table->deleteRow(DataTable::ID_SUMMARY_ROW);
  
              $actionsByVisitId = array();
  
              if (!$doNotFetchActions) {
                  $visitIds = $table->getColumn('idvisit');
  
                  $visitorDetailsManipulators = Visitor::getAllVisitorDetailsInstances();
  
                  foreach ($visitorDetailsManipulators as $instance) {
                      $instance->provideActionsForVisitIds($actionsByVisitId, $visitIds);
                  }
              }
  
              foreach ($table->getRows() as $visitorDetailRow) {
                  $visitorDetailsArray = Visitor::cleanVisitorDetails($visitorDetailRow->getColumns());
  
                  $visitor = $visitorFactory->create($visitorDetailsArray);
                  $visitorDetailsArray = $visitor->getAllVisitorDetails();
  
                  $visitorDetailsArray['actionDetails'] = array();
                  if (!$doNotFetchActions) {
                      $bulkFetchedActions  = isset($actionsByVisitId[$visitorDetailsArray['idVisit']]) ? $actionsByVisitId[$visitorDetailsArray['idVisit']] : array();
                      $visitorDetailsArray = Visitor::enrichVisitorArrayWithActions($visitorDetailsArray, $bulkFetchedActions);
                  }
  
                  if ($flat) {
                      $visitorDetailsArray = Visitor::flattenVisitorDetailsArray($visitorDetailsArray);
                  }
  
                  $visitorDetailRow->setColumns($visitorDetailsArray);
              }
          });
      }
code: 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 */
              $visitorFactory = new VisitorFactory();
  
              // live api is not summable, prevents errors like "Unexpected ECommerce status value"
              $table->deleteRow(DataTable::ID_SUMMARY_ROW);
  
              $actionsByVisitId = array();
  
              if (!$doNotFetchActions) {
                  $visitIds = $table->getColumn('idvisit');
  
                  $visitorDetailsManipulators = Visitor::getAllVisitorDetailsInstances();
  
                  foreach ($visitorDetailsManipulators as $instance) {
                      $instance->provideActionsForVisitIds($actionsByVisitId, $visitIds);
                  }
              }
  
              foreach ($table->getRows() as $visitorDetailRow) {
                  $visitorDetailsArray = Visitor::cleanVisitorDetails($visitorDetailRow->getColumns());
  
                  $visitor = $visitorFactory->create($visitorDetailsArray);
                  $visitorDetailsArray = $visitor->getAllVisitorDetails();
  
                  $visitorDetailsArray['actionDetails'] = array();
                  if (!$doNotFetchActions) {
                      $bulkFetchedActions  = isset($actionsByVisitId[$visitorDetailsArray['idVisit']]) ? $actionsByVisitId[$visitorDetailsArray['idVisit']] : array();
                      $visitorDetailsArray = Visitor::enrichVisitorArrayWithActions($visitorDetailsArray, $bulkFetchedActions);
                  }
  
                  if ($flat) {
                      $visitorDetailsArray = Visitor::flattenVisitorDetailsArray($visitorDetailsArray);
                  }
  
                  $visitorDetailRow->setColumns($visitorDetailsArray);
              }
          });
      }
code_tokens: 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 */ $ visitorFactory = new VisitorFactory ( ) ; // live api is not summable, prevents errors like "Unexpected ECommerce status value" $ table -> deleteRow ( DataTable :: ID_SUMMARY_ROW ) ; $ actionsByVisitId = array ( ) ; if ( ! $ doNotFetchActions ) { $ visitIds = $ table -> getColumn ( 'idvisit' ) ; $ visitorDetailsManipulators = Visitor :: getAllVisitorDetailsInstances ( ) ; foreach ( $ visitorDetailsManipulators as $ instance ) { $ instance -> provideActionsForVisitIds ( $ actionsByVisitId , $ visitIds ) ; } } foreach ( $ table -> getRows ( ) as $ visitorDetailRow ) { $ visitorDetailsArray = Visitor :: cleanVisitorDetails ( $ visitorDetailRow -> getColumns ( ) ) ; $ visitor = $ visitorFactory -> create ( $ visitorDetailsArray ) ; $ visitorDetailsArray = $ visitor -> getAllVisitorDetails ( ) ; $ visitorDetailsArray [ 'actionDetails' ] = array ( ) ; if ( ! $ doNotFetchActions ) { $ bulkFetchedActions = isset ( $ actionsByVisitId [ $ visitorDetailsArray [ 'idVisit' ] ] ) ? $ actionsByVisitId [ $ visitorDetailsArray [ 'idVisit' ] ] : array ( ) ; $ visitorDetailsArray = Visitor :: enrichVisitorArrayWithActions ( $ visitorDetailsArray , $ bulkFetchedActions ) ; } if ( $ flat ) { $ visitorDetailsArray = Visitor :: flattenVisitorDetailsArray ( $ visitorDetailsArray ) ; } $ visitorDetailRow -> setColumns ( $ visitorDetailsArray ) ; } } ) ; }
docstring: 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
docstring_tokens: For an array of visits query the list of pages for this visit as well as make the data human readable