Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Add analytics for meilisearch engine #681

Merged
merged 2 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Release Instructions

1. Update the version in [`EngineManager.php`](./src/EngineManager.php) and commit it
1. Update the version in [`Scout.php`](./src/Scout.php) and commit it
2. Create a new GitHub release for this version with the release notes
2 changes: 1 addition & 1 deletion src/EngineManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function createAlgoliaDriver()
{
$this->ensureAlgoliaClientIsInstalled();

UserAgent::addCustomUserAgent('Laravel Scout', '9.6.2');
UserAgent::addCustomUserAgent('Laravel Scout', Scout::VERSION);

$config = SearchConfig::create(
config('scout.algolia.id'),
Expand Down
7 changes: 7 additions & 0 deletions src/Scout.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

class Scout
{
/**
* The Scout library version.
*
* @var string
*/
const VERSION = '9.6.2';

/**
* The job class that should make models searchable.
*
Expand Down
19 changes: 15 additions & 4 deletions src/ScoutServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
use Laravel\Scout\Console\ImportCommand;
use Laravel\Scout\Console\IndexCommand;
use Laravel\Scout\Console\SyncIndexSettingsCommand;
use MeiliSearch\Client as MeiliSearch;
use MeiliSearch\Client as MeiliSearchClient;
use Meilisearch\Meilisearch;

class ScoutServiceProvider extends ServiceProvider
{
Expand All @@ -22,11 +23,21 @@ public function register()
{
$this->mergeConfigFrom(__DIR__.'/../config/scout.php', 'scout');

if (class_exists(MeiliSearch::class)) {
$this->app->singleton(MeiliSearch::class, function ($app) {
if (class_exists(MeilisearchClient::class)) {
mmachatschek marked this conversation as resolved.
Show resolved Hide resolved
$this->app->singleton(MeilisearchClient::class, function ($app) {
$config = $app['config']->get('scout.meilisearch');

return new MeiliSearch($config['host'], $config['key']);
if (version_compare(Meilisearch::VERSION, '0.24.2') >= 0) {
return new MeilisearchClient(
$config['host'],
$config['key'],
null,
null,
[sprintf('Meilisearch Laravel Scout (v%s)', Scout::VERSION)],
);
}

return new MeilisearchClient($config['host'], $config['key']);
});
}

Expand Down