-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,11 +225,27 @@ export function createInsightsMiddleware< | |
immediate: true, | ||
}); | ||
|
||
// @ts-ignore | ||
const insightsClientWithLocalCredentials = (method, payload) => { | ||
return insightsClient(method, payload, { | ||
headers: { | ||
'X-Algolia-Application-Id': appId, | ||
'X-Algolia-API-Key': apiKey, | ||
}, | ||
}); | ||
}; | ||
|
||
instantSearchInstance.sendEventToInsights = (event: InsightsEvent) => { | ||
if (onEvent) { | ||
onEvent(event, _insightsClient as TInsightsClient); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe passing There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)? |
||
onEvent( | ||
event, | ||
insightsClientWithLocalCredentials as TInsightsClient | ||
); | ||
} else if (event.insightsMethod) { | ||
insightsClient(event.insightsMethod, event.payload); | ||
insightsClientWithLocalCredentials( | ||
event.insightsMethod, | ||
event.payload | ||
); | ||
|
||
warning( | ||
Boolean((helper.state as PlainSearchParameters).userToken), | ||
|
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.
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.