This repository was archived by the owner on Oct 31, 2018. It is now read-only.
forked from matomo-org/plugin-CustomDimensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisitor.php
More file actions
44 lines (37 loc) · 1.26 KB
/
Visitor.php
File metadata and controls
44 lines (37 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\CustomDimensions;
use Piwik\Plugins\CustomDimensions\Dao\LogTable;
use Piwik\Plugins\CustomDimensions\Tracker\CustomDimensionsRequestProcessor;
class Visitor
{
private $details = array();
public function __construct($details)
{
$this->details = $details;
}
public function getCustomDimensionValues($configuredVisitDimensions)
{
$values = array();
foreach ($configuredVisitDimensions as $dimension) {
if ($dimension['active'] && $dimension['scope'] === CustomDimensions::SCOPE_VISIT) {
// field in DB, eg custom_dimension_1
$field = LogTable::buildCustomDimensionColumnName($dimension);
// field for user, eg dimension1
$column = CustomDimensionsRequestProcessor::buildCustomDimensionTrackingApiName($dimension);
if (array_key_exists($field, $this->details)) {
$values[$column] = $this->details[$field];
} else {
$values[$column] = null;
}
}
}
return $values;
}
}