algolia / algoliasearch-client-javascript

⚡️ A fully-featured and blazing-fast JavaScript API client to interact with Algolia.
https://www.algolia.com/doc/api-client/javascript/getting-started/
MIT License
1.33k stars 221 forks source link

Recommend client is incorrectly sending Search user agents #1507

Open sarahdayan opened 6 months ago

sarahdayan commented 6 months ago

Actual

The Recommend client uses the same transporter utilities as the Search client, including the createUserAgent function. This causes it to set the "Algolia for JavaScript" user agent, which corresponds to Algolia Search, because createUserAgent sets this value by default. That's likely because the transporter was initially designed solely for the Search API, before Recommend existed.

Additionally, the Recommend passes it its own version to createUserAgent, resulting in the Search client agent being sent with the Recommend client version.

Expected

The Recommend client shouldn't send Algolia Search user agents at all.

Suggested solution

The createUserAgent function shouldn't set "Algolia for JavaScript" by default. Instead, this agent should be added in the build of the Search client.

Haroenv commented 6 months ago

Algolia for JavaScript is still relevant for recommend, no?

shortcuts commented 6 months ago

The createUserAgent function shouldn't set "Algolia for JavaScript" by default. Instead, this agent should be added in the build of the Search client.

IMHO this segment can stay because what differentiates the clients are those next segments https://github.com/algolia/algoliasearch-client-javascript/blob/252228ab7c5d5c94890885e8ce9bb9b072905756/packages/recommend/src/builds/node.ts#L39-L42 added in the init directly

Keeping the Algolia for JavaScript segment also allows us to track the global usage of the whole JavaScript API client

raed667 commented 6 months ago

I guess the question boils down to:

Algolia for JavaScript = search or all frontend libraries

shortcuts commented 6 months ago

All! It's clearer in the next major version as all clients can be used as standalone but it's mostly to identify the language associated to the API client for usage purposes, the other languages also have that notion