Skip to content

Commit 974037e

Browse files
committed
add Visit Monitoring Custom Conditions to readme
1 parent 47317bb commit 974037e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- [Views](#visit-monitoring-views)
2323
- [Ajax Requests](#ajax-requests)
2424
- [Visit Monitoring Guest Mode](#visit-monitoring-guest-mode)
25+
- [Visit Monitoring Custom Conditions](#visit-monitoring-custom-conditions)
2526
- [Action Monitoring](#action-monitoring)
2627
- [Views](#action-monitoring-views)
2728
- [Reverse Proxy Config](#action-monitoring-reverse-proxy-config)
@@ -366,6 +367,34 @@ When set to `false`, only authenticated user visits will be recorded.
366367
],
367368
```
368369

370+
<a name="visit-monitoring-custom-conditions"></a>
371+
### Visit Monitoring Custom Conditions
372+
373+
The `Laravel User Monitoring` package allows you to define custom conditions for visit monitoring.
374+
Conditions give you full control over when a visit should be logged.
375+
376+
#### 🔧 How It Works
377+
378+
- Conditions are checked before a visit is stored.
379+
- If any condition returns false, the visit will be skipped.
380+
- You can define conditions as closures or as class-based rules.
381+
382+
```php
383+
'visit_monitoring' => [
384+
'conditions' => [
385+
// Class-based condition (must implement MonitoringCondition interface)
386+
\App\Monitoring\YourCustomCondition::class,
387+
388+
// Closure-based condition (receives the Request and authenticated User)
389+
function (Illuminate\Http\Request $request) {
390+
$user = $request->user();
391+
392+
return $user && $user->isAdmin();
393+
},
394+
],
395+
],
396+
```
397+
369398
<a name="action-monitoring"></a>
370399
## Action Monitoring
371400

0 commit comments

Comments
 (0)