Skip to content

Commit

Permalink
Applying review changes: remove tracker_ prefix from config names, mo…
Browse files Browse the repository at this point in the history
…ve shouldForceNewVisit to VisitDimension and simplify triggerPredicateHookOnDimensions.
  • Loading branch information
diosmosis committed Dec 12, 2014
1 parent a6cb3c8 commit 09a15c2
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 42 deletions.
12 changes: 6 additions & 6 deletions config/global.ini.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,15 +586,15 @@
; Includes by default the GA style campaign keyword parameter utm_term
campaign_keyword_var_name = "pk_kwd,pk_keyword,piwik_kwd,utm_term"

; if set to 1, actions that contain different campaign information from the last action in the current visit will
; if set to 1, actions that contain different campaign information from the visitor's in progress visit will
; be treated as the start of a new visit. This will include situations when campaign information was absent before,
; but is present now (or vice versa).
tracker_create_new_visit_when_campaign_changes = 1
; but is present now.
create_new_visit_when_campaign_changes = 1

; if set to 1, actions that contain different website referrer information from the last action in the current visit
; if set to 1, actions that contain different website referrer information from the visitor's in progress visit
; will be treatedas the start of a new visit. This will include situations when website referrer information was
; absent before, but is present now (or vice versa).
tracker_create_new_visit_when_website_referrer_changes = 0
; absent before, but is present now.
create_new_visit_when_website_referrer_changes = 0

; maximum length of a Page Title or a Page URL recorded in the log_action.name table
page_maximum_length = 1024;
Expand Down
22 changes: 0 additions & 22 deletions core/Columns/Dimension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
use Piwik\Plugin\Dimension\ConversionDimension;
use Piwik\Plugin\Dimension\VisitDimension;
use Piwik\Plugin\Segment;
use Piwik\Tracker\Action;
use Piwik\Tracker\Request;
use Piwik\Tracker\Visitor;
use Piwik\Translate;

/**
Expand Down Expand Up @@ -169,25 +166,6 @@ public function getId()
return $pluginName . '.' . $dimensionName;
}

/**
* This hook is executed by the tracker when determining if an action is the start of a new visit
* or part of an existing one. Derived classes can use it to force new visits based on dimension
* data.
*
* For example, the Campaign dimension in the Referrers plugin will force a new visit if the
* campaign information for the current action is different from the last.
*
* @param Request $request The current tracker request information.
* @param Visitor $visitor The information for the currently recognized visitor.
* @param Action|null $action The current action information (if any).
* @return bool Return true to force a visit, false if otherwise.
* @api
*/
public function shouldForceNewVisit(Request $request, Visitor $visitor, Action $action = null)
{
return false;
}

/**
* Gets an instance of all available visit, action and conversion dimension.
* @return Dimension[]
Expand Down
19 changes: 19 additions & 0 deletions core/Plugin/Dimension/VisitDimension.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,25 @@ public function onAnyGoalConversion(Request $request, Visitor $visitor, $action)
return false;
}

/**
* This hook is executed by the tracker when determining if an action is the start of a new visit
* or part of an existing one. Derived classes can use it to force new visits based on dimension
* data.
*
* For example, the Campaign dimension in the Referrers plugin will force a new visit if the
* campaign information for the current action is different from the last.
*
* @param Request $request The current tracker request information.
* @param Visitor $visitor The information for the currently recognized visitor.
* @param Action|null $action The current action information (if any).
* @return bool Return true to force a visit, false if otherwise.
* @api
*/
public function shouldForceNewVisit(Request $request, Visitor $visitor, Action $action = null)
{
return false;
}

/**
* Get all visit dimensions that are defined by all activated plugins.
* @return VisitDimension[]
Expand Down
15 changes: 4 additions & 11 deletions core/Tracker/Visit.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,21 +542,14 @@ private function triggerHookOnDimensions($dimensions, $hook, $visitor, $action,
return $valuesToUpdate;
}

private function triggerPredicateHookOnDimensions($dimensions, $hook, Visitor $visitor, Action $action = null, $returnFirstTrue = true)
private function triggerPredicateHookOnDimensions($dimensions, $hook, Visitor $visitor, Action $action = null)
{
$result = $returnFirstTrue ? false : array();
foreach ($dimensions as $dimension) {
$value = $dimension->$hook($this->request, $visitor, $action);

if ($returnFirstTrue) {
if ($value) {
return true;
}
} else {
$result[] = $value;
if ($dimension->$hook($this->request, $visitor, $action)) {
return true;
}
}
return $result;
return false;
}

protected function getAllVisitDimensions()
Expand Down
2 changes: 1 addition & 1 deletion plugins/Referrers/Columns/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Campaign extends Base

public function __construct()
{
$this->createNewVisitWhenCampaignChanges = TrackerConfig::getConfigValue('tracker_create_new_visit_when_campaign_changes') == 1;
$this->createNewVisitWhenCampaignChanges = TrackerConfig::getConfigValue('create_new_visit_when_campaign_changes') == 1;
}

public function getName()
Expand Down
2 changes: 1 addition & 1 deletion plugins/Referrers/Columns/Website.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Website extends Base

public function __construct()
{
$this->createNewVisitWhenWebsiteReferrerChanges = TrackerConfig::getConfigValue('tracker_create_new_visit_when_website_referrer_changes') == 1;
$this->createNewVisitWhenWebsiteReferrerChanges = TrackerConfig::getConfigValue('create_new_visit_when_website_referrer_changes') == 1;
}

public function getName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function tearDown()
private function setPiwikEnviornmentOverrides()
{
$configOverride = $this->getTestEnvironment()->configOverride;
$configOverride['Tracker']['tracker_create_new_visit_when_website_referrer_changes'] = 1;
$configOverride['Tracker']['create_new_visit_when_website_referrer_changes'] = 1;
$this->getTestEnvironment()->configOverride = $configOverride;
$this->getTestEnvironment()->save();
}
Expand Down

0 comments on commit 09a15c2

Please sign in to comment.