:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(flags): add remote config as a distinct flag template (#62274)
Phil Haackd16ccfdcd046
diff --git a/frontend/src/scenes/feature-flags/NewFeatureFlagMenu.tsx b/frontend/src/scenes/feature-flags/NewFeatureFlagMenu.tsxindex f07b2feb5e1b..ef5c9948a1ce 100644--- a/frontend/src/scenes/feature-flags/NewFeatureFlagMenu.tsx+++ b/frontend/src/scenes/feature-flags/NewFeatureFlagMenu.tsx@@ -34,7 +34,10 @@ interface DropdownTemplateMetadata {icon: React.ComponentType}-const TEMPLATE_METADATA: Record<TemplateKey, DropdownTemplateMetadata> = {+// Remote config has its own dedicated menu item below, so the preset dropdown excludes it.+type PresetTemplateKey = Exclude<TemplateKey, 'remote-config'>++const TEMPLATE_METADATA: Record<PresetTemplateKey, DropdownTemplateMetadata> = {simple: {name: 'Simple flag',description: 'On/off for all users',@@ -57,7 +60,7 @@ const TEMPLATE_METADATA: Record<TemplateKey, DropdownTemplateMetadata> = {},}-const TEMPLATES: TemplateKey[] = ['simple', 'targeted', 'multivariate', 'targeted-multivariate']+const TEMPLATES: PresetTemplateKey[] = ['simple', 'targeted', 'multivariate', 'targeted-multivariate']const AI_TOOL_DEFINITION = getToolDefinition('create_feature_flag')!const AI_SUGGESTIONS = [@@ -67,7 +70,7 @@ const AI_SUGGESTIONS = ['Create a beta testing flag for…',]-function IntentSubmenu({ template, onBack }: { template: TemplateKey; onBack: () => void }): JSX.Element {+function IntentSubmenu({ template, onBack }: { template: PresetTemplateKey; onBack: () => void }): JSX.Element {const metadata = TEMPLATE_METADATA[template]return (@@ -114,7 +117,7 @@ export function OverlayForNewFeatureFlagMenu(): JSX.Element {const intentsEnabled = !!featureFlags[FEATURE_FLAGS.FEATURE_FLAG_CREATION_INTENTS]// useState is intentional — this is an ephemeral popover overlay that unmounts on close- const [selectedTemplate, setSelectedTemplate] = useState<TemplateKey | null>(null)+ const [selectedTemplate, setSelectedTemplate] = useState<PresetTemplateKey | null>(null)if (intentsEnabled && selectedTemplate) {return <IntentSubmenu template={selectedTemplate} onBack={() => setSelectedTemplate(null)} />diff --git a/products/feature_flags/frontend/FeatureFlagTemplatesScene.tsx b/products/feature_flags/frontend/FeatureFlagTemplatesScene.tsxindex 7a9bcb9a0779..9e970e305296 100644--- a/products/feature_flags/frontend/FeatureFlagTemplatesScene.tsx+++ b/products/feature_flags/frontend/FeatureFlagTemplatesScene.tsx@@ -2,7 +2,7 @@ import { useActions, useValues } from 'kea'import { combineUrl, router } from 'kea-router'import posthog from 'posthog-js'-import { IconArrowLeft, IconFlask, IconPeople, IconPlus, IconTestTube, IconToggle } from '@posthog/icons'+import { IconArrowLeft, IconCode, IconFlask, IconPeople, IconPlus, IconTestTube, IconToggle } from '@posthog/icons'import { LemonButton } from '@posthog/lemon-ui'import { FlagIntent } from 'scenes/feature-flags/featureFlagIntentWarningLogic'@@ -44,6 +44,11 @@ const TEMPLATES: FeatureFlagTemplate[] = [description: 'Test variants for specific user or group segments',icon: <IconFlask className="w-6 h-6 text-primary-3000" />,},+ {+ key: 'remote-config',+ description: 'Deliver configuration values to your app',+ icon: <IconCode className="w-6 h-6 text-primary-3000" />,+ },]interface TemplateCardProps {diff --git a/products/feature_flags/frontend/featureFlagTemplateConstants.ts b/products/feature_flags/frontend/featureFlagTemplateConstants.tsindex 1d4d2814d22d..f99cfdc261fb 100644--- a/products/feature_flags/frontend/featureFlagTemplateConstants.ts+++ b/products/feature_flags/frontend/featureFlagTemplateConstants.ts@@ -4,13 +4,14 @@ import { IconRocket, IconServer } from '@posthog/icons'import type { FlagIntent } from 'scenes/feature-flags/featureFlagIntentWarningLogic'-export type TemplateKey = 'simple' | 'targeted' | 'multivariate' | 'targeted-multivariate'+export type TemplateKey = 'simple' | 'targeted' | 'multivariate' | 'targeted-multivariate' | 'remote-config'export const TEMPLATE_NAMES: Record<TemplateKey, string> = {simple: 'Percentage rollout',targeted: 'Targeted release',multivariate: 'Multivariate','targeted-multivariate': 'Targeted multivariate',+ 'remote-config': 'Remote config',}export interface IntentMetadata {diff --git a/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.test.ts b/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.test.tsindex 0879e7be2477..756894ee2a1e 100644--- a/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.test.ts+++ b/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.test.ts@@ -1,3 +1,4 @@+import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'import { FEATURE_FLAGS } from 'lib/constants'@@ -56,4 +57,40 @@ describe('featureFlagTemplatesSceneLogic', () => {})})})++ describe('selectTemplate listener', () => {+ function mountWithIntents(enabled: boolean): void {+ enabledFeaturesLogic.actions.setFeatureFlags(+ [],+ enabled ? { [FEATURE_FLAGS.FEATURE_FLAG_CREATION_INTENTS]: true } : {}+ )+ logic = featureFlagTemplatesSceneLogic()+ logic.mount()+ }++ it.each([+ { name: 'when intents are enabled', intentsEnabled: true },+ { name: 'when intents are disabled', intentsEnabled: false },+ ])(+ 'routes remote-config to the new flag via type, skipping the intent step $name',+ async ({ intentsEnabled }) => {+ mountWithIntents(intentsEnabled)++ logic.actions.selectTemplate('remote-config')++ await expectLogic(logic).toMatchValues({ selectedTemplate: null })+ expect(router.values.location.pathname).toContain('/feature_flags/new')+ expect(router.values.searchParams.type).toBe('remote_config')+ expect(router.values.searchParams.template).toBeUndefined()+ }+ )++ it('shows the intent step for a non-remote-config template when intents are enabled', async () => {+ mountWithIntents(true)++ logic.actions.selectTemplate('targeted')++ await expectLogic(logic).toMatchValues({ selectedTemplate: 'targeted' })+ })+ })})diff --git a/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.ts b/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.tsindex 01d0b79b9a23..ae0dcb46b5bd 100644--- a/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.ts+++ b/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.ts@@ -18,7 +18,10 @@ export function navigateToNewFlag(intent?: FlagIntent): void {const params: Record<string, any> = { ...searchParams }- if (template && template !== 'blank') {+ if (template === 'remote-config') {+ // Remote config is a distinct flag type, not a targeting preset — route via the type param.+ params.type = 'remote_config'+ } else if (template && template !== 'blank') {params.template = template}if (intent) {@@ -54,7 +57,8 @@ export const featureFlagTemplatesSceneLogic = kea<featureFlagTemplatesSceneLogicselectTemplate: ({ template }) => {posthog.capture('feature flag template selected', { template_key: template })- if (values.intentsEnabled) {+ // Remote config skips the intent step — its evaluation warnings only apply to client-side flags.+ if (values.intentsEnabled && template !== 'remote-config') {actions.setSelectedTemplate(template)} else {navigateToNewFlag(router.values.searchParams, template)