Skip to content

Commit e646a5b

Browse files
committed
PR feedback
1 parent 045bf04 commit e646a5b

File tree

5 files changed

+26
-28
lines changed

5 files changed

+26
-28
lines changed

package-lock.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
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",

src/components/PostHogProvider/index.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff 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

src/constants.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,4 @@ export const OPEN_VSX_URL = 'https://open-vsx.org/extension/RooVeterinaryInc/roo
2828
export const CONTACT_EMAIL = 'mailto:[email protected]';
2929
export const CAREERS_URL = 'https://careers.roocode.com';
3030
export 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`;

src/lib/analytics/consent-manager.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
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
45
export 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
*/
3738
export 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
/**

0 commit comments

Comments
 (0)