File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,18 @@ export function useSearchClient(
1111) : SearchClient {
1212 const searchClient = React . useMemo ( ( ) => {
1313 const client = algoliasearch ( appId , apiKey ) ;
14- client . addAlgoliaAgent ( `docsearch (${ version } )` ) ;
14+ client . addAlgoliaAgent ( 'docsearch' , version ) ;
15+
16+ // Since DocSearch.js relies on DocSearch React with an alias to Preact,
17+ // we cannot add the `docsearch-react` user agent by default, otherwise
18+ // it would also be sent on a DocSearch.js integration.
19+ // We therefore only add the `docsearch-react` user agent if `docsearch.js`
20+ // is not present.
21+ if (
22+ / d o c s e a r c h .j s \( .* \) / . test ( client . transporter . userAgent . value ) === false
23+ ) {
24+ client . addAlgoliaAgent ( 'docsearch-react' , version ) ;
25+ }
1526
1627 return transformSearchClient ( client ) ;
1728 } , [ appId , apiKey , transformSearchClient ] ) ;
You can’t perform that action at this time.
0 commit comments