File tree Expand file tree Collapse file tree 5 files changed +26
-28
lines changed
components/PostHogProvider Expand file tree Collapse file tree 5 files changed +26
-28
lines changed Original file line number Diff line number Diff line change 2323 "@docusaurus/preset-classic" : " ^3.8.1" ,
2424 "@easyops-cn/docusaurus-search-local" : " ^0.48.5" ,
2525 "@mdx-js/react" : " ^3.0.0" ,
26+ "@roo-code/types" : " ^1.79.0" ,
2627 "@vscode/codicons" : " ^0.0.36" ,
2728 "clsx" : " ^2.0.0" ,
2829 "posthog-docusaurus" : " ^2.0.4" ,
Original file line number Diff line number Diff line change @@ -46,18 +46,6 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
4646 if ( typeof window !== 'undefined' && window . posthog ) {
4747 window . posthog . opt_out_capturing ( ) ;
4848 window . posthog . stop_session_recording ( ) ;
49- if ( document ) {
50- const cookies = document . cookie . split ( ';' ) ;
51- cookies . forEach ( cookie => {
52- const eqPos = cookie . indexOf ( '=' ) ;
53- const name = eqPos > - 1 ? cookie . substr ( 0 , eqPos ) . trim ( ) : cookie . trim ( ) ;
54- if ( name . startsWith ( 'ph_' ) || name . startsWith ( 'posthog' ) ) {
55- // Delete PostHog related cookies
56- document . cookie = `${ name } =; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=.roocode.com` ;
57- document . cookie = `${ name } =; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/` ;
58- }
59- } ) ;
60- }
6149 }
6250 } ;
6351
Original file line number Diff line number Diff line change @@ -28,7 +28,4 @@ export const OPEN_VSX_URL = 'https://open-vsx.org/extension/RooVeterinaryInc/roo
2828export const CONTACT_EMAIL = 'mailto:[email protected] ' ; 2929export const CAREERS_URL = 'https://careers.roocode.com' ;
3030export const WEBSITE_PRIVACY_URL = 'https://roocode.com/privacy' ;
31- export const EXTENSION_PRIVACY_URL = `${ GITHUB_MAIN_REPO_URL } /blob/main/PRIVACY.md` ;
32-
33- // Cookies
34- export const CONSENT_COOKIE_NAME = "roo-code-cookie-consent" ;
31+ export const EXTENSION_PRIVACY_URL = `${ GITHUB_MAIN_REPO_URL } /blob/main/PRIVACY.md` ;
Original file line number Diff line number Diff line change 1- import { CONSENT_COOKIE_NAME } from '../../constants' ;
1+ import { CONSENT_COOKIE_NAME } from '@roo-code/types' ;
2+ import { getCookieConsentValue } from 'react-cookie-consent' ;
23
34// Custom event names for consent tracking
45export const CONSENT_GRANTED_EVENT = 'cookieConsentGranted' ;
@@ -31,20 +32,12 @@ export function dispatchConsentEvent(granted: boolean): void {
3132}
3233
3334/**
34- * Checks if the user has already provided consent
35- * @returns boolean indicating if consent cookie exists and is set to 'true'
35+ * Check if user has given consent for analytics cookies
36+ * Uses react-cookie- consent's built-in function
3637 */
3738export function hasConsent ( ) : boolean {
3839 if ( typeof window === 'undefined' ) return false ;
39-
40- const cookies = document . cookie . split ( ';' ) ;
41- for ( let cookie of cookies ) {
42- const [ name , value ] = cookie . trim ( ) . split ( '=' ) ;
43- if ( name === CONSENT_COOKIE_NAME ) {
44- return value === 'true' ;
45- }
46- }
47- return false ;
40+ return getCookieConsentValue ( CONSENT_COOKIE_NAME ) === 'true' ;
4841}
4942
5043/**
You can’t perform that action at this time.
0 commit comments