예제 #1
0
 protected function configureSegments()
 {
     parent::configureSegments();
     $segment = new Segment();
     $segment->setType('dimension');
     $segment->setCategory(Piwik::translate('General_Visit'));
     $segment->setName(Piwik::translate('General_Visit') . " ID");
     $segment->setSegment('visitId');
     $segment->setAcceptedValues('Any integer.');
     $segment->setSqlSegment('log_visit.idvisit');
     $segment->setRequiresAtLeastViewAccess(true);
     $this->addSegment($segment);
 }
예제 #2
0
 protected function configureSegments()
 {
     parent::configureSegments();
     $segment = new Segment();
     $segment->setType('dimension');
     $segment->setCategory(Piwik::translate('General_Visit'));
     $segment->setName('General_VisitorID');
     $segment->setSegment('visitorId');
     $segment->setAcceptedValues('34c31e04394bdc63 - any 16 Hexadecimal chars ID, which can be fetched using the Tracking API function getVisitorId()');
     $segment->setSqlSegment('log_visit.idvisitor');
     $segment->setSqlFilterValue(array('Piwik\\Common', 'convertVisitorIdToBin'));
     $segment->setRequiresAtLeastViewAccess(true);
     $this->addSegment($segment);
 }
예제 #3
0
 protected function configureSegments()
 {
     parent::configureSegments();
     $segment = new Segment();
     $segment->setType('metric');
     $segment->setCategory(Piwik::translate('General_Visit'));
     $segment->setName('General_VisitorIP');
     $segment->setSegment('visitIp');
     $segment->setAcceptedValues('13.54.122.1. </code>Select IP ranges with notation: <code>visitIp>13.54.122.0;visitIp<13.54.122.255');
     $segment->setSqlSegment('log_visit.location_ip');
     $segment->setSqlFilterValue(array('Piwik\\Network\\IPUtils', 'stringToBinaryIP'));
     $segment->setRequiresAtLeastViewAccess(true);
     $this->addSegment($segment);
 }
예제 #4
0
 protected function getAllVisitDimensions()
 {
     if (is_null(self::$dimensions)) {
         self::$dimensions = VisitDimension::getAllDimensions();
         $dimensionNames = array();
         foreach (self::$dimensions as $dimension) {
             $dimensionNames[] = $dimension->getColumnName();
         }
         Common::printDebug("Following dimensions have been collected from plugins: " . implode(", ", $dimensionNames));
     }
     return self::$dimensions;
 }
예제 #5
0
 public static function getDimensions(Plugin $plugin)
 {
     $dimensions = array();
     foreach (VisitDimension::getDimensions($plugin) as $dimension) {
         $dimensions[] = $dimension;
     }
     foreach (ActionDimension::getDimensions($plugin) as $dimension) {
         $dimensions[] = $dimension;
     }
     foreach (ConversionDimension::getDimensions($plugin) as $dimension) {
         $dimensions[] = $dimension;
     }
     return $dimensions;
 }
예제 #6
0
 private function getGoalFromVisitor(Visitor $visitor, $visitorInformation, $action)
 {
     $goal = array('idvisit' => $visitorInformation['idvisit'], 'idvisitor' => $visitorInformation['idvisitor'], 'server_time' => Tracker::getDatetimeFromTimestamp($visitorInformation['visit_last_action_time']));
     $visitDimensions = VisitDimension::getAllDimensions();
     foreach ($visitDimensions as $dimension) {
         $value = $dimension->onAnyGoalConversion($this->request, $visitor, $action);
         if (false !== $value) {
             $goal[$dimension->getColumnName()] = $value;
         }
     }
     return $goal;
 }
