update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -8,13 +8,15 @@
|
|||
*/
|
||||
namespace Piwik;
|
||||
|
||||
use Piwik\Cache as PiwikCache;
|
||||
use Piwik\Metrics\Formatter;
|
||||
|
||||
require_once PIWIK_INCLUDE_PATH . "/core/Piwik.php";
|
||||
|
||||
/**
|
||||
* This class contains metadata regarding core metrics and contains several
|
||||
* related helper functions.
|
||||
*
|
||||
*
|
||||
* Of note are the `INDEX_...` constants. In the database, metric column names
|
||||
* in {@link DataTable} rows are stored as integers to save space. The integer
|
||||
* values used are determined by these constants.
|
||||
|
|
@ -76,6 +78,17 @@ class Metrics
|
|||
const INDEX_EVENT_MAX_EVENT_VALUE = 37;
|
||||
const INDEX_EVENT_NB_HITS_WITH_VALUE = 38;
|
||||
|
||||
// Number of unique User IDs
|
||||
const INDEX_NB_USERS = 39;
|
||||
const INDEX_SUM_DAILY_NB_USERS = 40;
|
||||
|
||||
// Contents
|
||||
const INDEX_CONTENT_NB_IMPRESSIONS = 41;
|
||||
const INDEX_CONTENT_NB_INTERACTIONS = 42;
|
||||
|
||||
// Unique visitors fingerprints (useful to process unique visitors across websites)
|
||||
const INDEX_NB_UNIQ_FINGERPRINTS = 43;
|
||||
|
||||
// Goal reports
|
||||
const INDEX_GOAL_NB_CONVERSIONS = 1;
|
||||
const INDEX_GOAL_REVENUE = 2;
|
||||
|
|
@ -86,10 +99,12 @@ class Metrics
|
|||
const INDEX_GOAL_ECOMMERCE_REVENUE_DISCOUNT = 7;
|
||||
const INDEX_GOAL_ECOMMERCE_ITEMS = 8;
|
||||
|
||||
static public $mappingFromIdToName = array(
|
||||
public static $mappingFromIdToName = array(
|
||||
Metrics::INDEX_NB_UNIQ_VISITORS => 'nb_uniq_visitors',
|
||||
Metrics::INDEX_NB_UNIQ_FINGERPRINTS => 'nb_uniq_fingerprints',
|
||||
Metrics::INDEX_NB_VISITS => 'nb_visits',
|
||||
Metrics::INDEX_NB_ACTIONS => 'nb_actions',
|
||||
Metrics::INDEX_NB_USERS => 'nb_users',
|
||||
Metrics::INDEX_MAX_ACTIONS => 'max_actions',
|
||||
Metrics::INDEX_SUM_VISIT_LENGTH => 'sum_visit_length',
|
||||
Metrics::INDEX_BOUNCE_COUNT => 'bounce_count',
|
||||
|
|
@ -98,6 +113,7 @@ class Metrics
|
|||
Metrics::INDEX_REVENUE => 'revenue',
|
||||
Metrics::INDEX_GOALS => 'goals',
|
||||
Metrics::INDEX_SUM_DAILY_NB_UNIQ_VISITORS => 'sum_daily_nb_uniq_visitors',
|
||||
Metrics::INDEX_SUM_DAILY_NB_USERS => 'sum_daily_nb_users',
|
||||
|
||||
// Actions metrics
|
||||
Metrics::INDEX_PAGE_NB_HITS => 'nb_hits',
|
||||
|
|
@ -131,11 +147,14 @@ class Metrics
|
|||
Metrics::INDEX_EVENT_SUM_EVENT_VALUE => 'sum_event_value',
|
||||
Metrics::INDEX_EVENT_MIN_EVENT_VALUE => 'min_event_value',
|
||||
Metrics::INDEX_EVENT_MAX_EVENT_VALUE => 'max_event_value',
|
||||
Metrics::INDEX_EVENT_NB_HITS_WITH_VALUE => 'nb_events_with_value'
|
||||
Metrics::INDEX_EVENT_NB_HITS_WITH_VALUE => 'nb_events_with_value',
|
||||
|
||||
// Contents
|
||||
Metrics::INDEX_CONTENT_NB_IMPRESSIONS => 'nb_impressions',
|
||||
Metrics::INDEX_CONTENT_NB_INTERACTIONS => 'nb_interactions'
|
||||
);
|
||||
|
||||
static public $mappingFromIdToNameGoal = array(
|
||||
public static $mappingFromIdToNameGoal = array(
|
||||
Metrics::INDEX_GOAL_NB_CONVERSIONS => 'nb_conversions',
|
||||
Metrics::INDEX_GOAL_NB_VISITS_CONVERTED => 'nb_visits_converted',
|
||||
Metrics::INDEX_GOAL_REVENUE => 'revenue',
|
||||
|
|
@ -146,29 +165,44 @@ class Metrics
|
|||
Metrics::INDEX_GOAL_ECOMMERCE_ITEMS => 'items',
|
||||
);
|
||||
|
||||
static protected $metricsAggregatedFromLogs = array(
|
||||
protected static $metricsAggregatedFromLogs = array(
|
||||
Metrics::INDEX_NB_UNIQ_VISITORS,
|
||||
Metrics::INDEX_NB_VISITS,
|
||||
Metrics::INDEX_NB_ACTIONS,
|
||||
Metrics::INDEX_NB_USERS,
|
||||
Metrics::INDEX_MAX_ACTIONS,
|
||||
Metrics::INDEX_SUM_VISIT_LENGTH,
|
||||
Metrics::INDEX_BOUNCE_COUNT,
|
||||
Metrics::INDEX_NB_VISITS_CONVERTED,
|
||||
);
|
||||
|
||||
static public function getVisitsMetricNames()
|
||||
public static function getVisitsMetricNames()
|
||||
{
|
||||
$names = array();
|
||||
|
||||
foreach (self::$metricsAggregatedFromLogs as $metricId) {
|
||||
$names[$metricId] = self::$mappingFromIdToName[$metricId];
|
||||
}
|
||||
|
||||
return $names;
|
||||
}
|
||||
|
||||
static public function getMappingFromIdToName()
|
||||
public static function getMappingFromNameToId()
|
||||
{
|
||||
$idToName = array_flip(self::$mappingFromIdToName);
|
||||
return $idToName;
|
||||
static $nameToId = null;
|
||||
if ($nameToId === null) {
|
||||
$nameToId = array_flip(self::$mappingFromIdToName);
|
||||
}
|
||||
return $nameToId;
|
||||
}
|
||||
|
||||
public static function getMappingFromNameToIdGoal()
|
||||
{
|
||||
static $nameToId = null;
|
||||
if ($nameToId === null) {
|
||||
$nameToId = array_flip(self::$mappingFromIdToNameGoal);
|
||||
}
|
||||
return $nameToId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -178,7 +212,7 @@ class Metrics
|
|||
*
|
||||
* @ignore
|
||||
*/
|
||||
static public function isLowerValueBetter($column)
|
||||
public static function isLowerValueBetter($column)
|
||||
{
|
||||
$lowerIsBetterPatterns = array(
|
||||
'bounce', 'exit'
|
||||
|
|
@ -200,11 +234,11 @@ class Metrics
|
|||
* @return string
|
||||
* @ignore
|
||||
*/
|
||||
static public function getUnit($column, $idSite)
|
||||
public static function getUnit($column, $idSite)
|
||||
{
|
||||
$nameToUnit = array(
|
||||
'_rate' => '%',
|
||||
'revenue' => MetricsFormatter::getCurrencySymbol($idSite),
|
||||
'revenue' => Site::getCurrencySymbolFor($idSite),
|
||||
'_time_' => 's'
|
||||
);
|
||||
|
||||
|
|
@ -217,8 +251,15 @@ class Metrics
|
|||
return '';
|
||||
}
|
||||
|
||||
static public function getDefaultMetricTranslations()
|
||||
public static function getDefaultMetricTranslations()
|
||||
{
|
||||
$cacheId = CacheId::pluginAware('DefaultMetricTranslations');
|
||||
$cache = PiwikCache::getTransientCache();
|
||||
|
||||
if ($cache->contains($cacheId)) {
|
||||
return $cache->fetch($cacheId);
|
||||
}
|
||||
|
||||
$translations = array(
|
||||
'label' => 'General_ColumnLabel',
|
||||
'date' => 'General_Date',
|
||||
|
|
@ -248,6 +289,7 @@ class Metrics
|
|||
$afterEntry = ' ' . Piwik::translate('General_AfterEntry');
|
||||
|
||||
$translations['sum_daily_nb_uniq_visitors'] = Piwik::translate('General_ColumnNbUniqVisitors') . $dailySum;
|
||||
$translations['sum_daily_nb_users'] = Piwik::translate('General_ColumnNbUsers') . $dailySum;
|
||||
$translations['sum_daily_entry_nb_uniq_visitors'] = Piwik::translate('General_ColumnUniqueEntrances') . $dailySum;
|
||||
$translations['sum_daily_exit_nb_uniq_visitors'] = Piwik::translate('General_ColumnUniqueExits') . $dailySum;
|
||||
$translations['entry_nb_actions'] = Piwik::translate('General_ColumnNbActions') . $afterEntry;
|
||||
|
|
@ -262,24 +304,44 @@ class Metrics
|
|||
*/
|
||||
Piwik::postEvent('Metrics.getDefaultMetricTranslations', array(&$translations));
|
||||
|
||||
$translations = array_map(array('\\Piwik\\Piwik','translate'), $translations);
|
||||
$translations = array_map(array('\\Piwik\\Piwik', 'translate'), $translations);
|
||||
|
||||
$cache->save($cacheId, $translations);
|
||||
|
||||
return $translations;
|
||||
}
|
||||
|
||||
static public function getDefaultMetrics()
|
||||
public static function getDefaultMetrics()
|
||||
{
|
||||
$cacheId = CacheId::languageAware('DefaultMetrics');
|
||||
$cache = PiwikCache::getTransientCache();
|
||||
|
||||
if ($cache->contains($cacheId)) {
|
||||
return $cache->fetch($cacheId);
|
||||
}
|
||||
|
||||
$translations = array(
|
||||
'nb_visits' => 'General_ColumnNbVisits',
|
||||
'nb_uniq_visitors' => 'General_ColumnNbUniqVisitors',
|
||||
'nb_actions' => 'General_ColumnNbActions',
|
||||
'nb_users' => 'General_ColumnNbUsers',
|
||||
);
|
||||
$translations = array_map(array('\\Piwik\\Piwik','translate'), $translations);
|
||||
$translations = array_map(array('\\Piwik\\Piwik', 'translate'), $translations);
|
||||
|
||||
$cache->save($cacheId, $translations);
|
||||
|
||||
return $translations;
|
||||
}
|
||||
|
||||
static public function getDefaultProcessedMetrics()
|
||||
public static function getDefaultProcessedMetrics()
|
||||
{
|
||||
$cacheId = CacheId::languageAware('DefaultProcessedMetrics');
|
||||
$cache = PiwikCache::getTransientCache();
|
||||
|
||||
if ($cache->contains($cacheId)) {
|
||||
return $cache->fetch($cacheId);
|
||||
}
|
||||
|
||||
$translations = array(
|
||||
// Processed in AddColumnsProcessedMetrics
|
||||
'nb_actions_per_visit' => 'General_ColumnActionsPerVisit',
|
||||
|
|
@ -287,22 +349,25 @@ class Metrics
|
|||
'bounce_rate' => 'General_ColumnBounceRate',
|
||||
'conversion_rate' => 'General_ColumnConversionRate',
|
||||
);
|
||||
return array_map(array('\\Piwik\\Piwik','translate'), $translations);
|
||||
$translations = array_map(array('\\Piwik\\Piwik', 'translate'), $translations);
|
||||
|
||||
$cache->save($cacheId, $translations);
|
||||
|
||||
return $translations;
|
||||
}
|
||||
|
||||
static public function getReadableColumnName($columnIdRaw)
|
||||
public static function getReadableColumnName($columnIdRaw)
|
||||
{
|
||||
$mappingIdToName = self::$mappingFromIdToName;
|
||||
|
||||
if (array_key_exists($columnIdRaw, $mappingIdToName)) {
|
||||
|
||||
return $mappingIdToName[$columnIdRaw];
|
||||
}
|
||||
|
||||
return $columnIdRaw;
|
||||
}
|
||||
|
||||
static public function getMetricIdsToProcessReportTotal()
|
||||
public static function getMetricIdsToProcessReportTotal()
|
||||
{
|
||||
return array(
|
||||
self::INDEX_NB_VISITS,
|
||||
|
|
@ -321,12 +386,20 @@ class Metrics
|
|||
);
|
||||
}
|
||||
|
||||
static public function getDefaultMetricsDocumentation()
|
||||
public static function getDefaultMetricsDocumentation()
|
||||
{
|
||||
$documentation = array(
|
||||
$cacheId = CacheId::pluginAware('DefaultMetricsDocumentation');
|
||||
$cache = PiwikCache::getTransientCache();
|
||||
|
||||
if ($cache->contains($cacheId)) {
|
||||
return $cache->fetch($cacheId);
|
||||
}
|
||||
|
||||
$translations = array(
|
||||
'nb_visits' => 'General_ColumnNbVisitsDocumentation',
|
||||
'nb_uniq_visitors' => 'General_ColumnNbUniqVisitorsDocumentation',
|
||||
'nb_actions' => 'General_ColumnNbActionsDocumentation',
|
||||
'nb_users' => 'General_ColumnNbUsersDocumentation',
|
||||
'nb_actions_per_visit' => 'General_ColumnActionsPerVisitDocumentation',
|
||||
'avg_time_on_site' => 'General_ColumnAvgTimeOnSiteDocumentation',
|
||||
'bounce_rate' => 'General_ColumnBounceRateDocumentation',
|
||||
|
|
@ -335,7 +408,19 @@ class Metrics
|
|||
'nb_hits' => 'General_ColumnPageviewsDocumentation',
|
||||
'exit_rate' => 'General_ColumnExitRateDocumentation'
|
||||
);
|
||||
return array_map(array('\\Piwik\\Piwik','translate'), $documentation);
|
||||
|
||||
/**
|
||||
* Use this event to register translations for metrics documentation processed by your plugin.
|
||||
*
|
||||
* @param string[] $translations The array mapping of column_name => Plugin_TranslationForColumnDocumentation
|
||||
*/
|
||||
Piwik::postEvent('Metrics.getDefaultMetricDocumentationTranslations', array(&$translations));
|
||||
|
||||
$translations = array_map(array('\\Piwik\\Piwik', 'translate'), $translations);
|
||||
|
||||
$cache->save($cacheId, $translations);
|
||||
|
||||
return $translations;
|
||||
}
|
||||
|
||||
public static function getPercentVisitColumn()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue