Add device, platform, and country analytics to link show page.
Deploy Ladill Link / deploy (push) Successful in 32s
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:
@@ -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}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user