Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2013-04-20 13:02:35 +0400
committermattab <matthieu.aubry@gmail.com>2013-04-20 13:02:36 +0400
commit35f975accb45152dd669e0009237eed3dc6ada2b (patch)
tree8a0a82519a8a3502ae18c31ae3db7bf2d148af55 /plugins
parent6575c1f85e6d4276cbce2d8a22535c6d499cb8ce (diff)
Fixes #3904:
* new segment 'siteSearchKeyword' Fixes #3903, #3905: * adding few fields in the Live API output to accomodate getSuggestedValuesForSegment * renamed other fields for consistency with segment names Fixes #3906: * new API: getSuggestedValuesForSegment which returns top suggested values for a particular segment. It uses the Live.getLastVisitsDetails API to fetch the most recently used values, and will show the most used values first * Adding tests for everything. The test case actually generates data for all segments so that VisitsSummary.get returns some data for each of the 47 segments being tested returns some data. How it works: * generate extended data in fixture * Tests (1) call getSuggestedValuesForSegment for each segment, check there is some data returned for each segment * get the first suggested value from the list, * Tests (2) call VisitsSummary.get with this segment value, eg. countryCode==ru. * I worked this way for all 47 segments until all tests had some data ==> now we know that all segments have been tested and that the auto suggest works for all segments. TDD FTW!
Diffstat (limited to 'plugins')
-rw-r--r--plugins/API/API.php66
-rw-r--r--plugins/Actions/Actions.php54
-rw-r--r--plugins/CoreUpdater/CoreUpdater.php3
-rw-r--r--plugins/Live/API.php130
-rw-r--r--plugins/Live/Visitor.php38
-rw-r--r--plugins/Transitions/API.php12
-rw-r--r--plugins/UserCountry/UserCountry.php13
-rw-r--r--plugins/UserSettings/UserSettings.php4
8 files changed, 275 insertions, 45 deletions
diff --git a/plugins/API/API.php b/plugins/API/API.php
index 5ca4e2156c..9c69be2d5c 100644
--- a/plugins/API/API.php
+++ b/plugins/API/API.php
@@ -78,7 +78,8 @@ class Piwik_API extends Piwik_Plugin
* <li>the list of metrics that will be returned by each method, along with their human readable name, via "getDefaultMetrics" and "getDefaultProcessedMetrics"</li>
* <li>the list of segments metadata supported by all functions that have a 'segment' parameter</li>
* <li>the (truly magic) method "getProcessedReport" will return a human readable version of any other report, and include the processed metrics such as
- * conversion rate, time on site, etc. which are not directly available in other methods.
+ * conversion rate, time on site, etc. which are not directly available in other methods.</li>
+ * <li>the method "getSuggestedValuesForSegment" returns top suggested values for a particular segment. It uses the Live.getLastVisitsDetails API to fetch the most recently used values, and will return the most often used values first.</li>
* </ul>
* The Metadata API is for example used by the Piwik Mobile App to automatically display all Piwik reports, with translated report & columns names and nicely formatted values.
* More information on the <a href='http://piwik.org/docs/analytics-api/metadata/' target='_blank'>Metadata API documentation page</a>
@@ -912,7 +913,7 @@ class Piwik_API_API
foreach ($columns as $name => $ignore) {
// if the current column should not be kept, remove it
$idx = array_search($name, $columnsToKeep);
- if ($idx === FALSE) // if $name is not in $columnsToKeep
+ if ($idx === false) // if $name is not in $columnsToKeep
{
unset($columns[$name]);
}
@@ -1625,4 +1626,65 @@ class Piwik_API_API
}
return $result;
}
+
+ /**
+ * Given a segment, will return a list of the most used values for this particular segment.
+ * @param $segmentName
+ * @param $idSite
+ * @throws Exception
+ */
+ public function getSuggestedValuesForSegment($segmentName, $idSite)
+ {
+ Piwik::checkUserHasViewAccess($idSite);
+ $maxSuggestionsToReturn = 30;
+ $segmentsMetadata = $this->getSegmentsMetadata($idSite, $_hideImplementationData = false);
+
+ $segmentFound = false;
+ foreach($segmentsMetadata as $segmentMetadata) {
+ if($segmentMetadata['segment'] == $segmentName) {
+ $segmentFound = $segmentMetadata;
+ break;
+ }
+ }
+ if(empty($segmentFound)) {
+ throw new Exception("Requested segment not found.");
+ }
+
+ $startDate = Piwik_Date::now()->subDay(60)->toString();
+
+ // we know which SQL field this segment matches to: call the LIVE api to get last 1000 visitors values
+ $request = new Piwik_API_Request("method=Live.getLastVisitsDetails
+ &idSite=$idSite
+ &period=range
+ &date=$startDate,today
+ &filter_limit=10000
+ &format=original
+ &serialize=0
+ &flat=1
+ &segment=");
+ $table = $request->process();
+ if(empty($table)) {
+ throw new Exception("There was no data to suggest for $segmentName");
+ }
+
+ // Cleanup data to return the top suggested (non empty) labels for this segment
+ $values = $table->getColumn($segmentName);
+
+ // Select also flattened keys (custom variables "page" scope, page URLs for one visit, page titles for one visit)
+ $valuesBis = $table->getColumnsStartingWith($segmentName . Piwik_DataTable_Filter_ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP);
+ $values = array_merge($values, $valuesBis);
+
+ // remove false values (while keeping zeros)
+ $values = array_filter( $values, 'strlen' );
+
+ // we have a list of all values. let's show the most frequently used first.
+ $values = array_count_values( $values );
+ arsort($values);
+ $values = array_keys($values);
+
+ $values = array_map( array('Piwik_Common', 'unsanitizeInputValue'), $values);
+
+ $values = array_slice($values, 0, $maxSuggestionsToReturn);
+ return $values;
+ }
}
diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php
index 097d2e3dee..8a9be015d7 100644
--- a/plugins/Actions/Actions.php
+++ b/plugins/Actions/Actions.php
@@ -103,7 +103,14 @@ class Piwik_Actions extends Piwik_Plugin
'sqlSegment' => 'log_link_visit_action.idaction_name',
'sqlFilter' => $sqlFilter,
);
- // TODO here could add keyword segment and hack $sqlFilter to make it select the right idaction
+ $segments[] = array(
+ 'type' => 'dimension',
+ 'category' => 'Actions_Actions',
+ 'name' => 'Actions_SiteSearchKeyword',
+ 'segment' => 'siteSearchKeyword',
+ 'sqlSegment' => 'log_link_visit_action.idaction_name',
+ 'sqlFilter' => $sqlFilter,
+ );
}
/**
@@ -113,30 +120,29 @@ class Piwik_Actions extends Piwik_Plugin
* Usually, these callbacks only return a value that should be compared to the
* column in the database. In this case, that doesn't work since multiple IDs
* can match an expression (e.g. "pageUrl=@foo").
- * @param string $string
+ * @param string $valueToMatch
* @param string $sqlField
* @param string $matchType
* @throws Exception
* @return array|int|string
*/
- public function getIdActionFromSegment($string, $sqlField, $matchType = '==')
+ public function getIdActionFromSegment($valueToMatch, $sqlField, $matchType, $segmentName)
{
- // Field is visit_*_idaction_url or visit_*_idaction_name
- $actionType = strpos($sqlField, '_name') === false
- ? Piwik_Tracker_Action::TYPE_ACTION_URL
- : Piwik_Tracker_Action::TYPE_ACTION_NAME;
+ $actionType = $this->guessActionTypeFromSegment($segmentName);
if ($actionType == Piwik_Tracker_Action::TYPE_ACTION_URL) {
// for urls trim protocol and www because it is not recorded in the db
- $string = preg_replace('@^http[s]?://(www\.)?@i', '', $string);
+ $valueToMatch = preg_replace('@^http[s]?://(www\.)?@i', '', $valueToMatch);
}
+ $valueToMatch = Piwik_Common::sanitizeInputValue(Piwik_Common::unsanitizeInputValue($valueToMatch));
+
// exact matches work by returning the id directly
if ($matchType == Piwik_SegmentExpression::MATCH_EQUAL
|| $matchType == Piwik_SegmentExpression::MATCH_NOT_EQUAL
) {
$sql = Piwik_Tracker_Action::getSqlSelectActionId();
- $bind = array($string, $string, $actionType);
+ $bind = array($valueToMatch, $valueToMatch, $actionType);
$idAction = Piwik_FetchOne($sql, $bind);
// if the action is not found, we hack -100 to ensure it tries to match against an integer
// otherwise binding idaction_name to "false" returns some rows for some reasons (in case &segment=pageTitle==Větrnásssssss)
@@ -150,23 +156,24 @@ class Piwik_Actions extends Piwik_Plugin
// build the expression based on the match type
$sql = 'SELECT idaction FROM ' . Piwik_Common::prefixTable('log_action') . ' WHERE ';
+ $sqlMatchType = 'AND type = ' . $actionType;
switch ($matchType) {
case '=@':
// use concat to make sure, no %s occurs because some plugins use %s in their sql
- $sql .= '( name LIKE CONCAT(\'%\', ?, \'%\') AND type = ' . $actionType . ' )';
+ $sql .= '( name LIKE CONCAT(\'%\', ?, \'%\') ' . $sqlMatchType . ' )';
break;
case '!@':
- $sql .= '( name NOT LIKE CONCAT(\'%\', ?, \'%\') AND type = ' . $actionType . ' )';
+ $sql .= '( name NOT LIKE CONCAT(\'%\', ?, \'%\') ' . $sqlMatchType . ' )';
break;
default:
- throw new Exception("This match type is not available for action-segments.");
+ throw new Exception("This match type $matchType is not available for action-segments.");
break;
}
return array(
// mark that the returned value is an sql-expression instead of a literal value
'SQL' => $sql,
- 'bind' => $string
+ 'bind' => $valueToMatch,
);
}
@@ -600,5 +607,26 @@ class Piwik_Actions extends Piwik_Plugin
{
return Piwik_PluginsManager::getInstance()->isPluginActivated('CustomVariables');
}
+
+ /**
+ * @param $segmentName
+ * @return int
+ * @throws Exception
+ */
+ protected function guessActionTypeFromSegment($segmentName)
+ {
+ if (stripos($segmentName, 'pageurl') !== false) {
+ $actionType = Piwik_Tracker_Action::TYPE_ACTION_URL;
+ return $actionType;
+ } elseif (stripos($segmentName, 'pagetitle') !== false) {
+ $actionType = Piwik_Tracker_Action::TYPE_ACTION_NAME;
+ return $actionType;
+ } elseif (stripos($segmentName, 'sitesearch') !== false) {
+ $actionType = Piwik_Tracker_Action::TYPE_SITE_SEARCH;
+ return $actionType;
+ } else {
+ throw new Exception(" The segment $segmentName has an unexpected value.");
+ }
+ }
}
diff --git a/plugins/CoreUpdater/CoreUpdater.php b/plugins/CoreUpdater/CoreUpdater.php
index 30a28f76a6..865c3da4ad 100644
--- a/plugins/CoreUpdater/CoreUpdater.php
+++ b/plugins/CoreUpdater/CoreUpdater.php
@@ -69,7 +69,8 @@ class Piwik_CoreUpdater extends Piwik_Plugin
&& $action == 'saveLanguage')
) {
if (Piwik_FrontController::shouldRethrowException()) {
- throw new Exception("Piwik and/or some plugins have been upgraded to a new version. Please run the update process first. See documentation: http://piwik.org/docs/update/");
+ throw new Exception("Piwik and/or some plugins have been upgraded to a new version. \n".
+ "--> Please run the update process first. See documentation: http://piwik.org/docs/update/ \n");
} else {
Piwik::redirectToModule('CoreUpdater');
}
diff --git a/plugins/Live/API.php b/plugins/Live/API.php
index 919afb0682..5cb3043839 100644
--- a/plugins/Live/API.php
+++ b/plugins/Live/API.php
@@ -97,13 +97,15 @@ class Piwik_Live_API
* @param int $visitorId
* @param int $idSite
* @param int $filter_limit
+ * @param bool $flat Whether to flatten the visitor details array
+ *
* @return Piwik_DataTable
*/
- public function getLastVisitsForVisitor($visitorId, $idSite, $filter_limit = 10)
+ public function getLastVisitsForVisitor($visitorId, $idSite, $filter_limit = 10, $flat = false)
{
Piwik::checkUserHasViewAccess($idSite);
$visitorDetails = $this->loadLastVisitorDetailsFromDatabase($idSite, $period = false, $date = false, $segment = false, $filter_limit, $filter_offset = false, $visitorId);
- $table = $this->getCleanedVisitorsFromDetails($visitorDetails, $idSite);
+ $table = $this->getCleanedVisitorsFromDetails($visitorDetails, $idSite, $flat);
return $table;
}
@@ -121,25 +123,23 @@ class Piwik_Live_API
*
* @return Piwik_DataTable
*/
- public function getLastVisitsDetails($idSite, $period, $date, $segment = false, $filter_limit = false, $filter_offset = false, $minTimestamp = false)
+ public function getLastVisitsDetails($idSite, $period, $date, $segment = false, $filter_limit = false, $filter_offset = false, $minTimestamp = false, $flat = false)
{
if (empty($filter_limit)) {
$filter_limit = 10;
}
Piwik::checkUserHasViewAccess($idSite);
$visitorDetails = $this->loadLastVisitorDetailsFromDatabase($idSite, $period, $date, $segment, $filter_limit, $filter_offset, $visitorId = false, $minTimestamp);
- $dataTable = $this->getCleanedVisitorsFromDetails($visitorDetails, $idSite);
-
+ $dataTable = $this->getCleanedVisitorsFromDetails($visitorDetails, $idSite, $flat);
return $dataTable;
}
/**
* @deprecated
*/
-
public function getLastVisits($idSite, $filter_limit = 10, $minTimestamp = false)
{
- return $this->getLastVisitsDetails($idSite, $period = false, $date = false, $segment = false, $filter_limit, $filter_offset = false, $minTimestamp);
+ return $this->getLastVisitsDetails($idSite, $period = false, $date = false, $segment = false, $filter_limit, $filter_offset = false, $minTimestamp, $flat = false);
}
/**
@@ -147,9 +147,10 @@ class Piwik_Live_API
* as well as make the data human readable
* @param array $visitorDetails
* @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
* @return Piwik_DataTable
*/
- private function getCleanedVisitorsFromDetails($visitorDetails, $idSite)
+ private function getCleanedVisitorsFromDetails($visitorDetails, $idSite, $flat = false)
{
$actionsLimit = (int)Piwik_Config::getInstance()->General['visitor_log_maximum_actions_per_visit'];
@@ -200,6 +201,7 @@ class Piwik_Live_API
LEFT JOIN " . Piwik_Common::prefixTable('log_action') . " AS log_action_title
ON log_link_visit_action.idaction_name = log_action_title.idaction
WHERE log_link_visit_action.idvisit = ?
+ ORDER BY server_time ASC
LIMIT 0, $actionsLimit
";
$actionDetails = Piwik_FetchAll($sql, array($idvisit));
@@ -212,8 +214,8 @@ class Piwik_Live_API
$cvarKey = $actionDetail['custom_var_k' . $i];
$cvarKey = $this->getCustomVariablePrettyKey($cvarKey);
$customVariablesPage[$i] = array(
- 'customVariableName' . $i => $cvarKey,
- 'customVariableValue' . $i => $actionDetail['custom_var_v' . $i],
+ 'customVariablePageName' . $i => $cvarKey,
+ 'customVariablePageValue' . $i => $actionDetail['custom_var_v' . $i],
);
}
unset($actionDetail['custom_var_k' . $i]);
@@ -222,21 +224,30 @@ class Piwik_Live_API
if (!empty($customVariablesPage)) {
$actionDetail['customVariables'] = $customVariablesPage;
}
- // reconstruct url from prefix
+
+ // Reconstruct url from prefix
$actionDetail['url'] = Piwik_Tracker_Action::reconstructNormalizedUrl($actionDetail['url'], $actionDetail['url_prefix']);
unset($actionDetail['url_prefix']);
- // set the time spent for this action (which is the timeSpentRef of the next action)
+
+ // Set the time spent for this action (which is the timeSpentRef of the next action)
if (isset($actionDetails[$actionIdx + 1])) {
$actionDetail['timeSpent'] = $actionDetails[$actionIdx + 1]['timeSpentRef'];
$actionDetail['timeSpentPretty'] = Piwik::getPrettyTimeFromSeconds($actionDetail['timeSpent']);
}
unset($actionDetails[$actionIdx]['timeSpentRef']); // not needed after timeSpent is added
- // handle generation time
+
+ // Handle generation time
if ($actionDetail['custom_float'] > 0) {
$actionDetail['generationTime'] = Piwik::getPrettyTimeFromSeconds($actionDetail['custom_float'] / 1000);
}
unset($actionDetail['custom_float']);
+
+ // Handle Site Search
+ if($actionDetail['type'] == Piwik_Tracker_Action::TYPE_SITE_SEARCH) {
+ $actionDetail['siteSearchKeyword'] = $actionDetail['pageTitle'];
+ unset($actionDetail['pageTitle']);
+ }
}
// If the visitor converted a goal, we shall select all Goals
@@ -244,6 +255,7 @@ class Piwik_Live_API
SELECT
'goal' as type,
goal.name as goalName,
+ goal.idgoal as goalId,
goal.revenue as revenue,
log_conversion.idlink_va as goalPageId,
log_conversion.server_time as serverTimePretty,
@@ -256,6 +268,7 @@ class Piwik_Live_API
AND goal.deleted = 0
WHERE log_conversion.idvisit = ?
AND log_conversion.idgoal > 0
+ ORDER BY server_time ASC
LIMIT 0, $actionsLimit
";
$goalDetails = Piwik_FetchAll($sql, array($idvisit));
@@ -274,6 +287,7 @@ class Piwik_Live_API
FROM " . Piwik_Common::prefixTable('log_conversion') . " AS log_conversion
WHERE idvisit = ?
AND idgoal <= " . Piwik_Tracker_GoalManager::IDGOAL_ORDER . "
+ ORDER BY server_time ASC
LIMIT 0, $actionsLimit";
$ecommerceDetails = Piwik_FetchAll($sql, array($idvisit));
@@ -365,9 +379,13 @@ class Piwik_Live_API
// Convert datetimes to the site timezone
$dateTimeVisit = Piwik_Date::factory($details['serverTimePretty'], $timezone);
$details['serverTimePretty'] = $dateTimeVisit->getLocalized(Piwik_Translate('CoreHome_ShortDateFormat') . ' %time%');
+
}
$visitorDetailsArray['goalConversions'] = count($goalDetails);
+ if($flat) {
+ $visitorDetailsArray = $this->flattenVisitorDetailsArray($visitorDetailsArray);
+ }
$table->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => $visitorDetailsArray));
}
return $table;
@@ -385,6 +403,92 @@ class Piwik_Live_API
return $key;
}
+ /**
+ * The &flat=1 feature is used by API.getSuggestedValuesForSegment
+ *
+ * @param $visitorDetailsArray
+ * @return array
+ */
+ private function flattenVisitorDetailsArray($visitorDetailsArray)
+ {
+ // flatten visit custom variables
+ if (is_array($visitorDetailsArray['customVariables'])) {
+ foreach ($visitorDetailsArray['customVariables'] as $thisCustomVar) {
+ $visitorDetailsArray = array_merge($visitorDetailsArray, $thisCustomVar);
+ }
+ unset($visitorDetailsArray['customVariables']);
+ }
+
+ // flatten page views custom variables
+ $count = 1;
+ foreach ($visitorDetailsArray['actionDetails'] as $action) {
+ if (!empty($action['customVariables'])) {
+ foreach ($action['customVariables'] as $thisCustomVar) {
+ foreach ($thisCustomVar as $cvKey => $cvValue) {
+ $flattenedKeyName = $cvKey . Piwik_DataTable_Filter_ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
+ $visitorDetailsArray[$flattenedKeyName] = $cvValue;
+ $count++;
+ }
+ }
+ }
+ }
+ // Flatten Goals
+ $count = 1;
+ foreach($visitorDetailsArray['actionDetails'] as $action) {
+ if(!empty($action['goalId'])) {
+ $flattenedKeyName = 'visitConvertedGoalId' . Piwik_DataTable_Filter_ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
+ $visitorDetailsArray[$flattenedKeyName] = $action['goalId'];
+ $count++;
+ }
+ }
+
+ // Flatten Page Titles/URLs
+ $count = 1;
+ foreach($visitorDetailsArray['actionDetails'] as $action) {
+ if(!empty($action['url'])) {
+ $flattenedKeyName = 'pageUrl' . Piwik_DataTable_Filter_ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
+ $visitorDetailsArray[$flattenedKeyName] = $action['url'];
+ }
+
+ if(!empty($action['pageTitle'])) {
+ $flattenedKeyName = 'pageTitle' . Piwik_DataTable_Filter_ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
+ $visitorDetailsArray[$flattenedKeyName] = $action['pageTitle'];
+ }
+
+ if(!empty($action['siteSearchKeyword'])) {
+ $flattenedKeyName = 'siteSearchKeyword' . Piwik_DataTable_Filter_ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
+ $visitorDetailsArray[$flattenedKeyName] = $action['siteSearchKeyword'];
+ }
+ $count++;
+ }
+
+ // Entry/exit pages
+ $firstAction = $lastAction = false;
+ foreach($visitorDetailsArray['actionDetails'] as $action) {
+ if($action['type'] == 'action') {
+ if(empty($firstAction)) {
+ $firstAction = $action;
+ }
+ $lastAction = $action;
+ }
+ }
+
+ if(!empty($firstAction['pageTitle'])) {
+ $visitorDetailsArray['entryPageTitle'] = $firstAction['pageTitle'];
+ }
+ if(!empty($firstAction['url'])) {
+ $visitorDetailsArray['entryPageUrl'] = $firstAction['url'];
+ }
+ if(!empty($lastAction['pageTitle'])) {
+ $visitorDetailsArray['exitPageTitle'] = $lastAction['pageTitle'];
+ }
+ if(!empty($lastAction['url'])) {
+ $visitorDetailsArray['exitPageUrl'] = $lastAction['url'];
+ }
+
+ return $visitorDetailsArray;
+ }
+
private function sortByServerTime($a, $b)
{
$ta = strtotime($a['serverTimePretty']);
diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php
index aaa4e8a61d..45a3ec7f08 100644
--- a/plugins/Live/Visitor.php
+++ b/plugins/Live/Visitor.php
@@ -60,6 +60,8 @@ class Piwik_Live_Visitor
// all time entries
'serverDate' => $this->getServerDate(),
'visitLocalTime' => $this->getVisitLocalTime(),
+ 'visitLocalHour' => $this->getVisitLocalHour(),
+ 'visitServerHour' => $this->getVisitServerHour(),
'firstActionTimestamp' => $this->getTimestampFirstAction(),
'lastActionTimestamp' => $this->getTimestampLastAction(),
'lastActionDateTime' => $this->getDateTimeLastAction(),
@@ -77,6 +79,7 @@ class Piwik_Live_Visitor
'countryCode' => $this->getCountryCode(),
'countryFlag' => $this->getCountryFlag(),
'region' => $this->getRegionName(),
+ 'regionCode' => $this->getRegionCode(),
'city' => $this->getCityName(),
'location' => $this->getPrettyLocation(),
'latitude' => $this->getLatitude(),
@@ -93,12 +96,15 @@ class Piwik_Live_Visitor
'referrerSearchEngineUrl' => $this->getSearchEngineUrl(),
'referrerSearchEngineIcon' => $this->getSearchEngineIcon(),
'operatingSystem' => $this->getOperatingSystem(),
+ 'operatingSystemCode' => $this->getOperatingSystemCode(),
'operatingSystemShortName' => $this->getOperatingSystemShortName(),
'operatingSystemIcon' => $this->getOperatingSystemIcon(),
'browserFamily' => $this->getBrowserFamily(),
'browserFamilyDescription' => $this->getBrowserFamilyDescription(),
'browserName' => $this->getBrowser(),
'browserIcon' => $this->getBrowserIcon(),
+ 'browserCode' => $this->getBrowserCode(),
+ 'browserVersion' => $this->getBrowserVersion(),
'screenType' => $this->getScreenType(),
'resolution' => $this->getResolution(),
'screenTypeIcon' => $this->getScreenTypeIcon(),
@@ -120,6 +126,16 @@ class Piwik_Live_Visitor
return $this->details['visitor_localtime'];
}
+ function getVisitServerHour()
+ {
+ return date('G', strtotime($this->details['visit_last_action_time']));
+ }
+
+ function getVisitLocalHour()
+ {
+ return date('G', strtotime('2012-12-21 ' . $this->details['visitor_localtime']));
+ }
+
function getVisitCount()
{
return $this->details['visitor_count_visits'];
@@ -249,7 +265,7 @@ class Piwik_Live_Visitor
public function getRegionName()
{
- $region = $this->details['location_region'];
+ $region = $this->getRegionCode();
if ($region != '' && $region != Piwik_Tracker_Visit::UNKNOWN_CODE) {
return Piwik_UserCountry_LocationProvider_GeoIp::getRegionNameFromCodes(
$this->details['location_country'], $region);
@@ -257,6 +273,11 @@ class Piwik_Live_Visitor
return null;
}
+ public function getRegionCode()
+ {
+ return $this->details['location_region'];
+ }
+
function getPrettyLocation()
{
$parts = array();
@@ -430,6 +451,11 @@ class Piwik_Live_Visitor
return null;
}
+ function getOperatingSystemCode()
+ {
+ return $this->details['config_os'];
+ }
+
function getOperatingSystem()
{
return Piwik_getOSLabel($this->details['config_os']);
@@ -455,6 +481,16 @@ class Piwik_Live_Visitor
return Piwik_getBrowserFamily($this->details['config_browser_name']);
}
+ function getBrowserCode()
+ {
+ return $this->details['config_browser_name'];
+ }
+
+ function getBrowserVersion()
+ {
+ return $this->details['config_browser_version'];
+ }
+
function getBrowser()
{
return Piwik_getBrowserLabel($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
diff --git a/plugins/Transitions/API.php b/plugins/Transitions/API.php
index 80afa16d94..4457d71046 100644
--- a/plugins/Transitions/API.php
+++ b/plugins/Transitions/API.php
@@ -134,25 +134,25 @@ class Piwik_Transitions_API
case 'url':
$originalActionName = $actionName;
$actionName = Piwik_Common::unsanitizeInputValue($actionName);
- $id = $actionsPlugin->getIdActionFromSegment($actionName, 'idaction_url');
+ $id = $actionsPlugin->getIdActionFromSegment($actionName, 'idaction_url', Piwik_SegmentExpression::MATCH_EQUAL, 'pageUrl');
if ($id < 0) {
// an example where this is needed is urls containing < or >
$actionName = $originalActionName;
- $id = $actionsPlugin->getIdActionFromSegment($actionName, 'idaction_url');
+ $id = $actionsPlugin->getIdActionFromSegment($actionName, 'idaction_url', Piwik_SegmentExpression::MATCH_EQUALs, 'pageUrl');
}
return $id;
case 'title':
- $id = $actionsPlugin->getIdActionFromSegment($actionName, 'idaction_name');
+ $id = $actionsPlugin->getIdActionFromSegment($actionName, 'idaction_name', Piwik_SegmentExpression::MATCH_EQUAL, 'pageTitle');
if ($id < 0) {
- $unkown = Piwik_Actions_ArchivingHelper::getUnknownActionName(
+ $unknown = Piwik_Actions_ArchivingHelper::getUnknownActionName(
Piwik_Tracker_Action::TYPE_ACTION_NAME);
- if (trim($actionName) == trim($unkown)) {
- $id = $actionsPlugin->getIdActionFromSegment('', 'idaction_name');
+ if (trim($actionName) == trim($unknown)) {
+ $id = $actionsPlugin->getIdActionFromSegment('', 'idaction_name', Piwik_SegmentExpression::MATCH_EQUAL, 'pageTitle');
}
}
diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php
index 20d2935248..34003af178 100644
--- a/plugins/UserCountry/UserCountry.php
+++ b/plugins/UserCountry/UserCountry.php
@@ -164,7 +164,7 @@ class Piwik_UserCountry extends Piwik_Plugin
'type' => 'dimension',
'category' => 'Visit Location',
'name' => Piwik_Translate('UserCountry_Country'),
- 'segment' => 'country',
+ 'segment' => 'countryCode',
'sqlSegment' => 'log_visit.location_country',
'acceptedValues' => 'de, us, fr, in, es, etc.',
);
@@ -172,7 +172,7 @@ class Piwik_UserCountry extends Piwik_Plugin
'type' => 'dimension',
'category' => 'Visit Location',
'name' => Piwik_Translate('UserCountry_Continent'),
- 'segment' => 'continent',
+ 'segment' => 'continentCode',
'sqlSegment' => 'log_visit.location_country',
'acceptedValues' => 'eur, asi, amc, amn, ams, afr, ant, oce',
'sqlFilter' => array('Piwik_UserCountry', 'getCountriesForContinent'),
@@ -181,7 +181,7 @@ class Piwik_UserCountry extends Piwik_Plugin
'type' => 'dimension',
'category' => 'Visit Location',
'name' => Piwik_Translate('UserCountry_Region'),
- 'segment' => 'region',
+ 'segment' => 'regionCode',
'sqlSegment' => 'log_visit.location_region',
'acceptedValues' => '01 02, OR, P8, etc.<br/>eg. region=A1;country=fr',
);
@@ -197,7 +197,7 @@ class Piwik_UserCountry extends Piwik_Plugin
'type' => 'dimension',
'category' => 'Visit Location',
'name' => Piwik_Translate('UserCountry_Latitude'),
- 'segment' => 'lat',
+ 'segment' => 'latitude',
'sqlSegment' => 'log_visit.location_latitude',
'acceptedValues' => '-33.578, 40.830, etc.<br/>You can select visitors within a lat/long range using &segment=lat&gt;X;lat&lt;Y;long&gt;M;long&lt;N.',
);
@@ -205,7 +205,7 @@ class Piwik_UserCountry extends Piwik_Plugin
'type' => 'dimension',
'category' => 'Visit Location',
'name' => Piwik_Translate('UserCountry_Longitude'),
- 'segment' => 'long',
+ 'segment' => 'longitude',
'sqlSegment' => 'log_visit.location_longitude',
'acceptedValues' => '-70.664, 14.326, etc.',
);
@@ -489,9 +489,8 @@ class Piwik_UserCountry extends Piwik_Plugin
*/
public static function getCountriesForContinent($continent)
{
- $continent = strtolower($continent);
-
$result = array();
+ $continent = strtolower($continent);
foreach (Piwik_Common::getCountriesList() as $countryCode => $continentCode) {
if ($continent == $continentCode) {
$result[] = $countryCode;
diff --git a/plugins/UserSettings/UserSettings.php b/plugins/UserSettings/UserSettings.php
index d46b952c56..90be882806 100644
--- a/plugins/UserSettings/UserSettings.php
+++ b/plugins/UserSettings/UserSettings.php
@@ -59,7 +59,7 @@ class Piwik_UserSettings extends Piwik_Plugin
'UserSettings',
'getBrowser',
'UserSettings_ColumnBrowser',
- 'browserName',
+ 'browserCode',
'log_visit.config_browser_name',
'FF, IE, CH, SF, OP, etc.',
null,),
@@ -110,7 +110,7 @@ class Piwik_UserSettings extends Piwik_Plugin
'UserSettings',
'getOS',
'UserSettings_ColumnOperatingSystem',
- 'operatingSystem',
+ 'operatingSystemCode',
'log_visit.config_os',
'WXP, WI7, MAC, LIN, AND, IPD, etc.',
null,),