Closed edrisranjbar closed 5 months ago
Hey @edrisranjbar 👋
You can publish the config via the command:
php artisan vendor:publish --provider="AndreasElia\Analytics\AnalyticsServiceProvider"
After publishing the config you can update the middleware
array to include authentication middleware or any other kind of middleware if that's what you'd like to do.
https://github.com/andreaselia/laravel-analytics/blob/master/config/analytics.php#L14-L16
I did changed the config:
'prefix' => 'admin/analytics',
'middleware' => [
'admin',
],
but it keeps getting redirected to main dashboard!
@edrisranjbar what does your middleware look like? All we do in the package is assign the middleware in the config to the routes group, so don't think there is an issue there, so I think it must be coming from your middleware. Ensure your routes aren't cached either.
The authentication middleware and configs works fine for the entire admin and user panel and public website.
public function handle(Request $request, Closure $next): Response|RedirectResponse
{
if (!Auth::guard('admin')->check()) {
return redirect()->route('admin.login');
}
return $next($request);
}
the guard name is admin and here's the config:
<?php
return [
'enabled' => env('ANALYTICS_ENABLED', true),
/**
* Analytics Dashboard.
*
* The prefix and middleware for the analytics dashboard.
*/
'prefix' => 'analytics',
'middleware' => [
'admin',
],
/**
* Exclude.
*
* The routes excluded from page view tracking.
*/
'exclude' => [
'/analytics',
'/analytics/*',
],
/**
* Determine if traffic from robots should be tracked.
*/
'ignoreRobots' => true,
/**
* Ignored IP addresses.
*
* The IP addresses excluded from page view tracking.
*/
'ignoredIPs' => [
// '192.168.1.1',
],
/**
* Mask.
*
* Mask routes so they are tracked together.
*/
'mask' => [
// '/users/*',
],
/**
* Ignore methods.
*
* The HTTP verbs/methods that should be excluded from page view tracking.
*/
'ignoreMethods' => [
'OPTIONS', 'POST',
],
'session' => [
'provider' => \AndreasElia\Analytics\RequestSessionProvider::class,
],
];
will be appreciated if you can help here
Could it be a cache issue? Maybe check php artisan route:list
and see what middleware is registered to each route?
cc: @tomirons
Yeah i checked but it looks fine.
Could you show me the route list export please?
as far as I know, we do not have a choice for making that analytics endpoints part of a middle ware to limit public users get access to that. if would be great to include this setting in the config or somewhere to provide a wrapper middleware.