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

[FEAT]: Remember Cookie-Choice of the user #84

Closed
BerkeAras opened this issue Jul 16, 2021 · 0 comments
Closed

[FEAT]: Remember Cookie-Choice of the user #84

BerkeAras opened this issue Jul 16, 2021 · 0 comments

Comments

@BerkeAras
Copy link
Owner

Feature Request

Describe the Feature Request
Remember the Cookie-Choice of registered users.

Describe Preferred Solution
Store the cookie-choice in the Database

Describe Alternatives
N/A

Related Code

const acceptCookies = (e) => {
setCookiesAccepted(true)
localStorage.setItem('cookies_accepted', 'true')
}
const initializeTracking = (location) => {
if (process.env.REACT_APP_USE_GOOGLE_ANALYTICS == 'true') {
ReactGA.initialize(process.env.REACT_APP_GOOGLE_ANALYTICS, {
debug: false,
})
ReactGA.pageview(window.location.pathname)
}
}
const saveCookieSettings = () => {
if (analyticsCookiesChecked) {
// Analytics cookies are checked
initializeTracking(location)
localStorage.setItem('cookies_accepted', 'true')
} else {
// Remove cookies
document.cookie = '_ga=; Path=/; Domain=.example.com; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'
document.cookie = '_gat=; Path=/; Domain=.example.com; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'
document.cookie = '_gid=; Path=/; Domain=.example.com; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'
// Remove G-Analytics
if (document.querySelector('script[src="https://www.google-analytics.com/analytics.js"]')) {
document.querySelector('script[src="https://www.google-analytics.com/analytics.js"]').remove()
}
localStorage.removeItem('cookies_accepted')
localStorage.setItem('cookies_accepted', 'technical')
}
setCookiesAccepted(true)
setShowCookieSettingsModal(false)
}

Additional Context

N/A

@BerkeAras BerkeAras added the enhancement New feature or request label Jul 16, 2021
@BerkeAras BerkeAras added this to To do in WorkGroup-Board via automation Jul 16, 2021
WorkGroup-Board automation moved this from To do to Done Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant