@justinvelluppillai opened this Pull Request on July 8th 2021 Contributor

Description:

Fixes #17417 by setting the cookie domain (configCookieDomain) even when cookies are disabled.

Also checks whether setCookie is able to successfully create a cookie and if not, log a console message for visibility.

Build js

Review

  • [ ] Functional review done
  • [ ] Potential edge cases thought about (behavior of the code with strange input, with strange internal state or possible interactions with other Matomo subsystems)
  • [ ] Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • [ ] Security review done see checklist
  • [ ] Code review done
  • [ ] Tests were added if useful/possible
  • [ ] Reviewed for breaking changes
  • [ ] Developer changelog updated if needed
  • [ ] Documentation added if needed
  • [ ] Existing documentation updated if needed
@justinvelluppillai commented on July 8th 2021 Contributor

build js

@diosmosis commented on July 11th 2021 Member

Tested locally via the test-examples repo, after adding the following code:

        _paq.push(['requireCookieConsent']);
        _paq.push(["setCookieDomain", ".matomotestexamples"]);

And viewing the page on the www.matomotestexamples URL (both mapped via /etc/hosts).

On 4.x-dev, rememberConsentGiven() creates cookies (only one set, for the www.matomotestexamples domain). On this branch, the cookies are not created and the message "There was an error setting the cookie" is in the console log. I'm not sure why it works in one but not the other...

@justinvelluppillai commented on July 11th 2021 Contributor

@diosmosis I think that issue is because you are trying to set cookies on a top level domain (.matomotestexamples). Other than that your results are as I expect.

@diosmosis commented on July 11th 2021 Member

@justinvelluppillai would you know why it works without your changes and sets the cookie correctly, but doesn't w/ the changes? I don't see anything in the code that could cause this, but it is reproducible.

@justinvelluppillai commented on July 11th 2021 Contributor

@diosmosis it used to set the cookie on the wrong domain, ignoring the setCookieDomain directive. On the new it doesn't ignore the setCookieDomain directive and tries to set the cookie on the domain specified, but you have specified a top level domain on which it can't set a cookie, therefore it doesn't set the cookie on the new. Once you change the test domains to for example www.matomotestexamples.matomo and .matomotestexamples.matomo it will work

@diosmosis commented on July 11th 2021 Member

@justinvelluppillai I see, thanks for the explanation!

@diosmosis commented on July 11th 2021 Member

@justinvelluppillai fyi, there are still some JSLint errors it seems

@justinvelluppillai commented on July 14th 2021 Contributor

build js

@justinvelluppillai commented on July 15th 2021 Contributor

build js

@justinvelluppillai commented on July 15th 2021 Contributor

build js

@justinvelluppillai commented on July 15th 2021 Contributor

Passing js tests now @diosmosis - took me a few iterations of adding semicolons to get it through the jslint-ing.

This Pull Request was closed on July 15th 2021
Powered by GitHub Issue Mirror