-
Notifications
You must be signed in to change notification settings - Fork 529
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
feat(createInsightsMiddleware): always pass Algolia credentials locally #5554
feat(createInsightsMiddleware): always pass Algolia credentials locally #5554
Conversation
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 0b73dfd:
|
1299efc
to
71f997d
Compare
instantSearchInstance.sendEventToInsights = (event: InsightsEvent) => { | ||
if (onEvent) { | ||
onEvent(event, _insightsClient as TInsightsClient); |
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.
I believe passing _insightsClient
here was a bug, as this wouldn't point to the right function in an auto-pulled scenario.
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 yes, with auto-pulling that is wrong, but it used to be the user-provided one on purpose in case someone passes null
, the insightsClient
would be null and not noop, but that's not very different
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.
Do you think it should stay nullable (e.g., when opting-out of auto-pull)?
71f997d
to
102d61f
Compare
102d61f
to
0b73dfd
Compare
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.
👍
// @ts-ignore | ||
const insightsClientWithLocalCredentials = (method, payload) => { |
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.
// @ts-ignore | |
const insightsClientWithLocalCredentials = (method, payload) => { | |
const insightsClientWithLocalCredentials: InsightsClient = (method, payload) => { |
does that work without angering TS?
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.
Not yet, we need to release the new version of the Insights client so that the types are up to date.
I can do it in a different PR if we don't release it before we're ready to merge this one.
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.
looks good like this
This attaches the Algolia credentials to each event we send, via
headers
.The goal is to ensure events are always sent to the right app even when the Insights client is shared—for example, when using InstantSearch together with Autocomplete.
FX-2278