Skip to content

Commit

Permalink
CHG: added userId parameter to methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tuegeb committed Jul 6, 2016
1 parent 33e8c68 commit 51acc9b
Showing 1 changed file with 35 additions and 28 deletions.
63 changes: 35 additions & 28 deletions FACTFinder/Adapter/Tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,24 @@ public function __construct(
* not available, it will try to use session_id() to fetch one.
*
* @param string $sid session id
* @param string $userId id of user
* @return bool Success?
*/
public function doTrackingFromRequest($sid = null)
public function doTrackingFromRequest($sid = null, $userId = null)
{
$this->setupTrackingFromRequest($sid);
$this->setupTrackingFromRequest($sid, $userId);
return $this->applyTracking();
}

/**
* Use this method directly if you want to separate the setup from sending
* the request. This is particularly useful when using the
* MultiCurlRequestFactory.
*
* @param string $sid session id
* @param string $userId id of user
*/
public function setupTrackingFromRequest($sid = null)
public function setupTrackingFromRequest($sid = null, $userId = null)
{
if (strlen($sid) > 0)
$this->parameters['sid'] = $sid;
Expand All @@ -63,6 +67,9 @@ public function setupTrackingFromRequest($sid = null)
) {
$this->parameters['sid'] = session_id();
}

if (strlen($userId) > 0)
$this->parameters['userId'] = $userId;
}

/**
Expand All @@ -80,7 +87,7 @@ public function setupTrackingFromRequest($sid = null)
* @param string $title title of product (optional - is empty by default)
* @param int $pageSize size of the page where the product was found (optional - is 12 by default)
* @param int $origPageSize original size of the page before the user could have changed it (optional - is set equals to $page by default)
* @param string $userid id of user (optional if modul personalisation is not used)
* @param string $userId id of user (optional if modul personalisation is not used)
* @return boolean $success
*/
public function trackClick(
Expand All @@ -96,10 +103,10 @@ public function trackClick(
$title = '',
$pageSize = 12,
$origPageSize = -1,
$userid = null
$userId = null
) {
$this->setupClickTracking($id, $query, $pos, $masterId, $sid, $cookieId, $origPos, $page,
$simi, $title, $pageSize, $origPageSize, $userid);
$simi, $title, $pageSize, $origPageSize, $userId);
return $this->applyTracking();
}

Expand All @@ -121,7 +128,7 @@ public function setupClickTracking(
$title = '',
$pageSize = 12,
$origPageSize = -1,
$userid = null
$userId = null
) {
if (strlen($sid) == 0) $sid = session_id();
if ($origPos == -1) $origPos = $pos;
Expand All @@ -140,7 +147,7 @@ public function setupClickTracking(
'origPageSize' => $origPageSize,
);

if (strlen($userid) > 0) $params['userId'] = $userid;
if (strlen($userId) > 0) $params['userId'] = $userId;
if (strlen($cookieId) > 0) $params['cookieId'] = $cookieId;
if (strlen($masterId) > 0) $params['masterId'] = $masterId;

Expand All @@ -159,7 +166,7 @@ public function setupClickTracking(
* @param string $cookieId cookie id (optional)
* @param int $count number of items purchased for each product (optional - default 1)
* @param float $price this is the single unit price (optional)
* @param string $userid id of user (optional if modul personalisation is not used)
* @param string $userId id of user (optional if modul personalisation is not used)
* @return boolean $success
*/
public function trackCart(
Expand All @@ -171,9 +178,9 @@ public function trackCart(
$cookieId = null,
$count = 1,
$price = null,
$userid = null
$userId = null
) {
$this->setupCartTracking($id, $masterId, $title, $query, $sid, $cookieId, $count, $price, $userid);
$this->setupCartTracking($id, $masterId, $title, $query, $sid, $cookieId, $count, $price, $userId);
return $this->applyTracking();
}

Expand All @@ -191,7 +198,7 @@ public function setupCartTracking(
$cookieId = null,
$count = 1,
$price = null,
$userid = null
$userId = null
) {
if (strlen($sid) == 0) $sid = session_id();
$params = array(
Expand All @@ -203,7 +210,7 @@ public function setupCartTracking(
);

if (strlen($price) > 0) $params['price'] = $price;
if (strlen($userid) > 0) $params['userId'] = $userid;
if (strlen($userId) > 0) $params['userId'] = $userId;
if (strlen($cookieId) > 0) $params['cookieId'] = $cookieId;
if (strlen($masterId) > 0) $params['masterId'] = $masterId;
if (strlen($query) > 0) $params['query'] = $query;
Expand All @@ -223,7 +230,7 @@ public function setupCartTracking(
* @param string $cookieId cookie id (optional)
* @param int $count number of items purchased for each product (optional - default 1)
* @param float $price this is the single unit price (optional)
* @param string $userid id of user (optional if modul personalisation is not used)
* @param string $userId id of user (optional if modul personalisation is not used)
* @return boolean $success
*/
public function trackCheckout(
Expand All @@ -235,9 +242,9 @@ public function trackCheckout(
$cookieId = null,
$count = 1,
$price = null,
$userid = null
$userId = null
) {
$this->setupCheckoutTracking($id, $masterId, $title, $query, $sid, $cookieId, $count, $price, $userid);
$this->setupCheckoutTracking($id, $masterId, $title, $query, $sid, $cookieId, $count, $price, $userId);
return $this->applyTracking();
}

Expand All @@ -255,7 +262,7 @@ public function setupCheckoutTracking(
$cookieId = null,
$count = 1,
$price = null,
$userid = null
$userId = null
) {
if (strlen($sid) == 0) $sid = session_id();
$params = array(
Expand All @@ -268,7 +275,7 @@ public function setupCheckoutTracking(
);

if (strlen($price) > 0) $params['price'] = $price;
if (strlen($userid) > 0) $params['userId'] = $userid;
if (strlen($userId) > 0) $params['userId'] = $userId;
if (strlen($cookieId) > 0) $params['cookieId'] = $cookieId;
if (strlen($query) > 0) $params['query'] = $query;
if (strlen($masterId) > 0) $params['masterId'] = $masterId;
Expand All @@ -285,7 +292,7 @@ public function setupCheckoutTracking(
* @param string $masterId master id of the product (see field with the role "Master article number")
* @param string $sid session id (if empty, then try to set using the function session_id() )
* @param string $cookieId cookie id (optional)
* @param string $userid id of user (optional if modul personalisation is not used)
* @param string $userId id of user (optional if modul personalisation is not used)
* @return boolean $success
*/
public function trackRecommendationClick(
Expand All @@ -294,9 +301,9 @@ public function trackRecommendationClick(
$masterId = null,
$sid = null,
$cookieId = null,
$userid = null
$userId = null
) {
$this->setupRecommendationClickTracking($id, $mainId, $masterId, $sid, $cookieId, $userid);
$this->setupRecommendationClickTracking($id, $mainId, $masterId, $sid, $cookieId, $userId);
return $this->applyTracking();
}

Expand All @@ -311,7 +318,7 @@ public function setupRecommendationClickTracking(
$masterId = null,
$sid = null,
$cookieId = null,
$userid = null
$userId = null
) {
if (strlen($sid) == 0) $sid = session_id();
$params = array(
Expand All @@ -323,7 +330,7 @@ public function setupRecommendationClickTracking(
'event' => 'recommendationClick'
);

if (strlen($userid) > 0) $params['userId'] = $userid;
if (strlen($userId) > 0) $params['userId'] = $userId;
if (strlen($cookieId) > 0) $params['cookieId'] = $cookieId;
if (strlen($masterId) > 0) $params['masterId'] = $masterId;

Expand All @@ -336,15 +343,15 @@ public function setupRecommendationClickTracking(
*
* @param string $sid session id (if empty, then try to set using the function session_id() )
* @param string $cookieId cookie id (optional)
* @param string $userid id of user who logged in
* @param string $userId id of user who logged in
* @return boolean $success
*/
public function trackLogin(
$sid = null,
$cookieId = null,
$userid = null
$userId = null
) {
$this->setupLoginTracking($sid, $cookieId, $userid);
$this->setupLoginTracking($sid, $cookieId, $userId);
return $this->applyTracking();
}

Expand All @@ -356,12 +363,12 @@ public function trackLogin(
public function setupLoginTracking(
$sid = null,
$cookieId = null,
$userid = null
$userId = null
) {
if (strlen($sid) == 0) $sid = session_id();
$params = array(
'sid' => $sid,
'userId' => $userid,
'userId' => $userId,
'event' => 'login'
);

Expand Down

0 comments on commit 51acc9b

Please sign in to comment.