public function test_isSiteEmpty()
 {
     $this->assertTrue($this->model->isSiteEmpty(1));
     $fixture = new OneVisitorTwoVisits();
     $fixture->setUp();
     $this->assertFalse($this->model->isSiteEmpty(1));
 }
 public function recordLogs(VisitProperties $visitProperties, Request $request)
 {
     $model = new Model();
     /** @var Action $action */
     $action = $request->getMetadata('Actions', 'action');
     if (!empty($action)) {
         $idLinkVisit = $action->getIdLinkVisitAction();
         $idVisit = $visitProperties->getProperty('idvisit');
         $model->updateVisit($request->getIdSite(), $idVisit, array('last_idlink_va' => $idLinkVisit));
     }
     $lastIdLinkVa = $visitProperties->getProperty('last_idlink_va');
     $timeSpent = $visitProperties->getProperty('time_spent_ref_action');
     if (!empty($lastIdLinkVa) && $timeSpent > 0) {
         $model->updateAction($lastIdLinkVa, array('time_spent' => $timeSpent));
     }
 }
Beispiel #3
0
 public function findKnownVisitor($configId, VisitProperties $visitProperties, Request $request)
 {
     $idSite = $request->getIdSite();
     $idVisitor = $request->getVisitorId();
     $isVisitorIdToLookup = !empty($idVisitor);
     if ($isVisitorIdToLookup) {
         $visitProperties->setProperty('idvisitor', $idVisitor);
         Common::printDebug("Matching visitors with: visitorId=" . bin2hex($idVisitor) . " OR configId=" . bin2hex($configId));
     } else {
         Common::printDebug("Visitor doesn't have the piwik cookie...");
     }
     $persistedVisitAttributes = $this->getVisitFieldsPersist();
     $shouldMatchOneFieldOnly = $this->shouldLookupOneVisitorFieldOnly($isVisitorIdToLookup, $request);
     list($timeLookBack, $timeLookAhead) = $this->getWindowLookupThisVisit($request);
     $visitRow = $this->model->findVisitor($idSite, $configId, $idVisitor, $persistedVisitAttributes, $shouldMatchOneFieldOnly, $isVisitorIdToLookup, $timeLookBack, $timeLookAhead);
     $isNewVisitForced = $request->getParam('new_visit');
     $isNewVisitForced = !empty($isNewVisitForced);
     $enforceNewVisit = $isNewVisitForced || $this->trackerAlwaysNewVisitor;
     if (!$enforceNewVisit && $visitRow && count($visitRow) > 0) {
         // These values will be used throughout the request
         foreach ($persistedVisitAttributes as $field) {
             $visitProperties->setProperty($field, $visitRow[$field]);
         }
         $visitProperties->setProperty('visit_last_action_time', strtotime($visitRow['visit_last_action_time']));
         $visitProperties->setProperty('visit_first_action_time', strtotime($visitRow['visit_first_action_time']));
         // Custom Variables copied from Visit in potential later conversion
         if (!empty($numCustomVarsToRead)) {
             for ($i = 1; $i <= $numCustomVarsToRead; $i++) {
                 if (isset($visitRow['custom_var_k' . $i]) && strlen($visitRow['custom_var_k' . $i])) {
                     $visitProperties->setProperty('custom_var_k' . $i, $visitRow['custom_var_k' . $i]);
                 }
                 if (isset($visitRow['custom_var_v' . $i]) && strlen($visitRow['custom_var_v' . $i])) {
                     $visitProperties->setProperty('custom_var_v' . $i, $visitRow['custom_var_v' . $i]);
                 }
             }
         }
         Common::printDebug("The visitor is known (idvisitor = " . bin2hex($visitProperties->getProperty('idvisitor')) . ",\n                    config_id = " . bin2hex($configId) . ",\n                    idvisit = {$visitProperties->getProperty('idvisit')},\n                    last action = " . date("r", $visitProperties->getProperty('visit_last_action_time')) . ",\n                    first action = " . date("r", $visitProperties->getProperty('visit_first_action_time')) . ",\n                    visit_goal_buyer' = " . $visitProperties->getProperty('visit_goal_buyer') . ")");
         return true;
     } else {
         Common::printDebug("The visitor was not matched with an existing visitor...");
         return false;
     }
 }
Beispiel #4
0
 public function redirectDashboardToWelcomePage(&$module, &$action)
 {
     if ($module !== 'CoreHome' || $action !== 'index') {
         return;
     }
     $siteId = Common::getRequestVar('idSite', false, 'int');
     if (!$siteId) {
         return;
     }
     // Skip the screen if purging logs is enabled
     $settings = PrivacyManager::getPurgeDataSettings();
     if ($settings['delete_logs_enable'] == 1) {
         return;
     }
     $trackerModel = new TrackerModel();
     if ($trackerModel->isSiteEmpty($siteId)) {
         $module = 'SitesManager';
         $action = 'siteWithoutData';
     }
 }
Beispiel #5
0
 public function test_createEcommerceItems_shouldNotFail_IfWritingSameItemTwice()
 {
     $item = array(array('idsite' => '1', 'idvisitor' => 'test', 'server_time' => '2014-01-01 00:00:00', 'idvisit' => '1', 'idorder' => '12', 'idaction_sku' => '1', 'idaction_name' => '2', 'idaction_category' => '3', 'idaction_category2' => '4', 'idaction_category3' => '5', 'idaction_category4' => '6', 'idaction_category5' => '7', 'price' => '10.00', 'quantity' => '1', 'deleted' => '0'));
     $this->model->createEcommerceItems($item);
     $this->model->createEcommerceItems($item);
 }