feat: migrate PostHog client to ph.roocode.com (#9402)

Co-authored-by: Roo Code <roomote@roocode.com>
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
This commit is contained in:
roomote[bot] 2025-11-19 14:44:22 -05:00 committed by GitHub
parent 61fc39176d
commit ee19904b29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 9 additions and 16 deletions

View file

@ -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)

View file

@ -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) {
@ -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") {

View file

@ -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" })
}
/**

View file

@ -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}">

View file

@ -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

View file

@ -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),
}),

View file

@ -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,

View file

@ -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),
}),