Skip to content
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

ai_user cookie not present after reenabling the cookie #1585

Closed
julen-folky opened this issue Jun 17, 2021 · 5 comments
Closed

ai_user cookie not present after reenabling the cookie #1585

julen-folky opened this issue Jun 17, 2021 · 5 comments

Comments

@julen-folky
Copy link

My app (Vue) starts with the cookies disabled (disableCookiesUsage set to true).
When the user consents cookies, the app enables the cookies (getCookieMgr().setEnabled(true)).
After a breve navigation the ai_session is set but the ai_user is not.
I recently moved to the lastest version of the package (from 2.5.X to 2.6.2).
Is this an issue, somehting I am missing or just the ai_user is no longer used?

@MSNev
Copy link
Collaborator

MSNev commented Jun 17, 2021

Simply, re-enabling cookies does not cause the code that creates cookies to execute -- likewise disabling cookies doesn't delete them.

The ai_user cookie is still used, but it's only "created" as part of the creating (loading) of the SDK...

The assumption is that the next time your app/page loads cookies will be enabled and therefore the ai_user would get created...

As your using Vue, can I assume your case is a SPA and you won't be "reloading" and therefore "creating" an instance?

@julen-folky
Copy link
Author

Exactly, after the first load the page will not be load again.
If the ai_user is not set, I guess some info is not going to be collected (before your reply I assume that if ai_session would be in charge of that in 2.6.2).
Should I manually set the cookie? But, how can I know its value?
(BTW, thank you for your help)

@MSNev
Copy link
Collaborator

MSNev commented Jun 18, 2021

users and sessions are slightly different concepts.
So with no user cookie the user would be considered to be effectively "anonymous" (same as if the user blocked cookies on the browser) and therefore they would be lumped together (I'm not sure how this is visualized in the portal)
And the session is "refreshed" after around 30mins (depending on whether the user stays active)

In theory you could set the value yourself but that is not supported and will be potentially broken in a future release.

We already have a setAuthenticatedUser which you could possibly use as a fudge to workaround this (when stored in the cookie it is a session cookie)
_self.setAuthenticatedUserContext = (authenticatedUserId: string, accountId?: string, storeInCookie = false) => {

I'm going to mark this Issue as an enhancement on the basis that we should add a new function suggestion setUserCookie to handle this scenario. Not currently sure on the timing of when this might get added.

@MSNev MSNev added enhancement SPA support Required to support SPA style apps labels Jun 18, 2021
@MSNev MSNev added this to the 2.x.x (Next Release) milestone Aug 10, 2021
@xiao-lix xiao-lix added the fixed - waiting release PR Committed and waiting deployment label Aug 11, 2021
MSNev added a commit that referenced this issue Aug 11, 2021
- Add optimization to avoid always updating the cookie value
MSNev added a commit that referenced this issue Aug 11, 2021
* ai_user cookie not present after reenabling the cookie #1585
- Add optimization to avoid always updating the cookie value

* Add missing result setting
@MSNev
Copy link
Collaborator

MSNev commented Sep 13, 2021

v2.7.0 is not fully deployed to NPM and all CDN endpoints

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants