private function getVisitDimensions() { // see eg https://github.com/piwik/piwik/issues/8399 we fetch them only on demand to improve performance if (!isset($this->visitDimensions)) { $this->visitDimensions = VisitDimension::getAllDimensions(); } return $this->visitDimensions; }
/** * @param $pluginName */ private function executePluginUninstall($pluginName) { try { $plugin = $this->getLoadedPlugin($pluginName); $plugin->uninstall(); } catch (\Exception $e) { } if (empty($plugin)) { return; } try { $visitDimensions = VisitDimension::getAllDimensions(); foreach (VisitDimension::getDimensions($plugin) as $dimension) { $this->uninstallDimension(VisitDimension::INSTALLER_PREFIX, $dimension, $visitDimensions); } } catch (\Exception $e) { } try { $actionDimensions = ActionDimension::getAllDimensions(); foreach (ActionDimension::getDimensions($plugin) as $dimension) { $this->uninstallDimension(ActionDimension::INSTALLER_PREFIX, $dimension, $actionDimensions); } } catch (\Exception $e) { } try { $conversionDimensions = ConversionDimension::getAllDimensions(); foreach (ConversionDimension::getDimensions($plugin) as $dimension) { $this->uninstallDimension(ConversionDimension::INSTALLER_PREFIX, $dimension, $conversionDimensions); } } catch (\Exception $e) { } }
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; }
/** * Gets an instance of all available visit, action and conversion dimension. * @return Dimension[] */ public static function getAllDimensions() { $dimensions = array(); foreach (VisitDimension::getAllDimensions() as $dimension) { $dimensions[] = $dimension; } foreach (ActionDimension::getAllDimensions() as $dimension) { $dimensions[] = $dimension; } foreach (ConversionDimension::getAllDimensions() as $dimension) { $dimensions[] = $dimension; } return $dimensions; }
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; }
/** * 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); } }
private static function getVisitDimensions() { return VisitDimension::getAllDimensions(); }
/** * @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; }
public static function getAllVersions() { // to avoid having to load all dimensions on each request we check if there were any changes on the file system // can easily save > 100ms for each request $cachedTimes = self::getCachedDimensionFileChanges(); $currentTimes = self::getCurrentDimensionFileChanges(); $diff = array_diff_assoc($currentTimes, $cachedTimes); if (empty($diff)) { return array(); } $versions = array(); $visitColumns = DbHelper::getTableColumns(Common::prefixTable('log_visit')); $actionColumns = DbHelper::getTableColumns(Common::prefixTable('log_link_visit_action')); $conversionColumns = DbHelper::getTableColumns(Common::prefixTable('log_conversion')); foreach (VisitDimension::getAllDimensions() as $dimension) { $versions = self::mixinVersions($dimension, 'log_visit.', $visitColumns, $versions); } foreach (ActionDimension::getAllDimensions() as $dimension) { $versions = self::mixinVersions($dimension, 'log_link_visit_action.', $actionColumns, $versions); } foreach (ConversionDimension::getAllDimensions() as $dimension) { $versions = self::mixinVersions($dimension, 'log_conversion.', $conversionColumns, $versions); } return $versions; }
/** * @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; }
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; }
/** * @param VisitDimension[]|null $visitDimensions * @param ActionDimension[]|null $actionDimensions * @param ConversionDimension[]|null $conversionDimensions */ public function __construct(array $visitDimensions = null, array $actionDimensions = null, array $conversionDimensions = null) { $this->visitDimensions = $visitDimensions === null ? VisitDimension::getAllDimensions() : $visitDimensions; $this->actionDimensions = $actionDimensions === null ? ActionDimension::getAllDimensions() : $actionDimensions; $this->conversionDimensions = $conversionDimensions === null ? ConversionDimension::getAllDimensions() : $conversionDimensions; }
/** * @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; }
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)); } }
protected function getAllVisitDimensions() { $dimensions = VisitDimension::getAllDimensions(); return $dimensions; }