You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -286,14 +286,18 @@ This is used by the PostHog driver as the `distinctId`, and is available to any
286
286
287
287
### Custom user ID resolver
288
288
289
-
You can override the default resolution by providing your own closure:
289
+
You can override the default resolution by providing your own closure. The driver instance is passed to your closure, so you can fall back to the built-in anonymous ID if needed:
290
290
291
291
```php
292
-
Metrics::resolveUserIdWith(fn() => auth()->id());
292
+
Metrics::resolveUserIdUsing(function($driver) {
293
+
return auth()->check()
294
+
? 'custom-prefix:' . auth()->id()
295
+
: $driver->getAnonymousId();
296
+
});
293
297
```
294
298
295
299
This will apply to all drivers. You can also set it on a specific driver:
0 commit comments