: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): move the flag called warning into a flag-gated notice (#114172)
Phil Haack24dd56345953
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 165c9f367d1e..87e619c0dca4 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -880,6 +880,10 @@ snapshots:hash: v1.k794b7964.991e5f44ceae5eced661d06ca75fdd314fea213b73791c697078d601655b3876.pDXTpK6DyIMq248_s0s0QZJxOnwPiQKzjoJanIrQL-8components-feature-previews--empty--light:hash: v1.k794b7964.6fa703c825304215f198e3c1c37821a15fdec4772505a4b5db2e4e0ce491ff8d.Xp_4MqTRyevKnhM7Q2mIK9B_PhsbXY-R_lTqCpViZVY+ components-flag-called-move-notice--under-an-event-description--dark:+ hash: v1.k794b7964.79dffd277b259e7550cc45da0aee9fd908f07f37cc5e5e270fd8510f5849a9f2.8Lj_rPLTbRjssG5IldG5oFNe7qOmVMsFINqZ-r1y7zM+ components-flag-called-move-notice--under-an-event-description--light:+ hash: v1.k794b7964.22cb35f375fe9ac0e0b2e63c575298f37de632aa5914084eb6161db5e116f371.X5Gb34qDPIt9ksr4SFamxZvAqy3_EoMYzs1nvaDS0D8components-hedgehogmode--profile-picture-hog--dark:hash: v1.k794b7964.969bdab0c4f15b4457bc162b9ad87ec0341d5e98ed3a9279494cc2f019c12250.5eEGiofVhJFttdE4ETVy01n1PTA-WrkIsgHZEB9rG5Icomponents-hedgehogmode--profile-picture-hog--light:diff --git a/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsx b/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsxindex 8147ed374d8f..380a48d4fcf7 100644--- a/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsx+++ b/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsx@@ -9,6 +9,7 @@ import { ActionPopoverInfo } from 'lib/components/DefinitionPopover/ActionPopoveimport { CohortPopoverInfo } from 'lib/components/DefinitionPopover/CohortPopoverInfo'import { DefinitionPopover } from 'lib/components/DefinitionPopover/DefinitionPopover'import { DefinitionPopoverState, definitionPopoverLogic } from 'lib/components/DefinitionPopover/definitionPopoverLogic'+import { FlagCalledMoveNotice } from 'lib/components/FlagCalledMoveNotice/FlagCalledMoveNotice'import { ObjectTags } from 'lib/components/ObjectTags/ObjectTags'import { PropertyKeyInfo } from 'lib/components/PropertyKeyInfo'import {@@ -176,6 +177,7 @@ function DefinitionView({ group }: { group: TaxonomicFilterGroup }): JSX.Element) : (<DefinitionPopover.DescriptionEmpty />)}+ <FlagCalledMoveNotice name={definition.name} groupType={group.type} className="mb-2" /><DefinitionPopover.Example value={group?.getValue?.(definition)?.toString()} />{definition && 'tags' in definition && !!definition.tags?.length && (<ObjectTagsdiff --git a/frontend/src/lib/components/FlagCalledMoveNotice/FlagCalledMoveNotice.stories.tsx b/frontend/src/lib/components/FlagCalledMoveNotice/FlagCalledMoveNotice.stories.tsxnew file mode 100644index 000000000000..f38abcdce611--- /dev/null+++ b/frontend/src/lib/components/FlagCalledMoveNotice/FlagCalledMoveNotice.stories.tsx@@ -0,0 +1,24 @@+import { Meta, StoryObj } from '@storybook/react'++import { FlagCalledMoveNotice } from 'lib/components/FlagCalledMoveNotice/FlagCalledMoveNotice'+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'+import { FEATURE_FLAGS } from 'lib/constants'++type Story = StoryObj<{}>+const meta: Meta = {+ title: 'Components/Flag Called Move Notice',+ parameters: {+ featureFlags: [FEATURE_FLAGS.FLAG_CALLED_MOVE_NOTICES],+ },+}+export default meta++export const UnderAnEventDescription: Story = {+ render: () => (+ // DefinitionPopover.scss caps the definition popover at this width (20rem), so the notice wraps as it does there.+ <div className="w-80 border rounded p-3 bg-surface-primary">+ <p>Sent by PostHog SDKs each time a feature flag is evaluated.</p>+ <FlagCalledMoveNotice name="$feature_flag_called" groupType={TaxonomicFilterGroupType.Events} />+ </div>+ ),+}diff --git a/frontend/src/lib/components/FlagCalledMoveNotice/FlagCalledMoveNotice.tsx b/frontend/src/lib/components/FlagCalledMoveNotice/FlagCalledMoveNotice.tsxnew file mode 100644index 000000000000..f9bdca47452a--- /dev/null+++ b/frontend/src/lib/components/FlagCalledMoveNotice/FlagCalledMoveNotice.tsx@@ -0,0 +1,55 @@+import { useValues } from 'kea'++import { IconWarning } from '@posthog/icons'++import { showsFlagCalledMoveNotice } from 'lib/components/FlagCalledMoveNotice/showsFlagCalledMoveNotice'+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'+import { FEATURE_FLAGS } from 'lib/constants'+import { Link } from 'lib/lemon-ui/Link'+import { featureFlagLogic, getFeatureFlagPayload } from 'lib/logic/featureFlagLogic'+import { cn } from 'lib/utils/css-classes'+import { isHttpsUrl } from 'lib/utils/url'+import { teamLogic } from 'scenes/teamLogic'++interface FlagCalledMoveNoticeProps {+ name: string | null | undefined+ groupType: TaxonomicFilterGroupType+ className?: string+}++// Remove once every organization is on flag_evaluations_mode 2 (#88126). Delete this folder and its render sites+// together. Other move warnings also read FEATURE_FLAGS.FLAG_CALLED_MOVE_NOTICES, so delete the constant only after+// the last of them is gone.+export function FlagCalledMoveNotice({ name, groupType, className }: FlagCalledMoveNoticeProps): JSX.Element | null {+ const { featureFlags } = useValues(featureFlagLogic)+ const { currentTeam } = useValues(teamLogic)++ if (+ !featureFlags[FEATURE_FLAGS.FLAG_CALLED_MOVE_NOTICES] ||+ !showsFlagCalledMoveNotice(name, groupType, currentTeam?.flag_evaluations_mode)+ ) {+ return null+ }++ const announcementUrl = getFeatureFlagPayload(FEATURE_FLAGS.FLAG_CALLED_MOVE_NOTICES)?.url++ return (+ <div className={cn('flex items-start gap-1.5', className)} data-attr="flag-called-move-notice">+ <IconWarning className="shrink-0 mt-0.5 text-warning" />+ <span>+ <code>$feature_flag_called</code> is moving from <code>events</code> to{' '}+ <code>posthog.flag_evaluations</code>. Once the move finishes for your organization, insights and+ queries on this event will stop returning results, and you can query{' '}+ <code>posthog.flag_evaluations</code> instead.+ {typeof announcementUrl === 'string' && isHttpsUrl(announcementUrl) && (+ <>+ {' '}+ <Link to={announcementUrl} target="_blank" data-attr="flag-called-move-notice-announcement">+ Learn more+ </Link>+ </>+ )}+ </span>+ </div>+ )+}diff --git a/frontend/src/lib/components/FlagCalledMoveNotice/showsFlagCalledMoveNotice.test.ts b/frontend/src/lib/components/FlagCalledMoveNotice/showsFlagCalledMoveNotice.test.tsnew file mode 100644index 000000000000..0dc3d708ee3e--- /dev/null+++ b/frontend/src/lib/components/FlagCalledMoveNotice/showsFlagCalledMoveNotice.test.ts@@ -0,0 +1,30 @@+import { showsFlagCalledMoveNotice } from 'lib/components/FlagCalledMoveNotice/showsFlagCalledMoveNotice'+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'++import { FlagEvaluationsModeEnumApi } from '~/generated/core/api.schemas'++const { Events, EventProperties } = TaxonomicFilterGroupType+const {+ Number0: EVENTS_MODE,+ Number1: READS_FLAG_EVALUATIONS,+ Number2: FLAG_EVALUATIONS_ONLY,+} = FlagEvaluationsModeEnumApi++describe('showsFlagCalledMoveNotice', () => {+ it.each([+ ['the team is on the Events mode', EVENTS_MODE],+ ['no team is loaded', undefined],+ ])('shows the notice on the flag called event when %s', (_label, mode) => {+ expect(showsFlagCalledMoveNotice('$feature_flag_called', Events, mode)).toBe(true)+ })++ it.each([+ // These modes read flag calls from flag_evaluations, where the event keeps working.+ ['the team reads flag evaluations', '$feature_flag_called', Events, READS_FLAG_EVALUATIONS],+ ['the team writes only flag evaluations', '$feature_flag_called', Events, FLAG_EVALUATIONS_ONLY],+ ['the event is another event', '$pageview', Events, EVENTS_MODE],+ ['the name is not an event', '$feature_flag_called', EventProperties, EVENTS_MODE],+ ])('hides the notice when %s', (_label, name, groupType, mode) => {+ expect(showsFlagCalledMoveNotice(name, groupType, mode)).toBe(false)+ })+})diff --git a/frontend/src/lib/components/FlagCalledMoveNotice/showsFlagCalledMoveNotice.ts b/frontend/src/lib/components/FlagCalledMoveNotice/showsFlagCalledMoveNotice.tsnew file mode 100644index 000000000000..edba0ace8947--- /dev/null+++ b/frontend/src/lib/components/FlagCalledMoveNotice/showsFlagCalledMoveNotice.ts@@ -0,0 +1,19 @@+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'++import { FlagEvaluationsModeEnumApi } from '~/generated/core/api.schemas'++const FEATURE_FLAG_CALLED_EVENT = '$feature_flag_called'++// On modes other than Events, flag views read flag calls from flag_evaluations and keep working, so the notice+// would be wrong there.+export function showsFlagCalledMoveNotice(+ name: string | null | undefined,+ groupType: TaxonomicFilterGroupType,+ flagEvaluationsMode: FlagEvaluationsModeEnumApi | undefined+): boolean {+ return (+ name === FEATURE_FLAG_CALLED_EVENT &&+ groupType === TaxonomicFilterGroupType.Events &&+ (flagEvaluationsMode ?? FlagEvaluationsModeEnumApi.Number0) === FlagEvaluationsModeEnumApi.Number0+ )+}diff --git a/frontend/src/lib/components/PropertyKeyInfo.tsx b/frontend/src/lib/components/PropertyKeyInfo.tsxindex 7bbd18b42cf0..6a3fc43a1158 100644--- a/frontend/src/lib/components/PropertyKeyInfo.tsx+++ b/frontend/src/lib/components/PropertyKeyInfo.tsx@@ -7,6 +7,7 @@ import React, { useState } from 'react'import { LemonDivider, TooltipProps } from '@posthog/lemon-ui'import { Logomark } from 'lib/brand'+import { FlagCalledMoveNotice } from 'lib/components/FlagCalledMoveNotice/FlagCalledMoveNotice'import { Popover } from 'lib/lemon-ui/Popover'import { pluralize } from 'lib/utils/strings'import { surveyQuestionLabelsLogic } from 'scenes/surveys/surveyQuestionLabelsLogic'@@ -91,6 +92,7 @@ const PropertyKeyInfoBase = React.forwardRef<HTMLSpanElement, PropertyKeyInfoPro<LemonDivider className="my-3" /><div>{coreDefinition.description ? <p>{coreDefinition.description}</p> : null}+ <FlagCalledMoveNotice name={value} groupType={type} className="mb-2" />{coreDefinition.examples ? (<p><i>diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.tsxindex 704f86354aec..9bc35a5f4e14 100644--- a/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.tsx@@ -15,6 +15,7 @@ import posthog from 'posthog-js'import { IconPin } from '@posthog/icons'import { Button, cn, ScrollArea, Separator } from '@posthog/quill'+import { FlagCalledMoveNotice } from 'lib/components/FlagCalledMoveNotice/FlagCalledMoveNotice'import { resolvePropertyDefinitionId } from 'lib/components/PropertyFilters/utils'import { Link } from 'lib/lemon-ui/Link'import { urls } from 'scenes/urls'@@ -76,6 +77,12 @@ function PreviewBody({ entry }: { entry: MenuFilterEntry }): JSX.Element | null<p className="text-xs italic text-tertiary">No description.</p>)}+ <FlagCalledMoveNotice+ name={entry.name}+ groupType={entry.group.type}+ className="text-xs leading-relaxed"+ />+{details.example && <p className="text-xs italic text-secondary">Example: {details.example}</p>}{details.propertyType && (diff --git a/frontend/src/scenes/data-management/events/DefinitionHeader.tsx b/frontend/src/scenes/data-management/events/DefinitionHeader.tsxindex c0ffb85d0e04..f95cb0da93b1 100644--- a/frontend/src/scenes/data-management/events/DefinitionHeader.tsx+++ b/frontend/src/scenes/data-management/events/DefinitionHeader.tsx@@ -13,6 +13,7 @@ import {IconServer,} from '@posthog/icons'+import { FlagCalledMoveNotice } from 'lib/components/FlagCalledMoveNotice/FlagCalledMoveNotice'import { PropertyKeyInfo } from 'lib/components/PropertyKeyInfo'import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'import { IconEyeHidden, IconSelectAll } from 'lib/lemon-ui/icons'@@ -236,13 +237,27 @@ export function DefinitionHeader({const description =definition.description || getCoreFilterDefinition(definition.name, taxonomicGroupType)?.description+ // The notice renders outside LemonTableLink. Inside the link's description, the notice's docs link would nest+ // in the row's anchor, and a string description would stop rendering as markdown.return (- <LemonTableLink- to={to}- description={description}- title={- <PropertyKeyInfo value={definition.name ?? ''} disablePopover disableIcon type={taxonomicGroupType} />- }- />+ <>+ <LemonTableLink+ to={to}+ description={description}+ title={+ <PropertyKeyInfo+ value={definition.name ?? ''}+ disablePopover+ disableIcon+ type={taxonomicGroupType}+ />+ }+ />+ <FlagCalledMoveNotice+ name={definition.name}+ groupType={taxonomicGroupType}+ className="text-xs text-tertiary max-w-[30rem] pb-1"+ />+ </>)}diff --git a/frontend/src/taxonomy/core-filter-definitions-by-group.json b/frontend/src/taxonomy/core-filter-definitions-by-group.jsonindex 1d71f729946c..e8438859127c 100644--- a/frontend/src/taxonomy/core-filter-definitions-by-group.json+++ b/frontend/src/taxonomy/core-filter-definitions-by-group.json@@ -3312,7 +3312,7 @@"label": "Feature enrollment"},"$feature_flag_called": {- "description": "Sent by PostHog SDKs each time a feature flag is evaluated.\n\nPostHog still collects this event, but its data is moving, so a saved query built on it will stop returning results. To see how a flag is used, open the flag and check its Usage tab.",+ "description": "Sent by PostHog SDKs each time a feature flag is evaluated.","examples": ["beta-feature"],"hidden_in_query_builders": true,"ignored_in_assistant": true,diff --git a/posthog/taxonomy/taxonomy.py b/posthog/taxonomy/taxonomy.pyindex 442e45ca2dce..f07cc15f3c16 100644--- a/posthog/taxonomy/taxonomy.py+++ b/posthog/taxonomy/taxonomy.py@@ -184,9 +184,7 @@ CORE_FILTER_DEFINITIONS_BY_GROUP: dict[str, dict[str, CoreFilterDefinition]] = {},"$feature_flag_called": {"label": "Feature flag called",- "description": (- "Sent by PostHog SDKs each time a feature flag is evaluated.\n\nPostHog still collects this event, but its data is moving, so a saved query built on it will stop returning results. To see how a flag is used, open the flag and check its Usage tab."- ),+ "description": "Sent by PostHog SDKs each time a feature flag is evaluated.","examples": ["beta-feature"],"ignored_in_assistant": True, # Mostly irrelevant product-wise"hidden_in_query_builders": True,