-
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
feat(insights): accept initParams for insightsClient #4608
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 8bbb98e:
|
what if the events get queued until the user token is given, so they don't get forgotten (like it works with |
but And if we just queue it and wait for user token, it might be problematic if they forgot to set user token and the events will be missing with no error or warning. |
regardless of what I'm suggesting next, I feel like this PR makes sense, however I think we should rethink useCookie; instead we should add If you add a userToken to init, there's no need for the anonymous token, and thus no use for the cookie either. This doesn't solve the "we want anonymous token but no cookie" use case, but neither does useCookie: false today. You could pass |
@Haroenv That is actually a good point. With |
Summary
This PR accepts new
initParams
atinsights
middleware for initializinginsightsClient
.It can be used to disable cookie like above. (The
useCookie
option is being implemented at the moment in algolia/search-insights.js#236)An extra thought about
useCookie: false
https://codesandbox.io/s/instantsearchjs-forked-5wu8h?file=/src/app.js:976-1197
If user passes
useCookie: false
, theinsightsClient
won't have any token at the time of initialization (because it will skip generating an anonymous user token).When the insights middleware will try to send events,
insightsClient
will throw, saying userToken is missing. However in that case, it doesn't make sense to send events when userToken is not specified. So they will have to postpone adding insights middleware.