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
Amend explicit-cross-domain-links.js
code
#2464
Conversation
explicit-cross-domain-links.js
code
d002a77
to
37fdda1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, one minor comment.
The code for explicit-cross-domain-links
was already a bit of a spaghetti before these changes, I think once this change has gone in we should look at refactoring the code a little bit to make it clearer. Specifically there are a lot of guard clauses in the start
function that maybe could be consolidated, and the whole thing could be restructured to make it more understandable. Something like:
window.addEventListener('cookie-consent', this.cookiesAreAccepted)
window.addEventListener('cookie-reject', this.cookiesAreRejected)
...
this.cookiesAreNotAnything = function () {
this.decorate(element, 'cookie_consent=not-engaged')
}
this.cookiesAreAccepted = function () {
// something here
}
this.cookiesAreRejected = function () {
this.decorate(element, 'cookie_consent=reject')
}
GOVUK.cookie('cookies_preferences_set', null) | ||
explicitCrossDomainLinks.start(element) | ||
|
||
GOVUK.cookie('cookies_preferences_set', 'true') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These three lines appear to be duplicated in the previous test - could they be moved into a beforeEach
function for this describe
block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point, have updated as suggested.
37fdda1
to
2cfa80f
Compare
Amend explicit-cross-domain-links code to account for the possibility of someone accepting/rejecting cookies on the page that the cross-domain link is present. On detecting the cookie consent or rejection event, the cross-domain link module should re-run and append the correct parameters to any cross domain links present on the page.
2cfa80f
to
359bbe5
Compare
Amend
explicit-cross-domain-links
code to account for the possibility of someone accepting/rejecting cookies on the page that the cross-domain link is present.This was raised as a bug on the Brexit page, where the Sign in link is a cross-domain link (leading to DI Sign In territory).
If someone has interacted with the cookie banner on this page, the link treats them as if they have not, i.e the
?cookie_consent=not_engaged
parameter remains unchanged, and the GA parameter is not added (if they have accepted cookies). The setting applies only after the page is reloaded.Before (the correct parameters are appended to the cross domain link only after the page is reloaded)
Screen.Recording.2021-11-23.at.11.37.33.mov
After (the correct parameters are appended to the cross domain link instantly when cookies are accepted or rejected)
Screen.Recording.2021-11-23.at.13.30.20.mov
Upon detecting the cookie consent or rejection event, the cross-domain link module should re-run and append the correct parameters to any cross domain links present on the page.