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
Don't create cookies when disabled #18935
Conversation
…g request first sent
…he cookie isn't set
build js |
All relevant tests now passing, so this is ready for review with particular consideration to implications for other plugins or unusual tracking setups. |
I looked through the code changes and imho they are looking fine. The only "issue" I could see is the slightly changed behavior when using multiple trackers. But that actually should only affect using the visitorid in the trackers before a first tracking request was send. To circumvent this, I guess the only possible solution would be to somehow store the initital visitorid in a global scope, that can be accessed in each tracker instance. But not sure if that is needed. |
@sgiehl I don't quite understand the issue. AFAIK, we expect each tracker to have a different visitorId, not the same. But I might remember it wrongly. In what case exactly would it cause an issue? Like how can it be reproduced? |
These tests suggest we want the same visitorId across trackers matomo/tests/javascript/index.php Line 2285 in e33a147
|
They are only the same if they point to the same URL and site. If there are different trackers used (pointing to a different site, matomo url, or cookie prefix), then they should be different. Which we can also see in matomo/tests/javascript/index.php Lines 2303 to 2312 in e33a147
Meaning it shouldn't be global if I see this right. Because in matomo/tests/javascript/index.php Line 2291 in e33a147
So the test is definitely expecting the right thing, the question is why isn't the |
@sgiehl I don't think that be a problem that often (using |
If we set the cookie when |
That be fine in that case @justinvelluppillai 👍 At least then people would have a way to fix this issue by calling |
…n getVisitorId is called, if it is not existing
build js |
build js |
build js |
build js |
Nice one thanks @tsteur. I've implemented that approach here and it passes tests without making those changes 👍 A couple of unrelated tests fail but this is good for review. |
@justinvelluppillai there is also |
build js |
@sgiehl I've added to now set visitor id cookie in |
build js |
build js |
Description:
Fixes #17892
Supersedes #18135 (created a few new PRs to get around submodule issues).
This PR moves visitorId cookie creation a bit later, ie only when needed for
trackPageView()
or similar call. VisitorId is now stored internally in the tracker to offset some of the impact of this, but in some cases where multiple trackers are being used there may be some functional differences as implied by the changes I've made to the tests where they only pass whentrackPageView()
is called before other tracker methods.Review