first commit from hostslim
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Alert extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'name',
|
||||
'metric',
|
||||
'condition',
|
||||
'threshold',
|
||||
'period',
|
||||
'channel',
|
||||
'is_active',
|
||||
'last_triggered_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'threshold' => 'decimal:2',
|
||||
'is_active' => 'boolean',
|
||||
'last_triggered_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
|
||||
public function notifications(): HasMany
|
||||
{
|
||||
return $this->hasMany(AlertNotification::class);
|
||||
}
|
||||
|
||||
public static array $metrics = [
|
||||
'page_views' => 'Page Views',
|
||||
'visitors' => 'Unique Visitors',
|
||||
'sessions' => 'Sessions',
|
||||
'bounce_rate' => 'Bounce Rate',
|
||||
];
|
||||
|
||||
public static array $conditions = [
|
||||
'above' => 'goes above',
|
||||
'below' => 'drops below',
|
||||
'change_up' => '% increase exceeds',
|
||||
'change_down' => '% decrease exceeds',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class AlertNotification extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'alert_id',
|
||||
'value',
|
||||
'message',
|
||||
'is_read',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'value' => 'decimal:2',
|
||||
'is_read' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function alert(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Alert::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class AnalyticsSession extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'visitor_id',
|
||||
'uid',
|
||||
'started_at',
|
||||
'ended_at',
|
||||
'duration',
|
||||
'is_bounce',
|
||||
'entry_page',
|
||||
'exit_page',
|
||||
'pages_count',
|
||||
'ip_address',
|
||||
'referrer_url',
|
||||
'referrer_domain',
|
||||
'utm_source',
|
||||
'utm_medium',
|
||||
'utm_campaign',
|
||||
'utm_term',
|
||||
'utm_content',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'started_at' => 'datetime',
|
||||
'ended_at' => 'datetime',
|
||||
'is_bounce' => 'boolean',
|
||||
'duration' => 'integer',
|
||||
'pages_count' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
|
||||
public function visitor(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Visitor::class);
|
||||
}
|
||||
|
||||
public function pageViews(): HasMany
|
||||
{
|
||||
return $this->hasMany(PageView::class);
|
||||
}
|
||||
|
||||
public function events(): HasMany
|
||||
{
|
||||
return $this->hasMany(Event::class);
|
||||
}
|
||||
|
||||
public function goalConversions(): HasMany
|
||||
{
|
||||
return $this->hasMany(GoalConversion::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Annotation extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'user_id',
|
||||
'date',
|
||||
'text',
|
||||
'category',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public static array $categories = [
|
||||
'general' => 'General',
|
||||
'deployment' => 'Deployment',
|
||||
'campaign' => 'Campaign',
|
||||
'incident' => 'Incident',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class DailyAggregate extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'date',
|
||||
'visitors',
|
||||
'sessions',
|
||||
'page_views',
|
||||
'bounce_count',
|
||||
'total_duration',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'visitors' => 'integer',
|
||||
'sessions' => 'integer',
|
||||
'page_views' => 'integer',
|
||||
'bounce_count' => 'integer',
|
||||
'total_duration' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class DashboardWidget extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'title',
|
||||
'widget_type',
|
||||
'config',
|
||||
'sort_order',
|
||||
'size',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'config' => 'array',
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
|
||||
public static array $types = [
|
||||
'metric' => 'Single Metric',
|
||||
'chart' => 'Visitors Chart',
|
||||
'top_pages' => 'Top Pages',
|
||||
'top_sources' => 'Top Sources',
|
||||
'events' => 'Events Overview',
|
||||
'conversions' => 'Goal Conversions',
|
||||
'new_vs_returning' => 'New vs Returning',
|
||||
'browsers' => 'Browsers',
|
||||
'countries' => 'Countries',
|
||||
];
|
||||
|
||||
public static array $metrics = [
|
||||
'page_views' => 'Page Views',
|
||||
'visitors' => 'Unique Visitors',
|
||||
'sessions' => 'Sessions',
|
||||
'bounce_rate' => 'Bounce Rate',
|
||||
'avg_duration' => 'Avg. Duration',
|
||||
'avg_pages' => 'Pages / Session',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Event extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'visitor_id',
|
||||
'analytics_session_id',
|
||||
'name',
|
||||
'category',
|
||||
'action',
|
||||
'label',
|
||||
'value',
|
||||
'properties',
|
||||
'occurred_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'value' => 'decimal:4',
|
||||
'properties' => 'array',
|
||||
'occurred_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
|
||||
public function visitor(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Visitor::class);
|
||||
}
|
||||
|
||||
public function session(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AnalyticsSession::class, 'analytics_session_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Funnel extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'name',
|
||||
'steps',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'steps' => 'array',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Goal extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'name',
|
||||
'type',
|
||||
'conditions',
|
||||
'default_value',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'conditions' => 'array',
|
||||
'default_value' => 'decimal:4',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
|
||||
public function conversions(): HasMany
|
||||
{
|
||||
return $this->hasMany(GoalConversion::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class GoalConversion extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'goal_id',
|
||||
'website_id',
|
||||
'visitor_id',
|
||||
'analytics_session_id',
|
||||
'value',
|
||||
'converted_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'value' => 'decimal:4',
|
||||
'converted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function goal(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Goal::class);
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
|
||||
public function visitor(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Visitor::class);
|
||||
}
|
||||
|
||||
public function session(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AnalyticsSession::class, 'analytics_session_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class PageDailyAggregate extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'date',
|
||||
'path',
|
||||
'views',
|
||||
'unique_views',
|
||||
'total_time_on_page',
|
||||
'bounces',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'views' => 'integer',
|
||||
'unique_views' => 'integer',
|
||||
'total_time_on_page' => 'integer',
|
||||
'bounces' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class PageView extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'visitor_id',
|
||||
'analytics_session_id',
|
||||
'url',
|
||||
'path',
|
||||
'title',
|
||||
'referrer',
|
||||
'time_on_page',
|
||||
'viewed_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'viewed_at' => 'datetime',
|
||||
'time_on_page' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
|
||||
public function visitor(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Visitor::class);
|
||||
}
|
||||
|
||||
public function session(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AnalyticsSession::class, 'analytics_session_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Segment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'name',
|
||||
'filters',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'filters' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the visitor IDs that match this segment's filters.
|
||||
*/
|
||||
public function matchingVisitorIds(): \Illuminate\Support\Collection
|
||||
{
|
||||
$query = Visitor::where('website_id', $this->website_id);
|
||||
|
||||
foreach ($this->filters as $filter) {
|
||||
$field = $filter['field'];
|
||||
$operator = $filter['operator'] ?? '=';
|
||||
$value = $filter['value'];
|
||||
|
||||
$allowedFields = ['country', 'region', 'city', 'browser', 'os', 'device_type', 'language', 'screen_resolution'];
|
||||
if (! in_array($field, $allowedFields)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
match ($operator) {
|
||||
'=' => $query->where($field, $value),
|
||||
'!=' => $query->where($field, '!=', $value),
|
||||
'contains' => $query->where($field, 'like', "%{$value}%"),
|
||||
'starts_with' => $query->where($field, 'like', "{$value}%"),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
return $query->pluck('id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function websites(): HasMany
|
||||
{
|
||||
return $this->hasMany(Website::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Visitor extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'uid',
|
||||
'first_seen_at',
|
||||
'last_seen_at',
|
||||
'device_type',
|
||||
'browser',
|
||||
'browser_version',
|
||||
'os',
|
||||
'os_version',
|
||||
'screen_resolution',
|
||||
'language',
|
||||
'country',
|
||||
'region',
|
||||
'city',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'first_seen_at' => 'datetime',
|
||||
'last_seen_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
|
||||
public function sessions(): HasMany
|
||||
{
|
||||
return $this->hasMany(AnalyticsSession::class);
|
||||
}
|
||||
|
||||
public function pageViews(): HasMany
|
||||
{
|
||||
return $this->hasMany(PageView::class);
|
||||
}
|
||||
|
||||
public function events(): HasMany
|
||||
{
|
||||
return $this->hasMany(Event::class);
|
||||
}
|
||||
|
||||
public function goalConversions(): HasMany
|
||||
{
|
||||
return $this->hasMany(GoalConversion::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Website extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'name',
|
||||
'domain',
|
||||
'tracking_id',
|
||||
'is_active',
|
||||
'settings',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_active' => 'boolean',
|
||||
'settings' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (Website $website) {
|
||||
if (empty($website->tracking_id)) {
|
||||
$website->tracking_id = 'TA-' . strtoupper(Str::random(10));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function visitors(): HasMany
|
||||
{
|
||||
return $this->hasMany(Visitor::class);
|
||||
}
|
||||
|
||||
public function sessions(): HasMany
|
||||
{
|
||||
return $this->hasMany(AnalyticsSession::class);
|
||||
}
|
||||
|
||||
public function pageViews(): HasMany
|
||||
{
|
||||
return $this->hasMany(PageView::class);
|
||||
}
|
||||
|
||||
public function events(): HasMany
|
||||
{
|
||||
return $this->hasMany(Event::class);
|
||||
}
|
||||
|
||||
public function goals(): HasMany
|
||||
{
|
||||
return $this->hasMany(Goal::class);
|
||||
}
|
||||
|
||||
public function goalConversions(): HasMany
|
||||
{
|
||||
return $this->hasMany(GoalConversion::class);
|
||||
}
|
||||
|
||||
public function funnels(): HasMany
|
||||
{
|
||||
return $this->hasMany(Funnel::class);
|
||||
}
|
||||
|
||||
public function segments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Segment::class);
|
||||
}
|
||||
|
||||
public function dashboardWidgets(): HasMany
|
||||
{
|
||||
return $this->hasMany(DashboardWidget::class);
|
||||
}
|
||||
|
||||
public function alerts(): HasMany
|
||||
{
|
||||
return $this->hasMany(Alert::class);
|
||||
}
|
||||
|
||||
public function annotations(): HasMany
|
||||
{
|
||||
return $this->hasMany(Annotation::class);
|
||||
}
|
||||
|
||||
public function dailyAggregates(): HasMany
|
||||
{
|
||||
return $this->hasMany(DailyAggregate::class);
|
||||
}
|
||||
|
||||
public function pageDailyAggregates(): HasMany
|
||||
{
|
||||
return $this->hasMany(PageDailyAggregate::class);
|
||||
}
|
||||
|
||||
public function getDataRetentionDaysAttribute(): int
|
||||
{
|
||||
return $this->settings['data_retention_days'] ?? 365;
|
||||
}
|
||||
|
||||
public function embedSnippet(): string
|
||||
{
|
||||
$scriptUrl = route('tracking.script', $this->tracking_id);
|
||||
|
||||
return <<<HTML
|
||||
<!-- Analytics Tracker -->
|
||||
<script defer src="{$scriptUrl}"></script>
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user