Skip to content

Commit a989695

Browse files
committed
Generalzies cookie scope to *.roocode.com, exposts constants
1 parent 1b7b71c commit a989695

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

apps/web-roo-code/src/components/CookieConsent.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"use client"
22

3-
import React from "react"
3+
import React, { useState, useEffect } from "react"
44
import ReactCookieConsent from "react-cookie-consent"
55
import { Cookie } from "lucide-react"
6+
import { CONSENT_COOKIE_NAME, CONSENT_COOKIE_DOMAIN } from "@/lib/constants"
67

78
export interface CookieConsentProps {
89
/**
@@ -43,9 +44,19 @@ export function CookieConsent({
4344
onAccept,
4445
onDecline,
4546
className = "",
46-
cookieName = "roo-code-cookie-consent",
47+
cookieName = CONSENT_COOKIE_NAME,
4748
debug = false,
4849
}: CookieConsentProps) {
50+
const [hostname, setHostname] = useState<string>("localhost")
51+
52+
useEffect(() => {
53+
setHostname(window.location.hostname)
54+
}, [])
55+
56+
const extraCookieOptions = {
57+
domain: process.env.NODE_ENV === "production" ? hostname : CONSENT_COOKIE_DOMAIN,
58+
}
59+
4960
const containerClasses = `
5061
fixed bottom-2 left-2 right-2 z-[999]
5162
bg-black/95 dark:bg-white/95
@@ -109,6 +120,7 @@ export function CookieConsent({
109120
buttonClasses={acceptButtonClasses}
110121
buttonWrapperClasses={buttonWrapperClasses}
111122
declineButtonClasses={declineButtonClasses}
123+
extraCookieOptions={extraCookieOptions}
112124
disableStyles={true}
113125
ariaAcceptLabel={`Accept`}
114126
ariaDeclineLabel={`Decline`}>

apps/web-roo-code/src/lib/analytics/consent-manager.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
* Works with react-cookie-consent library
44
*/
55

6-
/**
7-
* Cookie name used by react-cookie-consent
8-
*/
9-
const CONSENT_COOKIE_NAME = "roo-code-cookie-consent"
6+
import { CONSENT_COOKIE_NAME } from "../constants"
107

118
/**
129
* Event name for consent changes

apps/web-roo-code/src/lib/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ export const EXTERNAL_LINKS = {
3030
export const INTERNAL_LINKS = {
3131
PRIVACY_POLICY_WEBSITE: "/privacy",
3232
}
33+
34+
// Cookie consent settings
35+
export const CONSENT_COOKIE_NAME = "roo-code-cookie-consent"
36+
export const CONSENT_COOKIE_DOMAIN = process.env.CONSENT_COOKIE_DOMAIN || "roocode.com"

0 commit comments

Comments
 (0)