feat: plugin analytics avec custom field kirbyup + Chart.js
Refactoring complet du plugin analytics : remplacement de la section avec template Vue inline par un custom field compilé avec kirbyup. Dashboard avec KPIs, line chart Chart.js et filtres par date. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
7371e66ec1
commit
8a73da920f
15 changed files with 873 additions and 0 deletions
46
public/site/plugins/analytics/classes/Visit.php
Normal file
46
public/site/plugins/analytics/classes/Visit.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace adrienpayet\analytics;
|
||||
|
||||
class Visit
|
||||
{
|
||||
public string $id;
|
||||
public string $email;
|
||||
public ?string $country;
|
||||
public string $timestamp;
|
||||
public string $sessionId;
|
||||
public string $pageUrl;
|
||||
public string $pageType;
|
||||
public ?string $pageName;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->id = $data['id'] ?? uniqid('visit_', true);
|
||||
$this->email = $data['email'];
|
||||
$this->country = $data['country'] ?? null;
|
||||
$this->timestamp = $data['timestamp'] ?? date('Y-m-d H:i:s');
|
||||
$this->sessionId = $data['sessionId'];
|
||||
$this->pageUrl = $data['pageUrl'];
|
||||
$this->pageType = $data['pageType'];
|
||||
$this->pageName = $data['pageName'] ?? null;
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'email' => $this->email,
|
||||
'country' => $this->country,
|
||||
'timestamp' => $this->timestamp,
|
||||
'sessionId' => $this->sessionId,
|
||||
'pageUrl' => $this->pageUrl,
|
||||
'pageType' => $this->pageType,
|
||||
'pageName' => $this->pageName,
|
||||
];
|
||||
}
|
||||
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
return new self($data);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue