commit 62b81dc916c3b80634669ce1b2068286125aae34 Author: Lukas Winkler Date: Sun May 24 11:14:21 2020 +0200 complete WIP 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