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

Add client header with package information #1272

Merged
merged 11 commits into from
Jun 28, 2022

Conversation

bidoubiwa
Copy link
Contributor

@bidoubiwa bidoubiwa commented Jun 23, 2022

As per this issue
And as per the new custom header coming in Meilisearch v0.28.0: X-Meilisearch-Client

This PR adds the information on the package information in the custom X-Meilisearch-Client and provides the possibility to add further information in front of the package info.

Exemple:

Default X-Meilisearch-Client header is Meilisearch JS (v0.22.1)

To add further context information in the header:

const client = new MeiliSearch({
  host: 'http://127.0.0.1:7700',
  apiKey: 'masterKey',
  clientAgents: ['My own plugin (v0.2.3)']
})

resolves in the following X-Meilisearch-Client header being send to Meilisearch

"My own plugin (v0.2.3) ; Meilisearch JS (v0.22.1)"

@bidoubiwa bidoubiwa added the enhancement New feature or request label Jun 23, 2022
@bidoubiwa bidoubiwa requested review from brunoocasali and mdubus June 23, 2022 14:31
Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @bidoubiwa 🎉 🎉

I left some comments to you, I think you can think about them and maybe change something here :)

.github/scripts/check-release.sh Show resolved Hide resolved
src/http-requests.ts Outdated Show resolved Hide resolved
src/http-requests.ts Outdated Show resolved Hide resolved
src/http-requests.ts Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
src/http-requests.ts Outdated Show resolved Hide resolved
tests/client.test.ts Outdated Show resolved Hide resolved
@brunoocasali brunoocasali self-requested a review June 27, 2022 14:44
Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just left my answer to your question @bidoubiwa :)

Base automatically changed from pagination_system_v0.28.0 to bump-meilisearch-v0.28.0 June 27, 2022 14:54
@bidoubiwa bidoubiwa force-pushed the add_analytics branch 4 times, most recently from 81a0639 to bd0cb9a Compare June 27, 2022 15:17
@bidoubiwa bidoubiwa force-pushed the bump-meilisearch-v0.28.0 branch from cb4e04f to 60db7c2 Compare June 27, 2022 15:43
@bidoubiwa bidoubiwa requested review from brunoocasali and mdubus June 28, 2022 11:06
Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments to the PR, (trying to make this function simpler to read).

src/http-requests.ts Show resolved Hide resolved
)
}

return { ...defaultHeaders, ...headers }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can join just the contentType header + everything else in the headers object.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And make this Meilisearch JavaScript (v${PACKAGE_VERSION}) a variable + remove the line 30.

@bidoubiwa bidoubiwa requested a review from brunoocasali June 28, 2022 13:23
Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work @bidoubiwa let's do this! 🦖

@bidoubiwa bidoubiwa merged commit bb1a824 into bump-meilisearch-v0.28.0 Jun 28, 2022
@bidoubiwa bidoubiwa deleted the add_analytics branch June 28, 2022 13:47
meili-bors bot added a commit that referenced this pull request Jul 11, 2022
1294: Update version for the next release (v0.27.0) r=bidoubiwa a=bidoubiwa

This version makes this package compatible with Meilisearch v0.28.0 🎉
Check out the changelog of [Meilisearch v0.28.0](https://github.com/meilisearch/meilisearch/releases/tag/v0.28.0) for more information on the changes.

## 💥 Breaking changes

- `client.updateKey(key: string, options: KeyPayload): Promise<Key>` now can just update the `description` and/or the name. #1266
- The type `EnqueuedTask` now returns an `taskUid` instead of an `uid`
- `client.getTasks(...)` and `index.getTasks()` now returns a  TasksResults type containing the following fields: `results`, `limit`, `from`, `next`  #1269 
- `index.search` changes in the response parameters: #1263
    - `nbHits` replaced with `estimatedTotalHits`
    - `exhaustiveNbHits` is deleted
    - `exhaustiveFacetsCount` is deleted
- `index.search` changes in the request parameters:  #1263
    -  `matches` renamed `showMatchesPosition`
    -  `_matchesInfo` response parameter is renamed `_matchesPosition`
    - `facetsDistribution` request parameter is renamed `facets`.
    -  `facetsDistribution` response parameter is renamed `facetDistribution`.
- The `Index` type and returned `IndexObject` does not contain a `name` field anymore
- `client.getIndexes` and `client.getRawIndexes` now returns an `IndexesResults` type containing the following fields: `results`, `limit`, `offset`, `total` #1269
- `index.getDocuments` and `client.getDocuments` now returns an `DocumentsResults` type containing the following fields: `results`, `limit`, `offset`, `total` #1269
- `index.getDocuments` and `index.getDocument`  query parameter `attributesToRetrieve` is now called `fields` #1264
- `client.getDumpStatus` has been removed #1267
- `client.createDump()` now returns an `EnqueuedTask` #1267
- `client.generateTenantToken(apiKeyUid, searchRules, options)` has now a mandatory `apiKeyUid` parameter which should contain the uid of a specific API key. #1268  


## 🚀 Enhancements

- `client.getKeys(parameters: KeysQuery  = {})` now accepts pagination parameters: `limit`, `offset` #1269 
- `client.getKey(keyOrUid: string)` can now also find keys based on their key uid. #1266 
- `client.createKey(options: KeyCreation)` lets you specify a custom uid (optionally) to create a new Key #1269
- The returned `Key` now has an additional `name` and `uid` string fields. #1266 
- The `indexUid` field in both `EnqueuedTask` and `Task` can be null #1259 
- `client.getTasks(parameters: TasksQuery = {})` and   `index.getTasks(parameters: TasksQuery)` now accepts pagination parameters: `limit`, `from`, `next` and filters parameters: `type`, `status`, `indexUid` (same for `index.getTasks`) #1269 
- `client.getIndexes` and `client.getRawIndexes` now accepts pagination parameters: `limit`, `offset` #1269 
- `index.getDocuments` now accepts pagination parameters: `limit`, `offset` #1269 
- `new MeiliSearch({ host, apiKey, headers, clientAgents })` now accept a new parameter `clientAgents` that should contain the agent from which the library is used. #1272

Analytics is enabled by default in the server, but you can disable them by following [this guide](https://docs.meilisearch.com/learn/what_is_meilisearch/telemetry.html#how-to-disable-data-collection)
Also, of course, every analytics data we collect are **ANONYMOUS** [read the guide for more information](https://docs.meilisearch.com/learn/what_is_meilisearch/telemetry.html).

Thanks again to `@bidoubiwa` ! 🎉

Co-authored-by: Charlotte Vermandel <charlottevermandel@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants