$ composer require stounhandj/laravel-traffic-metrics
Or
{
"require": {
"stounhandj/laravel-traffic-metrics": "^0.1.0"
}
}
- Use following:
php artisan vendor:publish --tag=traffic-metrics
php artisan vendor:publish --tag=laravel-kafka-config
According to the standard, a unique visit is considered to be a user's visit to the page once every 1 minute. This can be changed in the configuration. 2. Run migrations
php artisan migrate
- Set up a connection to kafka: In config/kafka.php setup brokers. More information here
- Add provider in config/app.php:
StounhandJ\LaravelTrafficMetrics\TrafficMetricsProvider::class,
- Add Middleware in Kernel.php:
'metrics' => \StounhandJ\LaravelTrafficMetrics\Middleware\MetricsMiddleware::class,
- Use Middleware:
Route::get('/p/{product:id}', [ProductController::class, "index"])
->middleware("metrics")
->name("product.details");
- Put the handler on permanent execution:
php artisan metrics:check
- Getting metrics
Metrics::findByUri("/welcome")->getViews()