Skip to content

Commit

Permalink
Match configId even when userId is found (#15337)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteur authored Jan 2, 2020
1 parent 279cf80 commit bdb960e
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 45 deletions.
13 changes: 10 additions & 3 deletions core/Tracker/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public function updateAction($idLinkVa, $valuesToUpdate)
return $wasInserted;
}

public function findVisitor($idSite, $configId, $idVisitor, $fieldsToRead, $shouldMatchOneFieldOnly, $isVisitorIdToLookup, $timeLookBack, $timeLookAhead)
public function findVisitor($idSite, $configId, $idVisitor, $userId, $fieldsToRead, $shouldMatchOneFieldOnly, $isVisitorIdToLookup, $timeLookBack, $timeLookAhead)
{
$selectCustomVariables = '';

Expand Down Expand Up @@ -398,10 +398,17 @@ public function findVisitor($idSite, $configId, $idVisitor, $fieldsToRead, $shou
} elseif ($shouldMatchOneFieldOnly) {
$visitRow = $this->findVisitorByConfigId($configId, $select, $from, $configIdWhere, $configIdbindSql);
} else {
$visitRow = $this->findVisitorByVisitorId($idVisitor, $select, $from, $visitorIdWhere, $visitorIdbindSql);
if (!empty($idVisitor)) {
$visitRow = $this->findVisitorByVisitorId($idVisitor, $select, $from, $visitorIdWhere, $visitorIdbindSql);
} else {
$visitRow = false;
}

if (empty($visitRow)) {
$configIdWhere .= ' AND user_id IS NULL ';
if (!empty($userId)) {
$configIdWhere .= 'AND ( user_id IS NULL OR user_id = ? )';
$configIdbindSql[] = $userId;
}
$visitRow = $this->findVisitorByConfigId($configId, $select, $from, $configIdWhere, $configIdbindSql);
}
}
Expand Down
3 changes: 2 additions & 1 deletion core/Tracker/VisitorRecognizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function findKnownVisitor($configId, VisitProperties $visitProperties, Re
{
$idSite = $request->getIdSite();
$idVisitor = $request->getVisitorId();
$userId = $request->getForcedUserId();

$isVisitorIdToLookup = !empty($idVisitor);

Expand All @@ -98,7 +99,7 @@ public function findKnownVisitor($configId, VisitProperties $visitProperties, Re
$shouldMatchOneFieldOnly = $this->shouldLookupOneVisitorFieldOnly($isVisitorIdToLookup, $request);
list($timeLookBack, $timeLookAhead) = $this->getWindowLookupThisVisit($request);

$visitRow = $this->model->findVisitor($idSite, $configId, $idVisitor, $persistedVisitAttributes, $shouldMatchOneFieldOnly, $isVisitorIdToLookup, $timeLookBack, $timeLookAhead);
$visitRow = $this->model->findVisitor($idSite, $configId, $idVisitor, $userId, $persistedVisitAttributes, $shouldMatchOneFieldOnly, $isVisitorIdToLookup, $timeLookBack, $timeLookAhead);
$this->visitRow = $visitRow;

if ($visitRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
<serverTimePretty>Mar 6, 2010 13:22:33</serverTimePretty>
<pageId>5</pageId>
<bandwidth />
<timeSpent>360</timeSpent>
<timeSpentPretty>6 min 0s</timeSpentPretty>
<interactionPosition>2</interactionPosition>
<title>incredible title!</title>
<subtitle>http://example.org/index.htm</subtitle>
Expand All @@ -111,15 +113,6 @@
<timestamp>1267881753</timestamp>
<bandwidth_pretty>0 M</bandwidth_pretty>
</row>
</actionDetails>
<lastActionDateTime>2010-03-06 13:22:33</lastActionDateTime>
<userId>[email protected]</userId>
<actions>2</actions>
</row>
<row>
<idVisit>4</idVisit>
<visitorId>6ccebef4faef4969</visitorId>
<actionDetails>
<row>
<type>action</type>
<url>http://example.org/index.htm</url>
Expand All @@ -129,7 +122,7 @@
<serverTimePretty>Mar 6, 2010 13:28:33</serverTimePretty>
<pageId>6</pageId>
<bandwidth />
<interactionPosition>1</interactionPosition>
<interactionPosition>3</interactionPosition>
<title>second page</title>
<subtitle>http://example.org/index.htm</subtitle>
<icon />
Expand All @@ -140,10 +133,10 @@
</actionDetails>
<lastActionDateTime>2010-03-06 13:28:33</lastActionDateTime>
<userId>[email protected]</userId>
<actions>1</actions>
<actions>3</actions>
</row>
<row>
<idVisit>5</idVisit>
<idVisit>4</idVisit>
<visitorId>2f16b4d842cc294d</visitorId>
<actionDetails>
<row>
Expand All @@ -169,7 +162,7 @@
<actions>1</actions>
</row>
<row>
<idVisit>6</idVisit>
<idVisit>5</idVisit>
<visitorId>7dcebef4faef4969</visitorId>
<actionDetails>
<row>
Expand Down Expand Up @@ -274,7 +267,7 @@
<actions>3</actions>
</row>
<row>
<idVisit>7</idVisit>
<idVisit>6</idVisit>
<visitorId>7dcebef4faef4325</visitorId>
<actionDetails>
<row>
Expand All @@ -300,7 +293,7 @@
<actions>1</actions>
</row>
<row>
<idVisit>8</idVisit>
<idVisit>7</idVisit>
<visitorId>6ccebef4faef4969</visitorId>
<actionDetails>
<row>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<result>
<nb_uniq_visitors>6</nb_uniq_visitors>
<nb_uniq_visitors>5</nb_uniq_visitors>
<nb_users>2</nb_users>
<nb_visits>6</nb_visits>
<nb_visits>5</nb_visits>
<nb_actions>10</nb_actions>
<nb_visits_converted>1</nb_visits_converted>
<bounce_count>3</bounce_count>
<sum_visit_length>1623</sum_visit_length>
<bounce_count>2</bounce_count>
<sum_visit_length>1983</sum_visit_length>
<max_actions>3</max_actions>
<bounce_rate>50%</bounce_rate>
<nb_actions_per_visit>1.7</nb_actions_per_visit>
<avg_time_on_site>271</avg_time_on_site>
<bounce_rate>40%</bounce_rate>
<nb_actions_per_visit>2</nb_actions_per_visit>
<avg_time_on_site>397</avg_time_on_site>
</result>
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<result>
<nb_uniq_visitors>7</nb_uniq_visitors>
<nb_users>3</nb_users>
<nb_visits>8</nb_visits>
<nb_visits>7</nb_visits>
<nb_actions>12</nb_actions>
<nb_visits_converted>1</nb_visits_converted>
<bounce_count>5</bounce_count>
<sum_visit_length>1623</sum_visit_length>
<bounce_count>4</bounce_count>
<sum_visit_length>1983</sum_visit_length>
<max_actions>3</max_actions>
<bounce_rate>63%</bounce_rate>
<nb_actions_per_visit>1.5</nb_actions_per_visit>
<avg_time_on_site>203</avg_time_on_site>
<bounce_rate>57%</bounce_rate>
<nb_actions_per_visit>1.7</nb_actions_per_visit>
<avg_time_on_site>283</avg_time_on_site>
</result>
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<result>
<nb_uniq_visitors>6</nb_uniq_visitors>
<nb_uniq_visitors>5</nb_uniq_visitors>
<nb_users>2</nb_users>
<nb_visits>6</nb_visits>
<nb_visits>5</nb_visits>
<nb_actions>10</nb_actions>
<nb_visits_converted>1</nb_visits_converted>
<bounce_count>3</bounce_count>
<sum_visit_length>1623</sum_visit_length>
<bounce_count>2</bounce_count>
<sum_visit_length>1983</sum_visit_length>
<max_actions>3</max_actions>
<bounce_rate>50%</bounce_rate>
<nb_actions_per_visit>1.7</nb_actions_per_visit>
<avg_time_on_site>271</avg_time_on_site>
<bounce_rate>40%</bounce_rate>
<nb_actions_per_visit>2</nb_actions_per_visit>
<avg_time_on_site>397</avg_time_on_site>
</result>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<result>
<nb_visits>8</nb_visits>
<nb_visits>7</nb_visits>
<nb_actions>12</nb_actions>
<nb_visits_converted>1</nb_visits_converted>
<bounce_count>5</bounce_count>
<sum_visit_length>1623</sum_visit_length>
<bounce_count>4</bounce_count>
<sum_visit_length>1983</sum_visit_length>
<max_actions>3</max_actions>
<bounce_rate>63%</bounce_rate>
<nb_actions_per_visit>1.5</nb_actions_per_visit>
<avg_time_on_site>203</avg_time_on_site>
<bounce_rate>57%</bounce_rate>
<nb_actions_per_visit>1.7</nb_actions_per_visit>
<avg_time_on_site>283</avg_time_on_site>
</result>

0 comments on commit bdb960e

Please sign in to comment.