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

make Piwik.js generate proper visitor ID values #7335

Merged
merged 2 commits into from Mar 3, 2015
Merged

Conversation

mattab
Copy link
Member

@mattab mattab commented Mar 3, 2015

#7290

Note to self: do not merge pull request changing piwik.js without making sure it's tested thoroughly!

mattab pushed a commit that referenced this pull request Mar 3, 2015
make Piwik.js generate proper visitor ID values
@mattab mattab merged commit a27b89c into master Mar 3, 2015
@mattab mattab added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Mar 3, 2015
@mattab mattab added this to the Piwik 2.11.2 milestone Mar 3, 2015
@mattab mattab deleted the 7290_js_visitorid branch March 4, 2015 03:10
@@ -4012,6 +4060,7 @@ if (typeof Piwik !== 'object') {
*/
detectBrowserFeatures();
updateDomainHash();
setVisitorIdCookie();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you remember why this one is needed? It causes cookies to be set even if they might be disabled later via Tracker.disableCookies. Can we remove it from the constructor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this line is commented then following tests fail:

failed test after removing line

These tests were written to document the existing behaviour. I'm not 100% sure that these tests are correct but I think they are mostly correct... Let me know if you want more info

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setVisitorIdCookie() is only executed if Piwik.getTracker(url, siteId) is actually called this way and provided with a siteId. In all other cases (meaning when the default async tracker is used via _paq) this method will not have an effect since the method setVisitorIdCookie() will only do something if configTrackerSiteId is set.

The tests succeed when updating the test to eg from

var delayedTracker = Piwik.getTracker();

to

var delayedTracker = Piwik.getTracker();
delayedTracker.setSiteId(1);

which would be better. I think it is rather an accident that this test works because the tests are not atomic and do not reset everything in each test suite. In reality one would have to set at least a siteId making everything work again. This would also give developers a chance to do the following if they want:

var delayedTracker = Piwik.getTracker();
delayedTracker.disableCookies();
delayedTracker.setSiteId(1);

We should maybe remove the parameter siteId from Piwik.getTracker() at some point and for now just recommend to not use it if they want to use disableCookies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants