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.
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 secondinit
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: https://github.com/algolia/instantsearch/pull/6377):