mirror of
https://github.com/DanielSiepmann/tracking.git
synced 2024-11-22 13:56:09 +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;
|
private $url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $userAgent;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
int $pageUid,
|
int $pageUid,
|
||||||
SiteLanguage $language,
|
SiteLanguage $language,
|
||||||
\DateTimeImmutable $crdate,
|
\DateTimeImmutable $crdate,
|
||||||
int $pageType,
|
int $pageType,
|
||||||
string $url
|
string $url,
|
||||||
|
string $userAgent
|
||||||
) {
|
) {
|
||||||
$this->pageUid = $pageUid;
|
$this->pageUid = $pageUid;
|
||||||
$this->language = $language;
|
$this->language = $language;
|
||||||
$this->crdate = $crdate;
|
$this->crdate = $crdate;
|
||||||
$this->pageType = $pageType;
|
$this->pageType = $pageType;
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
$this->userAgent = $userAgent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPageUid(): int
|
public function getPageUid(): int
|
||||||
|
@ -88,4 +95,9 @@ class Pageview
|
||||||
{
|
{
|
||||||
return $this->url;
|
return $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUserAgent(): string
|
||||||
|
{
|
||||||
|
return $this->userAgent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,8 @@ class Factory implements FromRequest
|
||||||
$request->getAttribute('language'),
|
$request->getAttribute('language'),
|
||||||
new \DateTimeImmutable(),
|
new \DateTimeImmutable(),
|
||||||
static::getRouting($request)->getPageType(),
|
static::getRouting($request)->getPageType(),
|
||||||
(string) $request->getUri()
|
(string) $request->getUri(),
|
||||||
|
$request->getHeader('User-Agent')[0] ?? ''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ class Pageview
|
||||||
'type' => $pageview->getPageType(),
|
'type' => $pageview->getPageType(),
|
||||||
'sys_language_uid' => $pageview->getLanguage()->getLanguageId(),
|
'sys_language_uid' => $pageview->getLanguage()->getLanguageId(),
|
||||||
'url' => $pageview->getUrl(),
|
'url' => $pageview->getUrl(),
|
||||||
|
'user_agent' => $pageview->getUserAgent(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,11 @@ return [
|
||||||
],
|
],
|
||||||
'interface' => [
|
'interface' => [
|
||||||
'always_description' => 0,
|
'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' => [
|
'types' => [
|
||||||
'0' => [
|
'0' => [
|
||||||
'showitem' => 'sys_language_uid, pid, url, type, crdate',
|
'showitem' => 'sys_language_uid, pid, url, user_agent, type, crdate',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'columns' => [
|
'columns' => [
|
||||||
|
@ -50,6 +50,13 @@ return [
|
||||||
'readOnly' => true,
|
'readOnly' => true,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
'user_agent' => [
|
||||||
|
'label' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.pageview.user_agent',
|
||||||
|
'config' => [
|
||||||
|
'type' => 'input',
|
||||||
|
'readOnly' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
'type' => [
|
'type' => [
|
||||||
'label' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.pageview.type',
|
'label' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.pageview.type',
|
||||||
'config' => [
|
'config' => [
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
<trans-unit id="table.pageview.type">
|
<trans-unit id="table.pageview.type">
|
||||||
<source>Pagetype</source>
|
<source>Pagetype</source>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="table.pageview.user_agent">
|
||||||
|
<source>User agent</source>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
CREATE TABLE tx_tracking_pageview (
|
CREATE TABLE tx_tracking_pageview (
|
||||||
url text,
|
url text,
|
||||||
|
user_agent text,
|
||||||
type int(11) unsigned DEFAULT '0' NOT NULL,
|
type int(11) unsigned DEFAULT '0' NOT NULL,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue