Skip to content
Extraits de code Groupes Projets
Valider 08090f2c rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

minor UserId tweaks, enable row evolution for userId etc (#10072)

parent eac5a581
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -22,20 +22,17 @@ use Piwik\DataTable\Row; ...@@ -22,20 +22,17 @@ use Piwik\DataTable\Row;
class API extends \Piwik\Plugin\API class API extends \Piwik\Plugin\API
{ {
/** /**
* Get DataTable with User Ids and some aggregated data. Supports pagination, sorting * Get a report of all User Ids.
* and filtering by user_id
* *
* @param int $idSite * @param int $idSite
* *
* @param $period * @param string $period
* @param $date * @param int $date
* @param $segment * @param string|bool $segment
* @param $expanded
* @param $flat
* *
* @return DataTable * @return DataTable
*/ */
public function getUsers($idSite, $period, $date, $segment = false, $expanded = false, $flat = false) public function getUsers($idSite, $period, $date, $segment = false)
{ {
Piwik::checkUserHasViewAccess($idSite); Piwik::checkUserHasViewAccess($idSite);
$archive = Archive::build($idSite, $period, $date, $segment); $archive = Archive::build($idSite, $period, $date, $segment);
......
...@@ -77,12 +77,13 @@ class Archiver extends \Piwik\Plugin\Archiver ...@@ -77,12 +77,13 @@ class Archiver extends \Piwik\Plugin\Archiver
$userIdFieldName = self::USER_ID_FIELD; $userIdFieldName = self::USER_ID_FIELD;
$visitorIdFieldName = self::VISITOR_ID_FIELD; $visitorIdFieldName = self::VISITOR_ID_FIELD;
/** @var Zend_Db_Statement $query */ /** @var \Zend_Db_Statement $query */
$query = $this->getLogAggregator()->queryVisitsByDimension( $query = $this->getLogAggregator()->queryVisitsByDimension(
array(self::USER_ID_FIELD), array(self::USER_ID_FIELD),
"$userIdFieldName IS NOT NULL AND $userIdFieldName != ''", "$userIdFieldName IS NOT NULL AND $userIdFieldName != ''",
array("LOWER(HEX($visitorIdFieldName)) as $visitorIdFieldName") array("LOWER(HEX($visitorIdFieldName)) as $visitorIdFieldName")
); );
if ($query === false) { if ($query === false) {
return; return;
} }
...@@ -114,7 +115,7 @@ class Archiver extends \Piwik\Plugin\Archiver ...@@ -114,7 +115,7 @@ class Archiver extends \Piwik\Plugin\Archiver
* *
* @param array $row * @param array $row
*/ */
protected function rememberVisitorId($row) private function rememberVisitorId($row)
{ {
if (!empty($row[self::USER_ID_FIELD]) && !empty($row[self::VISITOR_ID_FIELD])) { if (!empty($row[self::USER_ID_FIELD]) && !empty($row[self::VISITOR_ID_FIELD])) {
$this->visitorIdsUserIdsMap[$row[self::USER_ID_FIELD]] = $row[self::VISITOR_ID_FIELD]; $this->visitorIdsUserIdsMap[$row[self::USER_ID_FIELD]] = $row[self::VISITOR_ID_FIELD];
...@@ -126,7 +127,7 @@ class Archiver extends \Piwik\Plugin\Archiver ...@@ -126,7 +127,7 @@ class Archiver extends \Piwik\Plugin\Archiver
* *
* @param DataTable $dataTable * @param DataTable $dataTable
*/ */
protected function setVisitorIds(DataTable $dataTable) private function setVisitorIds(DataTable $dataTable)
{ {
foreach ($dataTable->getRows() as $row) { foreach ($dataTable->getRows() as $row) {
$userId = $row->getColumn('label'); $userId = $row->getColumn('label');
......
<?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\UserId\Columns;
use Piwik\Piwik;
use Piwik\Plugin\Dimension\VisitDimension;
/**
* UserId dimension
*/
class UserId extends VisitDimension
{
/**
* The name of the dimension which will be visible for instance in the UI of a related report and in the mobile app.
* @return string
*/
public function getName()
{
return Piwik::translate('UserId_UserId');
}
}
\ No newline at end of file
...@@ -11,6 +11,8 @@ namespace Piwik\Plugins\UserId\Reports; ...@@ -11,6 +11,8 @@ namespace Piwik\Plugins\UserId\Reports;
use Piwik\Piwik; use Piwik\Piwik;
use Piwik\Plugin\Report; use Piwik\Plugin\Report;
use Piwik\Plugin\ViewDataTable; use Piwik\Plugin\ViewDataTable;
use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable;
use Piwik\Plugins\UserId\Columns\UserId;
use Piwik\View; use Piwik\View;
/** /**
...@@ -19,26 +21,27 @@ use Piwik\View; ...@@ -19,26 +21,27 @@ use Piwik\View;
*/ */
class GetUsers extends Base class GetUsers extends Base
{ {
/**
* @return array
*/
public static function getColumnsToDisplay()
{
return array(
'label', 'nb_visits', 'nb_actions', 'nb_visits_converted'
);
}
protected function init() protected function init()
{ {
parent::init(); parent::init();
$this->name = Piwik::translate('UsersManager_MenuUsers'); $this->name = Piwik::translate('UserId_UserReportTitle');
$this->menuTitle = $this->name; $this->menuTitle = $this->name;
$this->widgetTitle = $this->menuTitle;
$this->documentation = ''; $this->documentation = '';
$this->dimension = new UserId();
$this->metrics = array('label', 'nb_visits', 'nb_actions', 'nb_visits_converted');
// This defines in which order your report appears in the mobile app, in the menu and in the list of widgets // This defines in which order your report appears in the mobile app, in the menu and in the list of widgets
$this->order = 1; $this->order = 9;
}
/**
* @return array
*/
public static function getColumnsToDisplay()
{
return ;
} }
/** /**
...@@ -52,14 +55,17 @@ class GetUsers extends Base ...@@ -52,14 +55,17 @@ class GetUsers extends Base
/* /*
* Hide most of the table footer actions, leaving only export icons and pagination * Hide most of the table footer actions, leaving only export icons and pagination
*/ */
$view->config->columns_to_display = $this->getColumnsToDisplay(); $view->config->columns_to_display = $this->metrics;
$view->config->show_all_views_icons = false; $view->config->show_all_views_icons = false;
$view->config->show_active_view_icon = false; $view->config->show_active_view_icon = false;
$view->config->show_related_reports = false; $view->config->show_related_reports = false;
$view->config->show_insights = false; $view->config->show_insights = false;
$view->config->show_pivot_by_subtable = false; $view->config->show_pivot_by_subtable = false;
$view->config->show_flatten_table = false; $view->config->show_flatten_table = false;
$view->config->disable_row_evolution = true;
if ($view->isViewDataTableId(HtmlTable::ID)) {
$view->config->disable_row_evolution = false;
}
// exclude users with less then 2 visits, when low population filter is active // exclude users with less then 2 visits, when low population filter is active
$view->requestConfig->filter_excludelowpop_value = 2; $view->requestConfig->filter_excludelowpop_value = 2;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
DataTable_RowActions_VisitorDetails.prototype.performAction = function (label, tr, e) { DataTable_RowActions_VisitorDetails.prototype.performAction = function (label, tr, e) {
var visitorId = this.getRowMetadata($(tr)).idvisitor || ''; var visitorId = this.getRowMetadata($(tr)).idvisitor || '';
visitorId = encodeURIComponent(visitorId);
if (visitorId.length > 0) { if (visitorId.length > 0) {
DataTable_RowAction.prototype.openPopover.apply(this, ['module=Live&action=getVisitorProfilePopup&visitorId=' + visitorId]); DataTable_RowAction.prototype.openPopover.apply(this, ['module=Live&action=getVisitorProfilePopup&visitorId=' + visitorId]);
} }
......
{
"UserId": {
"UserId": "UserId",
"UserReportTitle": "Users"
}
}
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter