diff --git a/.changeset/real-cobras-rule.md b/.changeset/real-cobras-rule.md new file mode 100644 index 00000000..a43e80c8 --- /dev/null +++ b/.changeset/real-cobras-rule.md @@ -0,0 +1,5 @@ +--- +"claude-dev": minor +--- + +Add remote config with posthog allowing for disabling new features until they're reading, making for a better developer experience. diff --git a/src/services/telemetry/TelemetryService.ts b/src/services/telemetry/TelemetryService.ts index 7d84c76f..df1ea3ff 100644 --- a/src/services/telemetry/TelemetryService.ts +++ b/src/services/telemetry/TelemetryService.ts @@ -4,6 +4,7 @@ import { version as extensionVersion } from "../../../package.json" import type { TaskFeedbackType } from "@shared/WebviewMessage" import type { BrowserSettings } from "@shared/BrowserSettings" +import { posthogConfig } from "@/shared/services/config/posthog-config" /** * PostHogClient handles telemetry event tracking for the Cline extension @@ -93,8 +94,8 @@ class PostHogClient { * Initializes PostHog client with configuration */ private constructor() { - this.client = new PostHog("phc_qfOAGxZw2TL5O8p9KYd9ak3bPBFzfjC8fy5L6jNWY7K", { - host: "https://us.i.posthog.com", + this.client = new PostHog(posthogConfig.apiKey, { + host: posthogConfig.host, enableExceptionAutocapture: false, }) } diff --git a/src/shared/services/config/posthog-config.ts b/src/shared/services/config/posthog-config.ts new file mode 100644 index 00000000..c4a793ff --- /dev/null +++ b/src/shared/services/config/posthog-config.ts @@ -0,0 +1,5 @@ +// Public PostHog key (safe for open source) +export const posthogConfig = { + apiKey: "phc_qfOAGxZw2TL5O8p9KYd9ak3bPBFzfjC8fy5L6jNWY7K", + host: "https://us.i.posthog.com", +} diff --git a/src/shared/services/feature-flags/feature-flags.ts b/src/shared/services/feature-flags/feature-flags.ts new file mode 100644 index 00000000..58e5f267 --- /dev/null +++ b/src/shared/services/feature-flags/feature-flags.ts @@ -0,0 +1,6 @@ +export const FEATURE_FLAGS = { + CUSTOM_INSTRUCTIONS: "custom-instructions", + // Further flags here +} as const + +export type FeatureFlag = (typeof FEATURE_FLAGS)[keyof typeof FEATURE_FLAGS] diff --git a/webview-ui/src/Providers.tsx b/webview-ui/src/Providers.tsx index e1a60f47..16660b46 100644 --- a/webview-ui/src/Providers.tsx +++ b/webview-ui/src/Providers.tsx @@ -3,13 +3,22 @@ import type { ReactNode } from "react" import { ExtensionStateContextProvider } from "./context/ExtensionStateContext" import { FirebaseAuthProvider } from "./context/FirebaseAuthContext" import { HeroUIProvider } from "@heroui/react" +import { PostHogProvider } from "posthog-js/react" +import { posthogConfig } from "@shared/services/config/posthog-config" +import posthog from "posthog-js" + +posthog.init(posthogConfig.apiKey, { + api_host: posthogConfig.host, +}) export function Providers({ children }: { children: ReactNode }) { return ( - - {children} - + + + {children} + + ) } diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index bdc1e31a..4367d9a1 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -10,7 +10,8 @@ import { useEvent } from "react-use" import { ExtensionMessage } from "@shared/ExtensionMessage" import BrowserSettingsSection from "./BrowserSettingsSection" import TerminalSettingsSection from "./TerminalSettingsSection" - +import { useFeatureFlag } from "@/hooks/useFeatureFlag" +import { FEATURE_FLAGS } from "@shared/services/feature-flags/feature-flags" const { IS_DEV } = process.env type SettingsViewProps = { @@ -82,16 +83,16 @@ const SettingsView = ({ onDone }: SettingsViewProps) => { // validate as soon as the component is mounted /* - useEffect will use stale values of variables if they are not included in the dependency array. - so trying to use useEffect with a dependency array of only one value for example will use any - other variables' old values. In most cases you don't want this, and should opt to use react-use - hooks. + useEffect will use stale values of variables if they are not included in the dependency array. + so trying to use useEffect with a dependency array of only one value for example will use any + other variables' old values. In most cases you don't want this, and should opt to use react-use + hooks. - // uses someVar and anotherVar - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [someVar]) + // uses someVar and anotherVar + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [someVar]) If we only want to run code once on mount we can use react-use's useEffectOnce or useMount - */ + */ const handleMessage = useCallback( (event: MessageEvent) => { @@ -145,6 +146,8 @@ const SettingsView = ({ onDone }: SettingsViewProps) => { handleSubmit(true) } + const showCustomInstructions = useFeatureFlag(FEATURE_FLAGS.CUSTOM_INSTRUCTIONS) + return (
@@ -183,20 +186,24 @@ const SettingsView = ({ onDone }: SettingsViewProps) => { /> )} -
- setCustomInstructions(e.target?.value ?? "")}> - Custom Instructions - -

- These instructions are added to the end of the system prompt sent with every request. -

-
+ {showCustomInstructions && ( +
+ setCustomInstructions(e.target?.value ?? "")}> + Custom Instructions + +

+ These instructions are added to the end of the system prompt sent with every request. +

+
+ )}
{ + const payload = useFeatureFlagPayload(flagName) as { enabled: boolean } + if (payload && payload.enabled) { + return payload.enabled + } + console.warn(`Feature flag ${flagName} not found or missing enabled property.`) + return false +}