Add device, platform, and country analytics to link show page.
Deploy Ladill Link / deploy (push) Successful in 32s

Record parsed user-agent and geo data on clicks, then surface breakdowns and richer recent-click context on per-link and account analytics views.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-06-27 19:32:40 +00:00
co-authored by Cursor
parent 9d89aef17e
commit 0e5e0f6ca5
12 changed files with 453 additions and 32 deletions
+19
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use App\Support\Link\LinkGeoResolver;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -12,6 +13,9 @@ class LinkClick extends Model
'ip_hash',
'user_agent',
'referer',
'device_type',
'browser',
'os',
'country',
'is_unique',
'clicked_at',
@@ -26,4 +30,19 @@ class LinkClick extends Model
{
return $this->belongsTo(ShortLink::class);
}
public function contextLabel(): string
{
$parts = array_filter([
$this->device_type ? ucfirst($this->device_type) : null,
$this->browser,
$this->os,
$this->country ? LinkGeoResolver::countryLabel($this->country) : null,
]);
$context = $parts !== [] ? implode(' · ', $parts) : null;
$referer = $this->referer ? parse_url($this->referer, PHP_URL_HOST) ?: $this->referer : 'Direct';
return $context ? "{$context} · via {$referer}" : "via {$referer}";
}
}