Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ jobs:
rm -f .env.example
rm -f deploy.sh

# Never ship a local sqlite — would overwrite production data
rm -f database/*.sqlite database/*.sqlite-journal

# Force the server to re-cache config/routes after deploy
rm -f bootstrap/cache/config.php
rm -f bootstrap/cache/routes-v7.php
rm -f bootstrap/cache/services.php
rm -f bootstrap/cache/packages.php

- name: Deploy via SFTP
uses: wlixcc/SFTP-Deploy-Action@v1.2.4
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:

name: PHP ${{ matrix.php }}

env:
VISITOR_TRACKER_DASHBOARD_ENABLED: false

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
/storage/*.key
/storage/pail
/vendor
/bootstrap/cache/*.php
/database/*.sqlite
/database/*.sqlite-journal
Homestead.json
Homestead.yaml
Thumbs.db
Expand Down
33 changes: 33 additions & 0 deletions app/Http/Controllers/ToolController.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ public function index(): View
'route' => 'tools.diff',
'icon' => 'diff',
],
[
'name' => 'Visitor Tracker',
'description' => 'Server-side visitor analytics for Laravel applications',
'route' => 'tools.visitor-tracker',
'icon' => 'chart',
],
];

return view('home', compact('tools'));
Expand Down Expand Up @@ -266,4 +272,31 @@ public function diff(): View
{
return view('tools.diff');
}

public function visitorTracker(): View
{
$stats = app(\Ghdj\VisitorTracker\Services\StatisticsService::class);
$parser = new \Ghdj\VisitorTracker\Services\UserAgentParser();
$botDetector = new \Ghdj\VisitorTracker\Services\BotDetector();

$userAgent = request()->userAgent();
$parsedUA = $parser->parse($userAgent);
$isBot = $botDetector->isBot($userAgent);
$botName = $isBot ? $botDetector->getBotName($userAgent) : null;
$botCategory = $isBot ? $botDetector->getBotCategory($userAgent) : null;

return view('tools.visitor-tracker', [
'summary' => $stats->summary(),
'browsers' => $stats->browserStats(5),
'platforms' => $stats->platformStats(5),
'devices' => $stats->deviceStats(),
'topPages' => $stats->mostVisitedPages(5),
'userAgent' => $userAgent,
'parsedUA' => $parsedUA,
'isBot' => $isBot,
'botName' => $botName,
'botCategory' => $botCategory,
'visitorIp' => request()->ip(),
]);
}
}
4 changes: 3 additions & 1 deletion bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
//
$middleware->web(append: [
\Ghdj\VisitorTracker\Middleware\TrackVisitor::class,
]);
})
->withExceptions(function (Exceptions $exceptions): void {
//
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"require": {
"php": "^8.2",
"doctrine/sql-formatter": "^1.5",
"ghdj/laravel-visitor-tracker": "^1.1",
"laravel/framework": "^12.0",
"laravel/tinker": "^2.10.1",
"league/commonmark": "^2.8",
Expand Down
79 changes: 78 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading