Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds measuarable settings to disable visits log and visitor profile #16561

Merged
merged 13 commits into from Oct 19, 2020

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Oct 12, 2020

fixes #16259

@sgiehl sgiehl added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label Oct 12, 2020
@sgiehl sgiehl added this to the 4.0.0-RC milestone Oct 12, 2020
@sgiehl sgiehl force-pushed the disablevlogprofile branch 2 times, most recently from 517a5d0 to 6e88855 Compare October 13, 2020 08:04
@sgiehl
Copy link
Member Author

sgiehl commented Oct 13, 2020

@tsteur Do we also need a possibility to define the default value for new websites, or maybe the possibility to disable the features in config, so it's not possible to enable them in UI?

@tsteur
Copy link
Member

tsteur commented Oct 13, 2020

Haven't looked at the PR so not sure what is implemented. I think a global system setting to disable the feature for all sites be needed. When the feature is disabled globally then it should not be present in measurable settings.

If it's enabled, then we would show it in measurable settings.

If we use a system setting for the global flag then it'll be automatically configurable through the config file as well and would be then removed in the UI. I think that should do.

@sgiehl sgiehl force-pushed the disablevlogprofile branch 2 times, most recently from 5eac8bd to 04f0d3a Compare October 14, 2020 14:00
@sgiehl sgiehl marked this pull request as ready for review October 14, 2020 14:16
@sgiehl sgiehl added Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. and removed Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. labels Oct 14, 2020
@sgiehl sgiehl force-pushed the disablevlogprofile branch 2 times, most recently from bfd5dea to 70cd195 Compare October 14, 2020 16:21
@sgiehl
Copy link
Member Author

sgiehl commented Oct 14, 2020

Seems due to the new UI test file, some tests moved between the splitting causing some tests to have other results. Will fix those later. But everything else can already be reviewed...

@sgiehl sgiehl force-pushed the disablevlogprofile branch 2 times, most recently from 29bb2fa to 7d91f75 Compare October 15, 2020 07:39
@tsteur tsteur requested a review from diosmosis October 18, 2020 22:48
@@ -90,6 +92,7 @@ public function goalConversionsOverview()
$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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check for Manager::getInstance()->isPluginActivated('Live') in Live::isVisitorLogEnabled or do the checks need to be separate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory guess we could do that. But might be better if we always check if a plugin is installed & activated before using it.
Not sure if Matomo would even run correctly if the Live plugin would be deleted, but if that would work, the code would break here if we directly use a part of the plugin without checking if it's available...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -19,6 +19,9 @@
*/
class Live extends \Piwik\Plugin
{
protected static $visitorProfileEnabled = null;
protected static $visitorLogEnabled = null;
protected static $siteIdLoaded = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: if adding static variables like this, we'd need to make sure they are unset in Fixture::clearInMemoryCaches() (though these won't affect any existing tests I think, but they might in the future). If using the transient cache, then nothing needs to change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using transient cache instead sound fine... will change that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -189,6 +189,10 @@ public function getVisitorProfile($idSite, $visitorId = false, $segment = false,
{
Piwik::checkUserHasViewAccess($idSite);

if (!Live::isVisitorProfileEnabled($idSite)) {
throw new Exception('Visitor profile has been disabled in website settings');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be translated? Since the user could see it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He should actually only see this when calling the API directly. The UI shouldn't try to load the visitor profile at all when it's disabled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember how, but I was able to see the error in the UI a couple times. Once in widgets, once in the visitor log page. This was while switching the setting on/off in one tab and testing in another, however, so it could have been an edge case users wouldn't notice.

Copy link
Member

@diosmosis diosmosis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple comments. Testing locally, everything seems to work 👍

@diosmosis diosmosis merged commit 619ee9b into 4.x-dev Oct 19, 2020
@diosmosis diosmosis deleted the disablevlogprofile branch October 19, 2020 17:15
$idSite = Common::getRequestVar('idSite', 0, 'int');
}

$cache = Cache::getTransientCache();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi @sgiehl in future we probably wouldn't need to cache these settings. If so, we could add a generic transient cache here to all settings: https://github.com/matomo-org/matomo/blob/4.0.0-b3/core/Settings/Storage/Factory.php#L134 but they shouldn't be majorly slow and partially already transient cached in the backend potentially

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow disabling Visitor Profile feature and visits log feature
3 participants