From 62b81dc916c3b80634669ce1b2068286125aae34 Mon Sep 17 00:00:00 2001 From: Lukas Winkler Date: Sun, 24 May 2020 11:14:21 +0200 Subject: [PATCH] complete WIP --- BotTracking.php | 51 +++++++++++++++++++++++++ CHANGELOG.md | 3 ++ Columns/BotCategory.php | 71 ++++++++++++++++++++++++++++++++++ Columns/BotName.php | 71 ++++++++++++++++++++++++++++++++++ Columns/BotProducer.php | 84 +++++++++++++++++++++++++++++++++++++++++ README.md | 6 +++ config/config.php | 2 + config/tracker.php | 2 + docs/faq.md | 5 +++ docs/index.md | 1 + lang/en.json | 5 +++ plugin.json | 30 +++++++++++++++ screenshots/.gitkeep | 0 13 files changed, 331 insertions(+) create mode 100644 BotTracking.php create mode 100644 CHANGELOG.md create mode 100644 Columns/BotCategory.php create mode 100644 Columns/BotName.php create mode 100644 Columns/BotProducer.php create mode 100644 README.md create mode 100644 config/config.php create mode 100644 config/tracker.php create mode 100644 docs/faq.md create mode 100644 docs/index.md create mode 100644 lang/en.json create mode 100644 plugin.json create mode 100644 screenshots/.gitkeep diff --git a/BotTracking.php b/BotTracking.php new file mode 100644 index 0000000..858bd52 --- /dev/null +++ b/BotTracking.php @@ -0,0 +1,51 @@ + 'isExcludedVisit' + ); + } + + public function isTrackerPlugin() + { + return true; + } + + public function isExcludedVisit(bool &$excluded, Request $request) + { + $userAgent = $request->getUserAgent(); + $userAgent = Common::unsanitizeInputValue($userAgent); +// $deviceDetector = StaticContainer::get(DeviceDetectorFactory::class)->makeInstance($userAgent); + // create new DeviceDetector with full data + $deviceDetector = new DeviceDetector($userAgent); + $deviceDetector->setCache(new DeviceDetectorCache(86400)); + $deviceDetector->parse(); + $isBot = $deviceDetector->isBot(); + if ($isBot) { + $request->setMetadata("BotTracking", "isBot", $deviceDetector->isBot()); + $botMeta = $deviceDetector->getBot(); + $request->setMetadata("BotTracking", "botName", $botMeta["name"]); + $request->setMetadata("BotTracking", "botCategory", $botMeta["category"]); + $request->setMetadata("BotTracking", "botProducer", $botMeta["producer"]["name"]); + $excluded = false; + } + } +} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8546318 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## Changelog + +Here goes the changelog text. diff --git a/Columns/BotCategory.php b/Columns/BotCategory.php new file mode 100644 index 0000000..8a6c866 --- /dev/null +++ b/Columns/BotCategory.php @@ -0,0 +1,71 @@ +getMetadata("BotTracking", "botCategory"); + } +} diff --git a/Columns/BotName.php b/Columns/BotName.php new file mode 100644 index 0000000..f51f677 --- /dev/null +++ b/Columns/BotName.php @@ -0,0 +1,71 @@ +getMetadata("BotTracking", "botName"); + } +} diff --git a/Columns/BotProducer.php b/Columns/BotProducer.php new file mode 100644 index 0000000..21d815d --- /dev/null +++ b/Columns/BotProducer.php @@ -0,0 +1,84 @@ +getMetadata("BotTracking", "botProducer"); + } + + + /** + * Sometimes you may want to make sure another dimension is executed before your dimension so you can persist + * a value depending on the value of other dimensions. You can do this by defining an array of dimension names. + * If you access any value of any other column within your events, you should require them here. Otherwise those + * values may not be available. + * @return array + * public function getRequiredVisitFields() + * { + * return array('idsite', 'server_time'); + * } + */ +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..26a3294 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Matomo BotTracking Plugin + +## Description + +Add your plugin description here. + diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..d266508 --- /dev/null +++ b/config/config.php @@ -0,0 +1,2 @@ +=4.0.0-b1,<5.0.0-b1", + "piwik": ">=4.0.0-b2,<5.0.0-b1" + }, + "authors": [ + { + "name": "Matomo", + "email": "", + "homepage": "" + } + ], + "support": { + "email": "", + "issues": "", + "forum": "", + "irc": "", + "wiki": "", + "source": "", + "docs": "", + "rss": "" + }, + "homepage": "", + "license": "GPL v3+", + "keywords": [] +} \ No newline at end of file diff --git a/screenshots/.gitkeep b/screenshots/.gitkeep new file mode 100644 index 0000000..e69de29