: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
fix(flags): reframe local evaluation banner as informational (#68818)
posthog[bot]cc8bfa88607e
diff --git a/frontend/src/scenes/feature-flags/FeatureFlagConditionWarning.tsx b/frontend/src/scenes/feature-flags/FeatureFlagConditionWarning.tsxindex 8b5320014933..edf3422c3e79 100644--- a/frontend/src/scenes/feature-flags/FeatureFlagConditionWarning.tsx+++ b/frontend/src/scenes/feature-flags/FeatureFlagConditionWarning.tsx@@ -19,7 +19,7 @@ export function FeatureFlagConditionWarning({className,evaluationRuntime = FeatureFlagEvaluationRuntime.ALL,}: FeatureFlagConditionWarningProps): JSX.Element | null {- const { warning } = useValues(featureFlagConditionWarningLogic({ properties, evaluationRuntime }))+ const { warning, hasStaticCohort } = useValues(featureFlagConditionWarningLogic({ properties, evaluationRuntime }))if (!warning) {return null@@ -27,11 +27,16 @@ export function FeatureFlagConditionWarning({return (<div- className={`flex items-center gap-2 text-xs p-2 rounded border border-warning-dark bg-warning-highlight${className ? ` ${className}` : ''}`}+ className={`flex items-start gap-2 text-xs p-2 rounded border border-primary bg-surface-secondary text-secondary${className ? ` ${className}` : ''}`}>- <IconInfo className="text-base shrink-0 text-warning-dark" />+ <IconInfo className="text-base shrink-0 text-muted mt-0.5" /><span>- Local evaluation unavailable ({warning}).{' '}+ This flag works as normal. Only <strong>local evaluation</strong> in server-side SDKs is affected by+ these conditions: {warning}. They are still evaluated through the PostHog API, just not from the SDK's+ local cache.+ {hasStaticCohort+ ? ' If you need local evaluation, target a dynamic (behavioral) cohort instead of a static one.'+ : ''}{' '}<Link to="https://posthog.com/docs/feature-flags/local-evaluation#restriction-on-local-evaluation">Learn more</Link>diff --git a/frontend/src/scenes/feature-flags/featureFlagConditionWarningLogic.test.ts b/frontend/src/scenes/feature-flags/featureFlagConditionWarningLogic.test.tsindex 6fb776943bba..461af31fe69c 100644--- a/frontend/src/scenes/feature-flags/featureFlagConditionWarningLogic.test.ts+++ b/frontend/src/scenes/feature-flags/featureFlagConditionWarningLogic.test.ts@@ -439,6 +439,7 @@ describe('featureFlagConditionWarningLogic', () => {logic.mount()expect(logic.values.warning).toBe('static cohorts')+ expect(logic.values.hasStaticCohort).toBe(true)})it('does not warn when cohort is not loaded yet', () => {@@ -459,6 +460,7 @@ describe('featureFlagConditionWarningLogic', () => {expectLogic(logic).toMatchValues({warning: undefined,+ hasStaticCohort: false,})})@@ -488,6 +490,7 @@ describe('featureFlagConditionWarningLogic', () => {logic.mount()expect(logic.values.warning).toBeUndefined()+ expect(logic.values.hasStaticCohort).toBe(false)})})diff --git a/frontend/src/scenes/feature-flags/featureFlagConditionWarningLogic.ts b/frontend/src/scenes/feature-flags/featureFlagConditionWarningLogic.tsindex 566c9aed6584..17c5f31cd30c 100644--- a/frontend/src/scenes/feature-flags/featureFlagConditionWarningLogic.ts+++ b/frontend/src/scenes/feature-flags/featureFlagConditionWarningLogic.ts@@ -18,6 +18,8 @@ const REGEX_BACKREFERENCE = /(?<!\\)\\[1-9]/ // \1 through \9// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface featureFlagConditionWarningLogicValues {cohortsById: Partial<Record<number | string, CohortType>> // cohortsModel+ hasStaticCohort: boolean+ issues: string[]warning: string | undefined}@@ -25,11 +27,13 @@ export interface featureFlagConditionWarningLogicValues {export interface featureFlagConditionWarningLogicMeta {key: string__keaTypeGenInternalSelectorTypes: {- warning: (+ issues: (cohortsById: Partial<Record<number | string, CohortType>>,properties: AnyPropertyFilter[],evaluationRuntime: FeatureFlagEvaluationRuntime- ) => string | undefined+ ) => string[]+ warning: (issues: string[]) => string | undefined+ hasStaticCohort: (issues: string[]) => boolean}}@@ -49,17 +53,17 @@ export const featureFlagConditionWarningLogic = kea<featureFlagConditionWarningL})),selectors({- warning: [+ issues: [(s, p) => [s.cohortsById, p.properties, p.evaluationRuntime],(cohortsById: Partial<Record<string | number, CohortType>>,properties: AnyPropertyFilter[],evaluationRuntime: FeatureFlagEvaluationRuntime- ): string | undefined => {+ ): string[] => {// Local evaluation is only relevant for server-side SDKs, so only show the warning// for flags that can be evaluated server-side (ALL or SERVER)if (evaluationRuntime === FeatureFlagEvaluationRuntime.CLIENT) {- return+ return []}const issues: string[] = []@@ -95,14 +99,15 @@ export const featureFlagConditionWarningLogic = kea<featureFlagConditionWarningL}})- if (issues.length === 0) {- return undefined- }-- const uniqueIssues = [...new Set(issues)]-- return uniqueIssues.join(', ')+ return [...new Set(issues)]},],++ warning: [+ (s) => [s.issues],+ (issues: string[]): string | undefined => (issues.length === 0 ? undefined : issues.join(', ')),+ ],++ hasStaticCohort: [(s) => [s.issues], (issues: string[]): boolean => issues.includes('static cohorts')],}),])