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

Cookie_Hover_Box #1127

Merged
merged 11 commits into from
Feb 25, 2022
Merged

Cookie_Hover_Box #1127

merged 11 commits into from
Feb 25, 2022

Conversation

bhaggya
Copy link
Contributor

@bhaggya bhaggya commented Jan 24, 2022

Closes #1075

@mealthebear
Copy link
Member

The PopUp.js file may be better suited for the components folder

Copy link
Member

@mealthebear mealthebear left a comment

Choose a reason for hiding this comment

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

Found some areas for touch ups; this looks pretty good so far!

Comment on lines 67 to 84
const setCookie = function (cookieEmail, cookieValue, expDays) {
date.setTime(date.getTime() + expDays);

const expires = 'expires=' + date.toUTCString();

document.cookie = cookieEmail + cookieValue + ';' + expires + ';path=/';

return document.cookie;
};

const deleteCookie = function (cookieEmail) {
date.setTime(date.getTime());
const expires = 'expires=' + date.toUTCString();
document.cookie = cookieEmail + expires + ';path=/';
};
const acceptCookieConsent = () => {
deleteCookie('civictecindex_cookie_consent');
setCookie('civictecindex_cookie_consent', 1, 30);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I'm not sure what the intended behavior for the cookie should be: currently the way it looks like it's working is the date is registered upon the user visiting the site, not when the user clicks 'Accept' on the cookie pop-up.

One concern I wanted to bring up is in certain scenarios where the user takes a while to select 'Accept', or visits the page but leaves it open for a long period of time.

This could potentially paint an inaccurate picture of traffic. Then again, maybe we only want to know the time when they just visit the site.

Wanted to bring this up to attention after playing around with and testing the cookie in the browser. :)

Hi Dennis
I was not told anything about functionality, I was just told to code as per reference with 311 data. I think the functionality will be told after

Comment on lines 83 to 84
deleteCookie('civictecindex_cookie_consent');
setCookie('civictecindex_cookie_consent', 1, 30);
Copy link
Member

Choose a reason for hiding this comment

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

Add missing letter 'h' to 'civictechindex'

Suggested change
deleteCookie('civictecindex_cookie_consent');
setCookie('civictecindex_cookie_consent', 1, 30);
deleteCookie('civictechindex_cookie_consent');
setCookie('civictechindex_cookie_consent', 1, 30);

Comment on lines 68 to 80
date.setTime(date.getTime() + expDays);

const expires = 'expires=' + date.toUTCString();

document.cookie = cookieEmail + cookieValue + ';' + expires + ';path=/';

return document.cookie;
};

const deleteCookie = function (cookieEmail) {
date.setTime(date.getTime());
const expires = 'expires=' + date.toUTCString();
document.cookie = cookieEmail + expires + ';path=/';
Copy link
Member

Choose a reason for hiding this comment

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

I recommend replacing string concatenation with template literals.

Suggested change
date.setTime(date.getTime() + expDays);
const expires = 'expires=' + date.toUTCString();
document.cookie = cookieEmail + cookieValue + ';' + expires + ';path=/';
return document.cookie;
};
const deleteCookie = function (cookieEmail) {
date.setTime(date.getTime());
const expires = 'expires=' + date.toUTCString();
document.cookie = cookieEmail + expires + ';path=/';
date.setTime(date.getTime() + expDays);
const expires = `expires=${date.toUTCString()}`;
document.cookie = `${cookieEmail}${cookieValue};${expires};path=/`;
return document.cookie;
};
const deleteCookie = function (cookieEmail) {
date.setTime(date.getTime());
const expires = `expires=${date.toUTCString()}`;
document.cookie = `${cookieEmail}${expires};path=/`

@mealthebear
Copy link
Member

So, I'm not sure what the intended behavior for the cookie should be: currently the way it looks like it's working is the date is registered upon the user visiting the site, not when the user clicks 'Accept' on the cookie pop-up.

One concern I wanted to bring up is in certain scenarios where the user takes a while to select 'Accept', or visits the page but leaves it open for a long period of time.

This could potentially paint an inaccurate picture of traffic. Then again, maybe we only want to know the time when they just visit the site.

Wanted to bring this up to attention after playing around with and testing the cookie in the browser. :)

@bruceplai
Copy link
Member

