mirror of
https://github.com/DanielSiepmann/tracking.git
synced 2024-12-24 16:36:10 +01:00
Add user agent to tracking
To enable fine grained filtering, and detect further bots / crawler to block.
This commit is contained in:
parent
cece44c735
commit
27819c73ef
6 changed files with 29 additions and 4 deletions
|
@ -50,18 +50,25 @@ class Pageview
|
|||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $userAgent;
|
||||
|
||||
public function __construct(
|
||||
int $pageUid,
|
||||
SiteLanguage $language,
|
||||
\DateTimeImmutable $crdate,
|
||||
int $pageType,
|
||||
string $url
|
||||
string $url,
|
||||
string $userAgent
|
||||
) {
|
||||
$this->pageUid = $pageUid;
|
||||
$this->language = $language;
|
||||
$this->crdate = $crdate;
|
||||
$this->pageType = $pageType;
|
||||
$this->url = $url;
|
||||
$this->userAgent = $userAgent;
|
||||
}
|
||||
|
||||
public function getPageUid(): int
|
||||
|
@ -88,4 +95,9 @@ class Pageview
|
|||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function getUserAgent(): string
|
||||
{
|
||||
return $this->userAgent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ class Factory implements FromRequest
|
|||
$request->getAttribute('language'),
|
||||
new \DateTimeImmutable(),
|
||||
static::getRouting($request)->getPageType(),
|
||||
(string) $request->getUri()
|
||||
(string) $request->getUri(),
|
||||
$request->getHeader('User-Agent')[0] ?? ''
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ class Pageview
|
|||
'type' => $pageview->getPageType(),
|
||||
'sys_language_uid' => $pageview->getLanguage()->getLanguageId(),
|
||||
'url' => $pageview->getUrl(),
|
||||
'user_agent' => $pageview->getUserAgent(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ return [
|
|||
],
|
||||
'interface' => [
|
||||
'always_description' => 0,
|
||||
'showRecordFieldList' => 'url, type, sys_language_uid, crdate, tstamp, crdate, cruser_id'
|
||||
'showRecordFieldList' => 'url, user_agent, type, sys_language_uid, crdate, tstamp, crdate, cruser_id'
|
||||
],
|
||||
'types' => [
|
||||
'0' => [
|
||||
'showitem' => 'sys_language_uid, pid, url, type, crdate',
|
||||
'showitem' => 'sys_language_uid, pid, url, user_agent, type, crdate',
|
||||
],
|
||||
],
|
||||
'columns' => [
|
||||
|
@ -50,6 +50,13 @@ return [
|
|||
'readOnly' => true,
|
||||
]
|
||||
],
|
||||
'user_agent' => [
|
||||
'label' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.pageview.user_agent',
|
||||
'config' => [
|
||||
'type' => 'input',
|
||||
'readOnly' => true,
|
||||
],
|
||||
],
|
||||
'type' => [
|
||||
'label' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.pageview.type',
|
||||
'config' => [
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
<trans-unit id="table.pageview.type">
|
||||
<source>Pagetype</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="table.pageview.user_agent">
|
||||
<source>User agent</source>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
CREATE TABLE tx_tracking_pageview (
|
||||
url text,
|
||||
user_agent text,
|
||||
type int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue