Skip to content

Commit

Permalink
fix(insights): detect appId and apiKey from client directly in v5 (#6492
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Haroenv authored Dec 26, 2024
1 parent 3215f76 commit 392a65b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/instantsearch.js/src/lib/utils/getAppIdAndApiKey.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// typed as any, since it accepts the _real_ js clients, not the interface we otherwise expect
export function getAppIdAndApiKey(searchClient: any): [string, string] {
if (searchClient.transporter) {
export function getAppIdAndApiKey(
searchClient: any
): [appId: string, apiKey: string] | [appId: undefined, apiKey: undefined] {
if (searchClient.appId && searchClient.apiKey) {
// searchClient v5
return [searchClient.appId, searchClient.apiKey];
} else if (searchClient.transporter) {
// searchClient v4 or v5
const transporter = searchClient.transporter;
const headers = transporter.headers || transporter.baseHeaders;
Expand Down

0 comments on commit 392a65b

Please sign in to comment.