-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(templates): rename userAgent to algoliaAgent (#508)
Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
- Loading branch information
Showing
40 changed files
with
141 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
clients/algoliasearch-client-javascript/packages/client-common/src/createAlgoliaAgent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { AlgoliaAgentOptions, AlgoliaAgent } from './types'; | ||
|
||
export function createAlgoliaAgent(version: string): AlgoliaAgent { | ||
const algoliaAgent = { | ||
value: `Algolia for JavaScript (${version})`, | ||
add(options: AlgoliaAgentOptions): AlgoliaAgent { | ||
const addedAlgoliaAgent = `; ${options.segment}${ | ||
options.version !== undefined ? ` (${options.version})` : '' | ||
}`; | ||
|
||
if (algoliaAgent.value.indexOf(addedAlgoliaAgent) === -1) { | ||
algoliaAgent.value = `${algoliaAgent.value}${addedAlgoliaAgent}`; | ||
} | ||
|
||
return algoliaAgent; | ||
}, | ||
}; | ||
|
||
return algoliaAgent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
clients/algoliasearch-client-javascript/packages/client-common/src/createUserAgent.ts
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
clients/algoliasearch-client-javascript/packages/client-common/src/getAlgoliaAgent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { createAlgoliaAgent } from './createAlgoliaAgent'; | ||
import type { AlgoliaAgentOptions, AlgoliaAgent } from './types'; | ||
|
||
export type GetAlgoliaAgent = { | ||
algoliaAgents: AlgoliaAgentOptions[]; | ||
client: string; | ||
version: string; | ||
}; | ||
|
||
export function getAlgoliaAgent({ | ||
algoliaAgents, | ||
client, | ||
version, | ||
}: GetAlgoliaAgent): AlgoliaAgent { | ||
const defaultAlgoliaAgent = createAlgoliaAgent(version).add({ | ||
segment: client, | ||
version, | ||
}); | ||
|
||
algoliaAgents.forEach((algoliaAgent) => | ||
defaultAlgoliaAgent.add(algoliaAgent) | ||
); | ||
|
||
return defaultAlgoliaAgent; | ||
} |
23 changes: 0 additions & 23 deletions
23
clients/algoliasearch-client-javascript/packages/client-common/src/getUserAgent.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.