diff --git a/config/scout.php b/config/scout.php index fe7478ab..d8f0f3bb 100644 --- a/config/scout.php +++ b/config/scout.php @@ -74,18 +74,18 @@ /* |-------------------------------------------------------------------------- - | Auto Identify User + | Identify User |-------------------------------------------------------------------------- | - | This option allows you to control whether to automatically - | identify the currently authenticated user with a search - | engine that is supported. By default it's turned off. + | This option allows you to control whether to notify the search engine + | of the user performing the search. This is sometimes useful if the + | engine supports any analytics based on this application's users. | | Supported engines: "algolia" | */ - 'identify_user' => env('SCOUT_IDENTIFY_USER', false), + 'identify' => env('SCOUT_IDENTIFY', false), /* |-------------------------------------------------------------------------- diff --git a/src/EngineManager.php b/src/EngineManager.php index 8087e96b..4628909f 100644 --- a/src/EngineManager.php +++ b/src/EngineManager.php @@ -65,26 +65,25 @@ protected function ensureAlgoliaClientIsInstalled() } /** - * Set the default Algolia config headers. + * Set the default Algolia configuration headers. * * @return array */ protected function defaultAlgoliaHeaders() { - if (! config('scout.identify_user')) { + if (! config('scout.identify')) { return []; } $headers = []; - if ( - ! config('app.debug') && + if (! config('app.debug') && filter_var($ip = request()->ip(), FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) ) { $headers['X-Forwarded-For'] = $ip; } - if ($user = request()->user()) { + if ($user = request()->user() && method_exists($user, 'getKey')) { $headers['X-Algolia-UserToken'] = $user->getKey(); }