diff options
author | Stefan Giehl <stefan@matomo.org> | 2020-10-19 20:15:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-19 20:15:00 +0300 |
commit | 619ee9b48c5f11bbea38a8cf35f4a06b8fba0e11 (patch) | |
tree | f193503258cc0cf7a825ae2786ace92e1022691e /plugins | |
parent | 85618037852baa54631fbc9fbb42170afcde7553 (diff) |
Adds measuarable settings to disable visits log and visitor profile (#16561)
* Adds measuarable settings to disable visits log and visitor profile
* updates expected test files
* Adds some UI tests to check deactivating visitor log / profile works
* code improvements
* more ui tests
* Adds global system settings to disable visits log / profile
* adds UI tests for system setting
* updates expected screenshots
* code improvement
* improve tests
* reset custom logo usage after test
* updates expected screenshots
* use transient cache
Diffstat (limited to 'plugins')
34 files changed, 570 insertions, 31 deletions
diff --git a/plugins/CoreAdminHome/tests/UI/CustomLogo_spec.js b/plugins/CoreAdminHome/tests/UI/CustomLogo_spec.js index b8071c1fa3..452c653d9c 100644 --- a/plugins/CoreAdminHome/tests/UI/CustomLogo_spec.js +++ b/plugins/CoreAdminHome/tests/UI/CustomLogo_spec.js @@ -71,4 +71,13 @@ describe("CustomLogo", function () { expect(await navWrap.screenshot()).to.matchImage('unsubscribe'+appendName); }); }); + + // dummy test to ensure custom logo usage is reset + it('should remove the custom logo usage', async function () { + testEnvironment.optionsOverride = { + branding_use_custom_logo: '0' + }; + testEnvironment.save(); + await page.goto(""); + }); });
\ No newline at end of file diff --git a/plugins/Dashboard/tests/UI/expected-screenshots/DashboardManager_create_new.png b/plugins/Dashboard/tests/UI/expected-screenshots/DashboardManager_create_new.png index 41bc19cbfd..18fb84a245 100644 --- a/plugins/Dashboard/tests/UI/expected-screenshots/DashboardManager_create_new.png +++ b/plugins/Dashboard/tests/UI/expected-screenshots/DashboardManager_create_new.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7982d34428935e423434c6fc2757cb3231412a7a19fdb7b7f4f75a8d08d7fdf5 -size 314636 +oid sha256:a77d9df5aa0d557f57e2ebe2c6c2042c3625618316ac1e1940d590d2c0f2bd62 +size 312857 diff --git a/plugins/Dashboard/tests/UI/expected-screenshots/DashboardManager_removed.png b/plugins/Dashboard/tests/UI/expected-screenshots/DashboardManager_removed.png index ecaee6ba85..d5346199b9 100644 --- a/plugins/Dashboard/tests/UI/expected-screenshots/DashboardManager_removed.png +++ b/plugins/Dashboard/tests/UI/expected-screenshots/DashboardManager_removed.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:62884fc520829091a33301b4032be83fdfcf36fa2a8f856dcc9bf9a107e8a8cf -size 481911 +oid sha256:e518d84cfd5f749b573065d2dd019197d36fae72f661a807a8ae8a3808500b93 +size 480017 diff --git a/plugins/Ecommerce/Controller.php b/plugins/Ecommerce/Controller.php index b3e4cf84a3..67c4f1fa66 100644 --- a/plugins/Ecommerce/Controller.php +++ b/plugins/Ecommerce/Controller.php @@ -13,7 +13,9 @@ use Piwik\Common; use Piwik\FrontController; use Piwik\Http; use Piwik\Piwik; +use Piwik\Plugin\Manager; use Piwik\Plugins\Goals\API as GoalsApi; +use Piwik\Plugins\Live\Live; use Piwik\Translation\Translator; use Piwik\View; use Piwik\Plugins\Goals\TranslationHelper; @@ -91,6 +93,7 @@ class Controller extends \Piwik\Plugins\Goals\Controller $dataRow = $goalMetrics->getFirstRow(); + $view->visitorLogEnabled = Manager::getInstance()->isPluginActivated('Live') && Live::isVisitorLogEnabled($this->idSite); $view->idSite = $this->idSite; $view->idGoal = $idGoal; diff --git a/plugins/Ecommerce/Widgets/GetEcommerceLog.php b/plugins/Ecommerce/Widgets/GetEcommerceLog.php index b77d7bed1c..a480e7aa14 100644 --- a/plugins/Ecommerce/Widgets/GetEcommerceLog.php +++ b/plugins/Ecommerce/Widgets/GetEcommerceLog.php @@ -9,6 +9,9 @@ namespace Piwik\Plugins\Ecommerce\Widgets; use Piwik\Common; +use Piwik\Plugin\Manager; +use Piwik\Plugins\Live\Live; +use Piwik\Plugins\Live\MeasurableSettings; use Piwik\Widget\WidgetConfig; use Piwik\Site; @@ -28,6 +31,10 @@ class GetEcommerceLog extends \Piwik\Widget\Widget $site = new Site($idSite); $config->setIsEnabled($site->isEcommerceEnabled()); + + if (!Manager::getInstance()->isPluginActivated('Live') || !Live::isVisitorLogEnabled($idSite)) { + $config->disable(); + } } } diff --git a/plugins/Ecommerce/templates/conversionOverview.twig b/plugins/Ecommerce/templates/conversionOverview.twig index 98df3f6efe..e8672a2c84 100644 --- a/plugins/Ecommerce/templates/conversionOverview.twig +++ b/plugins/Ecommerce/templates/conversionOverview.twig @@ -1,6 +1,7 @@ <div piwik-content-block content-title="{{ 'Goals_ConversionsOverview'|translate|e('html_attr') }}"> <ul class="ulGoalTopElements"> + <li> {{ 'General_ColumnRevenue'|translate }}: {{ revenue|money(idSite)|raw -}} {% if revenue_subtotal is not empty %}, {{ 'General_Subtotal'|translate }}: {{ revenue_subtotal|money(idSite)|raw -}} @@ -14,9 +15,12 @@ {%- if revenue_discount is not empty -%}, {{ 'General_Discount'|translate }}: {{ revenue_discount|money(idSite)|raw -}} {% endif %} + </li> </ul> + {% if visitorLogEnabled %} <a href="javascript:;" class="segmentedlog" onclick="SegmentedVisitorLog.show('Goals.getMetrics', 'visitConvertedGoalId=={{ idGoal }}', {})"> <span class="icon-visitor-profile rowActionIcon"></span> {{ 'Live_RowActionTooltipWithDimension'|translate('General_Goal'|translate) }} </a> + {% endif %} <br style="clear:left"/> </div>
\ No newline at end of file diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php index 00e0e57925..02f8ee5c9e 100644 --- a/plugins/Goals/Controller.php +++ b/plugins/Goals/Controller.php @@ -15,6 +15,8 @@ use Piwik\DataTable\Renderer\Json; use Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal; use Piwik\FrontController; use Piwik\Piwik; +use Piwik\Plugin\Manager; +use Piwik\Plugins\Live\Live; use Piwik\Plugins\Referrers\API as APIReferrers; use Piwik\Translation\Translator; use Piwik\View; @@ -90,6 +92,7 @@ class Controller extends \Piwik\Plugin\Controller $view->conversion_rate_returning = $this->formatConversionRate($goalMetrics, 'conversion_rate_returning_visit'); $view->conversion_rate_new = $this->formatConversionRate($goalMetrics, 'conversion_rate_new_visit'); $view->idGoal = $idGoal; + $view->visitorLogEnabled = Manager::getInstance()->isPluginActivated('Live') && Live::isVisitorLogEnabled($this->idSite); return $view->render(); } diff --git a/plugins/Goals/templates/conversionOverview.twig b/plugins/Goals/templates/conversionOverview.twig index 1daa4dbb31..1743441c68 100644 --- a/plugins/Goals/templates/conversionOverview.twig +++ b/plugins/Goals/templates/conversionOverview.twig @@ -15,9 +15,11 @@ , {{ 'Goals_NewVisitorsConversionRateIs'|translate("<strong>"~conversion_rate_new~"</strong>")|raw }} </li> </ul> +{% if visitorLogEnabled %} <a href="javascript:;" class="segmentedlog" onclick="SegmentedVisitorLog.show('Goals.getMetrics', 'visitConvertedGoalId=={{ idGoal }}', {})"> <span class="icon-visitor-profile rowActionIcon"></span> {{ 'Live_RowActionTooltipWithDimension'|translate('General_Goal'|translate) }} </a> +{% endif %} {{ postEvent("Template.afterGoalConversionOverviewReport") }} <br style="clear:left"/> diff --git a/plugins/IntranetMeasurable/tests/UI/expected-screenshots/IntranetMeasurable_intranet_create.png b/plugins/IntranetMeasurable/tests/UI/expected-screenshots/IntranetMeasurable_intranet_create.png index 0c9bff3e1b..0b4b8ad96d 100644 --- a/plugins/IntranetMeasurable/tests/UI/expected-screenshots/IntranetMeasurable_intranet_create.png +++ b/plugins/IntranetMeasurable/tests/UI/expected-screenshots/IntranetMeasurable_intranet_create.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b2ef6a0d106665c1158e92c6b2b96b3cfe586b12300d47b56c48e6b499f967e1 -size 254195 +oid sha256:bc82d19a990194c727a088aed4dd2c9ba99734f9806bfe33b5c894be4e718b54 +size 260758 diff --git a/plugins/Live/API.php b/plugins/Live/API.php index 69eeff0c4e..56a5b6824a 100644 --- a/plugins/Live/API.php +++ b/plugins/Live/API.php @@ -189,6 +189,10 @@ class API extends \Piwik\Plugin\API { Piwik::checkUserHasViewAccess($idSite); + if (!Live::isVisitorProfileEnabled($idSite)) { + throw new Exception('Visitor profile has been disabled in website settings'); + } + if ($limitVisits <= 0) { $limitVisits = VisitorProfile::VISITOR_PROFILE_MAX_VISITS_TO_SHOW; } else { diff --git a/plugins/Live/Controller.php b/plugins/Live/Controller.php index 1cef559808..b4486adb95 100644 --- a/plugins/Live/Controller.php +++ b/plugins/Live/Controller.php @@ -140,6 +140,11 @@ class Controller extends \Piwik\Plugin\Controller public function getVisitorProfilePopup() { Piwik::checkUserHasViewAccess($this->idSite); + + if (!Live::isVisitorProfileEnabled($this->idSite)) { + throw new \Exception('Visitor profile has been disabled in website settings'); + } + $visitorData = Request::processRequest('Live.getVisitorProfile'); if (empty($visitorData)) { diff --git a/plugins/Live/Live.php b/plugins/Live/Live.php index 855ed752fa..d0be4209c8 100644 --- a/plugins/Live/Live.php +++ b/plugins/Live/Live.php @@ -19,6 +19,9 @@ use Piwik\Container\StaticContainer; */ class Live extends \Piwik\Plugin { + const ProfileEnabledCacheKey = 'Live.ProfileEnabled'; + const LogEnabledCacheKey = 'Live.LogEnabled'; + const CurrentSiteCacheKey = 'Live.CurrentSite'; /** * @see \Piwik\Plugin::registerEvents @@ -48,10 +51,77 @@ class Live extends \Piwik\Plugin { $actionsToDisplayCollapsed = (int)StaticContainer::get('Live.pageViewActionsToDisplayCollapsed'); $out .= " + piwik.visitorLogEnabled = ".json_encode(self::isVisitorLogEnabled())."; + piwik.visitorProfileEnabled = ".json_encode(self::isVisitorProfileEnabled())."; piwik.visitorLogActionsToDisplayCollapsed = $actionsToDisplayCollapsed; "; } + public static function isVisitorLogEnabled($idSite = null) + { + [$profileEnabled, $logEnabled] = self::getSettings($idSite); + + return $logEnabled; + } + + public static function isVisitorProfileEnabled($idSite = null) + { + [$profileEnabled, $logEnabled] = self::getSettings($idSite); + + return $profileEnabled; + } + + private static function getSettings($idSite = null) + { + if (empty($idSite)) { + $idSite = Common::getRequestVar('idSite', 0, 'int'); + } + + $cache = Cache::getTransientCache(); + $siteIdLoaded = $cache->fetch(self::CurrentSiteCacheKey); + $visitorProfileCached = $cache->contains(self::ProfileEnabledCacheKey); + $visitorLogCached = $cache->contains(self::LogEnabledCacheKey); + + if ($visitorProfileCached && $visitorLogCached && $idSite == $siteIdLoaded) { + return [ + $cache->fetch(self::ProfileEnabledCacheKey), + $cache->fetch(self::LogEnabledCacheKey), + ]; + } + + $siteIdLoaded = $idSite; + $visitorProfileEnabled = true; + $visitorLogEnabled = true; + + try { + if (!empty($idSite)) { + $settings = new MeasurableSettings($idSite); + + $visitorProfileEnabled = $settings->activateVisitorProfile->getValue(); + $visitorLogEnabled = $settings->activateVisitorLog->getValue(); + } + + $systemSettings = new SystemSettings(); + + if ($systemSettings->activateVisitorProfile->getValue() === false) { + $visitorProfileEnabled = false; + } + + if ($systemSettings->activateVisitorLog->getValue() === false) { + $visitorLogEnabled = false; + } + + $cache->save(self::CurrentSiteCacheKey, $siteIdLoaded); + $cache->save(self::ProfileEnabledCacheKey, $visitorProfileEnabled); + $cache->save(self::LogEnabledCacheKey, $visitorLogEnabled); + } catch (\Exception $e) { + // method might be called in a state where site can't be loaded (e.g. missing or outdated authentication) + // so simply ignore errors + } + + return [$visitorProfileEnabled, $visitorLogEnabled]; + } + public function getStylesheetFiles(&$stylesheets) { $stylesheets[] = "plugins/Live/stylesheets/live.less"; diff --git a/plugins/Live/MeasurableSettings.php b/plugins/Live/MeasurableSettings.php new file mode 100644 index 0000000000..cd68640b9d --- /dev/null +++ b/plugins/Live/MeasurableSettings.php @@ -0,0 +1,57 @@ +<?php +/** + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\Live; + +use Piwik\Piwik; +use Piwik\Settings\FieldConfig; +use Piwik\Settings\Measurable\MeasurableSetting; + +class MeasurableSettings extends \Piwik\Settings\Measurable\MeasurableSettings +{ + /** @var MeasurableSetting|null */ + public $activateVisitorLog; + + /** @var MeasurableSetting|null */ + public $activateVisitorProfile; + + protected function init() + { + $this->activateVisitorLog = $this->makeVisitorLogSetting(); + $this->activateVisitorProfile = $this->makeVisitorProfileSetting(); + + $systemSettings = new SystemSettings(); + + $this->activateVisitorLog->setIsWritableByCurrentUser($systemSettings->activateVisitorLog->getValue()); + $this->activateVisitorProfile->setIsWritableByCurrentUser($systemSettings->activateVisitorProfile->getValue()); + } + + private function makeVisitorLogSetting(): MeasurableSetting + { + $defaultValue = true; + $type = FieldConfig::TYPE_BOOL; + + return $this->makeSetting('activate_visitor_log', $defaultValue, $type, function (FieldConfig $field) { + $field->title = Piwik::translate('Live_EnableVisitsLog'); + $field->inlineHelp = ''; + $field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX; + }); + } + + private function makeVisitorProfileSetting(): MeasurableSetting + { + $defaultValue = true; + $type = FieldConfig::TYPE_BOOL; + + return $this->makeSetting('activate_visitor_profile', $defaultValue, $type, function (FieldConfig $field) { + $field->title = Piwik::translate('Live_EnableVisitorProfile'); + $field->inlineHelp = ''; + $field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX; + }); + } +}
\ No newline at end of file diff --git a/plugins/Live/Reports/GetLastVisitsDetails.php b/plugins/Live/Reports/GetLastVisitsDetails.php index a21c8ca4c2..701c7a18f9 100644 --- a/plugins/Live/Reports/GetLastVisitsDetails.php +++ b/plugins/Live/Reports/GetLastVisitsDetails.php @@ -8,7 +8,7 @@ */ namespace Piwik\Plugins\Live\Reports; -use Piwik\Plugin\Report; +use Piwik\Plugins\Live\Live; use Piwik\Plugins\Live\Visualizations\VisitorLog; use Piwik\Report\ReportWidgetFactory; use Piwik\Widget\WidgetsList; @@ -45,4 +45,8 @@ class GetLastVisitsDetails extends Base $widgetsList->addWidgetConfig($widget); } + public function isEnabled() + { + return Live::isVisitorLogEnabled(); + } } diff --git a/plugins/Live/SystemSettings.php b/plugins/Live/SystemSettings.php new file mode 100644 index 0000000000..f9d8e857a6 --- /dev/null +++ b/plugins/Live/SystemSettings.php @@ -0,0 +1,52 @@ +<?php +/** + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\Live; + +use Piwik\Piwik; +use Piwik\Settings\FieldConfig; +use Piwik\Settings\Plugin\SystemSetting; + +class SystemSettings extends \Piwik\Settings\Plugin\SystemSettings +{ + /** @var SystemSetting|null */ + public $activateVisitorLog; + + /** @var SystemSetting|null */ + public $activateVisitorProfile; + + protected function init() + { + $this->activateVisitorLog = $this->makeVisitorLogSetting(); + $this->activateVisitorProfile = $this->makeVisitorProfileSetting(); + } + + private function makeVisitorLogSetting(): SystemSetting + { + $defaultValue = true; + $type = FieldConfig::TYPE_BOOL; + + return $this->makeSetting('activate_visitor_log', $defaultValue, $type, function (FieldConfig $field) { + $field->title = Piwik::translate('Live_EnableVisitsLog'); + $field->inlineHelp = ''; + $field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX; + }); + } + + private function makeVisitorProfileSetting(): SystemSetting + { + $defaultValue = true; + $type = FieldConfig::TYPE_BOOL; + + return $this->makeSetting('activate_visitor_profile', $defaultValue, $type, function (FieldConfig $field) { + $field->title = Piwik::translate('Live_EnableVisitorProfile'); + $field->inlineHelp = ''; + $field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX; + }); + } +}
\ No newline at end of file diff --git a/plugins/Live/Visualizations/VisitorLog.php b/plugins/Live/Visualizations/VisitorLog.php index 6b8c415696..b403673759 100644 --- a/plugins/Live/Visualizations/VisitorLog.php +++ b/plugins/Live/Visualizations/VisitorLog.php @@ -16,10 +16,9 @@ use Piwik\Piwik; use Piwik\Plugin; use Piwik\Plugin\ViewDataTable; use Piwik\Plugin\Visualization; +use Piwik\Plugins\Live\Live; use Piwik\Plugins\PrivacyManager\PrivacyManager; -use Piwik\Plugins\TagManager\Model\Container\StaticContainerIdGenerator; use Piwik\Tracker\Action; -use Piwik\View; /** * A special DataTable visualization for the Live.getLastVisitsDetails API method. @@ -121,6 +120,10 @@ class VisitorLog extends Visualization $this->config->custom_parameters['hideProfileLink'] = (int)(1 == Common::getRequestVar('hideProfileLink', 0, 'int')); $this->config->custom_parameters['pageUrlNotDefined'] = Piwik::translate('General_NotDefined', Piwik::translate('Actions_ColumnPageURL')); + if (!Live::isVisitorProfileEnabled()) { + $this->config->custom_parameters['hideProfileLink'] = 1; + } + if (!$this->isInPopover()) { $this->config->footer_icons = array( array( diff --git a/plugins/Live/Widgets/GetVisitorProfilePopup.php b/plugins/Live/Widgets/GetVisitorProfilePopup.php index 3530edc37c..745234cbf6 100644 --- a/plugins/Live/Widgets/GetVisitorProfilePopup.php +++ b/plugins/Live/Widgets/GetVisitorProfilePopup.php @@ -8,7 +8,9 @@ */ namespace Piwik\Plugins\Live\Widgets; +use Piwik\Common; use Piwik\Piwik; +use Piwik\Plugins\Live\Live; use Piwik\Widget\WidgetConfig; class GetVisitorProfilePopup extends \Piwik\Widget\Widget @@ -23,6 +25,16 @@ class GetVisitorProfilePopup extends \Piwik\Widget\Widget if (Piwik::isUserIsAnonymous()) { $config->disable(); } + + $idSite = Common::getRequestVar('idSite', 0, 'int'); + + if (empty($idSite)) { + return; + } + + if (!Live::isVisitorProfileEnabled($idSite)) { + $config->disable(); + } } public function render() diff --git a/plugins/Live/javascripts/SegmentedVisitorLog.js b/plugins/Live/javascripts/SegmentedVisitorLog.js index b355ce1a75..c130c3ae23 100644 --- a/plugins/Live/javascripts/SegmentedVisitorLog.js +++ b/plugins/Live/javascripts/SegmentedVisitorLog.js @@ -95,6 +95,11 @@ var SegmentedVisitorLog = function() { function show(apiMethod, segment, extraParams) { + if (!piwik.visitorLogEnabled) { + console.error('Visitor Log was disabled in website settings'); + return; + } + // open the popover var box = Piwik_Popover.showLoading('Segmented Visit Log'); box.addClass('segmentedVisitorLogPopover'); diff --git a/plugins/Live/javascripts/rowaction.js b/plugins/Live/javascripts/rowaction.js index 82befa46a5..e5c196b9df 100644 --- a/plugins/Live/javascripts/rowaction.js +++ b/plugins/Live/javascripts/rowaction.js @@ -136,7 +136,7 @@ ], isAvailableOnReport: function (dataTableParams, undefined) { - return true; + return !!piwik.visitorLogEnabled; }, isAvailableOnRow: function (dataTableParams, tr) { diff --git a/plugins/Live/javascripts/visitorProfile.js b/plugins/Live/javascripts/visitorProfile.js index d488267537..59c46f2536 100644 --- a/plugins/Live/javascripts/visitorProfile.js +++ b/plugins/Live/javascripts/visitorProfile.js @@ -41,8 +41,15 @@ * in a new tab/window. * * @param {String} visitorId The string visitor ID. + * @param {String} idSite The ID of the site. */ VisitorProfileControl.showPopover = function (visitorId, idSite) { + + if (!piwik.visitorProfileEnabled) { + console.error('Visitor Profile was disabled in website settings'); + return; + } + var url = 'module=Live&action=getVisitorProfilePopup&visitorId=' + encodeURIComponent(visitorId); if (idSite) { url += '&idSite=' + idSite; diff --git a/plugins/Live/lang/en.json b/plugins/Live/lang/en.json index f346c7557e..faa30bb934 100644 --- a/plugins/Live/lang/en.json +++ b/plugins/Live/lang/en.json @@ -31,11 +31,13 @@ "ActionsAndDuration": "%1$s actions in %2$s", "SimpleRealTimeWidget_Message": "%1$s and %2$s in the last %3$s", "ViewVisitorProfile": "View visitor profile", + "EnableVisitorProfile": "Enable visitor profile", "VisitedPages": "Visited pages", "RevisitedPages": "Pages viewed more than once", "ToggleActions": "Toggle visibility of all actions", "TopVisitedPages": "Top visited pages", "VisitsLog": "Visits Log", + "EnableVisitsLog": "Enable visits log", "QueryMaxExecutionTimeExceeded": "The query took too long to execute.", "QueryMaxExecutionTimeExceededReasonDateRange": "This can happen if the selected date range is too large. Please try to select a smaller date range.", "QueryMaxExecutionTimeExceededReasonSegment": "This can happen if the selected segment doesn't match any visit. Please try to check your selected segment.", diff --git a/plugins/Live/tests/UI/DeactivatedFeatures_spec.js b/plugins/Live/tests/UI/DeactivatedFeatures_spec.js new file mode 100644 index 0000000000..f4b6d3f670 --- /dev/null +++ b/plugins/Live/tests/UI/DeactivatedFeatures_spec.js @@ -0,0 +1,252 @@ +/*! + * Matomo - free/libre analytics platform + * + * Screenshot integration tests. + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +describe("DeactivatedFeatures", function () { + + afterEach(async function () { + await setFeatures(1, 1, 1); + if (testEnvironment.configOverride.Live) { + delete testEnvironment.configOverride.Live; + await testEnvironment.save(); + } + }); + + after(async function () { + await setFeatures(1, 1, 1); + if (testEnvironment.configOverride.Live) { + delete testEnvironment.configOverride.Live; + await testEnvironment.save(); + } + }); + + + async function setFeatures(idSite, vLog, vProfile) { + await testEnvironment.callApi("SitesManager.updateSite", { + idSite: idSite, settingValues: { + Live: [ + {name: 'activate_visitor_log', value: vLog}, + {name: 'activate_visitor_profile', value: vProfile}, + ] + } + }); + } + + async function setConfig(vLog, vProfile) { + testEnvironment.overrideConfig('Live', 'activate_visitor_log', vLog); + testEnvironment.overrideConfig('Live', 'activate_visitor_profile', vProfile); + await testEnvironment.save(); + } + + // test measurable setting + + it('menu should contain visits log when enabled', async function () { + await setFeatures(1, 1, 0); + await page.goto("?module=CoreHome&action=index&idSite=1&period=year&date=2009-01-04#?idSite=1&period=year&date=2009-01-04&category=General_Visitors&subcategory=General_Overview"); + await page.waitFor('#secondNavBar', {visible: true}); + + const element = await page.$('#secondNavBar .navbar a[href*="Live_VisitorLog"]'); + expect(element).to.be.ok; + }); + + it('menu should not contain visits log when deactivated', async function () { + await setFeatures(1, 0, 0); + await page.reload(); + await page.waitFor('#secondNavBar', {visible: true}); + + const element = await page.$('#secondNavBar .navbar a[href*="Live_VisitorLog"]'); + expect(element).to.be.not.ok; + }); + + it('it should not show visits log, when opened directly but disabled', async function () { + await setFeatures(1, 0, 0); + await page.goto("?module=CoreHome&action=index&idSite=1&period=year&date=2009-08-09#?idSite=1&period=year&date=2009-08-09&category=General_Visitors&subcategory=Live_VisitorLog"); + await page.waitForNetworkIdle(); + + expect(await page.getWholeCurrentUrl()).to.not.match(/Live_VisitorLog/); // page should be redirected to next subcategory + }); + + it('menu should contain ecommerce log when visits log enabled', async function () { + await setFeatures(1, 1, 0); + await page.goto("?module=CoreHome&action=index&idSite=1&period=year&date=2009-01-04#?idSite=1&period=year&date=2009-01-04&category=Goals_Ecommerce&subcategory=Goals_EcommerceLog"); + await page.waitFor('#secondNavBar', {visible: true}); + + const element = await page.$('#secondNavBar .navbar a[href*="Goals_EcommerceLog"]'); + expect(element).to.be.ok; + }); + + it('menu should not contain ecommerce log when visits log deactivated', async function () { + await setFeatures(1, 0, 0); + await page.reload(); + await page.waitFor('#secondNavBar', {visible: true}); + + const element = await page.$('#secondNavBar .navbar a[href*="Goals_EcommerceLog"]'); + expect(element).to.be.not.ok; + }); + + it('it should not show ecommerce log, when opened directly but disabled', async function () { + await setFeatures(1, 0, 0); + await page.goto("?module=CoreHome&action=index&idSite=1&period=year&date=2009-08-09#?idSite=1&period=year&date=2009-08-09&category=Goals_Ecommerce&subcategory=Goals_EcommerceLog"); + await page.waitForNetworkIdle(); + + expect(await page.getWholeCurrentUrl()).to.not.match(/Goals_EcommerceLog/); // page should be redirected to next subcategory + }); + + it('it should show profile link in visits log when enabled', async function () { + await setFeatures(1, 1, 1); + await page.goto("?module=CoreHome&action=index&idSite=1&period=year&date=2012-08-09#?idSite=1&period=year&date=2012-08-09&category=General_Visitors&subcategory=Live_VisitorLog"); + await page.waitFor('.dataTableVizVisitorLog'); + + const element = await page.$('.dataTableVizVisitorLog .card .visitor-log-visitor-profile-link'); + expect(element).to.be.ok; + }); + + it('it should not show profile link in visits log when disabled', async function () { + await setFeatures(1, 1, 0); + await page.reload(); + await page.waitFor('.dataTableVizVisitorLog'); + + const element = await page.$('.dataTableVizVisitorLog .card .visitor-log-visitor-profile-link'); + expect(element).to.be.not.ok; + }); + + it('it should show segmented visits log row action when enabled', async function () { + await setFeatures(1, 1, 0); + await page.goto("?module=CoreHome&action=index&idSite=1&period=year&date=2012-08-08#?idSite=1&period=year&date=2012-08-08&category=General_Visitors&subcategory=DevicesDetection_Software"); + await page.waitForNetworkIdle(); + + await (await page.jQuery('#widgetDevicesDetectiongetOsVersions td.label:first')).hover(); + await page.waitFor('#widgetDevicesDetectiongetOsVersions .dataTableRowActions', {visible: true}); + + const element = await page.$('#widgetDevicesDetectiongetOsVersions .dataTableRowActions .actionSegmentVisitorLog'); + expect(element).to.be.ok; + }); + + it('it should not show segmented visits log row action when disabled', async function () { + await setFeatures(1, 0, 0); + await page.reload(); + await page.waitForNetworkIdle(); + + await (await page.jQuery('#widgetDevicesDetectiongetOsVersions td.label:first')).hover(); + await page.waitFor('#widgetDevicesDetectiongetOsVersions .dataTableRowActions', {visible: true}); + + const element = await page.$('#widgetDevicesDetectiongetOsVersions .dataTableRowActions .actionSegmentVisitorLog'); + expect(element).to.be.not.ok; + }); + + it('widget list should contain log and profile when enabled', async function () { + await setFeatures(1, 1, 1); + await page.goto("?module=Widgetize&action=index&idSite=1&period=day&date=yesterday"); + await page.waitForNetworkIdle(); + + await (await page.jQuery('.widgetpreview-categorylist li:contains("Visitors"):first')).hover(); + await page.waitFor('.widgetpreview-widgetlist', {visible: true}); + + const profile = await page.$('.widgetpreview-widgetlist [uniqueid=widgetLivegetVisitorProfilePopup]'); + expect(profile).to.be.ok; + + const log = await page.$('.widgetpreview-widgetlist [uniqueid=widgetLivegetLastVisitsDetailsforceView1viewDataTableVisitorLogsmall1]'); + expect(log).to.be.ok; + }); + + it('widget list should not contain log and profile when disabled', async function () { + await setFeatures(1, 0, 0); + await page.goto("?module=Widgetize&action=index&idSite=1&period=day&date=yesterday"); + await page.waitForNetworkIdle(); + + await (await page.jQuery('.widgetpreview-categorylist li:contains("Visitors"):first')).hover(); + await page.waitFor('.widgetpreview-widgetlist', {visible: true}); + + const profile = await page.$('.widgetpreview-widgetlist [uniqueid=widgetLivegetVisitorProfilePopup]'); + expect(profile).to.be.not.ok; + + const log = await page.$('.widgetpreview-widgetlist [uniqueid=widgetLivegetLastVisitsDetailsforceView1viewDataTableVisitorLogsmall1]'); + expect(log).to.be.not.ok; + }); + + it('Goal overview contains segmented visitor log link when activated', async function () { + await setFeatures(1, 1, 0); + await page.goto("?module=CoreHome&action=index&idSite=1&period=year&date=2012-08-08#?idSite=1&period=year&date=2012-08-08&category=Goals_Goals&subcategory=1"); + await page.waitFor('#widgetGoalsgoalConversionsOverviewidGoal1', {visible: true}); + + const profile = await page.$('#widgetGoalsgoalConversionsOverviewidGoal1 a.segmentedlog'); + expect(profile).to.be.ok; + }); + + it('Goal overview does not contain segmented visitor log link when disabled', async function () { + await setFeatures(1, 0, 0); + await page.reload(); + await page.waitFor('#widgetGoalsgoalConversionsOverviewidGoal1', {visible: true}); + + const profile = await page.$('#widgetGoalsgoalConversionsOverviewidGoal1 a.segmentedlog'); + expect(profile).to.be.not.ok; + }); + + + // test system setting + + it('system settings for live plugin should be available by default', async function () { + await page.goto("?module=CoreAdminHome&action=generalSettings"); + await page.waitForNetworkIdle(); + + const log = await page.$('#LivePluginSettings #activate_visitor_log'); + expect(log).to.be.ok; + + const profile = await page.$('#LivePluginSettings #activate_visitor_profile'); + expect(profile).to.be.ok; + }); + + it('system settings for live plugin should be hidden if disabled in config', async function () { + await setConfig(0, 0); + await page.reload(); + await page.waitForNetworkIdle(); + + const log = await page.$('#LivePluginSettings #activate_visitor_log'); + expect(log).to.be.not.ok; + + const profile = await page.$('#LivePluginSettings #activate_visitor_profile'); + expect(profile).to.be.not.ok; + }); + + it('measurable settings for live plugin should be available by default', async function () { + await page.goto("?module=SitesManager&action=index&idSite=1"); + await page.waitForNetworkIdle(); + await page.click('[idsite="1"] .icon-edit'); + await page.waitForNetworkIdle(); + + const log = await page.$('[idsite="1"] #activate_visitor_log'); + expect(log).to.be.ok; + + const profile = await page.$('[idsite="1"] #activate_visitor_profile'); + expect(profile).to.be.ok; + }); + + it('measurable settings for live plugin should be available by default', async function () { + await setConfig(0, 0); + await page.reload(); + await page.waitForNetworkIdle(); + await page.click('[idsite="1"] .icon-edit'); + await page.waitForNetworkIdle(); + + const log = await page.$('[idsite="1"] #activate_visitor_log'); + expect(log).to.be.not.ok; + + const profile = await page.$('[idsite="1"] #activate_visitor_profile'); + expect(profile).to.be.not.ok; + }); + + it('menu should not contain visits log when deactivated globally', async function () { + await setConfig(0, 0); + await page.goto("?module=CoreHome&action=index&idSite=1&period=year&date=2009-01-04#?idSite=1&period=year&date=2009-01-04&category=General_Visitors&subcategory=General_Overview"); + await page.waitFor('#secondNavBar', {visible: true}); + + const element = await page.$('#secondNavBar .navbar a[href*="Live_VisitorLog"]'); + expect(element).to.be.not.ok; + }); + +});
\ No newline at end of file diff --git a/plugins/Overlay/javascripts/Piwik_Overlay.js b/plugins/Overlay/javascripts/Piwik_Overlay.js index b61eccf424..3c9a0b4551 100644 --- a/plugins/Overlay/javascripts/Piwik_Overlay.js +++ b/plugins/Overlay/javascripts/Piwik_Overlay.js @@ -84,7 +84,7 @@ var Piwik_Overlay = (function () { if (!$sidebar.find('.overlayNoData').length) { $rowEvolutionLink.show(); $transitionsLink.show(); - if ($('#segment').val()) { + if ($('#segment').val() && piwik.visitorLogEnabled) { $visitorLogLink.show(); } } diff --git a/plugins/SegmentEditor/tests/UI/expected-screenshots/SegmentSelectorEditorTest_complex_segment.png b/plugins/SegmentEditor/tests/UI/expected-screenshots/SegmentSelectorEditorTest_complex_segment.png index ef53691435..7790c942dd 100644 --- a/plugins/SegmentEditor/tests/UI/expected-screenshots/SegmentSelectorEditorTest_complex_segment.png +++ b/plugins/SegmentEditor/tests/UI/expected-screenshots/SegmentSelectorEditorTest_complex_segment.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2cd0a14698fde5d34e2a5cc38870d06c2498da331b42077659d8d93aba9aac32 -size 136343 +oid sha256:5580aa3511e7adc81b10aa5e7b2e483572041924554b341e0d2d436c24c9b081 +size 134807 diff --git a/plugins/SitesManager/tests/System/expected/test_SitesManager__SitesManager.getSiteSettings.xml b/plugins/SitesManager/tests/System/expected/test_SitesManager__SitesManager.getSiteSettings.xml index 80f68ce41e..407b10b1bf 100644 --- a/plugins/SitesManager/tests/System/expected/test_SitesManager__SitesManager.getSiteSettings.xml +++ b/plugins/SitesManager/tests/System/expected/test_SitesManager__SitesManager.getSiteSettings.xml @@ -219,6 +219,44 @@ https://www.example.org/</placeholder> </settings> </row> <row> + <pluginName>Live</pluginName> + <title>Live</title> + <settings> + <row> + <name>activate_visitor_log</name> + <title>Enable visits log</title> + <value>1</value> + <defaultValue>1</defaultValue> + <type>boolean</type> + <uiControl>checkbox</uiControl> + <uiControlAttributes> + </uiControlAttributes> + <availableValues /> + <description /> + <inlineHelp /> + <templateFile /> + <introduction /> + <condition /> + </row> + <row> + <name>activate_visitor_profile</name> + <title>Enable visitor profile</title> + <value>1</value> + <defaultValue>1</defaultValue> + <type>boolean</type> + <uiControl>checkbox</uiControl> + <uiControlAttributes> + </uiControlAttributes> + <availableValues /> + <description /> + <inlineHelp /> + <templateFile /> + <introduction /> + <condition /> + </row> + </settings> + </row> + <row> <pluginName>ExampleSettingsPlugin</pluginName> <title>ExampleSettingsPlugin</title> <settings> diff --git a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_loaded.png b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_loaded.png index 6d4ba0d044..48a16d2632 100644 --- a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_loaded.png +++ b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_loaded.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:faad7ccddbf271d2bd235eaff487f9b0cdc26e092dcc0d91c1ef31392e7ace3f -size 177118 +oid sha256:95e04551f119e1e9b8b820c17673d1f406dd0551fd94321230372d8dbefa1b07 +size 177262 diff --git a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_page_1.png b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_page_1.png index 3e676e3d44..1ba96865f1 100644 --- a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_page_1.png +++ b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_page_1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:177f4e90b1d78baf6373e8062b4daefba33df9510ef8e57feaef92b81287c39f -size 181538 +oid sha256:d62c70361f44a171784cc6192f24099eca39b29edd6f0f7845d38968eee4e8b6 +size 181767 diff --git a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_page_1_again.png b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_page_1_again.png index 8dfe074481..003dcfbd45 100644 --- a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_page_1_again.png +++ b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_page_1_again.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aaf35ed2b9ae40fc928a3c40745575f0607b4db4153cc35672777e223f29659a -size 181539 +oid sha256:15b42566d36e4085a857ff23362139cf4a37587fa69af52c14e46e39d9a5e611 +size 181762 diff --git a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_page_2.png b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_page_2.png index 2b500ea2cf..c01e5b6003 100644 --- a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_page_2.png +++ b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_page_2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d6acb7d862cf1d4ca17101eec65c6ccbd9a6ea9444ddc7b8440336e1a0c2d37d -size 184002 +oid sha256:131138db6f1a134d593409bedf603d869126fd65973987ee1d7c5ea8df272254 +size 184192 diff --git a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_search.png b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_search.png index 7644ace273..372ea3b96c 100644 --- a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_search.png +++ b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_search.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3225bb06a235956222aa0c752b892a5b014547440632a4aa2439a798cec24743 -size 176197 +oid sha256:24fbc319ff68fd83356d9364df18185af5c63a0ad0f0094789410247130cf67f +size 176260 diff --git a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_search_no_result.png b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_search_no_result.png index 6c4ed390b1..d60dd751d0 100644 --- a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_search_no_result.png +++ b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_search_no_result.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e89adc9c44fe94357508a3136b6a290a8c7590c838ecf7d6ff311251275b4839 -size 44955 +oid sha256:3fd423f46369202fd777327821e56cca7c3edc4aa2d53be9f4528ca5f96293d5 +size 45021 diff --git a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_search_page_1.png b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_search_page_1.png index be7dde71ec..8b9a4e3801 100644 --- a/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_search_page_1.png +++ b/plugins/SitesManager/tests/UI/expected-screenshots/SitesManager_search_page_1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1d3901b4c2477df7a077619703f20845000570d496d712a073182f48cbf3e622 -size 180341 +oid sha256:df0ef2e8806715fc4caeda4c81f7b3aa0c733739c67713ae5eb9937e9958c725 +size 180419 diff --git a/plugins/UserCountryMap/tests/UI/expected-screenshots/VisitorMap_cities.png b/plugins/UserCountryMap/tests/UI/expected-screenshots/VisitorMap_cities.png index b6bd0e6187..82b59c80a5 100644 --- a/plugins/UserCountryMap/tests/UI/expected-screenshots/VisitorMap_cities.png +++ b/plugins/UserCountryMap/tests/UI/expected-screenshots/VisitorMap_cities.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1e6eab272abfcfe11e07d8418a4ae36b6be24940c7e24b14bd66daca7e039971 -size 116131 +oid sha256:b8fa287087f6e90df90f91566013e868fb4fb8ed7e1a95d474fbae6efcc09552 +size 114508 diff --git a/plugins/UserCountryMap/tests/UI/expected-screenshots/VisitorMap_regions.png b/plugins/UserCountryMap/tests/UI/expected-screenshots/VisitorMap_regions.png index 8e2afb3e08..5159225887 100644 --- a/plugins/UserCountryMap/tests/UI/expected-screenshots/VisitorMap_regions.png +++ b/plugins/UserCountryMap/tests/UI/expected-screenshots/VisitorMap_regions.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:60331f813404c415e2fd3262c24844cfa2de8fce0a9fc980c8051493737c26ec -size 115647 +oid sha256:c1bb4c48dabc5e484d7e3d93db825f25590805c582016112178af4355fada02c +size 113953 |