Skip to content

Commit fc023e2

Browse files
committed
remove unnecessary backwards compatibility and require re-opt-in
1 parent ea31240 commit fc023e2

2 files changed

Lines changed: 5 additions & 30 deletions

File tree

analytics.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -388,19 +388,7 @@ class AnalyticsTracker {
388388
// ========================
389389
static hasConsent() {
390390
// Check localStorage for consent
391-
const localStorageConsent = localStorage.getItem('deepl_cookie_consent');
392-
if (localStorageConsent === 'accepted') {
393-
return true;
394-
}
395-
396-
// Also check cookie for backward compatibility
397-
const cookies = document.cookie.split('; ');
398-
const consentCookie = cookies.find(c => c.startsWith('cookie_consent='));
399-
if (consentCookie && consentCookie.split('=')[1] === 'true') {
400-
return true;
401-
}
402-
403-
return false;
391+
return localStorage.getItem('deepl_cookie_consent') === 'accepted';
404392
}
405393

406394
// ========================

cookie-banner.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
function getCookie(name) {
2-
const value = `; ${document.cookie}`;
3-
const parts = value.split(`; ${name}=`);
4-
if (parts.length === 2) return parts.pop().split(';').shift();
5-
}
6-
71
const showCookieBanner = () => {
8-
// Check both localStorage and cookie for consent
9-
const localStorageConsent = localStorage.getItem('deepl_cookie_consent');
10-
const cookieConsent = getCookie('cookie_consent');
2+
// Check localStorage for consent
3+
const consent = localStorage.getItem('deepl_cookie_consent');
114

12-
if (localStorageConsent === 'accepted' || cookieConsent === 'true') return;
5+
// Only hide banner if user has explicitly accepted or rejected
6+
if (consent === 'accepted' || consent === 'rejected') return;
137

148
const banner = document.createElement('div');
159
banner.id = 'cookie-banner';
@@ -32,23 +26,16 @@ const showCookieBanner = () => {
3226

3327
const acceptBtn = document.getElementById('cookie-accept');
3428
const rejectBtn = document.getElementById('cookie-reject');
35-
const ONE_YEAR_SECONDS = 60 * 60 * 24 * 365;
3629

3730
acceptBtn.onclick = function () {
38-
// Set localStorage for Mintlify telemetry integration
3931
localStorage.setItem('deepl_cookie_consent', 'accepted');
40-
// Also set cookie for backward compatibility
41-
document.cookie = 'cookie_consent=true; path=/; max-age=' + ONE_YEAR_SECONDS;
4232
banner.remove();
4333
// Reload to enable telemetry
4434
window.location.reload();
4535
};
4636

4737
rejectBtn.onclick = function () {
48-
// Set localStorage to rejected state
4938
localStorage.setItem('deepl_cookie_consent', 'rejected');
50-
// Also set cookie for backward compatibility
51-
document.cookie = 'cookie_consent=false; path=/; max-age=' + ONE_YEAR_SECONDS;
5239
banner.remove();
5340
};
5441
}

0 commit comments

Comments
 (0)