예제 #7
0
 /**
  * Records one or several goals matched in this request.
  *
  * @param Visitor $visitor
  * @param array $visitorInformation
  * @param array $visitCustomVariables
  * @param Action $action
  */
 public function recordGoals(Visitor $visitor, $visitorInformation, $visitCustomVariables, $action)
 {
     $goal = array('idvisit' => $visitorInformation['idvisit'], 'idvisitor' => $visitorInformation['idvisitor'], 'server_time' => Tracker::getDatetimeFromTimestamp($visitorInformation['visit_last_action_time']));
     foreach (VisitDimension::getAllDimensions() as $dimension) {
         $value = $dimension->onAnyGoalConversion($this->request, $visitor, $action);
         if (false !== $value) {
             $goal[$dimension->getColumnName()] = $value;
         }
     }
     // Copy Custom Variables from Visit row to the Goal conversion
     // Otherwise, set the Custom Variables found in the cookie sent with this request
     $goal += $visitCustomVariables;
     $maxCustomVariables = CustomVariables::getMaxCustomVariables();
     for ($i = 1; $i <= $maxCustomVariables; $i++) {
         if (isset($visitorInformation['custom_var_k' . $i]) && strlen($visitorInformation['custom_var_k' . $i])) {
             $goal['custom_var_k' . $i] = $visitorInformation['custom_var_k' . $i];
         }
         if (isset($visitorInformation['custom_var_v' . $i]) && strlen($visitorInformation['custom_var_v' . $i])) {
             $goal['custom_var_v' . $i] = $visitorInformation['custom_var_v' . $i];
         }
     }
     // some goals are converted, so must be ecommerce Order or Cart Update
     if ($this->requestIsEcommerce) {
         $this->recordEcommerceGoal($goal, $visitor, $action, $visitorInformation);
     } else {
         $this->recordStandardGoals($goal, $visitor, $action, $visitorInformation);
     }
 }
예제 #8
0
 private static function getVisitDimensions()
 {
     return VisitDimension::getAllDimensions();
 }
예제 #9
0
 /**
  * @return array
  */
 private function getVisitFieldsPersist()
 {
     if (is_null($this->visitFieldsToSelect)) {
         $fields = array('idvisitor', 'idvisit', 'user_id', 'visit_exit_idaction_url', 'visit_exit_idaction_name', 'visitor_returning', 'visitor_days_since_first', 'visitor_days_since_order', 'visitor_count_visits', 'visit_goal_buyer', 'location_country', 'location_region', 'location_city', 'location_latitude', 'location_longitude', 'referer_name', 'referer_keyword', 'referer_type');
         $dimensions = VisitDimension::getAllDimensions();
         foreach ($dimensions as $dimension) {
             if ($dimension->hasImplementedEvent('onExistingVisit') || $dimension->hasImplementedEvent('onAnyGoalConversion')) {
                 $fields[] = $dimension->getColumnName();
             }
             foreach ($dimension->getRequiredVisitFields() as $field) {
                 $fields[] = $field;
             }
         }
         /**
          * This event collects a list of [visit entity](/guides/persistence-and-the-mysql-backend#visits) properties that should be loaded when reading
          * the existing visit. Properties that appear in this list will be available in other tracking
          * events such as 'onExistingVisit'.
          *
          * Plugins can use this event to load additional visit entity properties for later use during tracking.
          *
          * This event is deprecated, use [Dimensions](http://developer.piwik.org/guides/dimensions) instead.
          *
          * @deprecated
          */
         $this->eventDispatcher->postEvent('Tracker.getVisitFieldsToPersist', array(&$fields));
         array_unshift($fields, 'visit_first_action_time');
         array_unshift($fields, 'visit_last_action_time');
         for ($index = 1; $index <= CustomVariables::getNumUsableCustomVariables(); $index++) {
             $fields[] = 'custom_var_k' . $index;
             $fields[] = 'custom_var_v' . $index;
         }
         $this->visitFieldsToSelect = array_unique($fields);
     }
     return $this->visitFieldsToSelect;
 }
예제 #10
0
 protected function getAllVisitDimensions()
 {
     $dimensions = VisitDimension::getAllDimensions();
     return $dimensions;
 }
