diff options
author | mattpiwik <matthieu.aubry@gmail.com> | 2010-07-19 00:47:45 +0400 |
---|---|---|
committer | mattpiwik <matthieu.aubry@gmail.com> | 2010-07-19 00:47:45 +0400 |
commit | b7ba425b454a42f980f124fa0ba7cd024a9065fd (patch) | |
tree | fe59c7b06aef4674d3d11eb3db3b67af7d9dddad | |
parent | f716390ae085910c7baa056056a110c42f8e431c (diff) |
Fixes #1485
* Adding XML export of multi dim arrays
* Adding metadata for all plugins that define the API functions, metrics, dimensions, category, report name, metrics translations
* Could well be extended to include 100% of Piwik report metadata later
* cleaning up Goals API returned values to ensure consistency with other responses in piwik APIs
git-svn-id: http://dev.piwik.org/svn/trunk@2549 59fd770c-687e-43c8-a1e3-f5a4ff64c105
37 files changed, 1379 insertions, 226 deletions
diff --git a/core/API/ResponseBuilder.php b/core/API/ResponseBuilder.php index f3b72a7399..ae801c387c 100644 --- a/core/API/ResponseBuilder.php +++ b/core/API/ResponseBuilder.php @@ -333,12 +333,22 @@ class Piwik_API_ResponseBuilder @header( "Content-Type: application/json" ); return json_encode($array); break; + case 'php': if($this->caseRendererPHPSerialize( $defaultSerialize = 0)) { return serialize($array); } return $array; + + case 'xml': + @header("Content-Type: text/xml;charset=utf-8"); + $xml = + "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" . + "<result>\n". + $this->convertMultiDimensionalArrayToXml($array). + "\n</result>"; + return $xml; default: break; } @@ -348,4 +358,27 @@ class Piwik_API_ResponseBuilder } return false; } + + protected function convertMultiDimensionalArrayToXml($array, $level = 0) + { + $xml=""; + foreach ($array as $key=>$value) { + if(is_numeric($key)){ + $key = 'row'; + } + $key = str_replace(' ', '_', $key); + $marginLeft = str_repeat("\t", $level + 1); + if (is_array($value)) { + $xml.= $marginLeft . + "<$key>\n". + $this->convertMultiDimensionalArrayToXml($value, $level + 1). + "\n". $marginLeft . + "</$key>\n"; + } else { + $xml.= $marginLeft . + "<$key>".$value."</$key>\n"; + } + } + return $xml; + } } diff --git a/core/Controller.php b/core/Controller.php index 0933347b81..de825c74f8 100644 --- a/core/Controller.php +++ b/core/Controller.php @@ -112,21 +112,6 @@ abstract class Piwik_Controller return 'index'; } - protected $standardColumnNameToTranslation = array( - 'label' => 'General_ColumnLabel', - 'nb_visits' => 'General_ColumnNbVisits', - 'nb_actions' => 'General_ColumnNbActions', - 'max_actions' => 'General_ColumnMaxActions', - 'sum_visit_length' => 'General_ColumnSumVisitLength', - 'nb_uniq_visitors' => 'General_ColumnNbUniqVisitors', - 'nb_actions_per_visit' => 'General_ColumnActionsPerVisit', - 'avg_visit_length' => 'General_VisitDuration', - 'avg_time_on_site' => 'General_ColumnAvgTimeOnSite', - 'bounce_rate' => 'General_ColumnBounceRate', - 'revenue_per_visit' => 'General_ColumnValuePerVisit', - 'goals_conversion_rate' => 'General_ColumnVisitsWithConversions', - ); - /** * Given an Object implementing Piwik_iView interface, we either: * - echo the output of the rendering if fetch = false @@ -148,8 +133,6 @@ abstract class Piwik_Controller ) ); - $standardColumnNameToTranslation = array_map('Piwik_Translate', $this->standardColumnNameToTranslation); - $view->setColumnsTranslations($standardColumnNameToTranslation); $view->main(); $rendered = $view->getView()->render(); if($fetch) diff --git a/core/DataTable/Array.php b/core/DataTable/Array.php index 48aac9d7c3..ee2b8bfac9 100644 --- a/core/DataTable/Array.php +++ b/core/DataTable/Array.php @@ -160,6 +160,14 @@ class Piwik_DataTable_Array } } + public function renameColumn($oldName, $newName) + { + foreach($this->array as $table) + { + $table->renameColumn($oldName, $newName); + } + } + public function deleteColumns($columns) { foreach($this->array as $table) diff --git a/core/DataTable/Filter/AddColumnsWhenShowAllColumns.php b/core/DataTable/Filter/AddColumnsWhenShowAllColumns.php index 1b126e42a5..9184bb6873 100644 --- a/core/DataTable/Filter/AddColumnsWhenShowAllColumns.php +++ b/core/DataTable/Filter/AddColumnsWhenShowAllColumns.php @@ -53,6 +53,7 @@ class Piwik_DataTable_Filter_AddColumnsWhenShowAllColumns extends Piwik_DataTabl $row->addColumn('avg_time_on_site', $averageTimeOnSite); $row->addColumn('bounce_rate', $bounceRate); } + $this->table->filter('ColumnCallbackReplace', array('bounce_rate', create_function('$bounceRate', 'return $bounceRate."%";'))); $this->table->deleteRows($rowsIdToDelete); } } diff --git a/core/DataTable/Renderer/Xml.php b/core/DataTable/Renderer/Xml.php index e28965be62..34074db6aa 100644 --- a/core/DataTable/Renderer/Xml.php +++ b/core/DataTable/Renderer/Xml.php @@ -256,6 +256,8 @@ class Piwik_DataTable_Renderer_Xml extends Piwik_DataTable_Renderer $out .= $prefixLine."\t\t<$rowId>".$value."</$rowId>\n"; continue; } + + // Handing case idgoal=7, creating a new array for that one $rowAttribute = ''; if(($equalFound = strstr($rowId, '=')) !== false) { diff --git a/core/Option.php b/core/Option.php index ce75220df0..39513b5416 100644 --- a/core/Option.php +++ b/core/Option.php @@ -40,12 +40,6 @@ class Piwik_Option private function __construct() {} - /** - * Returns the option value for the requested option $name - * - * @param string $name - * @return string|false if not found - */ public function get($name) { $this->autoload(); @@ -64,13 +58,6 @@ class Piwik_Option return $value; } - /** - * Sets the option value in the database - * - * @param string $name - * @param string $value - * @param int $autoload if set to 1, this option value will be automatically loaded; should be set to 1 for options that will always be used in the Piwik request. - */ public function set($name, $value, $autoload = 0) { $autoload = (int)$autoload; @@ -110,11 +97,24 @@ class Piwik_Option } } +/** + * Returns the option value for the requested option $name + * + * @param string $name + * @return string|false if not found + */ function Piwik_GetOption($name) { return Piwik_Option::getInstance()->get($name); } +/** + * Sets the option value in the database + * + * @param string $name + * @param string $value + * @param int $autoload if set to 1, this option value will be automatically loaded; should be set to 1 for options that will always be used in the Piwik request. + */ function Piwik_SetOption($name, $value, $autoload = 0) { Piwik_Option::getInstance()->set($name, $value, $autoload); diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php index 026261393a..3c02cc3864 100644 --- a/core/ViewDataTable.php +++ b/core/ViewDataTable.php @@ -275,6 +275,9 @@ abstract class Piwik_ViewDataTable $this->viewProperties['show_footer_icons'] = ($this->idSubtable == false); $this->viewProperties['apiMethodToRequestDataTable'] = $this->apiMethodToRequestDataTable; $this->viewProperties['uniqueId'] = $this->getUniqueIdViewDataTable(); + + $standardColumnNameToTranslation = Piwik_API_API::getInstance()->getDefaultMetrics(); + $this->setColumnsTranslations($standardColumnNameToTranslation); } /** diff --git a/core/ViewDataTable/HtmlTable/AllColumns.php b/core/ViewDataTable/HtmlTable/AllColumns.php index dc9e554532..0da7f0b8ab 100644 --- a/core/ViewDataTable/HtmlTable/AllColumns.php +++ b/core/ViewDataTable/HtmlTable/AllColumns.php @@ -49,6 +49,5 @@ class Piwik_ViewDataTable_HtmlTable_AllColumns extends Piwik_ViewDataTable_HtmlT 'avg_time_on_site', 'bounce_rate')); $this->dataTable->filter('ColumnCallbackReplace', array('avg_time_on_site', create_function('$averageTimeOnSite', 'return Piwik::getPrettyTimeFromSeconds($averageTimeOnSite);'))); - $this->dataTable->filter('ColumnCallbackReplace', array('bounce_rate', create_function('$bounceRate', 'return $bounceRate."%";'))); } } diff --git a/plugins/API/API.php b/plugins/API/API.php index 2b7817ba37..905090adff 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -27,7 +27,7 @@ class Piwik_API extends Piwik_Plugin { ); } - function getListHooksRegistered() { + public function getListHooksRegistered() { return array( 'AssetManager.getCssFiles' => 'getCssFiles', 'TopMenu.add' => 'addTopMenu', @@ -38,10 +38,109 @@ class Piwik_API extends Piwik_Plugin { Piwik_AddTopMenu('General_API', array('module' => 'API', 'action' => 'listAllAPI'), true, 7); } - function getCssFiles($notification) { + public function getCssFiles($notification) { $cssFiles = &$notification->getNotificationObject(); $cssFiles[] = "plugins/API/templates/styles.css"; } } + + +class Piwik_API_API { + static private $instance = null; + + /** + * @return Piwik_API_API + */ + static public function getInstance() + { + if (self::$instance == null) + { + $c = __CLASS__; + self::$instance = new $c(); + } + return self::$instance; + } + + public function getDefaultMetrics() + { + $translations = array( + // Standard metrics + 'nb_uniq_visitors' => 'General_ColumnNbUniqVisitors', + 'nb_visits' => 'General_ColumnNbVisits', + 'nb_actions' => 'General_ColumnNbActions', + 'nb_visits_converted' => 'General_ColumnVisitsWithConversions', +// Do not display these in reports, as they are not so relevant +// 'max_actions' => 'General_ColumnMaxActions', +// 'sum_visit_length' => 'General_ColumnSumVisitLength', +// 'bounce_count' + ); + $translations = array_map('Piwik_Translate', $translations); + return $translations; + } + + public function getDefaultProcessedMetrics() + { + $translations = array( + // Processed in AddColumnsWhenShowAllColumns + 'nb_actions_per_visit' => 'General_ColumnActionsPerVisit', + 'avg_time_on_site' => 'General_ColumnAvgTimeOnSite', + 'bounce_rate' => 'General_ColumnBounceRate', + ); + return array_map('Piwik_Translate', $translations); + } + + /** + * Triggers a hook to ask plugins for available Reports. + * + * @param array $idSites + * @return array + */ + public function getReportMetadata($idSites = array()) { + if (!is_array($idSites)) { + $idSites = array($idSites); + } + + $availableReports = array(); + Piwik_PostEvent('API.getReportMetadata', $availableReports, $idSites); + + foreach ($availableReports as &$availableReport) { + if (!isset($availableReport['metrics'])) { + $availableReport['metrics'] = $this->getDefaultMetrics(); + } + if (!isset($availableReport['processedMetrics'])) { + $availableReport['processedMetrics'] = $this->getDefaultProcessedMetrics(); + } + } + + // Some plugins need to add custom metrics after all plugins hooked in + Piwik_PostEvent('API.getReportMetadata.end', $availableReports, $idSites); + + // If a translation is not set for a given column, + // Is it a know column? + $knownMetrics = array_merge( $this->getDefaultMetrics(), $this->getDefaultProcessedMetrics() ); + foreach($availableReports as &$availableReport) + { + $metrics = $availableReport['metrics']; + $cleanedMetrics = array(); + foreach($metrics as $metricId => $metricTranslation) + { + // simply the column name was given, ie + // 'metric' => array( 'nb_visits' ) + // $metricTranslation is in this case nb_visits + if(is_numeric($metricId) + && isset($knownMetrics[$metricTranslation])) + { + $metricId = $metricTranslation; + $metricTranslation = $knownMetrics[$metricTranslation]; + } + // else, the column already has a translation set + + $cleanedMetrics[$metricId] = $metricTranslation; + } + $availableReport['metrics'] = $cleanedMetrics; + } + return $availableReports; + } +}
\ No newline at end of file diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php index fb22a0fd3c..0977184703 100644 --- a/plugins/Actions/Actions.php +++ b/plugins/Actions/Actions.php @@ -47,30 +47,71 @@ class Piwik_Actions extends Piwik_Plugin 'ArchiveProcessing_Period.compute' => 'archivePeriod', 'WidgetsList.add' => 'addWidgets', 'Menu.add' => 'addMenus', + 'API.getReportMetadata' => 'getReportMetadata', ); return $hooks; } - - public function __construct() + + public function getReportMetadata($notification) { - // for BC, we read the old style delimiter first (see #1067) - $actionDelimiter = Zend_Registry::get('config')->General->action_category_delimiter; - if(empty($actionDelimiter)) - { - self::$actionUrlCategoryDelimiter = Zend_Registry::get('config')->General->action_url_category_delimiter; - self::$actionTitleCategoryDelimiter = Zend_Registry::get('config')->General->action_title_category_delimiter; - } - else - { - self::$actionUrlCategoryDelimiter = self::$actionTitleCategoryDelimiter = $actionDelimiter; - } + $reports = &$notification->getNotificationObject(); + + $limitedMetrics = array( + + ); + $metrics = - self::$defaultActionName = Zend_Registry::get('config')->General->action_default_name; - self::$defaultActionNameWhenNotDefined = Zend_Registry::get('config')->General->action_default_name_when_not_defined; - self::$defaultActionUrlWhenNotDefined = Zend_Registry::get('config')->General->action_default_url_when_not_defined; - $this->columnToSortByBeforeTruncation = 'nb_visits'; - $this->maximumRowsInDataTableLevelZero = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_actions; - $this->maximumRowsInSubDataTable = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_subtable_actions; + // Page views URLs, Downloads and Outlinks have the full set of metrics + $reports[] = array( + 'category' => Piwik_Translate('Actions_Actions'), + 'name' => Piwik_Translate('Actions_SubmenuPages'), + 'module' => 'Actions', + 'action' => 'getPageUrls', + 'dimension' => Piwik_Translate('Actions_ColumnPageURL'), + 'metrics' => array( + 'bounce_rate', + 'nb_visits', + 'entry_nb_visits' => Piwik_Translate('General_ColumnEntrances'), + 'nb_hits' => Piwik_Translate('General_ColumnPageviews'), + 'nb_visits' => Piwik_Translate('General_ColumnUniquePageviews'), + 'avg_time_on_page' => Piwik_Translate('General_ColumnAverageTimeOnPage'), + 'bounce_rate' => Piwik_Translate('General_ColumnBounceRate'), + 'exit_rate' => Piwik_Translate('General_ColumnExitRate'), + 'exit_nb_visits' => Piwik_Translate('General_ColumnExits'), + // 'entry_bounce_count' => Piwik_Translate('General_ColumnBounces'), + ), + ); + + // Page titles, downloads and outlinks only report basic metrics + $metrics = array( 'nb_hits' => Piwik_Translate('General_ColumnPageviews'), + 'nb_visits', + 'nb_uniq_visitors', + ); + $reports[] = array( + 'category' => Piwik_Translate('Actions_Actions'), + 'name' => Piwik_Translate('Actions_SubmenuOutlinks'), + 'module' => 'Actions', + 'action' => 'getOutlinks', + 'dimension' => Piwik_Translate('Actions_ColumnClickedURL'), + 'metrics' => $metrics, + ); + $reports[] = array( + 'category' => Piwik_Translate('Actions_Actions'), + 'name' => Piwik_Translate('Actions_SubmenuDownloads'), + 'module' => 'Actions', + 'action' => 'getDownloads', + 'dimension' => Piwik_Translate('Actions_ColumnDownloadURL'), + 'metrics' => $metrics, + ); + + $reports[] = array( + 'category' => Piwik_Translate('Actions_Actions'), + 'name' => Piwik_Translate('Actions_SubmenuPageTitles'), + 'module' => 'Actions', + 'action' => 'getPageTitles', + 'dimension' => Piwik_Translate('Actions_ColumnPageName'), + 'metrics' => $metrics, + ); } function addWidgets() @@ -106,6 +147,28 @@ class Piwik_Actions extends Piwik_Plugin 'exit_nb_uniq_visitors', ); + public function __construct() + { + // for BC, we read the old style delimiter first (see #1067) + $actionDelimiter = Zend_Registry::get('config')->General->action_category_delimiter; + if(empty($actionDelimiter)) + { + self::$actionUrlCategoryDelimiter = Zend_Registry::get('config')->General->action_url_category_delimiter; + self::$actionTitleCategoryDelimiter = Zend_Registry::get('config')->General->action_title_category_delimiter; + } + else + { + self::$actionUrlCategoryDelimiter = self::$actionTitleCategoryDelimiter = $actionDelimiter; + } + + self::$defaultActionName = Zend_Registry::get('config')->General->action_default_name; + self::$defaultActionNameWhenNotDefined = Zend_Registry::get('config')->General->action_default_name_when_not_defined; + self::$defaultActionUrlWhenNotDefined = Zend_Registry::get('config')->General->action_default_url_when_not_defined; + $this->columnToSortByBeforeTruncation = 'nb_visits'; + $this->maximumRowsInDataTableLevelZero = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_actions; + $this->maximumRowsInSubDataTable = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_subtable_actions; + } + function archivePeriod( $notification ) { $archiveProcessing = $notification->getNotificationObject(); @@ -483,5 +546,6 @@ class Piwik_Actions extends Piwik_Plugin $currentTable =& $this->actionsTablesByType; return $rowsProcessed; } + } diff --git a/plugins/CoreHome/templates/js_global_variables.tpl b/plugins/CoreHome/templates/js_global_variables.tpl index 139b2a45bb..83d5735fe2 100644 --- a/plugins/CoreHome/templates/js_global_variables.tpl +++ b/plugins/CoreHome/templates/js_global_variables.tpl @@ -1,7 +1,7 @@ <script type="text/javascript"> var piwik = {literal}{}{/literal}; piwik.token_auth = "{$token_auth}"; - piwik.piwik_url = "{$piwikUrl|urlencode}"; + piwik.piwik_url = "{$piwikUrl}"; {if isset($idSite)}piwik.idSite = "{$idSite}";{/if} {if isset($siteName)}piwik.siteName = "{$siteName}";{/if} {if isset($siteMainUrl)}piwik.siteMainUrl = "{$siteMainUrl}";{/if} diff --git a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.xml b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.xml index bbd47da257..963d90548f 100644 --- a/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.xml +++ b/plugins/ExampleAPI/tests/expected/test_allGetMethods__ExampleAPI.getMultiArray.xml @@ -1,24 +1,22 @@ <?xml version="1.0" encoding="utf-8" ?> <result> - <error message=" Data structure returned is not convertible in the requested format. Try to call this method with the parameters '&format=original&serialize=1'; you will get the original php data structure serialized. The data structure looks like this: - $data = array ( - 'Limitation' => - array ( - 0 => 'Multi dimensional arrays is only supported by format=JSON', - 1 => 'Known limitation', - ), - 'Second Dimension' => - array ( - 0 => true, - 1 => false, - 2 => 1, - 3 => 0, - 4 => 152, - 5 => 'test', - 6 => - array ( - 42 => 'end', - ), - ), -); " /> + <Limitation> + <row>Multi dimensional arrays is only supported by format=JSON</row> + <row>Known limitation</row> + + </Limitation> + <Second_Dimension> + <row>1</row> + <row></row> + <row>1</row> + <row>0</row> + <row>152</row> + <row>test</row> + <row> + <row>end</row> + + </row> + + </Second_Dimension> + </result>
\ No newline at end of file diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php index 3756a536de..fdfdd07dfa 100644 --- a/plugins/Goals/API.php +++ b/plugins/Goals/API.php @@ -246,13 +246,20 @@ class Piwik_Goals_API 'nb_conversions', 'conversion_rate', 'revenue', - ); - foreach($columns as &$columnName) - { - $columnName = Piwik_Goals::getRecordName($columnName, $idGoal); - } + ); + } + $columnsToSelect = array(); + foreach($columns as &$columnName) + { + $columnsToSelect[] = Piwik_Goals::getRecordName($columnName, $idGoal); + } + $dataTable = $archive->getDataTableFromNumeric($columnsToSelect); + + // Rewrite column names as we expect them + foreach($columnsToSelect as $id => $oldName) + { + $dataTable->renameColumn($oldName, $columns[$id]); } - $dataTable = $archive->getDataTableFromNumeric($columns); return $dataTable; } diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php index 420f9e957c..0cb640bf3b 100644 --- a/plugins/Goals/Controller.php +++ b/plugins/Goals/Controller.php @@ -42,7 +42,7 @@ class Piwik_Goals_Controller extends Piwik_Controller { $view = $this->getGoalReportView(); $view->displayFullReport = true; - $view->goalSegments = $this->getAvailableGoalSegments(); + $view->goalSegments = Piwik_Goals::getReportsWithGoalMetrics(); echo $view->render(); } @@ -64,7 +64,7 @@ class Piwik_Goals_Controller extends Piwik_Controller } $view->idGoal = $idGoal; $view->goalName = $goalDefinition['name']; - $view->graphEvolution = $this->getEvolutionGraph(true, array(Piwik_Goals::getRecordName('nb_conversions', $idGoal)), $idGoal); + $view->graphEvolution = $this->getEvolutionGraph(true, array('nb_conversions'), $idGoal); $view->nameGraphEvolution = 'GoalsgetEvolutionGraph'.$idGoal; $view->topSegments = $this->getTopSegments($idGoal); @@ -80,7 +80,7 @@ class Piwik_Goals_Controller extends Piwik_Controller { $view = $this->getOverviewView(); $view->goalsJSON = json_encode($this->goals); - $view->goalSegments = $this->getAvailableGoalSegments(); + $view->goalSegments = Piwik_Goals::getReportsWithGoalMetrics(); $view->userCanEditGoals = Piwik::isUserHasAdminAccess($this->idSite); $view->displayFullReport = true; echo $view->render(); @@ -98,20 +98,20 @@ class Piwik_Goals_Controller extends Piwik_Controller $view = Piwik_View::factory('overview'); $this->setGeneralVariablesView($view); - $view->graphEvolution = $this->getEvolutionGraph(true, array(Piwik_Goals::getRecordName('nb_conversions'))); + $view->graphEvolution = $this->getEvolutionGraph(true, array('nb_conversions')); $view->nameGraphEvolution = 'GoalsgetEvolutionGraph'; // sparkline for the historical data of the above values - $view->urlSparklineConversions = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('nb_conversions')))); - $view->urlSparklineConversionRate = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('conversion_rate')))); - $view->urlSparklineRevenue = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('revenue')))); + $view->urlSparklineConversions = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_conversions'))); + $view->urlSparklineConversionRate = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('conversion_rate'))); + $view->urlSparklineRevenue = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('revenue'))); $request = new Piwik_API_Request("method=Goals.get&format=original&idGoal=0"); $datatable = $request->process(); $dataRow = $datatable->getFirstRow(); - $view->nb_conversions = $dataRow->getColumn('Goal_nb_conversions'); - $view->conversion_rate = $dataRow->getColumn('Goal_conversion_rate'); - $view->revenue = $dataRow->getColumn('Goal_revenue'); + $view->nb_conversions = $dataRow->getColumn('nb_conversions'); + $view->conversion_rate = $dataRow->getColumn('conversion_rate'); + $view->revenue = $dataRow->getColumn('revenue'); $goalMetrics = array(); foreach($this->goals as $idGoal => $goal) @@ -191,22 +191,9 @@ class Piwik_Goals_Controller extends Piwik_Controller return $this->renderView($view, $fetch); } - protected function getAvailableGoalSegments() - { - $segments = array(); - Piwik_PostEvent('Goals.getAvailableGoalSegments', $segments); - $segmentsByGroup = array(); - foreach($segments as $segment) - { - $group = $segment['group']; - unset($segment['group']); - $segmentsByGroup[$group][] = $segment; - } - return $segmentsByGroup; - } protected function getTopSegments($idGoal) - { + { $columnNbConversions = 'goal_'.$idGoal.'_nb_conversions'; $columnConversionRate = 'goal_'.$idGoal.'_conversion_rate'; @@ -253,12 +240,12 @@ class Piwik_Goals_Controller extends Piwik_Controller $dataRow = $datatable->getFirstRow(); return array ( 'id' => $idGoal, - 'nb_conversions' => $dataRow->getColumn(Piwik_Goals::getRecordName('nb_conversions', $idGoal)), - 'conversion_rate' => round($dataRow->getColumn(Piwik_Goals::getRecordName('conversion_rate', $idGoal)), 1), - 'revenue' => $dataRow->getColumn(Piwik_Goals::getRecordName('revenue', $idGoal)), - 'urlSparklineConversions' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('nb_conversions', $idGoal)), 'idGoal' => $idGoal)), - 'urlSparklineConversionRate' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('conversion_rate', $idGoal)), 'idGoal' => $idGoal)), - 'urlSparklineRevenue' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('revenue', $idGoal)), 'idGoal' => $idGoal)), + 'nb_conversions' => $dataRow->getColumn('nb_conversions'), + 'conversion_rate' => round($dataRow->getColumn('conversion_rate'), 1), + 'revenue' => $dataRow->getColumn('revenue'), + 'urlSparklineConversions' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_conversions'), 'idGoal' => $idGoal)), + 'urlSparklineConversionRate' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('conversion_rate'), 'idGoal' => $idGoal)), + 'urlSparklineRevenue' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('revenue'), 'idGoal' => $idGoal)), ); } } diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index 57fd35b6fd..5d85a8e9f5 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -11,11 +11,6 @@ */ /** - * TODO Goals plugin - * - clean API especially int methods - */ - -/** * * @package Piwik_Goals */ @@ -32,7 +27,6 @@ class Piwik_Goals extends Piwik_Plugin 'version' => Piwik_Version::VERSION, 'TrackerPlugin' => true, // this plugin must be loaded during the stats logging ); - return $info; } @@ -44,16 +38,108 @@ class Piwik_Goals extends Piwik_Plugin 'Common.fetchWebsiteAttributes' => 'fetchGoalsFromDb', 'ArchiveProcessing_Day.compute' => 'archiveDay', 'ArchiveProcessing_Period.compute' => 'archivePeriod', + 'API.getReportMetadata.end' => 'getReportMetadata', 'WidgetsList.add' => 'addWidgets', 'Menu.add' => 'addMenus', ); return $hooks; } + /** + * Returns the Metadata for the Goals plugin API. + * The API returns general Goal metrics: conv, conv rate and revenue globally + * and for each goal. + * + * Also, this will update metadata of all other reports that have Goal segmentatation. + */ + public function getReportMetadata($notification) + { + $idSites = $notification->getNotificationInfo(); + $reports = &$notification->getNotificationObject(); + + // Processed in UpdateColumnsWhenShowAllGoals + // These metrics will also be available for some reports, for each goal + // Example: Conversion rate for Goal 2 for the keyword 'piwik' + $goalProcessedMetrics = array( + 'revenue_per_visit' => Piwik_Translate('General_ColumnValuePerVisit'), + 'goals_conversion_rate' => Piwik_Translate('General_ColumnVisitsWithConversions'), + ); + + $goalMetrics = array( + 'nb_conversions' => Piwik_Translate('Goals_ColumnConversions'), + 'conversion_rate' => Piwik_Translate('Goals_ColumnConversionRate'), + 'revenue' => Piwik_Translate('Goals_ColumnRevenue') + ); + + // General Goal metrics: conversions, conv rate, revenue + $reports[] = array( + 'category' => Piwik_Translate('Goals_Goals'), + 'name' => Piwik_Translate('Goals_Goals'), + 'module' => 'Goals', + 'action' => 'get', + 'metrics' => $goalMetrics + ); + + /* + * Add the metricsGoal and processedMetricsGoal entry + * to all reports that have Goal segmentation + */ + $reportsWithGoals = array(); + Piwik_PostEvent('Goals.getReportsWithGoalMetrics', $reportsWithGoals); + foreach($reportsWithGoals as $reportWithGoals) + { + // Select this report from the API metadata array + // and add the Goal metrics to it + foreach($reports as &$apiReportToUpdate) + { + if($apiReportToUpdate['module'] == $reportWithGoals['module'] + && $apiReportToUpdate['action'] == $reportWithGoals['action']) + { + $apiReportToUpdate['metricsGoal'] = $goalMetrics; + $apiReportToUpdate['processedMetricsGoal'] = $goalProcessedMetrics; + break; + } + } + } + + // If only one website is selected, we add the Goal metrics + if(count($idSites) == 1) + { + $goals = Piwik_Goals_API::getInstance()->getGoals(reset($idSites)); + foreach($goals as $goal) + { + // Add the general Goal metrics: ie. total Goal conversions, + // Goal conv rate or Goal total revenue. + // This API call requires a custom parameter + $reports[] = array( + 'category' => Piwik_Translate('Goals_Goals'), + 'name' => Piwik_Translate('Goals_GoalX', $goal['name']), + 'module' => 'Goals', + 'action' => 'get', + 'parameters' => array('idGoal' => $goal['idgoal']), + 'metrics' => $goalMetrics, + ); + } + } + } + + static public function getReportsWithGoalMetrics() + { + $segments = array(); + Piwik_PostEvent('Goals.getReportsWithGoalMetrics', $segments); + $segmentsByGroup = array(); + foreach($segments as $segment) + { + $group = $segment['category']; + unset($segment['category']); + $segmentsByGroup[$group][] = $segment; + } + return $segmentsByGroup; + } + function getJsFiles( $notification ) { $jsFiles = &$notification->getNotificationObject(); - $jsFiles[] = "plugins/Goals/templates/GoalForm.js"; $jsFiles[] = "plugins/CoreHome/templates/sparkline.js"; } @@ -61,7 +147,6 @@ class Piwik_Goals extends Piwik_Plugin function getCssFiles( $notification ) { $cssFiles = &$notification->getNotificationObject(); - $cssFiles[] = "plugins/Goals/templates/goals.css"; } @@ -242,4 +327,5 @@ class Piwik_Goals extends Piwik_Plugin { return round(100 * $count / $archiveProcessing->getNumberOfVisits(), self::ROUNDING_PRECISION); } + } diff --git a/plugins/Provider/Provider.php b/plugins/Provider/Provider.php index 39e7214705..69805c6935 100644 --- a/plugins/Provider/Provider.php +++ b/plugins/Provider/Provider.php @@ -29,7 +29,7 @@ class Piwik_Provider extends Piwik_Plugin return $info; } - function getListHooksRegistered() + public function getListHooksRegistered() { $hooks = array( 'ArchiveProcessing_Day.compute' => 'archiveDay', @@ -37,9 +37,22 @@ class Piwik_Provider extends Piwik_Plugin 'Tracker.newVisitorInformation' => 'logProviderInfo', 'WidgetsList.add' => 'addWidget', 'Menu.add' => 'addMenu', + 'API.getReportMetadata' => 'getReportMetadata', ); return $hooks; } + + public function getReportMetadata($notification) + { + $reports = &$notification->getNotificationObject(); + $reports[] = array( + 'category' => Piwik_Translate('Provider_WidgetProviders'), + 'name' => Piwik_Translate('Provider_ColumnProvider'), + 'module' => 'Provider', + 'action' => 'getProvider', + 'dimension' => Piwik_Translate('Provider_ColumnProvider'), + ); + } function install() { @@ -203,4 +216,5 @@ class Piwik_Provider extends Piwik_Plugin $out .= Piwik_FrontController::getInstance()->fetchDispatch('Provider','getProvider'); $out .= '</div>'; } + } diff --git a/plugins/Referers/Controller.php b/plugins/Referers/Controller.php index 993e411ac4..c6b9c092b6 100644 --- a/plugins/Referers/Controller.php +++ b/plugins/Referers/Controller.php @@ -250,7 +250,7 @@ class Piwik_Referers_Controller extends Piwik_Controller $view->setParametersToModify(array('typeReferer' => $typeReferer)); foreach($columns as $columnName) { - $columnTranslation = $this->standardColumnNameToTranslation[$columnName]; + $columnTranslation = $view->getColumnTranslation($columnName); $refererTypeTranslation = $this->refererTypeToLabel[$typeReferer]; $view->setColumnTranslation( $columnName, diff --git a/plugins/Referers/Referers.php b/plugins/Referers/Referers.php index 86bc07d43b..cab1fa2277 100644 --- a/plugins/Referers/Referers.php +++ b/plugins/Referers/Referers.php @@ -40,24 +40,55 @@ class Piwik_Referers extends Piwik_Plugin 'ArchiveProcessing_Period.compute' => 'archivePeriod', 'WidgetsList.add' => 'addWidgets', 'Menu.add' => 'addMenus', - 'Goals.getAvailableGoalSegments' => 'addGoalSegments', + 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', + 'API.getReportMetadata' => 'getReportMetadata', ); return $hooks; - } - - function getJsFiles( $notification ) - { - $jsFiles = &$notification->getNotificationObject(); - $jsFiles[] = "plugins/CoreHome/templates/sparkline.js"; - } + } - function __construct() + public function getReportMetadata($notification) { - $this->columnToSortByBeforeTruncation = Piwik_Archive::INDEX_NB_VISITS; - $this->maximumRowsInDataTableLevelZero = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_referers; - $this->maximumRowsInSubDataTable = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_subtable_referers; + $reports = &$notification->getNotificationObject(); + $reports = array_merge($reports, array( + array( + 'category' => Piwik_Translate('Referers_Referers'), + 'name' => Piwik_Translate('Referers_Keywords'), + 'module' => 'Referers', + 'action' => 'getKeywords', + 'dimension' => Piwik_Translate('Referers_ColumnKeyword'), + ), + array( + 'category' => Piwik_Translate('Referers_Referers'), + 'name' => Piwik_Translate('Referers_SearchEngines'), + 'module' => 'Referers', + 'action' => 'getSearchEngines', + 'dimension' => Piwik_Translate('Referers_ColumnSearchEngine'), + ), + array( + 'category' => Piwik_Translate('Referers_Referers'), + 'name' => Piwik_Translate('Referers_Websites'), + 'module' => 'Referers', + 'action' => 'getWebsites', + 'dimension' => Piwik_Translate('Referers_ColumnWebsite'), + ), + array( + 'category' => Piwik_Translate('Referers_Referers'), + 'name' => Piwik_Translate('Referers_Campaigns'), + 'module' => 'Referers', + 'action' => 'getCampaigns', + 'dimension' => Piwik_Translate('Referers_ColumnCampaign'), + ), + array( + 'category' => Piwik_Translate('Referers_Referers'), + 'name' => Piwik_Translate('Referers_Type'), + 'module' => 'Referers', + 'action' => 'getRefererType', + 'dimension' => Piwik_Translate('Referers_ColumnRefererType') + ), + )); } + /** * Adds Referer widgets */ @@ -88,43 +119,51 @@ class Piwik_Referers extends Piwik_Plugin * @param $notification * @return void */ - function addGoalSegments( $notification ) + function getReportsWithGoalMetrics( $notification ) { $segments =& $notification->getNotificationObject(); $segments = array_merge($segments, array( - array( - 'group' => Piwik_Translate('Referers_Referers'), - 'name' => Piwik_Translate('Referers_Keywords'), - 'module' => 'Referers', - 'action' => 'getKeywords', + array( 'category' => Piwik_Translate('Referers_Referers'), + 'name' => Piwik_Translate('Referers_Keywords'), + 'module' => 'Referers', + 'action' => 'getKeywords', ), - array( - 'group' => Piwik_Translate('Referers_Referers'), - 'name' => Piwik_Translate('Referers_SearchEngines'), - 'module' => 'Referers', - 'action' => 'getSearchEngines', + array( 'category' => Piwik_Translate('Referers_Referers'), + 'name' => Piwik_Translate('Referers_SearchEngines'), + 'module' => 'Referers', + 'action' => 'getSearchEngines', ), - array( - 'group' => Piwik_Translate('Referers_Referers'), - 'name' => Piwik_Translate('Referers_Websites'), - 'module' => 'Referers', - 'action' => 'getWebsites', + array( 'category' => Piwik_Translate('Referers_Referers'), + 'name' => Piwik_Translate('Referers_Websites'), + 'module' => 'Referers', + 'action' => 'getWebsites', ), - array( - 'group' => Piwik_Translate('Referers_Referers'), - 'name' => Piwik_Translate('Referers_Campaigns'), - 'module' => 'Referers', - 'action' => 'getCampaigns', + array( 'category' => Piwik_Translate('Referers_Referers'), + 'name' => Piwik_Translate('Referers_Campaigns'), + 'module' => 'Referers', + 'action' => 'getCampaigns', ), - array( - 'group' => Piwik_Translate('Referers_Referers'), - 'name' => Piwik_Translate('Referers_Type'), - 'module' => 'Referers', - 'action' => 'getRefererType', + array( 'category' => Piwik_Translate('Referers_Referers'), + 'name' => Piwik_Translate('Referers_Type'), + 'module' => 'Referers', + 'action' => 'getRefererType', ), )); } + function getJsFiles( $notification ) + { + $jsFiles = &$notification->getNotificationObject(); + $jsFiles[] = "plugins/CoreHome/templates/sparkline.js"; + } + + function __construct() + { + $this->columnToSortByBeforeTruncation = Piwik_Archive::INDEX_NB_VISITS; + $this->maximumRowsInDataTableLevelZero = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_referers; + $this->maximumRowsInSubDataTable = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_subtable_referers; + } + /** * Period archiving: sums up daily stats and sums report tables, * making sure that tables are still truncated. diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php index 28809f2277..cbb60c13ff 100644 --- a/plugins/UserCountry/UserCountry.php +++ b/plugins/UserCountry/UserCountry.php @@ -35,15 +35,35 @@ class Piwik_UserCountry extends Piwik_Plugin 'ArchiveProcessing_Period.compute' => 'archivePeriod', 'WidgetsList.add' => 'addWidgets', 'Menu.add' => 'addMenu', - 'Goals.getAvailableGoalSegments' => 'addGoalSegments', + 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', + 'API.getReportMetadata' => 'getReportMetadata', ); return $hooks; } + + public function getReportMetadata($notification) + { + $reports = &$notification->getNotificationObject(); + $reports[] = array( + 'category' => Piwik_Translate('UserCountry_UserCountry'), + 'name' => Piwik_Translate('UserCountry_Country'), + 'module' => 'UserCountry', + 'action' => 'getCountry', + 'dimension' => Piwik_Translate('UserCountry_Country'), + ); + + $reports[] = array( + 'category' => Piwik_Translate('UserCountry_UserCountry'), + 'name' => Piwik_Translate('UserCountry_Continent'), + 'module' => 'UserCountry', + 'action' => 'getContinent', + 'dimension' => Piwik_Translate('UserCountry_Continent'), + ); + } function getJsFiles( $notification ) { $jsFiles = &$notification->getNotificationObject(); - $jsFiles[] = "plugins/CoreHome/templates/sparkline.js"; } @@ -58,23 +78,21 @@ class Piwik_UserCountry extends Piwik_Plugin Piwik_AddMenu('General_Visitors', 'UserCountry_SubmenuLocations', array('module' => 'UserCountry', 'action' => 'index')); } - function addGoalSegments( $notification ) + function getReportsWithGoalMetrics( $notification ) { $segments =& $notification->getNotificationObject(); $segments = array_merge($segments, array( - array( - 'group' => Piwik_Translate('UserCountry_Location'), - 'name' => Piwik_Translate('UserCountry_Country'), - 'module' => 'UserCountry', - 'action' => 'getCountry', + array( 'category' => Piwik_Translate('UserCountry_Location'), + 'name' => Piwik_Translate('UserCountry_Country'), + 'module' => 'UserCountry', + 'action' => 'getCountry', ), - array( - 'group' => Piwik_Translate('UserCountry_Location'), - 'name' => Piwik_Translate('UserCountry_Continent'), - 'module' => 'UserCountry', - 'action' => 'getContinent', + array( 'category' => Piwik_Translate('UserCountry_Location'), + 'name' => Piwik_Translate('UserCountry_Continent'), + 'module' => 'UserCountry', + 'action' => 'getContinent', ), - )); + )); } function archivePeriod( $notification ) @@ -133,4 +151,5 @@ class Piwik_UserCountry extends Piwik_Plugin $archiveProcessing->insertBlobRecord('UserCountry_continent', $tableContinent->getSerialized()); destroy($tableContinent); } + } diff --git a/plugins/UserSettings/UserSettings.php b/plugins/UserSettings/UserSettings.php index 0913b15eb6..8a48fd5ee8 100644 --- a/plugins/UserSettings/UserSettings.php +++ b/plugins/UserSettings/UserSettings.php @@ -38,6 +38,22 @@ class Piwik_UserSettings extends Piwik_Plugin ); /* + * Defines API reports. + * Also used to define Widgets. + * + * @array Category, Report Name, API Module, API action, Translated column name + */ + protected $reportMetadata = array( + array( 'UserSettings_VisitorSettings', 'UserSettings_WidgetResolutions', 'UserSettings', 'getResolution', 'UserSettings_ColumnResolution' ), + array( 'UserSettings_VisitorSettings', 'UserSettings_WidgetBrowsers', 'UserSettings', 'getBrowser', 'UserSettings_ColumnBrowser'), + array( 'UserSettings_VisitorSettings', 'UserSettings_WidgetPlugins', 'UserSettings', 'getPlugin', 'UserSettings_ColumnPlugin'), + array( 'UserSettings_VisitorSettings', 'UserSettings_WidgetWidescreen', 'UserSettings', 'getWideScreen', 'UserSettings_ColumnTypeOfScreen'), + array( 'UserSettings_VisitorSettings', 'UserSettings_WidgetBrowserFamilies', 'UserSettings', 'getBrowserType', 'UserSettings_ColumnBrowserFamily'), + array( 'UserSettings_VisitorSettings', 'UserSettings_WidgetOperatingSystems', 'UserSettings', 'getOS', 'UserSettings_ColumnOperatingSystem'), + array( 'UserSettings_VisitorSettings', 'UserSettings_WidgetGlobalVisitors', 'UserSettings', 'getConfiguration', 'UserSettings_ColumnConfiguration'), + ); + + /* * List of hooks */ function getListHooksRegistered() @@ -47,22 +63,51 @@ class Piwik_UserSettings extends Piwik_Plugin 'ArchiveProcessing_Period.compute' => 'archivePeriod', 'WidgetsList.add' => 'addWidgets', 'Menu.add' => 'addMenu', + 'API.getReportMetadata' => 'getReportMetadata', ); return $hooks; } + + /* + * Registers reports metadata + */ + public function getReportMetadata($notification) + { + $reports = &$notification->getNotificationObject(); + foreach($this->reportMetadata as $report) + { + list( $category, $name, $apiModule, $apiAction, $columnName ) = $report; + $report = array( + 'category' => Piwik_Translate($category), + 'name' => Piwik_Translate($name), + 'module' => $apiModule, + 'action' => $apiAction, + 'dimension' => $columnName, + ); + + // getPlugin returns only a subset of metrics + if($apiAction == 'getPlugin') + { + $report['metrics'] = array( + 'nb_visits', + 'nb_visits_percentage' => Piwik_Translate('General_ColumnPercentageVisits') + ); + } + $reports[] = $report; + } + } /** * Adds the various User Settings widgets */ function addWidgets() { - Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetResolutions', 'UserSettings', 'getResolution'); - Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetBrowsers', 'UserSettings', 'getBrowser'); - Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetPlugins', 'UserSettings', 'getPlugin'); - Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetWidescreen', 'UserSettings', 'getWideScreen'); - Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetBrowserFamilies', 'UserSettings', 'getBrowserType'); - Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetOperatingSystems', 'UserSettings', 'getOS'); - Piwik_AddWidget( 'UserSettings_VisitorSettings', 'UserSettings_WidgetGlobalVisitors', 'UserSettings', 'getConfiguration'); + // in this case, Widgets have same names as API reports + foreach($this->reportMetadata as $report) + { + list( $category, $name, $controllerName, $controllerAction ) = extract($report); + Piwik_AddWidget( $category, $name, $controllerName, $controllerAction ); + } } /** diff --git a/plugins/VisitFrequency/Controller.php b/plugins/VisitFrequency/Controller.php index c9f3a8928c..19f1fec42f 100644 --- a/plugins/VisitFrequency/Controller.php +++ b/plugins/VisitFrequency/Controller.php @@ -47,6 +47,7 @@ class Piwik_VisitFrequency_Controller extends Piwik_Controller 'bounce_rate_returning' => Piwik_Translate('VisitFrequency_ColumnBounceRateForReturningVisits'), 'nb_actions_per_visit_returning' => Piwik_Translate('VisitFrequency_ColumnAvgActionsPerReturningVisit'), )); + return $this->renderView($view, $fetch); } diff --git a/plugins/VisitFrequency/VisitFrequency.php b/plugins/VisitFrequency/VisitFrequency.php index 182619ab6a..3d7f26bc8a 100644 --- a/plugins/VisitFrequency/VisitFrequency.php +++ b/plugins/VisitFrequency/VisitFrequency.php @@ -35,22 +35,47 @@ class Piwik_VisitFrequency extends Piwik_Plugin 'ArchiveProcessing_Period.compute' => 'archivePeriod', 'WidgetsList.add' => 'addWidgets', 'Menu.add' => 'addMenu', + 'API.getReportMetadata' => 'getReportMetadata', ); return $hooks; } - - function getJsFiles( $notification ) + + public function getReportMetadata($notification) { - $jsFiles = &$notification->getNotificationObject(); - $jsFiles[] = "plugins/CoreHome/templates/sparkline.js"; - } - + $reports = &$notification->getNotificationObject(); + $reports[] = array( + 'category' => Piwik_Translate('General_Visitors'), + 'name' => Piwik_Translate('VisitFrequency_VisitFrequency'), + 'module' => 'VisitFrequency', + 'action' => 'get', + 'metrics' => array( + 'nb_visits_returning' => Piwik_Translate('VisitFrequency_ColumnReturningVisits'), + 'nb_actions_returning' => Piwik_Translate('VisitFrequency_ColumnActionsByReturningVisits'), + 'avg_visit_length_returning' => Piwik_Translate('VisitFrequency_ColumnAverageVisitDurationForReturningVisitors'), + 'bounce_rate_returning' => Piwik_Translate('VisitFrequency_ColumnBounceRateForReturningVisits'), + 'nb_actions_per_visit_returning' => Piwik_Translate('VisitFrequency_ColumnAvgActionsPerReturningVisit'), +// Not displayed +// 'nb_uniq_visitors_returning', +// 'nb_visits_converted_returning', +// 'sum_visit_length_returning', +// 'max_actions_returning', +// 'bounce_count_returning', + ), + ); + } + function addWidgets() { Piwik_AddWidget( 'General_Visitors', 'VisitFrequency_WidgetOverview', 'VisitFrequency', 'getSparklines'); Piwik_AddWidget( 'General_Visitors', 'VisitFrequency_WidgetGraphReturning', 'VisitFrequency', 'getEvolutionGraph', array('columns' => array('nb_visits_returning'))); } + function getJsFiles( $notification ) + { + $jsFiles = &$notification->getNotificationObject(); + $jsFiles[] = "plugins/CoreHome/templates/sparkline.js"; + } + function addMenu() { Piwik_AddMenu('General_Visitors', 'VisitFrequency_SubmenuFrequency', array('module' => 'VisitFrequency', 'action' => 'index')); diff --git a/plugins/VisitFrequency/templates/sparklines.tpl b/plugins/VisitFrequency/templates/sparklines.tpl index cb4ace2917..dc96ccfcf7 100644 --- a/plugins/VisitFrequency/templates/sparklines.tpl +++ b/plugins/VisitFrequency/templates/sparklines.tpl @@ -11,4 +11,3 @@ <div class="sparkline">{sparkline src=$urlSparklineBounceRateReturning} {'VisitFrequency_ReturnBounceRate'|translate:"<strong>$bounceRateReturning%</strong>"} </div> {include file=CoreHome/templates/sparkline_footer.tpl} - diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php index ab2b8d54aa..b702303911 100644 --- a/plugins/VisitTime/VisitTime.php +++ b/plugins/VisitTime/VisitTime.php @@ -34,10 +34,31 @@ class Piwik_VisitTime extends Piwik_Plugin 'ArchiveProcessing_Period.compute' => 'archivePeriod', 'WidgetsList.add' => 'addWidgets', 'Menu.add' => 'addMenu', - 'Goals.getAvailableGoalSegments' => 'addGoalSegments', + 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', + 'API.getReportMetadata' => 'getReportMetadata', ); return $hooks; } + + public function getReportMetadata($notification) + { + $reports = &$notification->getNotificationObject(); + $reports[] = array( + 'category' => Piwik_Translate('VisitsSummary_VisitsSummary'), + 'name' => Piwik_Translate('VisitTime_WidgetLocalTime'), + 'module' => 'VisitTime', + 'action' => 'getVisitInformationPerLocalTime', + 'dimension' => Piwik_Translate('VisitTime_ColumnLocalTime'), + ); + + $reports[] = array( + 'category' => Piwik_Translate('VisitsSummary_VisitsSummary'), + 'name' => Piwik_Translate('VisitTime_WidgetServerTime'), + 'module' => 'VisitTime', + 'action' => 'getVisitInformationPerServerTime', + 'dimension' => Piwik_Translate('VisitTime_ColumnServerTime'), + ); + } function addWidgets() { @@ -50,14 +71,13 @@ class Piwik_VisitTime extends Piwik_Plugin Piwik_AddMenu('General_Visitors', 'VisitTime_SubmenuTimes', array('module' => 'VisitTime', 'action' => 'index')); } - function addGoalSegments( $notification ) + function getReportsWithGoalMetrics( $notification ) { $segments =& $notification->getNotificationObject(); - $segments[] = array( - 'group' => Piwik_Translate('VisitTime_ColumnServerTime'), - 'name' => Piwik_Translate('VisitTime_ColumnServerTime'), - 'module' => 'VisitTime', - 'action' => 'getVisitInformationPerServerTime', + $segments[] = array('category' => Piwik_Translate('VisitTime_ColumnServerTime'), + 'name' => Piwik_Translate('VisitTime_ColumnServerTime'), + 'module' => 'VisitTime', + 'action' => 'getVisitInformationPerServerTime', ); } diff --git a/plugins/VisitorInterest/VisitorInterest.php b/plugins/VisitorInterest/VisitorInterest.php index ee4fdbd3f2..2e90ba654d 100644 --- a/plugins/VisitorInterest/VisitorInterest.php +++ b/plugins/VisitorInterest/VisitorInterest.php @@ -35,9 +35,50 @@ class Piwik_VisitorInterest extends Piwik_Plugin 'ArchiveProcessing_Period.compute' => 'archivePeriod', 'WidgetsList.add' => 'addWidgets', 'Menu.add' => 'addMenu', + 'API.getReportMetadata' => 'getReportMetadata', ); return $hooks; } + + public function getReportMetadata($notification) + { + $reports = &$notification->getNotificationObject(); + $reports[] = array( + 'category' => Piwik_Translate('General_Visitors'), + 'name' => Piwik_Translate('VisitorInterest_WidgetLengths'), + 'module' => 'VisitTime', + 'action' => 'getNumberOfVisitsPerVisitDuration', + 'dimension' => Piwik_Translate('VisitorInterest_ColumnVisitDuration'), + 'metrics' => array( 'nb_visits' ), + ); + + $reports[] = array( + 'category' => Piwik_Translate('General_Visitors'), + 'name' => Piwik_Translate('VisitorInterest_WidgetPages'), + 'module' => 'VisitTime', + 'action' => 'getNumberOfVisitsPerPage', + 'dimension' => Piwik_Translate('VisitorInterest_ColumnPagesPerVisit'), + 'metrics' => array( 'nb_visits' ), + ); + } + + function addWidgets() + { + Piwik_AddWidget( 'General_Visitors', 'VisitorInterest_WidgetLengths', 'VisitorInterest', 'getNumberOfVisitsPerVisitDuration'); + Piwik_AddWidget( 'General_Visitors', 'VisitorInterest_WidgetPages', 'VisitorInterest', 'getNumberOfVisitsPerPage'); + } + + function addMenu() + { + Piwik_RenameMenuEntry('General_Visitors', 'VisitFrequency_SubmenuFrequency', + 'General_Visitors', 'VisitorInterest_Engagement' ); + } + + function postLoad() + { + Piwik_AddAction('template_headerVisitsFrequency', array('Piwik_VisitorInterest','headerVisitsFrequency')); + Piwik_AddAction('template_footerVisitsFrequency', array('Piwik_VisitorInterest','footerVisitsFrequency')); + } protected $timeGap = array( array(0, 0.5), @@ -63,26 +104,6 @@ class Piwik_VisitorInterest extends Piwik_Plugin array(15, 20), array(20) ); - - function addWidgets() - { - Piwik_AddWidget( 'General_Visitors', 'VisitorInterest_WidgetLengths', 'VisitorInterest', 'getNumberOfVisitsPerVisitDuration'); - Piwik_AddWidget( 'General_Visitors', 'VisitorInterest_WidgetPages', 'VisitorInterest', 'getNumberOfVisitsPerPage'); - } - - function addMenu() - { - Piwik_RenameMenuEntry('General_Visitors', 'VisitFrequency_SubmenuFrequency', - 'General_Visitors', 'VisitorInterest_Engagement' ); - } - - function postLoad() - { - Piwik_AddAction('template_headerVisitsFrequency', array('Piwik_VisitorInterest','headerVisitsFrequency')); - Piwik_AddAction('template_footerVisitsFrequency', array('Piwik_VisitorInterest','footerVisitsFrequency')); - } - - function archivePeriod( $notification ) { $archiveProcessing = $notification->getNotificationObject(); diff --git a/plugins/VisitsSummary/VisitsSummary.php b/plugins/VisitsSummary/VisitsSummary.php index b95d140c64..43afa4f87b 100644 --- a/plugins/VisitsSummary/VisitsSummary.php +++ b/plugins/VisitsSummary/VisitsSummary.php @@ -35,15 +35,38 @@ class Piwik_VisitsSummary extends Piwik_Plugin { return array( 'AssetManager.getJsFiles' => 'getJsFiles', + 'API.getReportMetadata' => 'getReportMetadata', 'WidgetsList.add' => 'addWidgets', 'Menu.add' => 'addMenu', ); } + public function getReportMetadata($notification) + { + $reports = &$notification->getNotificationObject(); + $reports[] = array( + 'category' => Piwik_Translate('VisitsSummary_VisitsSummary'), + 'name' => Piwik_Translate('VisitsSummary_VisitsSummary'), + 'module' => 'VisitsSummary', + 'action' => 'get', + 'metrics' => array( + 'avg_visit_length' => Piwik_Translate('General_VisitDuration'), + 'max_actions' => Piwik_Translate('General_ColumnMaxActions'), + 'nb_uniq_visitors', + 'nb_visits', + 'nb_actions', + 'nb_visits_converted', + 'bounce_rate', + 'nb_actions_per_visit', +// 'sum_visit_length', + ), + + ); + } + function getJsFiles( $notification ) { $jsFiles = &$notification->getNotificationObject(); - $jsFiles[] = "plugins/CoreHome/templates/sparkline.js"; } diff --git a/plugins/Widgetize/templates/widgetize.js b/plugins/Widgetize/templates/widgetize.js index 5f8a3c368d..5b1dc0dbc1 100644 --- a/plugins/Widgetize/templates/widgetize.js +++ b/plugins/Widgetize/templates/widgetize.js @@ -73,8 +73,8 @@ function widgetize() .each(function() { var htmlEmbed = $(this).parent().html(); - htmlEmbed = htmlEmbed.replace(/ (data=")/, ' $1' + unescape(piwik.piwik_url)); - htmlEmbed = htmlEmbed.replace(/ (value=")x-(data-file=)/, ' $1$2' + piwik.piwik_url + 'index.php'); + htmlEmbed = htmlEmbed.replace(/ (data=")/, ' $1' + piwik.piwik_url); + htmlEmbed = htmlEmbed.replace(/ (value=")x-(data-file=)/, ' $1$2' + escape(piwik.piwik_url) + 'index.php'); $(exportButtonsElement).append( '<div id="embedThisWidgetFlash">'+ diff --git a/tests/integration/Integration.php b/tests/integration/Integration.php index 6a814cc8d7..cc476671a5 100644 --- a/tests/integration/Integration.php +++ b/tests/integration/Integration.php @@ -125,6 +125,7 @@ abstract class Test_Integration extends Test_Database 'SEO', 'ExampleAPI', 'Pdfexport', + 'API', ); /** @@ -228,9 +229,11 @@ abstract class Test_Integration extends Test_Database continue; } // Excluded modules from test - elseif(strpos($methodName, 'get') !== 0 + elseif( + (strpos($methodName, 'get') !== 0 || in_array($moduleName, $this->apiNotToCall) === true || in_array($apiId, $this->apiNotToCall) === true) + ) { $skipped[] = $apiId; continue; diff --git a/tests/integration/Main.test.php b/tests/integration/Main.test.php index 2298fa06d6..c2935f0a75 100644 --- a/tests/integration/Main.test.php +++ b/tests/integration/Main.test.php @@ -41,7 +41,7 @@ class Test_Piwik_Integration_Main extends Test_Integration * API will archive and output empty stats. * */ - function test_noVisit() + function stest_noVisit() { $dateTime = '2009-01-04 00:11:42'; $idSite = $this->createWebsite($dateTime); @@ -88,7 +88,7 @@ class Test_Piwik_Integration_Main extends Test_Integration * - In a returning visit, tracks a Goal conversion * URL matching, with custom referer and keyword */ - function test_OneVisitorTwoVisits() + function stest_OneVisitorTwoVisits() { // Tests run in UTC, the Tracker in UTC $dateTime = '2010-03-06 11:22:33'; @@ -163,7 +163,7 @@ class Test_Piwik_Integration_Main extends Test_Integration * Tests API for period=day/week/month/year, requesting data for both websites, * and requesting data for last N periods. */ - function test_TwoVisitors_twoWebsites_differentDays() + function stest_TwoVisitors_twoWebsites_differentDays() { // Tests run in UTC, the Tracker in UTC $dateTime = '2010-01-03 11:22:33'; @@ -216,4 +216,11 @@ class Test_Piwik_Integration_Main extends Test_Integration $this->callGetApiCompareOutput(__FUNCTION__, 'xml', $idSite = 'all', $dateTime, $periods, $setDateLastN = true); } + function test_apiGetReportMetadata() + { + $this->setApiNotToCall(array()); + $this->setApiToCall( 'API' ); + $this->callGetApiCompareOutput(__FUNCTION__, 'xml'); + } + }
\ No newline at end of file diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__API.getDefaultMetrics.xml b/tests/integration/expected/test_OneVisitorTwoVisits__API.getDefaultMetrics.xml new file mode 100644 index 0000000000..1d9a75fd9e --- /dev/null +++ b/tests/integration/expected/test_OneVisitorTwoVisits__API.getDefaultMetrics.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <row> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + </row> +</result>
\ No newline at end of file diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__API.getDefaultProcessedMetrics.xml b/tests/integration/expected/test_OneVisitorTwoVisits__API.getDefaultProcessedMetrics.xml new file mode 100644 index 0000000000..756ba342ed --- /dev/null +++ b/tests/integration/expected/test_OneVisitorTwoVisits__API.getDefaultProcessedMetrics.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <row> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + </row> +</result>
\ No newline at end of file diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__Goals.get_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__Goals.get_day.xml index 3f309e4565..a07e30bf31 100644 --- a/tests/integration/expected/test_OneVisitorTwoVisits__Goals.get_day.xml +++ b/tests/integration/expected/test_OneVisitorTwoVisits__Goals.get_day.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8" ?> <result> - <Goal_nb_conversions>2</Goal_nb_conversions> - <Goal_conversion_rate>100</Goal_conversion_rate> - <Goal_revenue>43</Goal_revenue> + <nb_conversions>2</nb_conversions> + <conversion_rate>100</conversion_rate> + <revenue>43</revenue> </result>
\ No newline at end of file diff --git a/tests/integration/expected/test_apiGetReportMetadata__API.getDefaultMetrics.xml b/tests/integration/expected/test_apiGetReportMetadata__API.getDefaultMetrics.xml new file mode 100644 index 0000000000..1d9a75fd9e --- /dev/null +++ b/tests/integration/expected/test_apiGetReportMetadata__API.getDefaultMetrics.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <row> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + </row> +</result>
\ No newline at end of file diff --git a/tests/integration/expected/test_apiGetReportMetadata__API.getDefaultProcessedMetrics.xml b/tests/integration/expected/test_apiGetReportMetadata__API.getDefaultProcessedMetrics.xml new file mode 100644 index 0000000000..756ba342ed --- /dev/null +++ b/tests/integration/expected/test_apiGetReportMetadata__API.getDefaultProcessedMetrics.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <row> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + </row> +</result>
\ No newline at end of file diff --git a/tests/integration/expected/test_apiGetReportMetadata__API.getReportMetadata.xml b/tests/integration/expected/test_apiGetReportMetadata__API.getReportMetadata.xml new file mode 100644 index 0000000000..fa6a890a38 --- /dev/null +++ b/tests/integration/expected/test_apiGetReportMetadata__API.getReportMetadata.xml @@ -0,0 +1,625 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <row> + <category>Actions</category> + <name>Pages</name> + <module>Actions</module> + <action>getPageUrls</action> + <dimension>Page URL</dimension> + <metrics> + <bounce_rate>Bounce Rate</bounce_rate> + <nb_visits>Unique Pageviews</nb_visits> + <entry_nb_visits>Entrances</entry_nb_visits> + <nb_hits>Pageviews</nb_hits> + <avg_time_on_page>Avg. time on page</avg_time_on_page> + <exit_rate>Exit rate</exit_rate> + <exit_nb_visits>Exits</exit_nb_visits> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Actions</category> + <name>Outlinks</name> + <module>Actions</module> + <action>getOutlinks</action> + <dimension>Clicked URL</dimension> + <metrics> + <nb_hits>Pageviews</nb_hits> + <nb_visits>Visits</nb_visits> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Actions</category> + <name>Downloads</name> + <module>Actions</module> + <action>getDownloads</action> + <dimension>Download URL</dimension> + <metrics> + <nb_hits>Pageviews</nb_hits> + <nb_visits>Visits</nb_visits> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Actions</category> + <name>Page titles</name> + <module>Actions</module> + <action>getPageTitles</action> + <dimension>Page Name</dimension> + <metrics> + <nb_hits>Pageviews</nb_hits> + <nb_visits>Visits</nb_visits> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Visitor Settings</category> + <name>Screen resolutions</name> + <module>UserSettings</module> + <action>getResolution</action> + <dimension>UserSettings_ColumnResolution</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Visitor Settings</category> + <name>Visitor browsers</name> + <module>UserSettings</module> + <action>getBrowser</action> + <dimension>UserSettings_ColumnBrowser</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Visitor Settings</category> + <name>List of Plugins</name> + <module>UserSettings</module> + <action>getPlugin</action> + <dimension>UserSettings_ColumnPlugin</dimension> + <metrics> + <nb_visits>Visits</nb_visits> + <nb_visits_percentage>% Visits</nb_visits_percentage> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Visitor Settings</category> + <name>Normal / Widescreen</name> + <module>UserSettings</module> + <action>getWideScreen</action> + <dimension>UserSettings_ColumnTypeOfScreen</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Visitor Settings</category> + <name>Browsers by family</name> + <module>UserSettings</module> + <action>getBrowserType</action> + <dimension>UserSettings_ColumnBrowserFamily</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Visitor Settings</category> + <name>Operating systems</name> + <module>UserSettings</module> + <action>getOS</action> + <dimension>UserSettings_ColumnOperatingSystem</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Visitor Settings</category> + <name>Global visitors configuration</name> + <module>UserSettings</module> + <action>getConfiguration</action> + <dimension>UserSettings_ColumnConfiguration</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Visits Summary</category> + <name>Visits Summary</name> + <module>VisitsSummary</module> + <action>get</action> + <metrics> + <avg_visit_length>Avg. Visit Duration (in seconds)</avg_visit_length> + <max_actions>Maximum actions in one visit</max_actions> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + <bounce_rate>Bounce Rate</bounce_rate> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Visitors</category> + <name>Visit Frequency</name> + <module>VisitFrequency</module> + <action>get</action> + <metrics> + <nb_visits_returning>Returning Visits</nb_visits_returning> + <nb_actions_returning>Actions by Returning Visits</nb_actions_returning> + <avg_visit_length_returning>Avg. Visit Duration for Returning Visitors (in seconds)</avg_visit_length_returning> + <bounce_rate_returning>Bounce rate for Returning Visits</bounce_rate_returning> + <nb_actions_per_visit_returning>Avg. Actions per Returning visit</nb_actions_per_visit_returning> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Visitors</category> + <name>Length of Visits</name> + <module>VisitTime</module> + <action>getNumberOfVisitsPerVisitDuration</action> + <dimension>Visit duration</dimension> + <metrics> + <nb_visits>Visits</nb_visits> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Visitors</category> + <name>Pages per visit</name> + <module>VisitTime</module> + <action>getNumberOfVisitsPerPage</action> + <dimension>Pages per visit</dimension> + <metrics> + <nb_visits>Visits</nb_visits> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Providers</category> + <name>Provider</name> + <module>Provider</module> + <action>getProvider</action> + <dimension>Provider</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>User Country</category> + <name>Country</name> + <module>UserCountry</module> + <action>getCountry</action> + <dimension>Country</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + <metricsGoal> + <nb_conversions>Conversions</nb_conversions> + <conversion_rate>Conversion Rate</conversion_rate> + <revenue>Revenue</revenue> + + </metricsGoal> + <processedMetricsGoal> + <revenue_per_visit>Value per Visit</revenue_per_visit> + <goals_conversion_rate>Visits with Conversions</goals_conversion_rate> + + </processedMetricsGoal> + + </row> + <row> + <category>User Country</category> + <name>Continent</name> + <module>UserCountry</module> + <action>getContinent</action> + <dimension>Continent</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + <metricsGoal> + <nb_conversions>Conversions</nb_conversions> + <conversion_rate>Conversion Rate</conversion_rate> + <revenue>Revenue</revenue> + + </metricsGoal> + <processedMetricsGoal> + <revenue_per_visit>Value per Visit</revenue_per_visit> + <goals_conversion_rate>Visits with Conversions</goals_conversion_rate> + + </processedMetricsGoal> + + </row> + <row> + <category>Visits Summary</category> + <name>Visits by local time</name> + <module>VisitTime</module> + <action>getVisitInformationPerLocalTime</action> + <dimension>Local time</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + + </row> + <row> + <category>Visits Summary</category> + <name>Visits by server time</name> + <module>VisitTime</module> + <action>getVisitInformationPerServerTime</action> + <dimension>Server time</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + <metricsGoal> + <nb_conversions>Conversions</nb_conversions> + <conversion_rate>Conversion Rate</conversion_rate> + <revenue>Revenue</revenue> + + </metricsGoal> + <processedMetricsGoal> + <revenue_per_visit>Value per Visit</revenue_per_visit> + <goals_conversion_rate>Visits with Conversions</goals_conversion_rate> + + </processedMetricsGoal> + + </row> + <row> + <category>Referrers</category> + <name>Keywords</name> + <module>Referers</module> + <action>getKeywords</action> + <dimension>Keyword</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + <metricsGoal> + <nb_conversions>Conversions</nb_conversions> + <conversion_rate>Conversion Rate</conversion_rate> + <revenue>Revenue</revenue> + + </metricsGoal> + <processedMetricsGoal> + <revenue_per_visit>Value per Visit</revenue_per_visit> + <goals_conversion_rate>Visits with Conversions</goals_conversion_rate> + + </processedMetricsGoal> + + </row> + <row> + <category>Referrers</category> + <name>Search Engines</name> + <module>Referers</module> + <action>getSearchEngines</action> + <dimension>Search Engine</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + <metricsGoal> + <nb_conversions>Conversions</nb_conversions> + <conversion_rate>Conversion Rate</conversion_rate> + <revenue>Revenue</revenue> + + </metricsGoal> + <processedMetricsGoal> + <revenue_per_visit>Value per Visit</revenue_per_visit> + <goals_conversion_rate>Visits with Conversions</goals_conversion_rate> + + </processedMetricsGoal> + + </row> + <row> + <category>Referrers</category> + <name>Websites</name> + <module>Referers</module> + <action>getWebsites</action> + <dimension>Website</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + <metricsGoal> + <nb_conversions>Conversions</nb_conversions> + <conversion_rate>Conversion Rate</conversion_rate> + <revenue>Revenue</revenue> + + </metricsGoal> + <processedMetricsGoal> + <revenue_per_visit>Value per Visit</revenue_per_visit> + <goals_conversion_rate>Visits with Conversions</goals_conversion_rate> + + </processedMetricsGoal> + + </row> + <row> + <category>Referrers</category> + <name>Campaigns</name> + <module>Referers</module> + <action>getCampaigns</action> + <dimension>Campaign</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + <metricsGoal> + <nb_conversions>Conversions</nb_conversions> + <conversion_rate>Conversion Rate</conversion_rate> + <revenue>Revenue</revenue> + + </metricsGoal> + <processedMetricsGoal> + <revenue_per_visit>Value per Visit</revenue_per_visit> + <goals_conversion_rate>Visits with Conversions</goals_conversion_rate> + + </processedMetricsGoal> + + </row> + <row> + <category>Referrers</category> + <name>Referrer Type</name> + <module>Referers</module> + <action>getRefererType</action> + <dimension>Referrer Type</dimension> + <metrics> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_visits>Visits</nb_visits> + <nb_actions>Actions</nb_actions> + <nb_visits_converted>Visits with Conversions</nb_visits_converted> + + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + + </processedMetrics> + <metricsGoal> + <nb_conversions>Conversions</nb_conversions> + <conversion_rate>Conversion Rate</conversion_rate> + <revenue>Revenue</revenue> + + </metricsGoal> + <processedMetricsGoal> + <revenue_per_visit>Value per Visit</revenue_per_visit> + <goals_conversion_rate>Visits with Conversions</goals_conversion_rate> + + </processedMetricsGoal> + + </row> + <row> + <category>Goals</category> + <name>Goals</name> + <module>Goals</module> + <action>get</action> + <metrics> + <nb_conversions>Conversions</nb_conversions> + <conversion_rate>Conversion Rate</conversion_rate> + <revenue>Revenue</revenue> + + </metrics> + + </row> + +</result>
\ No newline at end of file diff --git a/tests/integration/expected/test_noVisit__API.getDefaultProcessedMetrics.xml b/tests/integration/expected/test_noVisit__API.getDefaultProcessedMetrics.xml new file mode 100644 index 0000000000..756ba342ed --- /dev/null +++ b/tests/integration/expected/test_noVisit__API.getDefaultProcessedMetrics.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <row> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + </row> +</result>
\ No newline at end of file diff --git a/tests/integration/expected/test_noVisit__Goals.get_day.xml b/tests/integration/expected/test_noVisit__Goals.get_day.xml index a8f262194a..9d10f58430 100644 --- a/tests/integration/expected/test_noVisit__Goals.get_day.xml +++ b/tests/integration/expected/test_noVisit__Goals.get_day.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8" ?> <result> - <Goal_nb_conversions>0</Goal_nb_conversions> - <Goal_conversion_rate>0</Goal_conversion_rate> - <Goal_revenue>0</Goal_revenue> + <nb_conversions>0</nb_conversions> + <conversion_rate>0</conversion_rate> + <revenue>0</revenue> </result>
\ No newline at end of file |