Skip to content

Artisan commands

CommandScheduled by the packageDescription
visits:aggregateyes (schedule.enabled)Rebuild visit_stats_daily for one or more days
visits:close-stale-sessionsyes (schedule.enabled)Close sessions past session_timeout_minutes
visits:pruneneverDelete raw rows older than the retention window
visits:seed-demoneverGenerate demo data; not registered in production

Background and scheduling: Rollups, sessions & retention.

visits:aggregate {--date=} {--from=} {--to=} {--force}
OptionDescription
--datetoday (default), yesterday, or any date Carbon::parse() understands
--fromFirst day of a range; takes precedence over --date
--toLast day of the range; defaults to --from
--forceAlso recompute days older than retention_days

For each day and each distinct tenant_id of visit_visitors: deletes that day’s rows and inserts new totals and dimension counts for visitors, sessions, page_views and conversions, bots excluded. Prints Aggregated YYYY-MM-DD per day. A day that starts before now() - retention_days is skipped with a warning unless --force is given: its raw rows may already be pruned.

visits:close-stale-sessions

Sets ended_at (= last_activity_at), duration_seconds and exit_url (last page view) on every open session whose last_activity_at is older than session_timeout_minutes, bots included, in chunks of 500. Prints Closed N stale session(s).

visits:prune {--days= : Override retention_days from config} {--force : Skip the confirmation prompt}
OptionDescription
--daysRetention in days; defaults to retention_days (90). 0 deletes everything
--forceSkip the confirmation. Required when run non-interactively (scheduler, CI) — otherwise the prompt is answered “no” and nothing is deleted

Deletes, bots included: events with created_at, sessions with started_at, visitors with last_seen_at before the cutoff. Foreign keys cascade to the children of deleted sessions and visitors. Rollups are kept. Prints the three counts.

visits:seed-demo {--days=30} {--visitors=150} {--fresh} {--force}
OptionDescription
--daysSpread the visitors’ first_seen_at over this many past days
--visitorsNumber of visitors to create
--freshDelete all rows of the four visit_* tables first (asks for confirmation)
--forceSkip the --fresh confirmation

Creates visitors with one to three sessions and one to six events each, with consistent geo (real cities), device and UTM data, about 3% bots, then runs visits:aggregate over the seeded range. Registered only outside the production environment; requires fakerphp/faker.