You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: save existing anon tokens for multiple init calls (#562)
### Context
In InstantSearch, in order for user tokens to be set in time for the
first query on page load, anonymous user tokens are generated and set as
both the InstantSearch token and Insights token.
This flow has one issue though. When `useCookies` flag needs to be
changed later (such as with a cookie consent banner), a second `init`
call to insights with the flag set to true does not save the existing
token to a cookie.
A short repro is as follows with the very latest version of
InstantSearch where this behaviour was added (PR:
algolia/instantsearch#6377):
```js
const searchClient = algoliasearch(
// ...
);
window.aa('init', {
appId: 'id',
apiKey: 'key',
});
const search = instantsearch({
indexName: 'index',
searchClient,
insights: true,
});
search.addWidgets([
// ...
]);
// This does not save the cookie atm
setTimeout(() => {
window.aa('init', {
partial: true,
useCookie: true,
});
}, 5000);
```
0 commit comments