예제 #11
0
 /**
  * @return array
  */
 public static function getVisitFieldsPersist()
 {
     $fields = array('idvisitor', 'idvisit', 'visit_exit_idaction_url', 'visit_exit_idaction_name', 'visitor_returning', 'visitor_days_since_first', 'visitor_days_since_order', 'visitor_count_visits', 'location_country', 'location_region', 'location_city', 'location_latitude', 'location_longitude', 'referer_name', 'referer_keyword', 'referer_type');
     $dimensions = VisitDimension::getAllDimensions();
     foreach ($dimensions as $dimension) {
         if ($dimension->hasImplementedEvent('onExistingVisit')) {
             $fields[] = $dimension->getColumnName();
         }
         /**
          * This event collects a list of [visit entity]() properties that should be loaded when reading
          * the existing visit. Properties that appear in this list will be available in other tracking
          * events such as 'onExistingVisit'.
          *
          * Plugins can use this event to load additional visit entity properties for later use during tracking.
          */
         foreach ($dimension->getRequiredVisitFields() as $field) {
             $fields[] = $field;
         }
     }
     /**
      * @ignore
      */
     Piwik::postEvent('Tracker.getVisitFieldsToPersist', array(&$fields));
     return $fields;
 }
예제 #12
0
 private function getGoalFromVisitor(VisitProperties $visitProperties, Request $request, $action)
 {
     $goal = array('idvisit' => $visitProperties->getProperty('idvisit'), 'idvisitor' => $visitProperties->getProperty('idvisitor'), 'server_time' => Date::getDatetimeFromTimestamp($visitProperties->getProperty('visit_last_action_time')));
     $visitDimensions = VisitDimension::getAllDimensions();
     $visit = Visitor::makeFromVisitProperties($visitProperties, $request);
     foreach ($visitDimensions as $dimension) {
         $value = $dimension->onAnyGoalConversion($request, $visit, $action);
         if (false !== $value) {
             $goal[$dimension->getColumnName()] = $value;
         }
     }
     return $goal;
 }
예제 #13
0
 /**
  * @param ActionDimension|ConversionDimension|VisitDimension $dimension
  * @param string $componentPrefix
  * @param array $columns
  * @param array $versions
  * @return array The modified versions array
  */
 private function mixinVersions(PiwikUpdater $updater, $dimension, $componentPrefix, $columns, $versions)
 {
     $columnName = $dimension->getColumnName();
     // dimensions w/o columns do not need DB updates
     if (!$columnName || !$dimension->hasColumnType()) {
         return $versions;
     }
     $component = $componentPrefix . $columnName;
     $version = $dimension->getVersion();
     // if the column exists in the table, but has no associated version, and was one of the core columns
     // that was moved when the dimension refactor took place, then:
     // - set the installed version in the DB to the current code version
     // - and do not check for updates since we just set the version to the latest
     if (array_key_exists($columnName, $columns) && false === $updater->getCurrentComponentVersion($component) && self::wasDimensionMovedFromCoreToPlugin($component, $version)) {
         $updater->markComponentSuccessfullyUpdated($component, $version);
         return $versions;
     }
     $versions[$component] = $version;
     return $versions;
 }
