From 20070cf531ae0219eb43b6bd5ec61327a8e20bd0 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Wed, 26 Apr 2023 17:14:56 +0200 Subject: [PATCH] Ignore "Uptime-Kuma" checker by default (#106) Resolves: #105 --- Configuration/Services.yaml | 2 +- Documentation/Changelog/2.5.0.rst | 29 +++++++++++++++++++++++++++++ Tests/Functional/PageviewTest.php | 25 +++++++++++++++++++++++++ ext_emconf.php | 2 +- 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 Documentation/Changelog/2.5.0.rst diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index df8bb13..f4d66a6 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -64,7 +64,7 @@ services: and not (request.getHeader("User-Agent")[0] matches "/Wget|curl|Go-http-client/") and not (request.getHeader("User-Agent")[0] matches "/Googlebot|Bingbot|bingbot|Slurp|DuckDuckBot|Baiduspider|YandexBot|Sogou|Exabot|NextCloud-News|Feedly|XING FeedReader|CCBot|SemrushBot|SEOkicks|Twitterbot|Seekport Crawler|SemanticScholarBot|ia_archiver|PaperLiBot|TrendsmapResolver|AhrefsBot|Nuzzel/") and not (request.getHeader("User-Agent")[0] matches "/mattermost|Slackbot|WhatsApp/") - and not (request.getHeader("User-Agent")[0] matches "/UptimeRobot|Pingdom/") + and not (request.getHeader("User-Agent")[0] matches "/UptimeRobot|Pingdom|Uptime-Kuma/") DanielSiepmann\Tracking\Middleware\Recordview: public: true diff --git a/Documentation/Changelog/2.5.0.rst b/Documentation/Changelog/2.5.0.rst new file mode 100644 index 0000000..ee45f8a --- /dev/null +++ b/Documentation/Changelog/2.5.0.rst @@ -0,0 +1,29 @@ +2.5.0 +===== + +Breaking +-------- + +Nothing + +Features +-------- + +* Ignore Uptime-Kuma bot by default. + Thanks to `Kay Strobach `_. + Add tests to cover default ignores. + +Fixes +----- + +Nothing + +Tasks +----- + +Nothing + +Deprecation +----------- + +Nothing diff --git a/Tests/Functional/PageviewTest.php b/Tests/Functional/PageviewTest.php index cfa3d45..aba43d0 100644 --- a/Tests/Functional/PageviewTest.php +++ b/Tests/Functional/PageviewTest.php @@ -91,4 +91,29 @@ class PageviewTest extends TestCase $records = $this->getAllRecords('tx_tracking_pageview'); self::assertCount(0, $records); } + + /** + * @test + * + * @dataProvider possibleDeniedUserAgents + */ + public function preventsTrackingOfUserAgents(string $userAgent): void + { + $request = new InternalRequest(); + $request = $request->withPageId(1); + $request = $request->withHeader('User-Agent', $userAgent); + $response = $this->executeFrontendRequest($request); + + self::assertSame(200, $response->getStatusCode()); + self::assertCount(0, $this->getAllRecords('tx_tracking_pageview')); + } + + public static function possibleDeniedUserAgents(): array + { + return [ + 'Uptime-Kuma' => [ + 'userAgent' => 'Uptime-Kuma/1.21.2', + ], + ]; + } } diff --git a/ext_emconf.php b/ext_emconf.php index c5f5080..63ed72b 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,7 +8,7 @@ $EM_CONF[$_EXTKEY] = [ 'author' => 'Daniel Siepmann', 'author_email' => 'coding@daniel-siepmann.de', 'author_company' => '', - 'version' => '2.4.0', + 'version' => '2.5.0', 'constraints' => [ 'depends' => [ 'core' => '',