designtopack/public/site/plugins/analytics/classes/Visit.php
isUnknown 8a73da920f 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>
2026-03-03 10:33:15 +01:00

46 lines
1.2 KiB
PHP

<?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);
}
}