diff options
Diffstat (limited to 'core/Tracker')
-rw-r--r-- | core/Tracker/Request.php | 10 | ||||
-rw-r--r-- | core/Tracker/Settings.php | 11 | ||||
-rw-r--r-- | core/Tracker/Visit.php | 18 |
3 files changed, 35 insertions, 4 deletions
diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php index 57458fa000..98133e4319 100644 --- a/core/Tracker/Request.php +++ b/core/Tracker/Request.php @@ -208,7 +208,7 @@ class Request return true; } } - + Piwik::postEvent('Request.initAuthenticationObject'); /** @var \Piwik\Auth $auth */ @@ -541,7 +541,7 @@ class Request return Common::getRequestVar('ua', $default, 'string', $this->params); } - protected function shouldUseThirdPartyCookie() + public function shouldUseThirdPartyCookie() { return (bool)Config::getInstance()->Tracker['use_third_party_id_cookie']; } @@ -567,6 +567,10 @@ class Request return; } + if (\Piwik\Tracker\IgnoreCookie::isIgnoreCookieFound()) { + return; + } + $cookie = $this->makeThirdPartyCookieUID(); $idVisitor = bin2hex($idVisitor); $cookie->set(0, $idVisitor); @@ -631,7 +635,7 @@ class Request $found = false; if (TrackerConfig::getConfigValue('enable_userid_overwrites_visitorid')) { - // If User ID is set it takes precedence + // If User ID is set it takes precedence $userId = $this->getForcedUserId(); if ($userId) { $userIdHashed = $this->getUserIdHashed($userId); diff --git a/core/Tracker/Settings.php b/core/Tracker/Settings.php index 656d07dcca..74a66d0c65 100644 --- a/core/Tracker/Settings.php +++ b/core/Tracker/Settings.php @@ -57,6 +57,17 @@ class Settings // TODO: merge w/ visitor recognizer or make it it's own service. $os = empty($os['short_name']) ? 'UNK' : $os['short_name']; } + $client = $deviceDetector->getClient(); + if (!empty($client['name']) && $client['name'] === 'Internet Explorer') { + // we assume cookies are disabled... when in tracker cookies are disabled, this ensures when upgrading to this version + // that no fingerprint changes in the 30min window during the upgrade... + // We don't include it anymore as it otherwise may cause new visits to be created when switching between + // cookies disabled and enabled in IE11 or older. Before Matomo 3.13.7 when cookies were disabled, then + // this value was set to 0. For people with cookies enabled the fingerprint is not as relevant as the visitorId + // is used to identify a visitor + $plugin_Cookie = '0'; + } + $browserLang = substr($request->getBrowserLanguage(), 0, 20); // limit the length of this string to match db $trackerConfig = Config::getInstance()->Tracker; diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index 738f734f16..61c5893455 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -561,10 +561,26 @@ class Visit implements VisitInterface */ private function setIdVisitorForExistingVisit($valuesToUpdate) { - // Might update the idvisitor when it was forced or overwritten for this visit if (strlen($this->visitProperties->getProperty('idvisitor')) == Tracker::LENGTH_BINARY_ID) { $valuesToUpdate['idvisitor'] = $this->visitProperties->getProperty('idvisitor'); } + + $visitorId = $this->request->getVisitorId(); + if ($visitorId && strlen($visitorId) === Tracker::LENGTH_BINARY_ID) { + // Might update the idvisitor when it was forced or overwritten for this visit + $valuesToUpdate['idvisitor'] = $this->request->getVisitorId(); + } + + if (TrackerConfig::getConfigValue('enable_userid_overwrites_visitorid')) { + // User ID takes precedence and overwrites idvisitor value + $userId = $this->request->getForcedUserId(); + if ($userId) { + $userIdHash = $this->request->getUserIdHashed($userId); + $binIdVisitor = Common::hex2bin($userIdHash); + $this->visitProperties->setProperty('idvisitor', $binIdVisitor); + $valuesToUpdate['idvisitor'] = $binIdVisitor; + } + } if (TrackerConfig::getConfigValue('enable_userid_overwrites_visitorid')) { // User ID takes precedence and overwrites idvisitor value |