Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1651 from njam/tracking-public
Browse files Browse the repository at this point in the history
Make Tracking::getTrackings() public
  • Loading branch information
njam committed Feb 19, 2015
2 parents e609724 + bffca9d commit c8c2295
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
14 changes: 7 additions & 7 deletions library/CM/Service/Trackings.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,48 @@ public function __construct(array $trackingServiceNameList) {

public function getHtml(CM_Frontend_Environment $environment) {
$html = '';
foreach ($this->_getTrackingServiceList() as $trackingService) {
foreach ($this->getTrackingServiceList() as $trackingService) {
$html .= $trackingService->getHtml($environment);
}
return $html;
}

public function getJs() {
$js = '';
foreach ($this->_getTrackingServiceList() as $trackingService) {
foreach ($this->getTrackingServiceList() as $trackingService) {
$js .= $trackingService->getJs();
}
return $js;
}

public function trackAction(CM_Action_Abstract $action) {
foreach ($this->_getTrackingServiceList() as $trackingService) {
foreach ($this->getTrackingServiceList() as $trackingService) {
$trackingService->trackAction($action);
}
}

public function trackAffiliate($requestClientId, $affiliateName) {
foreach ($this->_getTrackingServiceList() as $trackingService) {
foreach ($this->getTrackingServiceList() as $trackingService) {
$trackingService->trackAffiliate($requestClientId, $affiliateName);
}
}

public function trackPageView(CM_Frontend_Environment $environment, $path) {
foreach ($this->_getTrackingServiceList() as $trackingService) {
foreach ($this->getTrackingServiceList() as $trackingService) {
$trackingService->trackPageView($environment, $path);
}
}

public function trackSplittest(CM_Splittest_Fixture $fixture, CM_Model_SplittestVariation $variation) {
foreach ($this->_getTrackingServiceList() as $trackingService) {
foreach ($this->getTrackingServiceList() as $trackingService) {
$trackingService->trackSplittest($fixture, $variation);
}
}

/**
* @return CM_Service_Tracking_ClientInterface[]
*/
protected function _getTrackingServiceList() {
public function getTrackingServiceList() {
return array_map(function ($trackingServiceName) {
return $this->getServiceManager()->get($trackingServiceName, 'CM_Service_Tracking_ClientInterface');
}, $this->_trackingServiceNameList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ public function trackEvent(array $parameterList) {
$this->trackHit($this->_parseParameterList($parameterList));
}

/**
* @return string
*/
public function getRandomClientId() {
return rand() . uniqid();
}

/**
* @param array $parameterList
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,12 @@ public function testTrackEventParamForWrongHitType() {
'exd' => 'My exception',
]);
}

public function testGetRandomClientId() {
$client = new CMService_GoogleAnalytics_MeasurementProtocol_Client('foo');

$this->assertInternalType('string', $client->getRandomClientId());
$this->assertGreaterThan(5, strlen($client->getRandomClientId()));
$this->assertNotEquals($client->getRandomClientId(), $client->getRandomClientId());
}
}

0 comments on commit c8c2295

Please sign in to comment.