问题描述
我目前正在使用antonioribeiro/tracker
获取Laravel的一些统计信息.
I'm currently using antonioribeiro/tracker
for some stats on my Laravel.
我正在使用配置中的do_not_track_routes
数组.
I'm struggling using the do_not_track_routes
array in the config.
我只是尝试禁用跟踪器来跟踪管理路由,但这不起作用.
I just try to disable the tracker to track admin route, but it doesn't work.
'do_not_track_routes' =>
[
'admin.*',
]
/* Admin routes */
Route::group(['namespace' => 'Admin', 'as'=>'admin', 'prefix' => 'admin1452872135', 'middleware' => ['auth', 'admin', 'language']], function () {
//some route
});
即使这样,跟踪器仍可以插入新会话...
Even this keep the tracker to insert new sessions...
'do_not_track_routes' =>
[
'*',
]
我真的尽我所能,感谢您的帮助...
I really try everything that came to my mind, I'll be thankfull for some help...
推荐答案
在包内调试后得到我自己的答案...实际上,do_not_track_routes
从未在Tracker.php
(vendor\pragmarx\tracker\src\Tracker.php
)
Get my own answer after debugging inside the package ...In fact, do_not_track_routes
is never used in the Tracker.php
(vendor\pragmarx\tracker\src\Tracker.php
)
所以我像这样更新了isTrackable方法:
So I update the isTrackable method like that :
protected function isTrackable() {
return $this->config->get('enabled') &&
$this->logIsEnabled() &&
$this->parserIsAvailable() &&
$this->isTrackableIp() &&
$this->isTrackableEnvironment() &&
$this->notRobot() &&
$this->isTrackableRoute();
}
并添加此新方法,以检查当前URL是否在do_not_track_route
数组中:
And add this new method, to check if the current URL is in the do_not_track_route
array :
protected function isTrackableRoute() {
if (is_null(\Request::path())) {
return true;
}
$routes = $this->config->get('do_not_track_routes');
foreach ($routes as $route) {
$match = preg_grep ('/'. $route .'/i', [\Request::path()]);
if(!empty($match)){
return false;
}
}
return true;
}
为我工作好,如果您找到更好的答案,我就来了! :)
Work well for me, if you find a better answer, I'm in ! :)
这篇关于Laravel,请勿使用"antonioribeiro/tracker"跟踪路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!