Just a reminder to close the privacy popup during the footer.spec test. Also, if possible, please create tests in a privacy.spec.js test file so that we have coverage of this new functionality. If any help/guidance is needed, let me know. Thank you!

Comment on lines 67 to 84
const setCookie = function (cookieEmail, cookieValue, expDays) {
date.setTime(date.getTime() + expDays);

const expires = 'expires=' + date.toUTCString();

document.cookie = cookieEmail + cookieValue + ';' + expires + ';path=/';

return document.cookie;
};

const deleteCookie = function (cookieEmail) {
date.setTime(date.getTime());
const expires = 'expires=' + date.toUTCString();
document.cookie = cookieEmail + expires + ';path=/';
};
const acceptCookieConsent = () => {
deleteCookie('civictecindex_cookie_consent');
setCookie('civictecindex_cookie_consent', 1, 30);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I'm not sure what the intended behavior for the cookie should be: currently the way it looks like it's working is the date is registered upon the user visiting the site, not when the user clicks 'Accept' on the cookie pop-up.

One concern I wanted to bring up is in certain scenarios where the user takes a while to select 'Accept', or visits the page but leaves it open for a long period of time.

This could potentially paint an inaccurate picture of traffic. Then again, maybe we only want to know the time when they just visit the site.

Wanted to bring this up to attention after playing around with and testing the cookie in the browser. :)

Hi Dennis
I was not told anything about functionality, I was just told to code as per reference with 311 data. I think the functionality will be told after

@bhaggya
Copy link
Contributor Author

bhaggya commented Jan 27, 2022

So, I'm not sure what the intended behavior for the cookie should be: currently the way it looks like it's working is the date is registered upon the user visiting the site, not when the user clicks 'Accept' on the cookie pop-up.

One concern I wanted to bring up is in certain scenarios where the user takes a while to select 'Accept', or visits the page but leaves it open for a long period of time.

This could potentially paint an inaccurate picture of traffic. Then again, maybe we only want to know the time when they just visit the site.

Wanted to bring this up to attention after playing around with and testing the cookie in the browser. :)

I don;t understand what you are saying

@mealthebear
Copy link
Member

My bad; ignore my previous comment. I got confused if we had already talked about how the cookie works.

date.setTime(date.getTime() + expDays);
const expires = 'expires=' + date.toUTCString();

document.cookie = `${cookieEmail} + ${cookieValue} + ';' + ${expires} + ';path=/'`;
Copy link
Member

Choose a reason for hiding this comment

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

With template literals, the pluses don't need to be used. It will actually show up in the string that way.

Suggested change
document.cookie = `${cookieEmail} + ${cookieValue} + ';' + ${expires} + ';path=/'`;
document.cookie = `${cookieEmail}${cookieValue}';'${expires}';path=/'`;

const deleteCookie = function (cookieEmail) {
date.setTime(date.getTime());
const expires = 'expires=' + date.toUTCString();
document.cookie = `${cookieEmail} + ${expires} + ';path=/'`;
Copy link
Member

Choose a reason for hiding this comment

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

Same thing here with template literal

Suggested change
document.cookie = `${cookieEmail} + ${expires} + ';path=/'`;
document.cookie = `${cookieEmail}${expires}';path=/'`;

mealthebear
mealthebear previously approved these changes Jan 28, 2022
Copy link
Member

@mealthebear mealthebear left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks Bhaggya!

@bhaggya
Copy link
Contributor Author

bhaggya commented Jan 28, 2022

Looks good to me. Thanks Bhaggya!

Thanks for reviewing my code and letting me know

@bruceplai
Copy link
Member

@smsada @kevindphan there is still the visual side effect of the privacy popup shifting to the left a few pixels when hovering over the header menu items (possibly due the scroll bar disappearing/appearing). Can we still merge this PR?

@bruceplai
Copy link
Member

PMs have decided to hold off on merging this until after MVP

@bruceplai bruceplai marked this pull request as draft February 1, 2022 04:20
@bhaggya bhaggya marked this pull request as ready for review February 18, 2022 02:51
@codeclimate
Copy link

codeclimate bot commented Feb 25, 2022

Code Climate has analyzed commit 4f54f78 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 81.0% (0.2% change).

View more on Code Climate.

@bruceplai bruceplai merged commit 47017c1 into main Feb 25, 2022
@bruceplai bruceplai deleted the Hover_Cookie_Box branch February 25, 2022 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create privacy policy web hover box
3 participants