Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2020-07-27 04:27:34 +0300
committerGitHub <noreply@github.com>2020-07-27 04:27:34 +0300
commit8f035baf642b2c15c5506b198b7f5cbcbb0a3faf (patch)
treea3145f06b070b3908cb1c6b7cd1ce541f2672e25 /plugins/CoreHome
parent539faeac7f49fac5d63e78edeaef25ab40f4020f (diff)
Add new dimension profilable (#16217)
Diffstat (limited to 'plugins/CoreHome')
-rw-r--r--plugins/CoreHome/Columns/Profilable.php55
-rw-r--r--plugins/CoreHome/lang/en.json5
2 files changed, 58 insertions, 2 deletions
diff --git a/plugins/CoreHome/Columns/Profilable.php b/plugins/CoreHome/Columns/Profilable.php
new file mode 100644
index 0000000000..c1a5d2ce4b
--- /dev/null
+++ b/plugins/CoreHome/Columns/Profilable.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\CoreHome\Columns;
+
+use Piwik\Plugin\Dimension\VisitDimension;
+use Piwik\Tracker\Request;
+use Piwik\Tracker\Visitor;
+
+class Profilable extends VisitDimension
+{
+ const COLUMN_TYPE = 'TINYINT(1) NULL';
+ protected $columnName = 'profilable';
+ protected $columnType = self::COLUMN_TYPE;
+ protected $nameSingular = 'CoreHome_Profilable';
+ protected $segmentName = 'profilable';
+ protected $type = self::TYPE_BOOL;
+
+ protected $acceptValues = '1 for profilable (eg cookies were used), 0 for not profilable (eg no cookies were used)';
+
+ public function __construct()
+ {
+ $this->suggestedValuesCallback = function ($idSite, $maxValuesToReturn) {
+ return ['0', '1'];
+ };
+ }
+
+ public function onNewVisit(Request $request, Visitor $visitor, $action)
+ {
+ $value = $request->getVisitorId();
+
+ if (empty($value)) {
+ return 0;
+ }
+
+ return 1;
+ }
+
+ public function onExistingVisit(Request $request, Visitor $visitor, $action)
+ {
+ if ($visitor->getVisitorColumn($this->columnName)) {
+ // once it is 1, we don't set it back to 0 if user disables cookies later cause user would be still idenfied
+ // for this same visit with the fingerprint
+ return 1;
+ }
+
+ return $this->onNewVisit($request, $visitor, $action);
+ }
+
+} \ No newline at end of file
diff --git a/plugins/CoreHome/lang/en.json b/plugins/CoreHome/lang/en.json
index 95d8b1230a..06cb3f9c76 100644
--- a/plugins/CoreHome/lang/en.json
+++ b/plugins/CoreHome/lang/en.json
@@ -109,6 +109,7 @@
"ReportWithMetadata": "Report with metadata",
"ReadMoreOnlineGuide": "Read more about this topic in the online guide.",
"SeeAvailableVersions": "See Available Versions",
- "QuickLinks": "Quick Links"
+ "QuickLinks": "Quick Links",
+ "Profilable": "Profilable"
}
-}
+} \ No newline at end of file