public function setUserId($userId)
    {
        if ($userId === false) {
            $this->setNewVisitorId();
            return $this;
        }
        if ($userId === '') {
            throw new Exception("User ID cannot be empty.");
        }
        $this->userId = $userId;
        return $this;
    }