Skip to content

Commit

Permalink
Merge pull request #44 from MichaelHeerklotz/unlink_userid_and_visitorid
Browse files Browse the repository at this point in the history
Unlink userId and visitorId logic
  • Loading branch information
diosmosis committed Nov 6, 2019
2 parents 2d23bea + ee74196 commit 3a002c5
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions PiwikTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ public function clearCustomTrackingParameters()
public function setNewVisitorId()
{
$this->randomVisitorId = substr(md5(uniqid(rand(), true)), 0, self::LENGTH_VISITOR_ID);
$this->userId = false;
$this->forcedVisitorId = false;
$this->cookieVisitorId = false;
return $this;
Expand Down Expand Up @@ -1171,10 +1170,6 @@ public function setIp($ip)
*/
public function setUserId($userId)
{
if ($userId === false) {
$this->setNewVisitorId();
return $this;
}
if ($userId === '') {
throw new Exception("User ID cannot be empty.");
}
Expand All @@ -1197,15 +1192,12 @@ public static function getUserIdHashed($id)

/**
* Forces the requests to be recorded for the specified Visitor ID.
* Note: it is recommended to use ->setUserId($userId); instead.
*
* Rather than letting Piwik attribute the user with a heuristic based on IP and other user fingeprinting attributes,
* force the action to be recorded for a particular visitor.
*
* If you use both setVisitorId and setUserId, setUserId will take precedence.
* If not set, the visitor ID will be fetched from the 1st party cookie, or will be set to a random UUID.
*
* @deprecated We recommend to use ->setUserId($userId).
* @param string $visitorId 16 hexadecimal characters visitor ID, eg. "33c31e01394bdc63"
* @return $this
* @throws Exception
Expand Down Expand Up @@ -1242,9 +1234,6 @@ public function setVisitorId($visitorId)
*/
public function getVisitorId()
{
if (!empty($this->userId)) {
return $this->getUserIdHashed($this->userId);
}
if (!empty($this->forcedVisitorId)) {
return $this->forcedVisitorId;
}
Expand Down

0 comments on commit 3a002c5

Please sign in to comment.