diff options
author | MichaelHeerklotz <michael.heerklotz@web.de> | 2019-11-08 06:25:20 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2019-11-08 06:25:20 +0300 |
commit | ea5a14bdf8aa9608cdc2ab7d5c8236a5ff1eb3e2 (patch) | |
tree | 1bfa77aad668a61f0db3159fc8fa63c6a389156a /plugins | |
parent | a6e68de3aef8daa0978edabbf867e5a86bfc6dac (diff) |
UserID no longer overwrites VisitorId (#14360)
* UserID no longer overwrites VisitorId
* Update piwik-php-tracker package
* Update matomo-php-tracker again.
* Fixing test.
* Add changelog note.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/CoreHome/Tracker/VisitRequestProcessor.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/CoreHome/Tracker/VisitRequestProcessor.php b/plugins/CoreHome/Tracker/VisitRequestProcessor.php index 73e7e0ae0a..30c5d0fd3a 100644 --- a/plugins/CoreHome/Tracker/VisitRequestProcessor.php +++ b/plugins/CoreHome/Tracker/VisitRequestProcessor.php @@ -189,6 +189,11 @@ class VisitRequestProcessor extends RequestProcessor return true; } + if (!$this->lastUserIdWasSetAndDoesMatch($visitProperties, $request)) { + Common::printDebug("Visitor detected, but last user_id does not match..."); + return true; + } + return false; } @@ -263,4 +268,25 @@ class VisitRequestProcessor extends RequestProcessor return $visitProperties->getProperty('visit_last_action_time'); } + + /** + * Returns true if the last user_id did not change. + * @return bool + */ + protected function lastUserIdWasSetAndDoesMatch(VisitProperties $visitProperties, Request $request) + { + $lastUserId = $visitProperties->getProperty('user_id'); + + if(empty($lastUserId)) { + return true; + } + + $currentUserId = $request->getForcedUserId(); + + if(empty($currentUserId)) { + return true; + } + + return $lastUserId === $currentUserId; + } } |