Skip to content

Commit ee19904

Browse files
roomote[bot]roomotemrubens
authored
feat: migrate PostHog client to ph.roocode.com (#9402)
Co-authored-by: Roo Code <[email protected]> Co-authored-by: Matt Rubens <[email protected]>
1 parent 61fc391 commit ee19904

File tree

8 files changed

+9
-16
lines changed

8 files changed

+9
-16
lines changed

apps/web-roo-code/.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# PostHog Analytics Configuration
22
# Replace these values with your actual PostHog API key and host
33
NEXT_PUBLIC_POSTHOG_KEY=your_posthog_api_key_here
4-
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
54

65
# Basin Form Endpoint for Static Form Submissions
76
# Replace this with your actual Basin form endpoint (e.g., https://usebasin.com/f/your-form-id)

apps/web-roo-code/src/components/providers/posthog-provider.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
3232
// Initialize PostHog immediately on the client side
3333
if (typeof window !== "undefined" && !posthog.__loaded) {
3434
const posthogKey = process.env.NEXT_PUBLIC_POSTHOG_KEY
35-
const posthogHost = process.env.NEXT_PUBLIC_POSTHOG_HOST
3635

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

46-
if (!posthogHost) {
47-
console.warn(
48-
"PostHog host URL is missing. Using default host. " +
49-
"Please set NEXT_PUBLIC_POSTHOG_HOST in your .env file.",
50-
)
51-
}
52-
5345
// Check if user has already consented to cookies
5446
const userHasConsented = hasConsent()
5547

5648
// Initialize PostHog with appropriate persistence based on consent
5749
posthog.init(posthogKey, {
58-
api_host: posthogHost || "https://us.i.posthog.com",
50+
api_host: "https://ph.roocode.com",
51+
ui_host: "https://us.posthog.com",
5952
capture_pageview: false, // We handle pageview tracking manually
6053
loaded: (posthogInstance) => {
6154
if (process.env.NODE_ENV === "development") {

packages/telemetry/src/PostHogTelemetryClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class PostHogTelemetryClient extends BaseTelemetryClient {
2525
debug,
2626
)
2727

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

3131
/**

src/core/webview/ClineProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ export class ClineProvider
11961196
<meta charset="utf-8">
11971197
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
11981198
<meta name="theme-color" content="#000000">
1199-
<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;">
1199+
<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;">
12001200
<link rel="stylesheet" type="text/css" href="${stylesUri}">
12011201
<link href="${codiconsUri}" rel="stylesheet" />
12021202
<script nonce="${nonce}">

src/core/webview/__tests__/ClineProvider.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ describe("ClineProvider", () => {
486486

487487
// Verify Content Security Policy contains the necessary PostHog domains
488488
expect(mockWebviewView.webview.html).toContain(
489-
"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",
489+
"connect-src vscode-webview://test-csp-source https://openrouter.ai https://api.requesty.ai https://ph.roocode.com",
490490
)
491491

492492
// Extract the script-src directive section and verify required security elements

webview-ui/src/__tests__/TelemetryClient.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe("TelemetryClient", () => {
5555
expect(posthog.init).toHaveBeenCalledWith(
5656
API_KEY,
5757
expect.objectContaining({
58-
api_host: "https://us.i.posthog.com",
58+
api_host: "https://ph.roocode.com",
5959
persistence: "localStorage",
6060
loaded: expect.any(Function),
6161
}),

webview-ui/src/utils/TelemetryClient.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class TelemetryClient {
1313
TelemetryClient.telemetryEnabled = true
1414

1515
posthog.init(apiKey, {
16-
api_host: "https://us.i.posthog.com",
16+
api_host: "https://ph.roocode.com",
17+
ui_host: "https://us.posthog.com",
1718
persistence: "localStorage",
1819
loaded: () => posthog.identify(distinctId),
1920
capture_pageview: false,

webview-ui/src/utils/__tests__/TelemetryClient.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe("TelemetryClient", () => {
6060
expect(posthog.init).toHaveBeenCalledWith(
6161
API_KEY,
6262
expect.objectContaining({
63-
api_host: "https://us.i.posthog.com",
63+
api_host: "https://ph.roocode.com",
6464
persistence: "localStorage",
6565
loaded: expect.any(Function),
6666
}),

0 commit comments

Comments
 (0)