Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/web-roo-code/.env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# PostHog Analytics Configuration
# Replace these values with your actual PostHog API key and host
NEXT_PUBLIC_POSTHOG_KEY=your_posthog_api_key_here
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com

# Basin Form Endpoint for Static Form Submissions
# Replace this with your actual Basin form endpoint (e.g., https://usebasin.com/f/your-form-id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
// Initialize PostHog immediately on the client side
if (typeof window !== "undefined" && !posthog.__loaded) {
const posthogKey = process.env.NEXT_PUBLIC_POSTHOG_KEY
const posthogHost = process.env.NEXT_PUBLIC_POSTHOG_HOST

// Check if environment variables are set
if (!posthogKey) {
Expand All @@ -43,19 +42,13 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
return
}

if (!posthogHost) {
console.warn(
"PostHog host URL is missing. Using default host. " +
"Please set NEXT_PUBLIC_POSTHOG_HOST in your .env file.",
)
}

// Check if user has already consented to cookies
const userHasConsented = hasConsent()

// Initialize PostHog with appropriate persistence based on consent
posthog.init(posthogKey, {
api_host: posthogHost || "https://us.i.posthog.com",
api_host: "https://ph.roocode.com",
ui_host: "https://us.posthog.com",
capture_pageview: false, // We handle pageview tracking manually
loaded: (posthogInstance) => {
if (process.env.NODE_ENV === "development") {
Expand Down
2 changes: 1 addition & 1 deletion packages/telemetry/src/PostHogTelemetryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class PostHogTelemetryClient extends BaseTelemetryClient {
debug,
)

this.client = new PostHog(process.env.POSTHOG_API_KEY || "", { host: "https://us.i.posthog.com" })
this.client = new PostHog(process.env.POSTHOG_API_KEY || "", { host: "https://ph.roocode.com" })
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ export class ClineProvider
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; font-src ${webview.cspSource} data:; style-src ${webview.cspSource} 'unsafe-inline'; img-src ${webview.cspSource} https://storage.googleapis.com https://img.clerk.com data:; media-src ${webview.cspSource}; script-src ${webview.cspSource} 'wasm-unsafe-eval' 'nonce-${nonce}' https://us-assets.i.posthog.com 'strict-dynamic'; connect-src ${webview.cspSource} ${openRouterDomain} https://api.requesty.ai https://us.i.posthog.com https://us-assets.i.posthog.com;">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; font-src ${webview.cspSource} data:; style-src ${webview.cspSource} 'unsafe-inline'; img-src ${webview.cspSource} https://storage.googleapis.com https://img.clerk.com data:; media-src ${webview.cspSource}; script-src ${webview.cspSource} 'wasm-unsafe-eval' 'nonce-${nonce}' https://ph.roocode.com 'strict-dynamic'; connect-src ${webview.cspSource} ${openRouterDomain} https://api.requesty.ai https://ph.roocode.com;">
<link rel="stylesheet" type="text/css" href="${stylesUri}">
<link href="${codiconsUri}" rel="stylesheet" />
<script nonce="${nonce}">
Expand Down
2 changes: 1 addition & 1 deletion src/core/webview/__tests__/ClineProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ describe("ClineProvider", () => {

// Verify Content Security Policy contains the necessary PostHog domains
expect(mockWebviewView.webview.html).toContain(
"connect-src vscode-webview://test-csp-source https://openrouter.ai https://api.requesty.ai https://us.i.posthog.com https://us-assets.i.posthog.com",
"connect-src vscode-webview://test-csp-source https://openrouter.ai https://api.requesty.ai https://ph.roocode.com",
)

// Extract the script-src directive section and verify required security elements
Expand Down
2 changes: 1 addition & 1 deletion webview-ui/src/__tests__/TelemetryClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe("TelemetryClient", () => {
expect(posthog.init).toHaveBeenCalledWith(
API_KEY,
expect.objectContaining({
api_host: "https://us.i.posthog.com",
api_host: "https://ph.roocode.com",
persistence: "localStorage",
loaded: expect.any(Function),
}),
Expand Down
3 changes: 2 additions & 1 deletion webview-ui/src/utils/TelemetryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class TelemetryClient {
TelemetryClient.telemetryEnabled = true

posthog.init(apiKey, {
api_host: "https://us.i.posthog.com",
api_host: "https://ph.roocode.com",
ui_host: "https://us.posthog.com",
persistence: "localStorage",
loaded: () => posthog.identify(distinctId),
capture_pageview: false,
Expand Down
2 changes: 1 addition & 1 deletion webview-ui/src/utils/__tests__/TelemetryClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe("TelemetryClient", () => {
expect(posthog.init).toHaveBeenCalledWith(
API_KEY,
expect.objectContaining({
api_host: "https://us.i.posthog.com",
api_host: "https://ph.roocode.com",
persistence: "localStorage",
loaded: expect.any(Function),
}),
Expand Down
Loading