mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
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:
parent
61fc39176d
commit
ee19904b29
8 changed files with 9 additions and 16 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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") {
|
||||
|
|
|
|||
|
|
@ -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" })
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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}">
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue