Ignore "Uptime-Kuma" checker by default (#106)

Resolves: #105
This commit is contained in:
Daniel Siepmann 2023-04-26 17:14:56 +02:00 committed by GitHub
parent cd9cb3f2a8
commit 20070cf531
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 2 deletions

View file

@ -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 "/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 "/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 "/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: DanielSiepmann\Tracking\Middleware\Recordview:
public: true public: true

View file

@ -0,0 +1,29 @@
2.5.0
=====
Breaking
--------
Nothing
Features
--------
* Ignore Uptime-Kuma bot by default.
Thanks to `Kay Strobach <https://github.com/kaystrobach>`_.
Add tests to cover default ignores.
Fixes
-----
Nothing
Tasks
-----
Nothing
Deprecation
-----------
Nothing

View file

@ -91,4 +91,29 @@ class PageviewTest extends TestCase
$records = $this->getAllRecords('tx_tracking_pageview'); $records = $this->getAllRecords('tx_tracking_pageview');
self::assertCount(0, $records); 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',
],
];
}
} }

View file

@ -8,7 +8,7 @@ $EM_CONF[$_EXTKEY] = [
'author' => 'Daniel Siepmann', 'author' => 'Daniel Siepmann',
'author_email' => 'coding@daniel-siepmann.de', 'author_email' => 'coding@daniel-siepmann.de',
'author_company' => '', 'author_company' => '',
'version' => '2.4.0', 'version' => '2.5.0',
'constraints' => [ 'constraints' => [
'depends' => [ 'depends' => [
'core' => '', 'core' => '',