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

fix(recommend): remove the search user-agent from requests [RECO-2154] #1508

Closed raed667 closed 16 hours ago

raed667 commented 6 months ago

What

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

Why

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.

The Recommend client shouldn't send Algolia Search user agents

How

Updated the function createUserAgent to accept an optional base UA as a second parameter. Recommend client can set that to an empty string, while the rest can still use the default value Algolia for JavaScript

Haroenv commented 6 months ago

If you look at #1507, I thought the conclusion was that "Algolia for JavaScript" isn't a search UA, but just a "JS client UA". Not sure this is needed

raed667 commented 6 months ago

Good catch @Haroenv i forgot about the Github issue 👀 i'll convert to draft for now and continue the discussion there.

shortcuts commented 6 months ago

Same comments as in the issue for me too, the UA is the whole string being sent, Algolia for JavaScript is not scoped to the search client, the following segment defines the current client

shortcuts commented 6 months ago

And also, this is common to every clients, see https://github.com/algolia/api-clients-automation/blob/main/tests/output/python/tests/client/monitoring_test.py#L27 or https://github.com/algolia/api-clients-automation/blob/main/tests/output/java/src/test/java/com/algolia/client/QuerySuggestions.test.java#L52 and so on