Skip to content

Commit 5cb9e15

Browse files
committed
feat: Update README for querying analytics data.
BREAKING CHANGE: This release changes the signature on the log request method and RequestDetails class.
1 parent 1c3a84e commit 5cb9e15

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Diff for: README.md

+31
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,37 @@ public function boot()
181181

182182
With the above example, the `method` variable for every request will be set to "TEST".
183183

184+
### Querying Analytics Records
185+
186+
You can use the `AnalyticsRepository` to query data out of the analytics tables. If you need to build a custom query, you can use the `query()` method on the repository instance.
187+
188+
```php
189+
public function loadAnalytics(AnalyticsRepository $analytics)
190+
{
191+
$records = $analytics->query()->where('method', 'GET')->get();
192+
}
193+
```
194+
195+
There's also a couple query scopes setup on the `Analytics` model.
196+
197+
Filter Analytics records that are related to the a given model:
198+
199+
```php
200+
$analytics = Analytics::relatedTo($user);
201+
```
202+
203+
Filter Analytics records that have metadata with a given key:
204+
205+
```php
206+
$analytics = Analytics::hasMeta('foo');
207+
```
208+
209+
Filter Analytics records that have a given metadata key/value pair:
210+
211+
```php
212+
$analytics = Analytics::withMetaValue('foo', 'bar');
213+
```
214+
184215
## Testing
185216

186217
``` bash

0 commit comments

Comments
 (0)