File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ class AnalyticsTracker {
1818 static EVENT_ID_NETWORK_REQUEST = 5000 ;
1919 static EVENT_ID_SEARCH_INPUT = 5001 ; // TODO change this after DAP update
2020
21+ static CONSENT_KEY = 'deepl_cookie_consent' ;
22+ static CONSENT_ACCEPTED = 'accepted' ;
23+
2124 static isProdStage = window . location . hostname === "developers.deepl.com" ;
2225 static statisticsUrl = this . isProdStage ?
2326 "https://s.deepl.com/web/statistics"
@@ -388,7 +391,7 @@ class AnalyticsTracker {
388391 // ========================
389392 static hasConsent ( ) {
390393 // Check localStorage for consent
391- return localStorage . getItem ( 'deepl_cookie_consent' ) === 'accepted' ;
394+ return localStorage . getItem ( this . CONSENT_KEY ) === this . CONSENT_ACCEPTED ;
392395 }
393396
394397 // ========================
Original file line number Diff line number Diff line change 1+ // Constants
2+ const CONSENT_KEY = 'deepl_cookie_consent' ;
3+ const CONSENT_ACCEPTED = 'accepted' ;
4+ const CONSENT_REJECTED = 'rejected' ;
5+
16const showCookieBanner = ( ) => {
27 // Check localStorage for consent
3- const consent = localStorage . getItem ( 'deepl_cookie_consent' ) ;
8+ const consent = localStorage . getItem ( CONSENT_KEY ) ;
49
510 // Only hide banner if user has explicitly accepted or rejected
6- if ( consent === 'accepted' || consent === 'rejected' ) return ;
11+ if ( consent === CONSENT_ACCEPTED || consent === CONSENT_REJECTED ) return ;
712
813 const banner = document . createElement ( 'div' ) ;
914 banner . id = 'cookie-banner' ;
@@ -28,14 +33,14 @@ const showCookieBanner = () => {
2833 const rejectBtn = document . getElementById ( 'cookie-reject' ) ;
2934
3035 acceptBtn . onclick = function ( ) {
31- localStorage . setItem ( 'deepl_cookie_consent' , 'accepted' ) ;
36+ localStorage . setItem ( CONSENT_KEY , CONSENT_ACCEPTED ) ;
3237 banner . remove ( ) ;
3338 // Reload to enable telemetry
3439 window . location . reload ( ) ;
3540 } ;
3641
3742 rejectBtn . onclick = function ( ) {
38- localStorage . setItem ( 'deepl_cookie_consent' , 'rejected' ) ;
43+ localStorage . setItem ( CONSENT_KEY , CONSENT_REJECTED ) ;
3944 banner . remove ( ) ;
4045 } ;
4146}
You can’t perform that action at this time.
0 commit comments