Skip to content

Commit

Permalink
Merge pull request #8 from binafy/add-turn-on-for-visit-monitoring
Browse files Browse the repository at this point in the history
[0.x] Add config for turn on-off for visit monitoring
  • Loading branch information
milwad-dev authored Aug 1, 2023
2 parents 7ba89b3 + 700ba86 commit 8f3c3c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config/user-monitoring.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
'visit_monitoring' => [
'table' => 'visits_monitoring',

/*
* If you want to disable visit monitoring, you can change it to false.
*/
'turn_on' => true,

/*
* You can specify pages not to be monitored.
*/
Expand Down
6 changes: 5 additions & 1 deletion src/Middlewares/VisitMonitoringMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class VisitMonitoringMiddleware
*/
public function handle(Request $request, Closure $next)
{
if (config('user-monitoring.visit_monitoring.turn_on', false) === false) {
return $next($request);
}

$agent = new Agent();
$guard = config('user-monitoring.user.guard', 'web');
$exceptPages = config('user-monitoring.visit_monitoring.expect_pages', []);
Expand Down Expand Up @@ -51,4 +55,4 @@ private function checkIsExpectPages(string $page, array $exceptPages)
{
return collect($exceptPages)->contains($page);
}
}
}

0 comments on commit 8f3c3c3

Please sign in to comment.