diff options
43 files changed, 510 insertions, 100 deletions
diff --git a/core/Plugin/ProcessedMetric.php b/core/Plugin/ProcessedMetric.php index ea77986c29..449fc61e32 100644 --- a/core/Plugin/ProcessedMetric.php +++ b/core/Plugin/ProcessedMetric.php @@ -53,7 +53,7 @@ abstract class ProcessedMetric extends Metric /** * TODO */ - public function shouldComputeForTable(Report $report, DataTable $table) + public function beforeCompute(Report $report, DataTable $table) { return true; } diff --git a/core/Plugin/Report.php b/core/Plugin/Report.php index e61d3efd60..fb009f06a2 100644 --- a/core/Plugin/Report.php +++ b/core/Plugin/Report.php @@ -721,7 +721,6 @@ class Report /** * TODO - * TODO: recursion (+ for format) * * TODO: put in new non-filter class. do not mark w/ @api. */ @@ -739,13 +738,18 @@ class Report } foreach ($processedMetrics as $name => $processedMetric) { - if (!$processedMetric->shouldComputeForTable($this, $dataTable)) { + if (!$processedMetric->beforeCompute($this, $dataTable)) { continue; } foreach ($dataTable->getRows() as $row) { if ($row->getColumn($name) === false) { // do not compute the metric if it has been computed already $row->addColumn($name, $processedMetric->compute($row)); + + $subtable = $row->getSubtable(); + if (!empty($subtable)) { + $this->computeProcessedMetrics($subtable); + } } } } @@ -773,6 +777,11 @@ class Report if ($columnValue !== false) { $row->setColumn($name, $processedMetric->format($columnValue)); } + + $subtable = $row->getSubtable(); + if (!empty($subtable)) { + $this->formatProcessedMetrics($subtable); + } } } } diff --git a/plugins/API/ProcessedReport.php b/plugins/API/ProcessedReport.php index 9b317a15d2..2b72e07849 100644 --- a/plugins/API/ProcessedReport.php +++ b/plugins/API/ProcessedReport.php @@ -456,7 +456,7 @@ class ProcessedReport private function handleTableReport($idSite, $dataTable, &$reportMetadata, $showRawMetrics = false) { $hasDimension = isset($reportMetadata['dimension']); - $columns = $reportMetadata['metrics']; + $columns = @$reportMetadata['metrics'] ?: array(); if ($hasDimension) { $columns = array_merge( diff --git a/plugins/Actions/API.php b/plugins/Actions/API.php index 41c8cccda1..cdb34b9961 100644 --- a/plugins/Actions/API.php +++ b/plugins/Actions/API.php @@ -17,6 +17,10 @@ use Piwik\Date; use Piwik\Metrics; use Piwik\Piwik; use Piwik\Plugin\Report; +use Piwik\Plugins\Actions\Metrics\AveragePageGenerationTime; +use Piwik\Plugins\Actions\Metrics\AverageTimeOnPage; +use Piwik\Plugins\Actions\Metrics\BounceRate; +use Piwik\Plugins\Actions\Metrics\ExitRate; use Piwik\Plugins\CustomVariables\API as APICustomVariables; use Piwik\Plugins\Actions\Actions\ActionSiteSearch; use Piwik\Tracker\Action; @@ -62,7 +66,7 @@ class API extends \Piwik\Plugin\API $newNameMapping = array_combine($inDbColumnNames, $columns); $dataTable->filter('ReplaceColumnNames', array($newNameMapping)); - // TODO: either replace w/ temporary metrics, or just include them in the results and let people remove themif + // TODO: either replace w/ temporary metrics, or just include them in the results and let people remove them if // they want. $dataTable->queueFilter('ColumnDelete', array(array('sum_time_generation', 'nb_hits_with_time_generation'))); @@ -162,7 +166,7 @@ class API extends \Piwik\Plugin\API { $callBackParameters = array('Actions_actions_url', $idSite, $period, $date, $segment, $expanded = false, $idSubtable = false); $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $pageUrl, Action::TYPE_PAGE_URL); - // $this->filterPageDatatable($dataTable); TODO: no report metadata for getPageUrl... problem? can add extra processed metrics via metadata. + $this->addPageProcessedMetrics($dataTable); $this->filterActionsDataTable($dataTable); return $dataTable; } @@ -202,7 +206,7 @@ class API extends \Piwik\Plugin\API { $callBackParameters = array('Actions_actions', $idSite, $period, $date, $segment, $expanded = false, $idSubtable = false); $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $pageName, Action::TYPE_PAGE_TITLE); - // $this->filterPageDatatable($dataTable); TODO: no GetPageTitle report + $this->addPageProcessedMetrics($dataTable); $this->filterActionsDataTable($dataTable); return $dataTable; } @@ -447,7 +451,7 @@ class API extends \Piwik\Plugin\API $dataTable->filter('ReplaceColumnNames'); $dataTable->filter('Sort', array('nb_visits', 'desc', $naturalSort = false, $expanded)); - //$dataTable->queueFilter('ReplaceSummaryRowLabel'); TODO: necessary? + $dataTable->queueFilter('ReplaceSummaryRowLabel'); } /** @@ -493,4 +497,14 @@ class API extends \Piwik\Plugin\API } return Archive::getDataTableFromArchive($name, $idSite, $period, $date, $segment, $expanded, $idSubtable, $skipAggregationOfSubTables, $depth); } -} + + private function addPageprocessedMetrics(DataTable $dataTable) + { + $extraProcessedMetrics = $dataTable->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME); + $extraProcessedMetrics[] = new AverageTimeOnPage(); + $extraProcessedMetrics[] = new BounceRate(); + $extraProcessedMetrics[] = new ExitRate(); + $extraProcessedMetrics[] = new AveragePageGenerationTime(); + $dataTable->setMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME, $extraProcessedMetrics); + } +}
\ No newline at end of file diff --git a/plugins/Actions/Metrics/AveragePageGenerationTime.php b/plugins/Actions/Metrics/AveragePageGenerationTime.php index 1bbe713a12..678fd52f31 100644 --- a/plugins/Actions/Metrics/AveragePageGenerationTime.php +++ b/plugins/Actions/Metrics/AveragePageGenerationTime.php @@ -43,9 +43,19 @@ class AveragePageGenerationTime extends ProcessedMetric return Piwik::getQuotientSafe($sumGenerationTime, $hitsWithTimeGeneration, $precision = 3); } - public function shouldComputeForTable(Report $report, DataTable $table) + public function beforeCompute(Report $report, DataTable $table) { - $hasTimeGeneration = array_sum($table->getColumn(Metrics::INDEX_PAGE_SUM_TIME_GENERATION)) > 0; + $columnName = Metrics::INDEX_PAGE_SUM_TIME_GENERATION; + + // TODO: code redundancy w/ another metric (VisitsPercent i think?) + $firstRow = $table->getFirstRow(); + if (!empty($firstRow) + && $firstRow->getColumn($columnName) === false + ) { + $columnName = 'sum_time_generation'; + } + + $hasTimeGeneration = array_sum($table->getColumn($columnName)) > 0; if (!$hasTimeGeneration) { // TODO: ideally this logic shouldn't exist... // No generation time: remove it from the API output and add it to empty_columns metadata, so that diff --git a/plugins/Actions/Metrics/ExitRate.php b/plugins/Actions/Metrics/ExitRate.php index 2570de0ac1..89a1955804 100644 --- a/plugins/Actions/Metrics/ExitRate.php +++ b/plugins/Actions/Metrics/ExitRate.php @@ -32,7 +32,12 @@ class ExitRate extends ProcessedMetric $exitVisits = $this->getColumn($row, 'exit_nb_visits'); $visits = $this->getColumn($row, 'nb_visits'); - return Piwik::getQuotientSafe($exitVisits, $visits, $precision = 0); + return Piwik::getQuotientSafe($exitVisits, $visits, $precision = 2); + } + + public function format($value) // TODO: should create ratio & percent processed metric base types + { + return ($value * 100) . '%'; } public function getDependenctMetrics() diff --git a/plugins/Actions/Reports/GetEntryPageTitles.php b/plugins/Actions/Reports/GetEntryPageTitles.php index f5b9c41817..f1332f2266 100644 --- a/plugins/Actions/Reports/GetEntryPageTitles.php +++ b/plugins/Actions/Reports/GetEntryPageTitles.php @@ -11,6 +11,10 @@ namespace Piwik\Plugins\Actions\Reports; use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; use Piwik\Plugins\Actions\Columns\EntryPageTitle; +use Piwik\Plugins\Actions\Metrics\AveragePageGenerationTime; +use Piwik\Plugins\Actions\Metrics\AverageTimeOnPage; +use Piwik\Plugins\Actions\Metrics\BounceRate; +use Piwik\Plugins\Actions\Metrics\ExitRate; class GetEntryPageTitles extends Base { @@ -22,7 +26,13 @@ class GetEntryPageTitles extends Base $this->name = Piwik::translate('Actions_EntryPageTitles'); $this->documentation = Piwik::translate('Actions_ExitPageTitlesReportDocumentation', '<br />') . ' ' . Piwik::translate('General_UsePlusMinusIconsDocumentation'); - $this->metrics = array('entry_nb_visits', 'entry_bounce_count', 'bounce_rate'); + $this->metrics = array('entry_nb_visits', 'entry_bounce_count'); + $this->processedMetrics = array( + new AverageTimeOnPage(), + new BounceRate(), + new ExitRate(), + new AveragePageGenerationTime() + ); $this->order = 6; $this->actionToLoadSubTables = $this->action; diff --git a/plugins/Actions/Reports/GetEntryPageUrls.php b/plugins/Actions/Reports/GetEntryPageUrls.php index 71cab238b7..d0c42891fe 100644 --- a/plugins/Actions/Reports/GetEntryPageUrls.php +++ b/plugins/Actions/Reports/GetEntryPageUrls.php @@ -13,6 +13,10 @@ use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; use Piwik\API\Request; use Piwik\Plugins\Actions\Columns\EntryPageUrl; +use Piwik\Plugins\Actions\Metrics\AveragePageGenerationTime; +use Piwik\Plugins\Actions\Metrics\AverageTimeOnPage; +use Piwik\Plugins\Actions\Metrics\BounceRate; +use Piwik\Plugins\Actions\Metrics\ExitRate; class GetEntryPageUrls extends Base { @@ -25,7 +29,13 @@ class GetEntryPageUrls extends Base $this->documentation = Piwik::translate('Actions_EntryPagesReportDocumentation', '<br />') . '<br />' . Piwik::translate('General_UsePlusMinusIconsDocumentation'); - $this->metrics = array('entry_nb_visits', 'entry_bounce_count', 'bounce_rate'); + $this->metrics = array('entry_nb_visits', 'entry_bounce_count'); + $this->processedMetrics = array( + new AverageTimeOnPage(), + new BounceRate(), + new ExitRate(), + new AveragePageGenerationTime() + ); $this->order = 3; $this->actionToLoadSubTables = $this->action; diff --git a/plugins/Actions/Reports/GetExitPageTitles.php b/plugins/Actions/Reports/GetExitPageTitles.php index a9d29bd552..996b418843 100644 --- a/plugins/Actions/Reports/GetExitPageTitles.php +++ b/plugins/Actions/Reports/GetExitPageTitles.php @@ -11,6 +11,10 @@ namespace Piwik\Plugins\Actions\Reports; use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; use Piwik\Plugins\Actions\Columns\ExitPageTitle; +use Piwik\Plugins\Actions\Metrics\AveragePageGenerationTime; +use Piwik\Plugins\Actions\Metrics\AverageTimeOnPage; +use Piwik\Plugins\Actions\Metrics\BounceRate; +use Piwik\Plugins\Actions\Metrics\ExitRate; class GetExitPageTitles extends Base { @@ -23,7 +27,13 @@ class GetExitPageTitles extends Base $this->documentation = Piwik::translate('Actions_EntryPageTitlesReportDocumentation', '<br />') . ' ' . Piwik::translate('General_UsePlusMinusIconsDocumentation'); - $this->metrics = array('exit_nb_visits', 'nb_visits', 'exit_rate'); + $this->metrics = array('exit_nb_visits', 'nb_visits'); + $this->processedMetrics = array( + new AverageTimeOnPage(), + new BounceRate(), + new ExitRate(), + new AveragePageGenerationTime() + ); $this->order = 7; $this->actionToLoadSubTables = $this->action; diff --git a/plugins/Actions/Reports/GetExitPageUrls.php b/plugins/Actions/Reports/GetExitPageUrls.php index 72a95379b6..781ca05f3a 100644 --- a/plugins/Actions/Reports/GetExitPageUrls.php +++ b/plugins/Actions/Reports/GetExitPageUrls.php @@ -13,6 +13,10 @@ use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; use Piwik\API\Request; use Piwik\Plugins\Actions\Columns\ExitPageUrl; +use Piwik\Plugins\Actions\Metrics\AveragePageGenerationTime; +use Piwik\Plugins\Actions\Metrics\AverageTimeOnPage; +use Piwik\Plugins\Actions\Metrics\BounceRate; +use Piwik\Plugins\Actions\Metrics\ExitRate; class GetExitPageUrls extends Base { @@ -25,7 +29,13 @@ class GetExitPageUrls extends Base $this->documentation = Piwik::translate('Actions_ExitPagesReportDocumentation', '<br />') . '<br />' . Piwik::translate('General_UsePlusMinusIconsDocumentation'); - $this->metrics = array('exit_nb_visits', 'nb_visits', 'exit_rate'); + $this->metrics = array('exit_nb_visits', 'nb_visits'); + $this->processedMetrics = array( + new AverageTimeOnPage(), + new BounceRate(), + new ExitRate(), + new AveragePageGenerationTime() + ); $this->actionToLoadSubTables = $this->action; $this->order = 4; diff --git a/plugins/Contents/API.php b/plugins/Contents/API.php index 002360588f..43d07b7cdc 100644 --- a/plugins/Contents/API.php +++ b/plugins/Contents/API.php @@ -61,8 +61,5 @@ class API extends \Piwik\Plugin\API } } }); - - // Content interaction rate = interactions / impressions - $dataTable->queueFilter('ColumnCallbackAddColumnPercentage', array('interaction_rate', 'nb_interactions', 'nb_impressions', $precision = 2)); } } diff --git a/plugins/Contents/Metrics/InteractionRate.php b/plugins/Contents/Metrics/InteractionRate.php new file mode 100644 index 0000000000..41efeac82a --- /dev/null +++ b/plugins/Contents/Metrics/InteractionRate.php @@ -0,0 +1,48 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\Contents\Metrics; + +use Piwik\DataTable\Row; +use Piwik\Piwik; +use Piwik\Plugin\ProcessedMetric; + +/** + * TODO +// Content interaction rate = interactions / impressions + */ +class InteractionRate extends ProcessedMetric +{ + public function getName() + { + return 'interaction_rate'; + } + + public function getTranslatedName() + { + return Piwik::translate('Contents_InteractionRate'); + } + + public function compute(Row $row) + { + $interactions = $this->getColumn($row, 'nb_interactions'); + $impressions = $this->getColumn($row, 'nb_impressions'); + + return Piwik::getQuotientSafe($interactions, $impressions, $precision = 4); + } + + public function format($value) + { + return ($value * 100) . '%'; + } + + public function getDependenctMetrics() + { + return array('nb_interactions', 'nb_impressions'); + } +}
\ No newline at end of file diff --git a/plugins/Events/API.php b/plugins/Events/API.php index 890979db2c..d81144f855 100644 --- a/plugins/Events/API.php +++ b/plugins/Events/API.php @@ -217,14 +217,5 @@ class API extends \Piwik\Plugin\API $row->setColumn('label', Piwik::translate('General_NotDefined', Piwik::translate('Events_EventName'))); } }); - - // add processed metric avg_event_value - $dataTable->queueFilter('ColumnCallbackAddColumnQuotient', - array('avg_event_value', - 'sum_event_value', - 'nb_events_with_value', - $precision = 2, - $shouldSkipRows = true) - ); } }
\ No newline at end of file diff --git a/plugins/Events/Metrics/AverageEventValue.php b/plugins/Events/Metrics/AverageEventValue.php new file mode 100644 index 0000000000..e09079f266 --- /dev/null +++ b/plugins/Events/Metrics/AverageEventValue.php @@ -0,0 +1,42 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\Events\Metrics; + +use Piwik\DataTable\Row; +use Piwik\Piwik; +use Piwik\Plugin\ProcessedMetric; + +/** + * TODO + */ +class AverageEventValue extends ProcessedMetric +{ + public function getName() + { + return 'avg_event_value'; + } + + public function getTranslatedName() + { + return Piwik::translate('Events_AvgValueDocumentation'); + } + + public function compute(Row $row) + { + $sumEventValue = $this->getColumn($row, 'sum_event_value'); + $eventsWithValue = $this->getColumn($row, 'nb_events_with_value'); + + return Piwik::getQuotientSafe($sumEventValue, $eventsWithValue, $precision = 2); // TODO: used to use shouldSkipRows = true + } + + public function getDependenctMetrics() + { + return array('sum_event_value', 'nb_events_with_value'); + } +}
\ No newline at end of file diff --git a/plugins/Events/Reports/Base.php b/plugins/Events/Reports/Base.php index 2caf9b6a75..e49c7815fa 100644 --- a/plugins/Events/Reports/Base.php +++ b/plugins/Events/Reports/Base.php @@ -9,13 +9,16 @@ namespace Piwik\Plugins\Events\Reports; use Piwik\Plugins\Events\API; +use Piwik\Plugins\Events\Metrics\AverageEventValue; abstract class Base extends \Piwik\Plugin\Report { protected function init() { $this->category = 'Events_Events'; - $this->processedMetrics = false; + $this->processedMetrics = array( + new AverageEventValue() + ); $this->widgetParams = array( 'secondaryDimension' => API::getInstance()->getDefaultSecondaryDimension($this->action) diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php index 36d0007f83..dcf39f8874 100644 --- a/plugins/Goals/API.php +++ b/plugins/Goals/API.php @@ -230,17 +230,8 @@ class API extends \Piwik\Plugin\API $dataTable->renameColumn(Metrics::INDEX_ECOMMERCE_ORDERS, $ordersColumn); } - // Average price = sum product revenue / quantity - $dataTable->queueFilter('ColumnCallbackAddColumnQuotient', array('avg_price', 'price', $ordersColumn, GoalManager::REVENUE_PRECISION)); - - // Average quantity = sum product quantity / abandoned carts - $dataTable->queueFilter('ColumnCallbackAddColumnQuotient', - array('avg_quantity', 'quantity', $ordersColumn, $precision = 1)); $dataTable->queueFilter('ColumnDelete', array('price')); - // Product conversion rate = orders / visits - $dataTable->queueFilter('ColumnCallbackAddColumnPercentage', array('conversion_rate', $ordersColumn, 'nb_visits', GoalManager::REVENUE_PRECISION)); - return $dataTable; } diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index 381c37f7ee..cd75af0c9e 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -117,7 +117,7 @@ class Goals extends \Piwik\Plugin 'revenue_per_visit' => 'General_ColumnValuePerVisit', 'quantity' => 'General_Quantity', 'avg_price' => 'General_AveragePrice', - 'avg_quantity' => 'General_AverageQuantity', + 'avg_quantity' => 'onv', 'revenue_subtotal' => 'General_Subtotal', 'revenue_tax' => 'General_Tax', 'revenue_shipping' => 'General_Shipping', diff --git a/plugins/Goals/Metrics/AveragePrice.php b/plugins/Goals/Metrics/AveragePrice.php new file mode 100644 index 0000000000..1bc6932d68 --- /dev/null +++ b/plugins/Goals/Metrics/AveragePrice.php @@ -0,0 +1,45 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\Goals\Metrics; + +use Piwik\DataTable\Row; +use Piwik\Piwik; +use Piwik\Plugin\ProcessedMetric; +use Piwik\Tracker\GoalManager; + +/** + * TODO +// Average price = sum product revenue / quantity + */ +class AveragePrice extends ProcessedMetric +{ + public function getName() + { + return 'avg_price'; + } + + public function getTranslatedName() + { + return Piwik::translate('General_AveragePrice'); + } + + public function compute(Row $row) + { + $price = $this->getColumn($row, 'price'); + $orders = $this->getColumn($row, 'orders'); + $abandonedCarts = $this->getColumn($row, 'abandoned_carts'); + + return Piwik::getQuotientSafe($price, $orders === false ? $abandonedCarts : $orders, GoalManager::REVENUE_PRECISION); + } + + public function getDependenctMetrics() + { + return array('price', 'orders', 'abandoned_carts'); + } +}
\ No newline at end of file diff --git a/plugins/Goals/Metrics/AverageQuantity.php b/plugins/Goals/Metrics/AverageQuantity.php new file mode 100644 index 0000000000..6644840e82 --- /dev/null +++ b/plugins/Goals/Metrics/AverageQuantity.php @@ -0,0 +1,44 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\Goals\Metrics; + +use Piwik\DataTable\Row; +use Piwik\Piwik; +use Piwik\Plugin\ProcessedMetric; + +/** + * TODO +// Average quantity = sum product quantity / abandoned carts + */ +class AverageQuantity extends ProcessedMetric +{ + public function getName() + { + return 'avg_quantity'; + } + + public function getTranslatedName() + { + return Piwik::translate('General_AverageQuantity'); + } + + public function compute(Row $row) + { + $quantity = $this->getColumn($row, 'quantity'); + $orders = $this->getColumn($row, 'orders'); + $abandonedCarts = $this->getColumn($row, 'abandoned_carts'); + + return Piwik::getQuotientSafe($quantity, $orders === false ? $abandonedCarts : $orders, $precision = 1); + } + + public function getDependenctMetrics() + { + return array('quantity', 'orders', 'abandoned_carts'); + } +}
\ No newline at end of file diff --git a/plugins/Goals/Metrics/ProductConversionRate.php b/plugins/Goals/Metrics/ProductConversionRate.php new file mode 100644 index 0000000000..7be6bf28af --- /dev/null +++ b/plugins/Goals/Metrics/ProductConversionRate.php @@ -0,0 +1,45 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\Goals\Metrics; + +use Piwik\DataTable\Row; +use Piwik\Piwik; +use Piwik\Plugin\ProcessedMetric; +use Piwik\Tracker\GoalManager; + +/** + * TODO +// Product conversion rate = orders / visits + */ +class ProductConversionRate extends ProcessedMetric +{ + public function getName() + { + return 'conversion_rate'; + } + + public function getTranslatedName() + { + return Piwik::translate('General_ColumnConversionRate'); + } + + public function compute(Row $row) + { + $orders = $this->getColumn($row, 'orders'); + $abandonedCarts = $this->getColumn($row, 'abandoned_carts'); + $visits = $this->getColumn($row, 'nb_visits'); + + return Piwik::getQuotientSafe($orders === false ? $abandonedCarts : $orders, $visits, GoalManager::REVENUE_PRECISION); + } + + public function getDependenctMetrics() + { + return array('orders', 'abandoned_carts', 'nb_visits'); + } +}
\ No newline at end of file diff --git a/plugins/Goals/Reports/BaseEcommerceItem.php b/plugins/Goals/Reports/BaseEcommerceItem.php index 8699fe386b..b74585c7f4 100644 --- a/plugins/Goals/Reports/BaseEcommerceItem.php +++ b/plugins/Goals/Reports/BaseEcommerceItem.php @@ -13,15 +13,22 @@ use Piwik\Piwik; use Piwik\Plugin\Report; use Piwik\Plugin\ViewDataTable; use Piwik\Plugins\Goals\Goals; +use Piwik\Plugins\Goals\Metrics\AveragePrice; +use Piwik\Plugins\Goals\Metrics\AverageQuantity; +use Piwik\Plugins\Goals\Metrics\ProductConversionRate; abstract class BaseEcommerceItem extends BaseEcommerce { protected function init() { parent::init(); - $this->processedMetrics = false; + $this->processedMetrics = array( + new AveragePrice(), + new AverageQuantity(), + new ProductConversionRate() + ); $this->metrics = array( - 'revenue', 'quantity', 'orders', 'avg_price', 'avg_quantity', 'nb_visits', 'conversion_rate' + 'revenue', 'quantity', 'orders', 'nb_visits' ); } diff --git a/plugins/Live/API.php b/plugins/Live/API.php index d15cca9e36..67f7d46cd4 100644 --- a/plugins/Live/API.php +++ b/plugins/Live/API.php @@ -167,6 +167,7 @@ class API extends \Piwik\Plugin\API $dataTable = $this->loadLastVisitorDetailsFromDatabase($idSite, $period, $date, $segment, $countVisitorsToFetch, $visitorId = false, $minTimestamp, $filterSortOrder); $this->addFilterToCleanVisitors($dataTable, $idSite, $flat, $doNotFetchActions); + // TODO: why is this necessary? shouldn't be. uncomment & see if tests pass. $filterSortColumn = Common::getRequestVar('filter_sort_column', false, 'string'); $filterSortOrder = Common::getRequestVar('filter_sort_order', 'desc', 'string'); diff --git a/plugins/UserSettings/API.php b/plugins/UserSettings/API.php index 76b98ad8b2..014db7a765 100644 --- a/plugins/UserSettings/API.php +++ b/plugins/UserSettings/API.php @@ -196,6 +196,14 @@ class API extends \Piwik\Plugin\API } } + // Calculate percentage, but ignore IE users because plugin detection doesn't work on IE + $ieVisits = 0; + + $ieStats = $browserType->getRowFromLabel('Trident'); + if ($ieStats !== false) { + $ieVisits = $ieStats->getColumn(Metrics::INDEX_NB_VISITS); + } + // get according visitsSum foreach ($visitSumsArray as $k => $visits) { if ($k == $key) { @@ -211,24 +219,9 @@ class API extends \Piwik\Plugin\API } } - // Calculate percentage, but ignore IE users because plugin detection doesn't work on IE - $ieVisits = 0; - - $ieStats = $browserType->getRowFromLabel('Trident'); - if ($ieStats !== false) { - $ieVisits = $ieStats->getColumn(Metrics::INDEX_NB_VISITS); - } - $visitsSum = $visitsSumTotal - $ieVisits; - // When Truncate filter is applied, it will call AddSummaryRow which tries to sum all rows. - // We tell the object to skip the column nb_visits_percentage when aggregating (since it's not correct to sum % values) - $columnAggregationOps = $table->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME); - $columnAggregationOps['nb_visits_percentage'] = 'skip'; - $table->setMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME, $columnAggregationOps); - - // The filter must be applied now so that the new column can - // be sorted by the generic filters (applied right after this loop exits) + // TODO: refactor this message before using PluginsVisitsPercent $table->filter('ColumnCallbackAddColumnPercentage', array('nb_visits_percentage', Metrics::INDEX_NB_VISITS, $visitsSum, 1)); $table->filter('RangeCheck', array('nb_visits_percentage')); } diff --git a/plugins/UserSettings/Metrics/PluginsVisitsPercent.php b/plugins/UserSettings/Metrics/PluginsVisitsPercent.php new file mode 100644 index 0000000000..b3b87bc0e5 --- /dev/null +++ b/plugins/UserSettings/Metrics/PluginsVisitsPercent.php @@ -0,0 +1,54 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\UserSettings\Metrics; + +use Piwik\DataTable; +use Piwik\DataTable\Row; +use Piwik\Piwik; +use Piwik\Plugin\ProcessedMetric; +use Piwik\Plugin\Report; + +/** + * TODO + */ +class PluginsVisitsPercent extends ProcessedMetric +{ + private $cachedTotalVisits = null; + + public function getName() + { + return 'nb_visits_percentage'; + } + + public function getTranslatedName() + { + return Piwik::translate('General_ColumnPercentageVisits'); + } + + public function compute(Row $row) + { + // TODO: Implement compute() method. + } + + public function format($value) + { + return ($value * 100) . '%'; + } + + public function getDependenctMetrics() + { + return array('nb_visits'); + } + + public function beforeCompute(Report $report, DataTable $table) + { + // TODO + return true; + } +}
\ No newline at end of file diff --git a/plugins/VisitFrequency/API.php b/plugins/VisitFrequency/API.php index a100521788..d05cf436c7 100644 --- a/plugins/VisitFrequency/API.php +++ b/plugins/VisitFrequency/API.php @@ -48,10 +48,12 @@ class API extends \Piwik\Plugin\API 'serialize' => 0 // tests set this to 1 ); - /** @var DataTable $table */ $table = Request::processRequest('VisitsSummary.get', $params); $this->prefixColumns($table, $period); - $table->clearQueuedFilters(); + + $table->filter(function (DataTable $table) { + $table->clearQueuedFilters(); + }); return $table; } diff --git a/plugins/VisitorInterest/API.php b/plugins/VisitorInterest/API.php index 44df111588..33f6d97b58 100644 --- a/plugins/VisitorInterest/API.php +++ b/plugins/VisitorInterest/API.php @@ -87,28 +87,6 @@ class API extends \Piwik\Plugin\API $dataTable->queueFilter('BeautifyRangeLabels', array( Piwik::translate('General_OneVisit'), Piwik::translate('General_NVisits'))); - // add visit percent column - self::addVisitsPercentColumn($dataTable); - return $dataTable; } - - /** - * Utility function that adds a visit percent column to a data table, - * regardless of whether the data table is an data table array or just - * a data table. - * - * @param DataTable $dataTable The data table to modify. - */ - private static function addVisitsPercentColumn($dataTable) - { - if ($dataTable instanceof DataTable\Map) { - foreach ($dataTable->getDataTables() as $table) { - self::addVisitsPercentColumn($table); - } - } else { - $totalVisits = array_sum($dataTable->getColumn(Metrics::INDEX_NB_VISITS)); - $dataTable->queueFilter('ColumnCallbackAddColumnPercentage', array('nb_visits_percentage', 'nb_visits', $totalVisits)); - } - } } diff --git a/plugins/VisitorInterest/Metrics/VisitsPercent.php b/plugins/VisitorInterest/Metrics/VisitsPercent.php new file mode 100644 index 0000000000..74afb172b9 --- /dev/null +++ b/plugins/VisitorInterest/Metrics/VisitsPercent.php @@ -0,0 +1,67 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\VisitorInterest\Metrics; + +use Piwik\DataTable; +use Piwik\DataTable\Row; +use Piwik\Metrics; +use Piwik\Piwik; +use Piwik\Plugin\ProcessedMetric; +use Piwik\Plugin\Report; + +/** + * TODO + */ +class VisitsPercent extends ProcessedMetric +{ + private $cachedTotalVisits = null; + + public function getName() + { + return 'nb_visits_percentage'; + } + + public function getTranslatedName() + { + return Piwik::translate('General_ColumnPercentageVisits'); + } + + public function compute(Row $row) + { + $visits = $this->getColumn($row, 'nb_visits'); + + return Piwik::getQuotientSafe($visits, $this->cachedTotalVisits, $precision = 2); + } + + public function format($value) + { + return ($value * 100) . '%'; + } + + public function getDependenctMetrics() + { + return array('nb_visits'); + } + + public function beforeCompute(Report $report, DataTable $table) + { + $columnName = 'nb_visits'; + + $firstRow = $table->getFirstRow(); + if (!empty($firstRow) + && $firstRow->getColumn($columnName) === false + ) { + $columnName = Metrics::INDEX_NB_VISITS; + } + + $this->cachedTotalVisits = array_sum($table->getColumn($columnName)); + + return true; // always compute + } +}
\ No newline at end of file diff --git a/plugins/VisitorInterest/Reports/GetNumberOfVisitsByVisitCount.php b/plugins/VisitorInterest/Reports/GetNumberOfVisitsByVisitCount.php index 74cf975a4d..0c42eafab0 100644 --- a/plugins/VisitorInterest/Reports/GetNumberOfVisitsByVisitCount.php +++ b/plugins/VisitorInterest/Reports/GetNumberOfVisitsByVisitCount.php @@ -12,6 +12,7 @@ use Piwik\Metrics; use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; use Piwik\Plugins\VisitorInterest\Columns\VisitsbyVisitNumber; +use Piwik\Plugins\VisitorInterest\Metrics\VisitsPercent; class GetNumberOfVisitsByVisitCount extends Base { @@ -23,7 +24,9 @@ class GetNumberOfVisitsByVisitCount extends Base $this->documentation = Piwik::translate('VisitorInterest_WidgetVisitsByNumDocumentation') . '<br />' . Piwik::translate('General_ChangeTagCloudView'); $this->metrics = array('nb_visits', 'nb_visits_percentage'); - $this->processedMetrics = false; + $this->processedMetrics = array( + new VisitsPercent() + ); $this->constantRowsCount = true; $this->order = 25; $this->widgetTitle = 'VisitorInterest_visitsByVisitCount'; diff --git a/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php b/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php index 0d6930fba1..287e6799f1 100755 --- a/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php +++ b/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php @@ -79,15 +79,7 @@ class OneVisitorTwoVisitsTest extends SystemTestCase $url = urlencode($url); } return array( - array('VisitFrequency.get', array('idSite' => $idSite, - 'date' => $dateTime, - 'otherRequestParameters' => array( - 'hideColumns' => 'nb_users', - ) - )) - ); - return array( - array('VisitFrequency.get', array('idSite' => $idSite, + array('all', array('idSite' => $idSite, 'date' => $dateTime, 'otherRequestParameters' => array( 'hideColumns' => 'nb_users', diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getEntryPageTitles_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getEntryPageTitles_day.xml index 124e271777..668fad20f4 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getEntryPageTitles_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getEntryPageTitles_day.xml @@ -5,6 +5,7 @@ <nb_visits>1</nb_visits> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.134</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> @@ -24,6 +25,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.134</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> @@ -47,6 +49,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>180</sum_time_spent> + <sum_time_generation>0.234</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.234</min_time_generation> <max_time_generation>0.234</max_time_generation> diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getEntryPageUrls_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getEntryPageUrls_day.xml index 5b3878f7b2..782624f6dc 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getEntryPageUrls_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getEntryPageUrls_day.xml @@ -6,6 +6,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>180</sum_time_spent> + <sum_time_generation>0.234</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.234</min_time_generation> <max_time_generation>0.234</max_time_generation> @@ -25,6 +26,7 @@ <nb_visits>1</nb_visits> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.134</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> @@ -44,6 +46,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.134</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getExitPageTitles_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getExitPageTitles_day.xml index f80bfdd222..e6cc3fafe0 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getExitPageTitles_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getExitPageTitles_day.xml @@ -5,6 +5,7 @@ <nb_visits>1</nb_visits> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.134</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> @@ -24,6 +25,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.134</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> @@ -47,6 +49,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.023</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.023</min_time_generation> <max_time_generation>0.023</max_time_generation> diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getExitPageUrls_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getExitPageUrls_day.xml index 3986b5b44b..39e9d36014 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getExitPageUrls_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getExitPageUrls_day.xml @@ -6,6 +6,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.023</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.023</min_time_generation> <max_time_generation>0.023</max_time_generation> @@ -22,6 +23,7 @@ <nb_visits>1</nb_visits> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.134</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> @@ -41,6 +43,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.134</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getPageTitles_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getPageTitles_day.xml index 510f81282a..863bb0ecb6 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getPageTitles_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getPageTitles_day.xml @@ -5,6 +5,7 @@ <nb_visits>1</nb_visits> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.134</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> @@ -24,6 +25,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.134</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> @@ -47,6 +49,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>180</sum_time_spent> + <sum_time_generation>0.234</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.234</min_time_generation> <max_time_generation>0.234</max_time_generation> @@ -66,6 +69,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.023</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.023</min_time_generation> <max_time_generation>0.023</max_time_generation> @@ -82,6 +86,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>900</sum_time_spent> + <sum_time_generation>0.224</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.224</min_time_generation> <max_time_generation>0.224</max_time_generation> diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getPageUrls_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getPageUrls_day.xml index 62c8fa6fc8..099d3c8c45 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getPageUrls_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__Actions.getPageUrls_day.xml @@ -6,6 +6,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>180</sum_time_spent> + <sum_time_generation>0.224</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.224</min_time_generation> <max_time_generation>0.224</max_time_generation> @@ -21,6 +22,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.023</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.023</min_time_generation> <max_time_generation>0.023</max_time_generation> @@ -38,6 +40,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>180</sum_time_spent> + <sum_time_generation>0.234</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.234</min_time_generation> <max_time_generation>0.234</max_time_generation> @@ -57,6 +60,7 @@ <nb_visits>1</nb_visits> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.134</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> @@ -76,6 +80,7 @@ <nb_uniq_visitors>1</nb_uniq_visitors> <nb_hits>1</nb_hits> <sum_time_spent>0</sum_time_spent> + <sum_time_generation>0.134</sum_time_generation> <nb_hits_with_time_generation>1</nb_hits_with_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__VisitsSummary.get_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__VisitsSummary.get_day.xml index b638a7f68c..40498bf45d 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__VisitsSummary.get_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__VisitsSummary.get_day.xml @@ -7,7 +7,7 @@ <bounce_count>1</bounce_count> <sum_visit_length>1621</sum_visit_length> <max_actions>7</max_actions> + <bounce_rate>50%</bounce_rate> <nb_actions_per_visit>4</nb_actions_per_visit> <avg_time_on_site>811</avg_time_on_site> - <bounce_rate>50%</bounce_rate> </result>
\ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_bulk_json__API.getBulkRequest.json b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_bulk_json__API.getBulkRequest.json index 4b75f2c513..54eec7681d 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_bulk_json__API.getBulkRequest.json +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_bulk_json__API.getBulkRequest.json @@ -1 +1 @@ -[{"2010-03-06":{"nb_uniq_visitors":1,"nb_users":0,"nb_visits":2,"nb_actions":8,"nb_visits_converted":2,"bounce_count":1,"sum_visit_length":1621,"max_actions":7,"nb_actions_per_visit":4,"avg_time_on_site":811,"bounce_rate":"50%"},"2010-03-07":[]},{"2010-03-06":{"nb_uniq_visitors":1,"nb_users":0,"nb_visits":2,"nb_actions":8,"nb_visits_converted":2,"bounce_count":1,"sum_visit_length":1621,"max_actions":7,"nb_actions_per_visit":4,"avg_time_on_site":811,"bounce_rate":"50%"},"2010-03-07":[]},[{"label":"0-10s","nb_visits":"1"},{"label":"11-30s","nb_visits":"0"},{"label":"31-60s","nb_visits":"0"},{"label":"1-2 min","nb_visits":"0"},{"label":"2-4 min","nb_visits":"0"},{"label":"4-7 min","nb_visits":"0"},{"label":"7-10 min","nb_visits":"0"},{"label":"10-15 min","nb_visits":"0"},{"label":"15-30 min","nb_visits":"1"},{"label":"30+ min","nb_visits":"0"}]]
\ No newline at end of file +[{"2010-03-06":{"nb_uniq_visitors":1,"nb_users":0,"nb_visits":2,"nb_actions":8,"nb_visits_converted":2,"bounce_count":1,"sum_visit_length":1621,"max_actions":7,"bounce_rate":"50%","nb_actions_per_visit":4,"avg_time_on_site":811},"2010-03-07":[]},{"2010-03-06":{"nb_uniq_visitors":1,"nb_users":0,"nb_visits":2,"nb_actions":8,"nb_visits_converted":2,"bounce_count":1,"sum_visit_length":1621,"max_actions":7,"bounce_rate":"50%","nb_actions_per_visit":4,"avg_time_on_site":811},"2010-03-07":[]},[{"label":"0-10s","nb_visits":"1"},{"label":"11-30s","nb_visits":"0"},{"label":"31-60s","nb_visits":"0"},{"label":"1-2 min","nb_visits":"0"},{"label":"2-4 min","nb_visits":"0"},{"label":"4-7 min","nb_visits":"0"},{"label":"7-10 min","nb_visits":"0"},{"label":"10-15 min","nb_visits":"0"},{"label":"15-30 min","nb_visits":"1"},{"label":"30+ min","nb_visits":"0"}]]
\ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_bulk_xml__API.getBulkRequest.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_bulk_xml__API.getBulkRequest.xml index df99d07898..e3455beeec 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_bulk_xml__API.getBulkRequest.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_bulk_xml__API.getBulkRequest.xml @@ -10,9 +10,9 @@ <bounce_count>1</bounce_count> <sum_visit_length>1621</sum_visit_length> <max_actions>7</max_actions> + <bounce_rate>50%</bounce_rate> <nb_actions_per_visit>4</nb_actions_per_visit> <avg_time_on_site>811</avg_time_on_site> - <bounce_rate>50%</bounce_rate> </row> <row key="2010-03-07"> </row> @@ -27,9 +27,9 @@ <bounce_count>1</bounce_count> <sum_visit_length>1621</sum_visit_length> <max_actions>7</max_actions> + <bounce_rate>50%</bounce_rate> <nb_actions_per_visit>4</nb_actions_per_visit> <avg_time_on_site>811</avg_time_on_site> - <bounce_rate>50%</bounce_rate> </row> <row key="2010-03-07"> </row> diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_csv__API.get_month.csv b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_csv__API.get_month.csv Binary files differindex ac649abb58..4fecaeba84 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_csv__API.get_month.csv +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_csv__API.get_month.csv diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___API.getProcessedReport_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___API.getProcessedReport_day.xml index fe3da65352..c9d8cb0877 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___API.getProcessedReport_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___API.getProcessedReport_day.xml @@ -9,12 +9,12 @@ <action>getPageTitles</action> <dimension>Page Name</dimension> <documentation>This report contains information about the titles of the pages that have been visited. <br /> The page title is the HTML <title> Tag that most browsers show in their window title.</documentation> - <metrics> - <exit_rate>Exit rate</exit_rate> - </metrics> <metricsDocumentation> <exit_rate>The percentage of visits that left the website after viewing this page.</exit_rate> </metricsDocumentation> + <processedMetrics> + <exit_rate>Exit rate</exit_rate> + </processedMetrics> <actionToLoadSubTables>getPageTitles</actionToLoadSubTables> <imageGraphUrl>index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=Actions&apiAction=getPageTitles&period=day&date=2010-03-06</imageGraphUrl> <imageGraphEvolutionUrl>index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=Actions&apiAction=getPageTitles&period=day&date=2010-02-05,2010-03-06</imageGraphEvolutionUrl> diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___Actions.getPageTitles_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___Actions.getPageTitles_day.xml index 793f02d8be..0d2e438d08 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___Actions.getPageTitles_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___Actions.getPageTitles_day.xml @@ -2,6 +2,7 @@ <result> <row> <label>Checkout</label> + <sum_time_generation>0.134</sum_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> <avg_time_on_page>0</avg_time_on_page> @@ -10,6 +11,7 @@ <row> <label> Purchasing...</label> <nb_uniq_visitors>1</nb_uniq_visitors> + <sum_time_generation>0.134</sum_time_generation> <min_time_generation>0.134</min_time_generation> <max_time_generation>0.134</max_time_generation> <avg_time_on_page>0</avg_time_on_page> @@ -20,6 +22,7 @@ <row> <label> incredible title!</label> <nb_uniq_visitors>1</nb_uniq_visitors> + <sum_time_generation>0.234</sum_time_generation> <min_time_generation>0.234</min_time_generation> <max_time_generation>0.234</max_time_generation> <avg_time_on_page>180</avg_time_on_page> @@ -28,6 +31,7 @@ <row> <label> Looking at homepage (again)...</label> <nb_uniq_visitors>1</nb_uniq_visitors> + <sum_time_generation>0.023</sum_time_generation> <min_time_generation>0.023</min_time_generation> <max_time_generation>0.023</max_time_generation> <avg_time_on_page>0</avg_time_on_page> @@ -36,6 +40,7 @@ <row> <label> Second page view - should be registered as URL</label> <nb_uniq_visitors>1</nb_uniq_visitors> + <sum_time_generation>0.224</sum_time_generation> <min_time_generation>0.224</min_time_generation> <max_time_generation>0.224</max_time_generation> <avg_time_on_page>900</avg_time_on_page> diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___VisitsSummary.get_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___VisitsSummary.get_day.xml index 0a131c30c2..e84bd27189 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___VisitsSummary.get_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___VisitsSummary.get_day.xml @@ -2,6 +2,6 @@ <result> <nb_uniq_visitors>1</nb_uniq_visitors> <nb_users>0</nb_users> - <nb_actions_per_visit>4</nb_actions_per_visit> <bounce_rate>50%</bounce_rate> + <nb_actions_per_visit>4</nb_actions_per_visit> </result>
\ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_showColumns___API.getProcessedReport_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_showColumns___API.getProcessedReport_day.xml index 6c94a197f7..0997fc815f 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_showColumns___API.getProcessedReport_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_showColumns___API.getProcessedReport_day.xml @@ -11,12 +11,14 @@ <documentation>This report contains information about the titles of the pages that have been visited. <br /> The page title is the HTML <title> Tag that most browsers show in their window title.</documentation> <metrics> <nb_hits>Pageviews</nb_hits> - <bounce_rate>Bounce Rate</bounce_rate> </metrics> <metricsDocumentation> <nb_hits>The number of times this page was visited.</nb_hits> <bounce_rate>The percentage of visits that started on this page and left the website straight away.</bounce_rate> </metricsDocumentation> + <processedMetrics> + <bounce_rate>Bounce Rate</bounce_rate> + </processedMetrics> <actionToLoadSubTables>getPageTitles</actionToLoadSubTables> <imageGraphUrl>index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=Actions&apiAction=getPageTitles&period=day&date=2010-03-06</imageGraphUrl> <imageGraphEvolutionUrl>index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=Actions&apiAction=getPageTitles&period=day&date=2010-02-05,2010-03-06</imageGraphEvolutionUrl> |