예제 #14
0
 /**
  * @return array
  */
 private function getVisitFieldsPersist()
 {
     static $fields;
     if (is_null($fields)) {
         $fields = array('idvisitor', 'idvisit', 'user_id', 'visit_exit_idaction_url', 'visit_exit_idaction_name', 'visitor_returning', 'visitor_days_since_first', 'visitor_days_since_order', 'visitor_count_visits', 'visit_goal_buyer', 'location_country', 'location_region', 'location_city', 'location_latitude', 'location_longitude', 'referer_name', 'referer_keyword', 'referer_type');
         $dimensions = VisitDimension::getAllDimensions();
         foreach ($dimensions as $dimension) {
             if ($dimension->hasImplementedEvent('onExistingVisit')) {
                 $fields[] = $dimension->getColumnName();
             }
             foreach ($dimension->getRequiredVisitFields() as $field) {
                 $fields[] = $field;
             }
         }
         /**
          * This event collects a list of [visit entity](/guides/persistence-and-the-mysql-backend#visits) properties that should be loaded when reading
          * the existing visit. Properties that appear in this list will be available in other tracking
          * events such as 'onExistingVisit'.
          *
          * Plugins can use this event to load additional visit entity properties for later use during tracking.
          */
         Piwik::postEvent('Tracker.getVisitFieldsToPersist', array(&$fields));
         array_unshift($fields, 'visit_first_action_time');
         array_unshift($fields, 'visit_last_action_time');
         $fields = array_unique($fields);
     }
     return $fields;
 }
예제 #15
0
 public function test_getAllDimensions_shouldLoadAllDimensionsButOnlyIfLoadedPlugins()
 {
     Manager::getInstance()->loadPlugins(array('Actions', 'DevicesDetection'));
     $dimensions = VisitDimension::getAllDimensions();
     $this->assertGreaterThan(10, count($dimensions));
     foreach ($dimensions as $dimension) {
         $this->assertInstanceOf('\\Piwik\\Plugin\\Dimension\\VisitDimension', $dimension);
         $this->assertRegExp('/Piwik.Plugins.(DevicesDetection|Actions).Columns/', get_class($dimension));
     }
 }
예제 #16
0
 /**
  * @param $pluginName
  */
 private function executePluginUninstall($pluginName)
 {
     try {
         $plugin = $this->getLoadedPlugin($pluginName);
         $plugin->uninstall();
     } catch (\Exception $e) {
     }
     if (empty($plugin)) {
         return;
     }
     try {
         foreach (VisitDimension::getDimensions($plugin) as $dimension) {
             $this->uninstallDimension($dimension);
         }
     } catch (\Exception $e) {
     }
     try {
         foreach (ActionDimension::getDimensions($plugin) as $dimension) {
             $this->uninstallDimension($dimension);
         }
     } catch (\Exception $e) {
     }
     try {
         foreach (ConversionDimension::getDimensions($plugin) as $dimension) {
             $this->uninstallDimension($dimension);
         }
     } catch (\Exception $e) {
     }
 }
예제 #17
0
파일: Manager.php 프로젝트: 962464/piwik
 /**
  * @param VisitDimension|ActionDimension|ConversionDimension $dimension
  * @param VisitDimension[]|ActionDimension[]|ConversionDimension[] $allDimensions
  * @return bool
  */
 private function doesAnotherPluginDefineSameColumnWithDbEntry($dimension, $allDimensions)
 {
     $module = $dimension->getModule();
     $columnName = $dimension->getColumnName();
     foreach ($allDimensions as $dim) {
         if ($dim->getColumnName() === $columnName && $dim->hasColumnType() && $dim->getModule() !== $module) {
             return true;
         }
     }
     return false;
 }
예제 #18
0
 /**
  * @param ActionDimension|ConversionDimension|VisitDimension $dimension
  * @param string $componentPrefix
  * @param array $columns
  * @param array $versions
  * @return array The modified versions array
  */
 private static function mixinVersions($dimension, $componentPrefix, $columns, $versions)
 {
     $columnName = $dimension->getColumnName();
     if (!$columnName || !$dimension->hasColumnType()) {
         return $versions;
     }
     $component = $componentPrefix . $columnName;
     $version = $dimension->getVersion();
     if (array_key_exists($columnName, $columns) && false === PiwikUpdater::getCurrentRecordedComponentVersion($component) && self::wasDimensionMovedFromCoreToPlugin($component, $version)) {
         PiwikUpdater::recordComponentSuccessfullyUpdated($component, $version);
         return $versions;
     }
     $versions[$component] = $version;
     return $versions;
 }