-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(insightsMiddleware): throw an error when credentials can't be extracted #4901
Conversation
…racted When api or appId is missing, an error gets thrown by search insights, but that doesn't explain *why* that error gets thrown. Ideally this would also clarify what the next step is (usually making sure to spread the previous search client, or leaving all properties in place, but i'm not too sure how to word that. This doesn't add a new error where there wasn't already one, as the search-insights library threw an error in this case already.
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit f812b80:
|
insightsClient, | ||
})({ instantSearchInstance }) | ||
).toThrowErrorMatchingInlineSnapshot( | ||
`"[insights middleware]: could not extract Algolia credentials from searchClient"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable, but I'm curious in which case searchClient didn't include the credentials? In that case, InstantSearch.js itself won't be functioning, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you do the following:
const client = algoliasearch()
const searchClient = {
search: client.search // or intercept
}
In that case only the "required" methods are present, as well as with a "backend search" without an algolia client the insights-thrown error is confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, that makes sense.
Summary
When api or appId is missing, an error gets thrown by search insights, but that doesn't explain why that error gets thrown.
Ideally this would also clarify what the next step is (usually making sure to spread the previous search client, or leaving all properties in place, but i'm not too sure how to word that.
This doesn't add a new error where there wasn't already one, as the search-insights library threw an error in this case already.
Result
An error that explains when the search client doesn't match insights' expectation