Added detection of visits from potential bots

This commit is contained in:
Alejandro Celaya
2021-05-22 15:09:14 +02:00
parent 663ae9f6bb
commit 9fa32b5b6b
16 changed files with 123 additions and 19 deletions

View File

@@ -12,17 +12,18 @@ class OrphanVisitsTest extends ApiTestCase
private const INVALID_SHORT_URL = [
'referer' => 'https://doma.in/foo',
'date' => '2020-03-01T00:00:00+00:00',
'userAgent' => 'shlink-tests-agent',
'userAgent' => 'cf-facebook',
'visitLocation' => null,
'potentialBot' => true,
'visitedUrl' => 'foo.com',
'type' => 'invalid_short_url',
];
private const REGULAR_NOT_FOUND = [
'referer' => 'https://doma.in/foo/bar',
'date' => '2020-02-01T00:00:00+00:00',
'userAgent' => 'shlink-tests-agent',
'visitLocation' => null,
'potentialBot' => false,
'visitedUrl' => '',
'type' => 'regular_404',
];
@@ -31,6 +32,7 @@ class OrphanVisitsTest extends ApiTestCase
'date' => '2020-01-01T00:00:00+00:00',
'userAgent' => 'shlink-tests-agent',
'visitLocation' => null,
'potentialBot' => false,
'visitedUrl' => '',
'type' => 'base_url',
];

View File

@@ -58,7 +58,7 @@ class VisitsFixture extends AbstractFixture implements DependentFixtureInterface
'2020-02-01',
));
$manager->persist($this->setVisitDate(
Visit::forInvalidShortUrl(new Visitor('shlink-tests-agent', 'https://doma.in/foo', '1.2.3.4', 'foo.com')),
Visit::forInvalidShortUrl(new Visitor('cf-facebook', 'https://doma.in/foo', '1.2.3.4', 'foo.com')),
'2020-03-01',
));