Skip to content

: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.

chore(flags): remove feature-flags-v2 flag and default to V2 UI (#61043)

Phil Haackf73a370966aa
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 83b871314318..88e9233b5363 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -1493,9 +1493,9 @@ snapshots:
dashboards-dashboard-widgets-widget-types-error-tracking-top-issues--loading--light:
hash: v1.k794b7964.4363c87e0a425bf93e4b83e5d17445a9ef2e0cdff86d09d92eb1e191d765438c.oHuVFS2dJ4GpvncvomHWDobEpXHkT20cYwEMN_whm1Q
dashboards-dashboard-widgets-widget-types-error-tracking-top-issues--populated--dark:
- hash: v1.k794b7964.df6deceded8b925d5187cfbf04382f3a53f8f9639004e47475bf1afcccf3367f.cq5L_uTHh4oi4DztD1oST8-KIxO14CAMrqji_0fYWVc
+ hash: v1.k794b7964.5b98c40a2ef206bd50ab9af293196ff4b4c00d19c022b495b4f798fe24f7c304.qxnJRQI612LDAH-_S__olstDXejLSsm4ApQKd0s2bdI
dashboards-dashboard-widgets-widget-types-error-tracking-top-issues--populated--light:
- hash: v1.k794b7964.24c5e063fbe69296895e6e45f1efb6f033d49eb8c4fcd3dbd3524dd3f711bc34.wMr-wm_Owoq73YycyRVTKKyWILrqKDCFYT6SQv7r_rA
+ hash: v1.k794b7964.44f9c33b82129d119f35df4d079d07eb6f52e45efb308821965ddfe5c1db3de7.8CBPOlCt43EEiExdyP4YCU6gnnYLfkevngqjVy8SY4E
dashboards-dashboard-widgets-widget-types-error-tracking-top-issues--setup-unavailable--dark:
hash: v1.k794b7964.7d69dce6ed2191849537eb642d3c89ac2236362de6063c36b330d8539b7fffb9.N2VC2kWXD-FMFINftmH1CnhNzb6araUv6QuurqnkaI8
dashboards-dashboard-widgets-widget-types-error-tracking-top-issues--setup-unavailable--light:
@@ -4779,21 +4779,21 @@ snapshots:
scenes-app-experiments--experiments--light:
hash: v1.k794b7964.c0734f95a7f4d2780fc4537af7e7d3de39dc7c1536e0d834e111c88cf76398a3.Ne0BjhsC4DpPVp1gu4aaBe7W5Lgt84G7EtaDXSullCc
scenes-app-feature-flags--edit-encrypted-remote-config-feature-flag--dark:
- hash: v1.k794b7964.0078633f4fb17e62b1029a6b5960a6edd1a2246cf6afb04dc6bf87918b056568.LdekUjcaMV7cmWzoNhuZFqU8GNIsxf5JZMKkr2K1D5A
+ hash: v1.k794b7964.034f69b1cd11aab2f5376828b2365e02ccbb2ccf9ccdb0d759bb578f46950d51.PoPFMXE0I7i15nkvIK7BkyODMAmKYNhd3dRFHOBigIQ
scenes-app-feature-flags--edit-encrypted-remote-config-feature-flag--light:
- hash: v1.k794b7964.9cf269be5a51883078782071cf00e65448d5a459a54194a214c7ae323c69b477.hggkE-JSkhiZ_y23gqRFNewauL8-7ktAItDTD5HCz0U
+ hash: v1.k794b7964.05c3564175381b22325b01b9b13da0dd2ad6e230be3904c73e710f15eaa7c5f1.Sb62G-22mNzi027n1QJNP51jsRFP7i_J09rj9MDUBr0
scenes-app-feature-flags--edit-feature-flag--dark:
- hash: v1.k794b7964.2a62a12776a9080f3559856568f19e751ec40cae2ad8128daf610036636dfe51.Zuhxi1MNnOF0565m-7UplqcCvIhl5xmbmOxyGDC9lwc
+ hash: v1.k794b7964.245a100df7cc734647e50d88a9059f0dea921672746692d924334ef70aa3a72a.X_XhkZUj2ETirpOUfkNxHqEW1UJrk_5PPpKcXfby4Hs
scenes-app-feature-flags--edit-feature-flag--light:
- hash: v1.k794b7964.11c872ba6e41f85eee7aba37e1d86b4f1882117fe03118744220e41a645a1a63.9GwVh2Bp2X_RAzCcdBIKM7Zs2gvRpHJjFc9WxFTBNX4
+ hash: v1.k794b7964.5630d5412841ae3deef46093f6415f1df99c5b58293be06f481a1102cdd8029a.0wLh_CYIofX-NUDTrhTrwQTH_PE8XcTGYNC4eYhg1MY
scenes-app-feature-flags--edit-multi-variate-feature-flag--dark:
- hash: v1.k794b7964.a995693db8f9b118e04dcc95a30e5716cc17e20760383ced9e2d1c403dd5c311.dZeokcbBBS31ZL2orUj0nGELSYSx3HbgnGEV7xHf_DA
+ hash: v1.k794b7964.d37a1d7cc7d12d2367a6ea4650c4bf35aebad3dabc21ac13a24a7930d9516c04.yH2nGgUwaKwKkJFJawIQtmtoRt8tYh_OXz_qchLj2Wk
scenes-app-feature-flags--edit-multi-variate-feature-flag--light:
- hash: v1.k794b7964.e8469b6227970508559686cfa6a1199f4f7c40fd952d0d53f3f4a12def2d3ee3.19TOMKsOHSw46qTtQFZdiM8h9iwwFqvPs1JTXesW9HY
+ hash: v1.k794b7964.4dcf1c41d48ccab4559971018d672aa86c503970ebf7663bc7314c7cba3da86e.BaIWzoxQ-K6hCWxaEqJJJqht_Uy8ViUdJ8Ti96l9Q-o
scenes-app-feature-flags--edit-remote-config-feature-flag--dark:
- hash: v1.k794b7964.4ddb456d47bd31ec31e44cb9d3ac291216e9b0cd46fda8d76b6725aa56464e7c.C_LAJlu4YJwwGofRLcuZIVj5HP0jcLnqDaX0yYrD4lY
+ hash: v1.k794b7964.93ecfe5493276e2bf76ac27fe91add645e3eddde71fc058475ccee68b412825d.sfb7Qe2pOBbDx5mIZVwsdUSKJIPw3LjN5WXAJXKEJ-k
scenes-app-feature-flags--edit-remote-config-feature-flag--light:
- hash: v1.k794b7964.9063ea0be68131a2a207cf1754d898b1c97752fb901b08cdc5076bc079faa4b9.34H_1L2i1Dz0-WYP5wbSErn6FMyR-Rxo6Q8dVfnWs2c
+ hash: v1.k794b7964.91fdf2be9faacb7297ebde3bd432f1c84ad547797ef159c531c63a0497aa5f4b.fweoGnYTE5OL5lk6vTAZI1UFVSBcFNt1kwKvbI_LLYo
scenes-app-feature-flags--feature-flag-not-found--dark:
hash: v1.k794b7964.36bbf6870a8070c1b5284a2bba1b659324f1986f1af18220b97d0ef22af5b314.0fdhZmbn_ck5kOOvzOzuMeg6oFHGAonFrOQ037BzwCU
scenes-app-feature-flags--feature-flag-not-found--light:
@@ -4803,17 +4803,17 @@ snapshots:
scenes-app-feature-flags--feature-flags-list--light:
hash: v1.k794b7964.433b55d4b908553bd3e5128fb13ca8edb6d6f142fd4103a0bb89bba772c8cbc5.tCKa7paABYG2BW5NxwcHE8QUmDKCeR1UEMmw5N3RoyQ
scenes-app-feature-flags--new-feature-flag--dark:
- hash: v1.k794b7964.837a4b952398127b79edb8fbc92a914a5acd91844b15c76c0a37ff3cd84998be.I1Rfe1_raHhb38A0YIttyu8LCo0r6rxsrPVEGpO8WDU
+ hash: v1.k794b7964.b8f6e0b677fa753d25fd9710066d8864cce28c2b8f17e96abd343d91ad72e95c.JX-Y63wT7ojk44kJmYVE9jeRnPRmyMqhkUytg1Opfjo
scenes-app-feature-flags--new-feature-flag--light:
- hash: v1.k794b7964.f4e33226f2d9dc4c1896e59b772e84d6c05243fe6aa1179d390905f0a44c7843.tNQWSyGlWM3N5t9myZ732Wz1A45RQijcTjUMXC2PqGI
+ hash: v1.k794b7964.6070b288eae780b0309d4d4ec6be43299e3a5f75f4d8f99f177967661cba73f9.xasdlli_s76qokmljDu-ZsbB5mF33QA1xjMvGTEhYFM
scenes-app-feature-flags--new-multivariate-flag-variant-key-error--dark:
- hash: v1.k794b7964.162a1ebe4a801337b84666b07a1e43055a7603f3abb230c0b98c8f42da585aad.tkpPEcXhdbvAA2AmSYkrYhfN-EQnLRPqNZAlQoZj870
+ hash: v1.k794b7964.8854deb3501dbeda7f349477f8af77ce618d50cf718e4987c999d2832ce8f53f.c8gUPbguiUSWuR41qtE6ftClF5byUprH4NJKR2TIDw8
scenes-app-feature-flags--new-multivariate-flag-variant-key-error--light:
- hash: v1.k794b7964.b02933f644aee3ce68340c02f2e73068c77b1804d10e10de6b93291f32f38b53.XkrGBrHhNOptEjC2JV5y7umfR7qovViNR_RqM7O6I_E
+ hash: v1.k794b7964.c7275b6430fbd53565f881d1330f2ea1479f8be838d1ae1689108b3249678f64.h7Ktlbp1VMFYhF6bSwLOS_Jfp_uV71Ia5aQMq9lVDPA
scenes-app-feature-flags--new-remote-config-flag-payload-error--dark:
- hash: v1.k794b7964.0716c42b31d25301be964cdab7e21c95243365277b659fbd9a75c6585e22ac21.m28YUxIOBIAXbBh41zQk8-v6_zTTCKBmd_elCFoika0
+ hash: v1.k794b7964.a6d78a11cd747b9112dd991820d8761b799ffed11abd8249cd7e5b0e43b2ba8d.VgLTpNiieD59TcJ6fTxCkC2LRMPrQ0XSwobH3-XyOGE
scenes-app-feature-flags--new-remote-config-flag-payload-error--light:
- hash: v1.k794b7964.6c218470f844481fc095ad6a185b4b6a26b4f53ec24fb7e90f7eb5e109ce54b1.9OV5jh7WsD_9Aem8CMAd3rOx_oZ_aBk9C6zWOd90LLM
+ hash: v1.k794b7964.7b9594f461cd8f64bb3f910eee70c50ff892a11fbf942f3ca2c9405580aee19c.5c4FR1Eo4orcBQHwvE357ngasRDvyePLNE6JTky4C0U
scenes-app-feature-flags-code-examples--code-instructions-node-with-group-multivariate-flag-local-evaluation--dark:
hash: v1.k794b7964.3ce50a6c3abbe37a320a41b9b595595f1f563ee2810f7039c1077de0de2ce541.NshMoutmoo5MZNYuOO7ESAXGz5weprcVLeWqVRJevZA
scenes-app-feature-flags-code-examples--code-instructions-node-with-group-multivariate-flag-local-evaluation--light:
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index f2e450ea109a..49e5ce482ddc 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -308,7 +308,6 @@ export const FEATURE_FLAGS = {
FEATURE_FLAG_NOTIFICATIONS: 'feature-flag-notifications', // owner: @reecejones #team-platform-features
FEATURE_FLAG_USAGE_DASHBOARD_CHECKBOX: 'feature-flag-usage-dashboard-checkbox', // owner: #team-feature-flags, globally disabled, enables opt-out of auto dashboard creation
FEATURE_FLAGS_ACROSS_PROJECTS_INDEX: 'feature-flags-across-projects-index', // owner: #team-platform-features
- FEATURE_FLAGS_V2: 'feature-flags-v2', // owner: @dmarticus #team-feature-flags
FLAG_EVALUATION_RUNTIMES: 'flag-evaluation-runtimes', // owner: @dmarticus #team-feature-flags
FLAG_EVALUATION_TAGS: 'flag-evaluation-tags', // owner: @dmarticus #team-feature-flags
FLAGGED_FEATURE_INDICATOR: 'flagged-feature-indicator', // owner: @benjackwhite
diff --git a/frontend/src/scenes/feature-flags/FeatureFlag.tsx b/frontend/src/scenes/feature-flags/FeatureFlag.tsx
index a232d497181a..429465873eb0 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlag.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlag.tsx
@@ -1,65 +1,39 @@
import './FeatureFlag.scss'
import { useActions, useValues } from 'kea'
-import { Form, Group } from 'kea-forms'
import { router } from 'kea-router'
-import posthog from 'posthog-js'
import { useEffect, useState } from 'react'
-import {
- IconCollapse,
- IconCopy,
- IconExpand,
- IconGlobe,
- IconLaptop,
- IconPlusSmall,
- IconRewind,
- IconServer,
- IconTrash,
-} from '@posthog/icons'
-import { LemonDialog, LemonSegmentedButton, LemonSkeleton, LemonSwitch } from '@posthog/lemon-ui'
+import { IconCopy, IconPlusSmall, IconRewind, IconTrash } from '@posthog/icons'
+import { LemonDialog, LemonSkeleton } from '@posthog/lemon-ui'
-import { approvalsGateLogic } from 'lib/approvals/approvalsGateLogic'
import { AccessControlAction } from 'lib/components/AccessControlAction'
import { AccessDenied } from 'lib/components/AccessDenied'
import { ActivityLog } from 'lib/components/ActivityLog/ActivityLog'
-import { CopyToClipboardInline } from 'lib/components/CopyToClipboard'
import { NotFound } from 'lib/components/NotFound'
-import { ObjectTags } from 'lib/components/ObjectTags/ObjectTags'
import { SceneAddToNotebookDropdownMenu } from 'lib/components/Scenes/InsightOrDashboard/SceneAddToNotebookDropdownMenu'
import { SceneFile } from 'lib/components/Scenes/SceneFile'
import { SceneMenuBarAddToNotebook } from 'lib/components/Scenes/SceneMenuBarAddToNotebook'
import { SceneMenuBarFileItems } from 'lib/components/Scenes/SceneMenuBarFileItems'
import { SceneTags } from 'lib/components/Scenes/SceneTags'
import { SceneTagsCombobox } from 'lib/components/Scenes/SceneTagsCombobox'
-import ViewRecordingsPlaylistButton from 'lib/components/ViewRecordingButton/ViewRecordingsPlaylistButton'
import { FEATURE_FLAGS } from 'lib/constants'
import { useFileSystemLogView } from 'lib/hooks/useFileSystemLogView'
-import { IconOpenInNew } from 'lib/lemon-ui/icons'
import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
-import { LemonCheckbox } from 'lib/lemon-ui/LemonCheckbox'
-import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
-import { LemonField } from 'lib/lemon-ui/LemonField'
-import { LemonInput } from 'lib/lemon-ui/LemonInput/LemonInput'
import { LemonTab, LemonTabs } from 'lib/lemon-ui/LemonTabs'
import { LemonTag } from 'lib/lemon-ui/LemonTag/LemonTag'
import 'lib/lemon-ui/Lettermark'
-import { LemonTextArea } from 'lib/lemon-ui/LemonTextArea/LemonTextArea'
import { Link } from 'lib/lemon-ui/Link'
import { featureFlagLogic as enabledFeaturesLogic } from 'lib/logic/featureFlagLogic'
import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
-import { Label } from 'lib/ui/Label/Label'
-import { capitalizeFirstLetter } from 'lib/utils'
import { userHasAccess } from 'lib/utils/accessControlUtils'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { addProductIntentForCrossSell } from 'lib/utils/product-intents'
import { PendingChangeRequestBanner } from 'scenes/approvals/PendingChangeRequestBanner'
-import { ApprovalActionKey } from 'scenes/approvals/utils'
import { Dashboard } from 'scenes/dashboard/Dashboard'
import { dashboardLogic } from 'scenes/dashboard/dashboardLogic'
import { EmptyDashboardComponent } from 'scenes/dashboard/EmptyDashboardComponent'
-import { JSONEditorInput } from 'scenes/feature-flags/JSONEditorInput'
import { FeatureFlagPermissions } from 'scenes/FeatureFlagPermissions'
import { NotebookNodeType } from 'scenes/notebooks/types'
import { SceneExport } from 'scenes/sceneTypes'
@@ -71,7 +45,6 @@ import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
-import { SceneDivider } from '~/layout/scenes/components/SceneDivider'
import {
SceneMenuBar,
SceneMenuBarItem,
@@ -80,7 +53,6 @@ import {
SceneMenuBarSeparator,
SceneMenuBarSubMenu,
} from '~/layout/scenes/components/SceneMenuBar'
-import { SceneSection } from '~/layout/scenes/components/SceneSection'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import {
ScenePanel,
@@ -100,31 +72,22 @@ import {
DashboardPlacement,
DashboardType,
EarlyAccessFeatureStage,
- FeatureFlagEvaluationRuntime,
- FeatureFlagGroupType,
FeatureFlagType,
PropertyFilterType,
PropertyOperator,
QueryBasedInsightModel,
} from '~/types'
-import { FeatureFlagCodeExample } from './FeatureFlagCodeExample'
-import { FeatureFlagConditionWarning } from './FeatureFlagConditionWarning'
import { FeatureFlagEvaluationContexts } from './FeatureFlagEvaluationContexts'
import { ExperimentsTab } from './FeatureFlagExperimentsTab'
import { FeedbackTab } from './FeatureFlagFeedbackTab'
import { FeatureFlagForm } from './FeatureFlagForm'
-import { DependentFlag, FeatureFlagLogicProps, featureFlagLogic, slugifyFeatureFlagKey } from './featureFlagLogic'
-import { FeatureFlagOverviewV2 } from './FeatureFlagOverviewV2'
+import { FeatureFlagLogicProps, featureFlagLogic } from './featureFlagLogic'
+import { FeatureFlagOverview } from './FeatureFlagOverview'
import FeatureFlagProjects from './FeatureFlagProjects'
-import { FeatureFlagReleaseConditions } from './FeatureFlagReleaseConditions'
import FeatureFlagSchedule from './FeatureFlagSchedule'
import { FeatureFlagsTab, featureFlagsLogic } from './featureFlagsLogic'
-import { FeatureFlagStatusIndicator } from './FeatureFlagStatusIndicator'
import { FeatureFlagTestingTab } from './FeatureFlagTestingTab'
-import { UserFeedbackSection } from './FeatureFlagUserFeedback'
-import { FeatureFlagVariantsForm, focusVariantKeyField } from './FeatureFlagVariantsForm'
-import { RecentFeatureFlagInsights } from './RecentFeatureFlagInsightsCard'
const RESOURCE_TYPE = 'feature_flag'
@@ -140,22 +103,19 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
const {
props,
featureFlag,
- originalFeatureFlag,
featureFlagLoading,
featureFlagMissing,
isEditingFlag,
activeTab,
accessDeniedToFeatureFlag,
- experiment,
+ earlyAccessFeaturesList,
} = useValues(featureFlagLogic)
const { featureFlags } = useValues(enabledFeaturesLogic)
const {
deleteFeatureFlag,
restoreFeatureFlag,
editFeatureFlag,
- loadFeatureFlag,
createStaticCohort,
- setFeatureFlagFilters,
setActiveTab,
updateFlag,
saveFeatureFlag,
@@ -163,18 +123,13 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
saveTagsInline,
} = useActions(featureFlagLogic)
- const { earlyAccessFeaturesList } = useValues(featureFlagLogic)
-
const { tags } = useValues(tagsModel)
const { currentTeamId } = useValues(teamLogic)
- const { isApprovalRequired } = useValues(approvalsGateLogic)
const { reportUserFeedbackButtonClicked } = useActions(eventUsageLogic)
const [isQuickSurveyModalOpen, setIsQuickSurveyModalOpen] = useState(false)
const [quickSurveyVariantKey, setQuickSurveyVariantKey] = useState<string | null>(null)
- const [advancedSettingsExpanded, setAdvancedSettingsExpanded] = useState(false)
-
const handleGetFeedback = (variantKey?: string): void => {
const hasVariantSurvey = variantKey
? !!getSurveyForFeatureFlagVariant(variantKey, featureFlag.surveys ?? [])
@@ -199,7 +154,6 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
}
const isNewFeatureFlag = id === 'new' || id === undefined
- const useFormUI = !!featureFlags[FEATURE_FLAGS.FEATURE_FLAGS_V2]
useFileSystemLogView({
type: 'feature_flag',
@@ -229,9 +183,9 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
)
}
- // Use new form UI for creating new flags or editing existing flags
- // For viewing existing flags (readonly), use the existing FeatureFlag UI with tabs
- if (useFormUI && (isNewFeatureFlag || isEditingFlag)) {
+ // Use the form UI for creating new flags or editing existing flags.
+ // For viewing existing flags (readonly), use the tabbed UI below.
+ if (isNewFeatureFlag || isEditingFlag) {
return <FeatureFlagForm id={id} />
}
@@ -239,36 +193,13 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
return <AccessDenied object="feature flag" />
}
- const earlyAccessFeature = earlyAccessFeaturesList?.find((f: any) => f.flagKey === featureFlag.key)
+ const earlyAccessFeature = earlyAccessFeaturesList?.find((f) => f.flagKey === featureFlag.key)
const tabs = [
{
label: 'Overview',
key: FeatureFlagsTab.OVERVIEW,
- content: useFormUI ? (
- <FeatureFlagOverviewV2 featureFlag={featureFlag} />
- ) : (
- <>
- <div className="flex flex-col gap-4">
- <FeatureFlagRollout readOnly onGetFeedback={handleGetFeedback} />
- {!featureFlag.is_remote_configuration && (
- <>
- <SceneDivider />
- <FeatureFlagReleaseConditions readOnly filters={featureFlag.filters} />
-
- <SceneDivider />
-
- <SceneSection title="Insights that use this feature flag">
- <RecentFeatureFlagInsights />
- </SceneSection>
- </>
- )}
-
- <SceneDivider />
- <FeatureFlagCodeExample featureFlag={featureFlag} />
- </div>
- </>
- ),
+ content: <FeatureFlagOverview featureFlag={featureFlag} />,
},
] as LemonTab<FeatureFlagsTab>[]
@@ -342,476 +273,191 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
return (
<>
<div className="feature-flag">
- {isNewFeatureFlag || isEditingFlag ? (
- <Form
- id="feature-flag"
- logic={featureFlagLogic}
- props={props}
- formKey="featureFlag"
- enableFormOnSubmit
- className="deprecated-space-y-4"
- >
- <SceneTitleSection
- name={featureFlag.key}
- resourceType={{
- type: featureFlag.active ? 'feature_flag' : 'feature_flag_off',
- }}
- actions={
- <>
- <LemonButton
- data-attr="cancel-feature-flag"
- type="secondary"
- size="small"
- onClick={() => {
- if (isEditingFlag) {
- editFeatureFlag(false)
- loadFeatureFlag()
- } else {
- router.actions.push(urls.featureFlags())
- }
- }}
- >
- Cancel
- </LemonButton>
- <LemonButton
- type="primary"
- data-attr="save-feature-flag"
- htmlType="submit"
- form="feature-flag"
- size="small"
- >
- Save
- </LemonButton>
- </>
- }
- />
-
- <SceneContent>
- {!isNewFeatureFlag && featureFlag.id && (
- <PendingChangeRequestBanner resourceType="feature_flag" resourceId={featureFlag.id} />
- )}
-
- {featureFlag.experiment_set && featureFlag.experiment_set.length > 0 && (
- <LemonBanner type="warning">
- This feature flag is linked to{' '}
- <Link target="_blank" to={urls.experiment(featureFlag.experiment_set[0])}>
- {experiment?.name ||
- featureFlag.experiment_set_metadata?.[0]?.name ||
- `experiment ${featureFlag.experiment_set[0]}`}
- </Link>
- . Make changes from the experiment page unless you need advanced flag settings.
- </LemonBanner>
- )}
- <div className="max-w-1/2 deprecated-space-y-4">
- <LemonField
- name="key"
- label="Key"
- help={
- id !== 'new' &&
- originalFeatureFlag &&
- featureFlag.key !== originalFeatureFlag.key ? (
- <span className="text-warning">
- <b>Warning! </b>Changing this key will break any existing code that
- references it (e.g.{' '}
- <code className="text-xs bg-fill-secondary rounded px-1 py-0.5">
- getFeatureFlag('{originalFeatureFlag.key}')
- </code>
- ). Make sure to update all SDK calls and integrations.
- </span>
- ) : undefined
- }
- >
- {({ value, onChange }) => (
- <>
- <LemonInput
- value={value}
- onChange={(v) => {
- const normalized = slugifyFeatureFlagKey(v)
- onChange(normalized)
- }}
- data-attr="feature-flag-key"
- className="ph-ignore-input"
- autoFocus
- placeholder="examples: new-landing-page, betaFeature, ab_test_1"
- autoComplete="off"
- autoCapitalize="off"
- autoCorrect="off"
- spellCheck={false}
- />
- <span className="text-secondary text-sm">
- Feature flag keys must be unique
- </span>
- </>
- )}
- </LemonField>
-
- <LemonField name="name" label="Description">
- {({ value, onChange }) => (
- <LemonTextArea
- className="ph-ignore-input"
- data-attr="feature-flag-description"
- value={value || ''}
- onChange={onChange}
- />
- )}
- </LemonField>
- </div>
- <SceneDivider />
- <FeatureFlagRollout onGetFeedback={handleGetFeedback} />
- <SceneDivider />
- {!featureFlag.is_remote_configuration && (
- <>
- <FeatureFlagReleaseConditions
- id={`${featureFlag.id}`}
- filters={featureFlag.filters}
- onChange={setFeatureFlagFilters}
- evaluationRuntime={featureFlag.evaluation_runtime}
- isDisabled={!featureFlag.active}
- />
- <SceneDivider />
- </>
- )}
- <LemonField name="active">
- {({ value, onChange }) => {
- const requiresApprovalToEnable =
- isNewFeatureFlag && isApprovalRequired(ApprovalActionKey.FEATURE_FLAG_ENABLE)
-
- // If approval is required and value is still true, set it to false
- if (requiresApprovalToEnable && value) {
- queueMicrotask(() => onChange(false))
+ <ScenePanel>
+ <ScenePanelInfoSection>
+ {featureFlags[FEATURE_FLAGS.FLAG_EVALUATION_TAGS] ? (
+ <FeatureFlagEvaluationContexts
+ tags={featureFlag.tags}
+ evaluationContexts={featureFlag.evaluation_contexts || []}
+ onSave={(updatedTags, updatedEvaluationContexts) => {
+ const updatedFlag = {
+ ...featureFlag,
+ tags: updatedTags,
+ evaluation_contexts: updatedEvaluationContexts,
}
-
- return (
- <div className="border rounded p-4">
- <LemonCheckbox
- id="flag-enabled-checkbox"
- label="Enable feature flag"
- onChange={() => onChange(!value)}
- checked={value}
- disabledReason={
- requiresApprovalToEnable
- ? 'Enabling feature flags requires approval. Create the flag first, then enable it.'
- : undefined
- }
- data-attr="feature-flag-enabled-checkbox"
- />
- <div className="text-secondary text-sm pl-7">
- When enabled, this flag evaluates according to your release conditions.
- When disabled, this flag will not be evaluated and PostHog SDKs default
- to returning <code>false</code>.
- </div>
- </div>
- )
+ updateFlag(updatedFlag)
+ saveFeatureFlag(updatedFlag)
}}
- </LemonField>
- {isNewFeatureFlag && featureFlags[FEATURE_FLAGS.FEATURE_FLAG_USAGE_DASHBOARD_CHECKBOX] && (
- <LemonField name="_should_create_usage_dashboard">
- {({ value, onChange }) => (
- <div className="border rounded p-4">
- <LemonCheckbox
- id="create-usage-dashboard-checkbox"
- label="Create usage dashboard"
- onChange={() => onChange(!value)}
- checked={value}
- data-attr="create-usage-dashboard-checkbox"
- />
- <div className="text-secondary text-sm pl-7">
- Automatically track how often this flag is called and what values are
- returned. Creates a dashboard with call volume trends and variant
- distribution insights.
- </div>
- </div>
- )}
- </LemonField>
- )}
- {!featureFlag.is_remote_configuration && (
- <LemonField name="ensure_experience_continuity">
- {({ value, onChange }) => (
- <div className="border rounded p-4">
- <LemonCheckbox
- id="continuity-checkbox"
- label="Persist flag across authentication steps"
- onChange={() => onChange(!value)}
- fullWidth
- checked={value}
- />
- <div className="text-secondary text-sm pl-7">
- If your feature flag is applied before identifying the user, use this to
- ensure that the flag value remains consistent for the same user.
- Depending on your setup, this option might not always be suitable. This
- feature requires creating profiles for anonymous users.{' '}
- <Link
- to="https://posthog.com/docs/feature-flags/creating-feature-flags#persisting-feature-flags-across-authentication-steps"
- target="_blank"
- >
- Learn more
- </Link>
- </div>
- </div>
- )}
- </LemonField>
- )}
- {featureFlags[FEATURE_FLAGS.FLAG_EVALUATION_RUNTIMES] && (
- <>
- <SceneDivider />
- <SceneSection title="Evaluation runtime">
- <div className="text-secondary text-sm mb-2">
- This setting controls where your feature flag can be evaluated. If you try
- to use a flag in a runtime where it's not allowed (e.g., using a server-only
- flag in client-side code), it won't evaluate.{' '}
- <Link
- to="https://posthog.com/docs/feature-flags/creating-feature-flags#step-5-configure-evaluation-runtime-and-contexts-optional"
- target="_blank"
- targetBlankIcon
- >
- Learn more about using evaluation runtimes
- </Link>
- </div>
- <LemonField name="evaluation_runtime">
- {({ value, onChange }) => (
- <div className="grid grid-cols-1 gap-3 md:grid-cols-3">
- {[
- {
- value: FeatureFlagEvaluationRuntime.ALL,
- icon: <IconGlobe />,
- title: 'Both client and server',
- description: 'Single-user apps + multi-user systems',
- },
- {
- value: FeatureFlagEvaluationRuntime.CLIENT,
- icon: <IconLaptop />,
- title: 'Client-side only',
- description: 'Single-user apps (mobile, desktop, embedded)',
- },
- {
- value: FeatureFlagEvaluationRuntime.SERVER,
- icon: <IconServer />,
- title: 'Server-side only',
- description: 'Multi-user systems in trusted environments',
- },
- ].map((option) => (
- <div
- key={option.value}
- className={`border rounded-lg p-4 cursor-pointer transition-all hover:border-primary-light ${
- value === option.value
- ? 'border-primary bg-primary-highlight'
- : 'border-border'
- }`}
- onClick={() => onChange(option.value)}
- >
- <div className="flex items-start gap-3">
- <div className="text-lg text-muted">{option.icon}</div>
- <div className="flex-1">
- <div className="font-medium text-sm">
- {option.title}
- </div>
- <div className="text-xs text-muted mt-1">
- {option.description}
- </div>
- </div>
- <input
- type="radio"
- name="evaluation-environment"
- checked={value === option.value}
- onChange={() => onChange(option.value)}
- className="cursor-pointer"
- />
- </div>
- </div>
- ))}
- </div>
- )}
- </LemonField>
- </SceneSection>
- </>
- )}
- <SceneDivider />
- <SceneSection title="Tags">
- {!featureFlags[FEATURE_FLAGS.FLAG_EVALUATION_TAGS] ? null : (
- <div className="text-secondary text-sm mb-2">
- Use tags to organize and filter your feature flags.
- </div>
- )}
- <LemonField name="tags">
- {({ value: formTags, onChange: onChangeTags }) => (
- <>
- {featureFlags[FEATURE_FLAGS.FLAG_EVALUATION_TAGS] ? (
- <LemonField name="evaluation_contexts">
- {({ value: formEvalContexts, onChange: onChangeEvalContexts }) => (
- <FeatureFlagEvaluationContexts
- tags={formTags}
- evaluationContexts={formEvalContexts || []}
- onChange={(updatedTags, updatedEvaluationContexts) => {
- onChangeTags(updatedTags)
- onChangeEvalContexts(updatedEvaluationContexts)
- }}
- tagsAvailable={tags.filter(
- (tag: string) => !formTags?.includes(tag)
- )}
- className="mt-2"
- flagId={featureFlag.id}
- context="form"
- />
- )}
- </LemonField>
- ) : (
- <ObjectTags
- tags={formTags}
- onChange={onChangeTags}
- saving={featureFlagLoading}
- tagsAvailable={tags.filter(
- (tag: string) => !formTags?.includes(tag)
- )}
- className="mt-2"
- />
- )}
- </>
- )}
- </LemonField>
- </SceneSection>
- <SceneDivider />
+ tagsAvailable={tags.filter((tag: string) => !featureFlag.tags?.includes(tag))}
+ flagId={featureFlag.id}
+ context="sidebar"
+ />
+ ) : (
+ <SceneTags
+ onSave={(tags) => {
+ const updatedFlag = { ...featureFlag, tags }
+ updateFlag(updatedFlag)
+ saveFeatureFlag(updatedFlag)
+ }}
+ canEdit
+ tags={featureFlag.tags}
+ tagsAvailable={tags.filter((tag: string) => !featureFlag.tags?.includes(tag))}
+ dataAttrKey={RESOURCE_TYPE}
+ />
+ )}
- <FeatureFlagCodeExample featureFlag={featureFlag} />
- <LemonDivider />
- {isNewFeatureFlag && (
- <>
- <div>
- <LemonButton
- fullWidth
- onClick={() => setAdvancedSettingsExpanded(!advancedSettingsExpanded)}
- sideIcon={advancedSettingsExpanded ? <IconCollapse /> : <IconExpand />}
- >
- <div>
- <h3 className="l4 mt-2">Advanced settings</h3>
- <div className="text-secondary mb-2 font-medium">
- Define who can modify this flag.
- </div>
- </div>
- </LemonButton>
- </div>
- {advancedSettingsExpanded && (
- <>
- <div className="border rounded bg-surface-primary">
- <h3 className="p-2 mb-0">Permissions</h3>
- <LemonDivider className="my-0" />
- <div className="p-3">
- <FeatureFlagPermissions featureFlag={featureFlag} />
- </div>
- </div>
- </>
- )}
- <LemonDivider />
- </>
- )}
- <div className="flex items-center gap-2 justify-end">
- <LemonButton
- data-attr="cancel-feature-flag"
- type="secondary"
+ <SceneFile dataAttrKey={RESOURCE_TYPE} />
+ </ScenePanelInfoSection>
+ <ScenePanelDivider />
+ <ScenePanelActionsSection>
+ <ButtonPrimitive
+ onClick={() => {
+ router.actions.push(urls.featureFlagNew({ sourceId: featureFlag.id }))
+ }}
+ menuItem
+ data-attr={`${RESOURCE_TYPE}-duplicate`}
+ >
+ <IconCopy />
+ Duplicate
+ </ButtonPrimitive>
+ <SceneAddToNotebookDropdownMenu dataAttrKey={RESOURCE_TYPE} />
+ {featureFlags[FEATURE_FLAGS.FEATURE_FLAG_COHORT_CREATION] && (
+ <ButtonPrimitive
+ menuItem
+ data-attr={`${RESOURCE_TYPE}-create-cohort`}
+ onClick={() => createStaticCohort()}
+ >
+ <IconPlusSmall />
+ Create cohort
+ </ButtonPrimitive>
+ )}
+ <ButtonPrimitive
+ menuItem
+ data-attr={`${RESOURCE_TYPE}-create-survey`}
+ onClick={() => handleGetFeedback()}
+ >
+ <IconPlusSmall />
+ Create survey
+ </ButtonPrimitive>
+ </ScenePanelActionsSection>
+ <ScenePanelDivider />
+ <ScenePanelActionsSection>
+ <AccessControlAction
+ resourceType={AccessControlResourceType.FeatureFlag}
+ minAccessLevel={AccessControlLevel.Editor}
+ >
+ {({ disabledReason }) => (
+ <ButtonPrimitive
+ menuItem
+ variant="danger"
+ disabled={!!disabledReason}
+ {...(disabledReason && { tooltip: disabledReason })}
+ data-attr={featureFlag.deleted ? 'restore-feature-flag' : 'delete-feature-flag'}
onClick={() => {
- if (isEditingFlag) {
- editFeatureFlag(false)
- loadFeatureFlag()
+ if (featureFlag.deleted) {
+ restoreFeatureFlag(featureFlag)
} else {
- router.actions.push(urls.featureFlags())
+ LemonDialog.open({
+ title: 'Delete feature flag?',
+ description: `Are you sure you want to delete "${featureFlag.key}"?`,
+ primaryButton: {
+ children: 'Delete',
+ status: 'danger',
+ onClick: () => deleteFeatureFlag(featureFlag),
+ size: 'small',
+ },
+ secondaryButton: {
+ children: 'Cancel',
+ type: 'tertiary',
+ size: 'small',
+ },
+ })
}
}}
- >
- Cancel
- </LemonButton>
- <LemonButton
- type="primary"
- data-attr="save-feature-flag"
- htmlType="submit"
- form="feature-flag"
- >
- Save
- </LemonButton>
- </div>
- </SceneContent>
- </Form>
- ) : (
- <>
- <ScenePanel>
- <ScenePanelInfoSection>
- {featureFlags[FEATURE_FLAGS.FLAG_EVALUATION_TAGS] ? (
- <FeatureFlagEvaluationContexts
- tags={featureFlag.tags}
- evaluationContexts={featureFlag.evaluation_contexts || []}
- onSave={(updatedTags, updatedEvaluationContexts) => {
- const updatedFlag = {
- ...featureFlag,
- tags: updatedTags,
- evaluation_contexts: updatedEvaluationContexts,
- }
- updateFlag(updatedFlag)
- saveFeatureFlag(updatedFlag)
- }}
- tagsAvailable={tags.filter((tag: string) => !featureFlag.tags?.includes(tag))}
- flagId={featureFlag.id}
- context="sidebar"
- />
- ) : (
- <SceneTags
- onSave={(tags) => {
- const updatedFlag = { ...featureFlag, tags }
- updateFlag(updatedFlag)
- saveFeatureFlag(updatedFlag)
- }}
- canEdit
- tags={featureFlag.tags}
- tagsAvailable={tags.filter((tag: string) => !featureFlag.tags?.includes(tag))}
- dataAttrKey={RESOURCE_TYPE}
- />
- )}
-
- <SceneFile dataAttrKey={RESOURCE_TYPE} />
- </ScenePanelInfoSection>
- <ScenePanelDivider />
- <ScenePanelActionsSection>
- <ButtonPrimitive
- onClick={() => {
- router.actions.push(urls.featureFlagNew({ sourceId: featureFlag.id }))
+ disabledReasons={{
+ "You have only 'View' access for this feature flag. To make changes, please contact the flag's creator.":
+ !featureFlag.can_edit,
+ 'This feature flag is in use with an early access feature. Delete the early access feature to delete this flag':
+ (featureFlag.features?.length || 0) > 0,
+ 'This feature flag is linked to an experiment. Delete the experiment to delete this flag':
+ (featureFlag.experiment_set?.length || 0) > 0,
+ 'This feature flag is linked to a survey. Delete the survey to delete this flag':
+ (featureFlag.surveys?.length || 0) > 0,
+ 'This feature flag is used in session replay settings for recording conditions. Remove it from replay settings to delete this flag':
+ featureFlag.is_used_in_replay_settings || false,
}}
- menuItem
- data-attr={`${RESOURCE_TYPE}-duplicate`}
>
- <IconCopy />
- Duplicate
+ {featureFlag.deleted ? <IconRewind /> : <IconTrash />}
+ {featureFlag.deleted ? 'Restore' : 'Delete'} feature flag
</ButtonPrimitive>
- <SceneAddToNotebookDropdownMenu dataAttrKey={RESOURCE_TYPE} />
- {featureFlags[FEATURE_FLAGS.FEATURE_FLAG_COHORT_CREATION] && (
- <ButtonPrimitive
- menuItem
- data-attr={`${RESOURCE_TYPE}-create-cohort`}
- onClick={() => createStaticCohort()}
+ )}
+ </AccessControlAction>
+ </ScenePanelActionsSection>
+ </ScenePanel>
+ <SceneContent>
+ {featureFlag.id && (
+ <PendingChangeRequestBanner resourceType="feature_flag" resourceId={featureFlag.id} />
+ )}
+
+ {earlyAccessFeature && earlyAccessFeature.stage === EarlyAccessFeatureStage.Concept && (
+ <LemonBanner type="info">
+ This feature flag is assigned to an early access feature in the{' '}
+ <LemonTag type="default" className="uppercase">
+ Concept
+ </LemonTag>{' '}
+ stage. All users who register interest will be assigned this feature flag. Gate your code
+ behind a different feature flag if you'd like to keep it hidden, and then switch your code
+ to this feature flag when you're ready to release to your early access users.
+ </LemonBanner>
+ )}
+ {featureFlags[FEATURE_FLAGS.SCENE_MENU_BAR] && (
+ <SceneMenuBar>
+ <SceneMenuBarMenu label="File" dataAttr={`${RESOURCE_TYPE}-menubar-file`}>
+ <SceneMenuBarSubMenu label="Create">
+ {featureFlag.id && (
+ <SceneMenuBarAddToNotebook
+ dataAttrKey={RESOURCE_TYPE}
+ notebookSelectButtonProps={{
+ resource: {
+ type: NotebookNodeType.FeatureFlag,
+ attrs: { id: featureFlag.id },
+ },
+ }}
+ />
+ )}
+ {featureFlags[FEATURE_FLAGS.FEATURE_FLAG_COHORT_CREATION] && (
+ <SceneMenuBarItem
+ onClick={() => createStaticCohort()}
+ data-attr={`${RESOURCE_TYPE}-menubar-create-cohort`}
+ >
+ <IconPlusSmall />
+ Cohort
+ </SceneMenuBarItem>
+ )}
+ <SceneMenuBarItem
+ opensFloatingUi
+ onClick={() => handleGetFeedback()}
+ data-attr={`${RESOURCE_TYPE}-menubar-create-survey`}
>
<IconPlusSmall />
- Create cohort
- </ButtonPrimitive>
- )}
- <ButtonPrimitive
- menuItem
- data-attr={`${RESOURCE_TYPE}-create-survey`}
- onClick={() => handleGetFeedback()}
- >
- <IconPlusSmall />
- Create survey
- </ButtonPrimitive>
- </ScenePanelActionsSection>
- <ScenePanelDivider />
- <ScenePanelActionsSection>
+ Survey
+ </SceneMenuBarItem>
+ </SceneMenuBarSubMenu>
+ <SceneMenuBarSeparator />
+ <SceneMenuBarFileItems dataAttrKey={RESOURCE_TYPE} />
+ <SceneMenuBarSeparator />
<AccessControlAction
resourceType={AccessControlResourceType.FeatureFlag}
minAccessLevel={AccessControlLevel.Editor}
>
{({ disabledReason }) => (
- <ButtonPrimitive
- menuItem
- variant="danger"
+ <SceneMenuBarItem
+ variant="destructive"
disabled={!!disabledReason}
- {...(disabledReason && { tooltip: disabledReason })}
data-attr={
- featureFlag.deleted ? 'restore-feature-flag' : 'delete-feature-flag'
+ featureFlag.deleted
+ ? `${RESOURCE_TYPE}-menubar-restore`
+ : `${RESOURCE_TYPE}-menubar-delete`
}
onClick={() => {
if (featureFlag.deleted) {
@@ -834,193 +480,79 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
})
}
}}
- disabledReasons={{
- "You have only 'View' access for this feature flag. To make changes, please contact the flag's creator.":
- !featureFlag.can_edit,
- 'This feature flag is in use with an early access feature. Delete the early access feature to delete this flag':
- (featureFlag.features?.length || 0) > 0,
- 'This feature flag is linked to an experiment. Delete the experiment to delete this flag':
- (featureFlag.experiment_set?.length || 0) > 0,
- 'This feature flag is linked to a survey. Delete the survey to delete this flag':
- (featureFlag.surveys?.length || 0) > 0,
- 'This feature flag is used in session replay settings for recording conditions. Remove it from replay settings to delete this flag':
- featureFlag.is_used_in_replay_settings || false,
- }}
>
{featureFlag.deleted ? <IconRewind /> : <IconTrash />}
{featureFlag.deleted ? 'Restore' : 'Delete'} feature flag
- </ButtonPrimitive>
+ </SceneMenuBarItem>
)}
</AccessControlAction>
- </ScenePanelActionsSection>
- </ScenePanel>
- <SceneContent>
- {featureFlag.id && (
- <PendingChangeRequestBanner resourceType="feature_flag" resourceId={featureFlag.id} />
- )}
-
- {earlyAccessFeature && earlyAccessFeature.stage === EarlyAccessFeatureStage.Concept && (
- <LemonBanner type="info">
- This feature flag is assigned to an early access feature in the{' '}
- <LemonTag type="default" className="uppercase">
- Concept
- </LemonTag>{' '}
- stage. All users who register interest will be assigned this feature flag. Gate your
- code behind a different feature flag if you'd like to keep it hidden, and then
- switch your code to this feature flag when you're ready to release to your early
- access users.
- </LemonBanner>
- )}
- {featureFlags[FEATURE_FLAGS.SCENE_MENU_BAR] && (
- <SceneMenuBar>
- <SceneMenuBarMenu label="File" dataAttr={`${RESOURCE_TYPE}-menubar-file`}>
- <SceneMenuBarSubMenu label="Create">
- {featureFlag.id && (
- <SceneMenuBarAddToNotebook
- dataAttrKey={RESOURCE_TYPE}
- notebookSelectButtonProps={{
- resource: {
- type: NotebookNodeType.FeatureFlag,
- attrs: { id: featureFlag.id },
- },
- }}
- />
- )}
- {featureFlags[FEATURE_FLAGS.FEATURE_FLAG_COHORT_CREATION] && (
- <SceneMenuBarItem
- onClick={() => createStaticCohort()}
- data-attr={`${RESOURCE_TYPE}-menubar-create-cohort`}
- >
- <IconPlusSmall />
- Cohort
- </SceneMenuBarItem>
- )}
- <SceneMenuBarItem
- opensFloatingUi
- onClick={() => handleGetFeedback()}
- data-attr={`${RESOURCE_TYPE}-menubar-create-survey`}
- >
- <IconPlusSmall />
- Survey
- </SceneMenuBarItem>
- </SceneMenuBarSubMenu>
- <SceneMenuBarSeparator />
- <SceneMenuBarFileItems dataAttrKey={RESOURCE_TYPE} />
- <SceneMenuBarSeparator />
- <AccessControlAction
- resourceType={AccessControlResourceType.FeatureFlag}
- minAccessLevel={AccessControlLevel.Editor}
- >
- {({ disabledReason }) => (
- <SceneMenuBarItem
- variant="destructive"
- disabled={!!disabledReason}
- data-attr={
- featureFlag.deleted
- ? `${RESOURCE_TYPE}-menubar-restore`
- : `${RESOURCE_TYPE}-menubar-delete`
- }
- onClick={() => {
- if (featureFlag.deleted) {
- restoreFeatureFlag(featureFlag)
- } else {
- LemonDialog.open({
- title: 'Delete feature flag?',
- description: `Are you sure you want to delete "${featureFlag.key}"?`,
- primaryButton: {
- children: 'Delete',
- status: 'danger',
- onClick: () => deleteFeatureFlag(featureFlag),
- size: 'small',
- },
- secondaryButton: {
- children: 'Cancel',
- type: 'tertiary',
- size: 'small',
- },
- })
- }
- }}
- >
- {featureFlag.deleted ? <IconRewind /> : <IconTrash />}
- {featureFlag.deleted ? 'Restore' : 'Delete'} feature flag
- </SceneMenuBarItem>
- )}
- </AccessControlAction>
- </SceneMenuBarMenu>
- <SceneMenuBarMenu label="Edit" dataAttr={`${RESOURCE_TYPE}-menubar-edit`}>
- <SceneMenuBarItem
- onClick={() => {
- router.actions.push(urls.featureFlagNew({ sourceId: featureFlag.id }))
- }}
- data-attr={`${RESOURCE_TYPE}-menubar-duplicate`}
- >
- <IconCopy />
- Duplicate
- </SceneMenuBarItem>
- </SceneMenuBarMenu>
- <SceneMenuBarPopover
- label="Metadata"
- dataAttr={`${RESOURCE_TYPE}-menubar-metadata`}
- >
- <SceneTagsCombobox
- onSave={(updatedTags) => saveTagsInline(updatedTags)}
- canEdit
- tags={featureFlag.tags}
- tagsAvailable={tags.filter(
- (tag: string) => !featureFlag.tags?.includes(tag)
- )}
- dataAttrKey={RESOURCE_TYPE}
- />
- </SceneMenuBarPopover>
- </SceneMenuBar>
- )}
- <SceneTitleSection
- name={featureFlag.key}
- description={featureFlag.name}
- resourceType={{
- type: featureFlag.active ? 'feature_flag' : 'feature_flag_off',
- }}
- canEdit={
- !featureFlag.deleted &&
- userHasAccess(
- AccessControlResourceType.FeatureFlag,
- AccessControlLevel.Editor,
- featureFlag.user_access_level
- )
- }
- saveOnBlur
- onDescriptionChange={(newName) => {
- saveDescriptionInline(newName)
- }}
- actions={
- <AccessControlAction
- resourceType={AccessControlResourceType.FeatureFlag}
- minAccessLevel={AccessControlLevel.Editor}
- userAccessLevel={featureFlag.user_access_level}
+ </SceneMenuBarMenu>
+ <SceneMenuBarMenu label="Edit" dataAttr={`${RESOURCE_TYPE}-menubar-edit`}>
+ <SceneMenuBarItem
+ onClick={() => {
+ router.actions.push(urls.featureFlagNew({ sourceId: featureFlag.id }))
+ }}
+ data-attr={`${RESOURCE_TYPE}-menubar-duplicate`}
+ >
+ <IconCopy />
+ Duplicate
+ </SceneMenuBarItem>
+ </SceneMenuBarMenu>
+ <SceneMenuBarPopover label="Metadata" dataAttr={`${RESOURCE_TYPE}-menubar-metadata`}>
+ <SceneTagsCombobox
+ onSave={(updatedTags) => saveTagsInline(updatedTags)}
+ canEdit
+ tags={featureFlag.tags}
+ tagsAvailable={tags.filter((tag: string) => !featureFlag.tags?.includes(tag))}
+ dataAttrKey={RESOURCE_TYPE}
+ />
+ </SceneMenuBarPopover>
+ </SceneMenuBar>
+ )}
+ <SceneTitleSection
+ name={featureFlag.key}
+ description={featureFlag.name}
+ resourceType={{
+ type: featureFlag.active ? 'feature_flag' : 'feature_flag_off',
+ }}
+ canEdit={
+ !featureFlag.deleted &&
+ userHasAccess(
+ AccessControlResourceType.FeatureFlag,
+ AccessControlLevel.Editor,
+ featureFlag.user_access_level
+ )
+ }
+ saveOnBlur
+ onDescriptionChange={(newName) => {
+ saveDescriptionInline(newName)
+ }}
+ actions={
+ <AccessControlAction
+ resourceType={AccessControlResourceType.FeatureFlag}
+ minAccessLevel={AccessControlLevel.Editor}
+ userAccessLevel={featureFlag.user_access_level}
+ >
+ {({ disabledReason }) => (
+ <LemonButton
+ type="secondary"
+ size="small"
+ disabledReason={disabledReason}
+ onClick={() => editFeatureFlag(true)}
>
- {({ disabledReason }) => (
- <LemonButton
- type="secondary"
- size="small"
- disabledReason={disabledReason}
- onClick={() => editFeatureFlag(true)}
- >
- Edit
- </LemonButton>
- )}
- </AccessControlAction>
- }
- />
- <LemonTabs
- activeKey={activeTab}
- onChange={(tab) => tab !== activeTab && setActiveTab(tab)}
- tabs={tabs}
- sceneInset
- />
- </SceneContent>
- </>
- )}
+ Edit
+ </LemonButton>
+ )}
+ </AccessControlAction>
+ }
+ />
+ <LemonTabs
+ activeKey={activeTab}
+ onChange={(tab) => tab !== activeTab && setActiveTab(tab)}
+ tabs={tabs}
+ sceneInset
+ />
+ </SceneContent>
</div>
<QuickSurveyModal
context={{
@@ -1159,700 +691,3 @@ function UsageTab({ featureFlag }: { featureFlag: FeatureFlagType }): JSX.Elemen
</div>
)
}
-
-function FeatureFlagRollout({
- readOnly,
- onGetFeedback,
-}: {
- readOnly?: boolean
- onGetFeedback?: (variantKey?: string) => void
-}): JSX.Element {
- const {
- multivariateEnabled,
- variants,
- nonEmptyVariants,
- aggregationTargetName,
- featureFlag,
- recordingFilterForFlag,
- flagStatus,
- flagType,
- flagTypeString,
- hasEncryptedPayloadBeenSaved,
- hasExperiment,
- isDraftExperiment,
- properties,
- variantErrors,
- experiment,
- experimentLoading,
- dependentFlags,
- featureFlagActiveUpdateLoading,
- } = useValues(featureFlagLogic)
- const { featureFlags } = useValues(enabledFeaturesLogic)
- const {
- distributeVariantsEqually,
- addVariant,
- removeVariant,
- setMultivariateEnabled,
- setFeatureFlag,
- setRemoteConfigEnabled,
- resetEncryptedPayload,
- toggleFeatureFlagActive,
- } = useActions(featureFlagLogic)
- const { addProductIntentForCrossSell } = useActions(teamLogic)
-
- const filterGroups: FeatureFlagGroupType[] = featureFlag.filters.groups || []
-
- const confirmRevertMultivariateEnabled = (): void => {
- LemonDialog.open({
- title: 'Change value type?',
- description: 'The existing variants will be lost',
- primaryButton: {
- children: 'Confirm',
- type: 'primary',
- onClick: () => setMultivariateEnabled(false),
- size: 'small',
- },
- secondaryButton: {
- children: 'Cancel',
- type: 'tertiary',
- size: 'small',
- },
- })
- }
-
- const confirmEncryptedPayloadReset = (): void => {
- LemonDialog.open({
- title: 'Reset payload?',
- description: 'The existing payload will not be reset until the feature flag is saved.',
- primaryButton: {
- children: 'Reset',
- onClick: resetEncryptedPayload,
- size: 'small',
- status: 'danger',
- },
- secondaryButton: {
- children: 'Cancel',
- type: 'tertiary',
- size: 'small',
- },
- })
- }
-
- const reportViewRecordingsClicked = (variantKey?: string): void => {
- const properties: Record<string, string> = {
- multivariate: multivariateEnabled.toString(),
- }
- if (variantKey) {
- properties.variant_key = variantKey
- }
- posthog.capture('viewed recordings from feature flag', properties)
- }
-
- const canEditVariant = (index: number): boolean => {
- if (hasExperiment && !isDraftExperiment) {
- return false
- }
- if (hasExperiment && isDraftExperiment && index === 0) {
- return false
- }
- return true
- }
-
- return (
- <SceneContent>
- {readOnly ? (
- <>
- <FeatureFlagConditionWarning
- properties={properties}
- evaluationRuntime={featureFlag.evaluation_runtime}
- />
- <div className="flex flex-col">
- <div className="grid grid-cols-2">
- <div className="card-secondary">Status</div>
- <div className="card-secondary">Type</div>
- <div>
- {featureFlag.deleted ? (
- <LemonTag size="medium" type="danger" className="uppercase">
- Deleted
- </LemonTag>
- ) : (
- <div className="flex gap-2">
- <AccessControlAction
- resourceType={AccessControlResourceType.FeatureFlag}
- minAccessLevel={AccessControlLevel.Editor}
- userAccessLevel={featureFlag.user_access_level}
- >
- <LemonSwitch
- onChange={(newValue) => {
- toggleFeatureFlagActive(newValue)
- }}
- label="Enable feature flag"
- loading={featureFlagActiveUpdateLoading}
- disabledReason={
- !featureFlag.can_edit
- ? "You only have view access to this feature flag. To make changes, contact the flag's creator."
- : null
- }
- checked={featureFlag.active}
- />
- </AccessControlAction>
-
- {!featureFlag.is_remote_configuration && (
- <FeatureFlagStatusIndicator flagStatus={flagStatus} />
- )}
- </div>
- )}
- </div>
- <div>
- <span className="mt-1">{flagTypeString}</span>
- </div>
-
- <div className="mt-4">
- <span className="card-secondary">Flag persistence</span>
- <div>
- This flag{' '}
- <b>{featureFlag.ensure_experience_continuity ? 'persists' : 'does not persist'} </b>
- across authentication events.
- </div>
- </div>
-
- {!experimentLoading &&
- experiment &&
- featureFlag.experiment_set &&
- featureFlag.experiment_set.length > 0 && (
- <div className="mt-4">
- <Label intent="menu">Linked experiment</Label>
- <div className="flex gap-1 items-center">
- <CopyToClipboardInline
- iconStyle={{
- color: 'var(--lemon-button-icon-opacity)',
- }}
- className="font-normal text-sm"
- description="experiment name"
- >
- {experiment.name}
- </CopyToClipboardInline>
- <Link
- target="_blank"
- className="font-semibold"
- to={urls.experiment(featureFlag.experiment_set[0])}
- >
- <IconOpenInNew fontSize="18" />
- </Link>
- </div>
- </div>
- )}
- </div>
-
- {featureFlags[FEATURE_FLAGS.FLAG_EVALUATION_RUNTIMES] && (
- <>
- <span className="card-secondary mt-4">Evaluation runtime</span>
- <div className="mt-2">
- <div className="flex items-center gap-2">
- {featureFlag.evaluation_runtime === FeatureFlagEvaluationRuntime.ALL ? (
- <>
- <IconGlobe className="text-lg text-muted" />
- <span className="font-medium">Both client and server</span>
- <LemonTag type="primary" size="small">
- Single + multi-user
- </LemonTag>
- </>
- ) : featureFlag.evaluation_runtime === FeatureFlagEvaluationRuntime.CLIENT ? (
- <>
- <IconLaptop className="text-lg text-muted" />
- <span className="font-medium">Client-side only</span>
- <LemonTag type="completion" size="small">
- Single-user apps
- </LemonTag>
- </>
- ) : (
- <>
- <IconServer className="text-lg text-muted" />
- <span className="font-medium">Server-side only</span>
- <LemonTag type="caution" size="small">
- Multi-user systems
- </LemonTag>
- </>
- )}
- </div>
- </div>
- </>
- )}
-
- {dependentFlags.length > 0 && (
- <div className="mt-4">
- <span className="card-secondary mt-4">Dependent flags</span>
- <div className="flex flex-col gap-1">
- {dependentFlags.map((flag: DependentFlag) => (
- <div key={flag.id} className="flex gap-1 items-center">
- <span className="font-normal text-sm">{flag.key}</span>
- <Link
- target="_blank"
- className="font-semibold"
- to={urls.featureFlag(flag.id)}
- aria-label={`Open ${flag.key}`}
- >
- <IconOpenInNew fontSize="18" />
- </Link>
- </div>
- ))}
- </div>
- </div>
- )}
- </div>
- <SceneDivider />
- {featureFlag.filters.multivariate && (
- <SceneSection title="Variant keys">
- <FeatureFlagVariantsForm
- variants={variants}
- payloads={featureFlag.filters?.payloads}
- readOnly={true}
- flagKey={featureFlag.key}
- hasEnrichedAnalytics={featureFlag.has_enriched_analytics}
- onViewRecordings={(variantKey) => {
- reportViewRecordingsClicked(variantKey)
- addProductIntentForCrossSell({
- from: ProductKey.FEATURE_FLAGS,
- to: ProductKey.SESSION_REPLAY,
- intent_context: ProductIntentContext.FEATURE_FLAG_VIEW_RECORDINGS,
- })
- }}
- onGetFeedback={onGetFeedback}
- surveys={featureFlag.surveys ?? []}
- variantErrors={variantErrors}
- />
- </SceneSection>
- )}
- </>
- ) : (
- <>
- <SceneSection title="Served value">
- <div data-attr="feature-flag-served-value-segmented-button">
- <LemonSegmentedButton
- size="small"
- options={[
- {
- label: 'Release toggle (boolean)',
- value: 'boolean',
- disabledReason: hasExperiment
- ? 'This feature flag is associated with an experiment.'
- : undefined,
- },
- {
- label: <span>Multiple variants with rollout percentages (A/B/n test)</span>,
- value: 'multivariate',
- },
- {
- label: <span>Remote config (single payload)</span>,
- value: 'remote_config',
- disabledReason: hasExperiment
- ? 'This feature flag is associated with an experiment.'
- : undefined,
- },
- ]}
- onChange={(value) => {
- if (['boolean', 'remote_config'].includes(value) && nonEmptyVariants.length) {
- confirmRevertMultivariateEnabled()
- } else {
- setMultivariateEnabled(value === 'multivariate')
- setRemoteConfigEnabled(value === 'remote_config')
- focusVariantKeyField(0)
- }
- }}
- value={flagType}
- />
- </div>
- <div className="text-secondary">
- {featureFlag.is_remote_configuration ? (
- <span>
- Remote config flags provide runtime configuration values in your app. Read more in
- the{' '}
- <Link to="https://posthog.com/docs/feature-flags/remote-config">
- remote config flags documentation
- </Link>
- .
- </span>
- ) : (
- <>
- <div>
- {capitalizeFirstLetter(aggregationTargetName)} will be served{' '}
- {multivariateEnabled ? (
- <>
- <strong>a variant key</strong> according to the below distribution
- </>
- ) : (
- <strong>
- <code>true</code>
- </strong>
- )}{' '}
- if they match one or more release condition groups.
- {multivariateEnabled && (
- <>
- {' '}
- Otherwise, the feature flag will evaluate to{' '}
- <strong>
- <code>false</code>
- </strong>
- .
- </>
- )}
- </div>
- </>
- )}
- </div>
- </SceneSection>
- {!multivariateEnabled && (
- <>
- <SceneDivider />
- <SceneSection title="Payload">
- {readOnly ? (
- featureFlag.filters.payloads?.['true'] ? (
- <JSONEditorInput
- readOnly={readOnly}
- value={featureFlag.filters.payloads?.['true']}
- />
- ) : (
- <span className="text-secondary">No payload associated with this flag</span>
- )
- ) : (
- <div className="w-1/2">
- <div className="text-secondary mb-4">
- {featureFlag.is_remote_configuration ? (
- <>
- Specify a valid JSON payload to be returned for the config flag.
- Read more in the{' '}
- <Link to="https://posthog.com/docs/feature-flags/creating-feature-flags#payloads">
- payload documentation
- </Link>
- .
- </>
- ) : (
- <>
- Optionally specify a valid JSON payload to be returned when the
- served value is{' '}
- <strong>
- <code>true</code>
- </strong>
- . Read more in the{' '}
- <Link to="https://posthog.com/docs/feature-flags/creating-feature-flags#payloads">
- payload documentation
- </Link>
- .
- </>
- )}
- </div>
- {featureFlag.is_remote_configuration && (
- <LemonField name="has_encrypted_payloads">
- {({ value, onChange }) => (
- <div className="border rounded mb-4 p-4">
- <LemonCheckbox
- id="flag-payload-encrypted-checkbox"
- label="Encrypt remote configuration payload"
- onChange={() => onChange(!value)}
- checked={value}
- data-attr="feature-flag-payload-encrypted-checkbox"
- disabledReason={
- hasEncryptedPayloadBeenSaved &&
- 'An encrypted payload has already been saved for this flag. Reset the payload or create a new flag to create an unencrypted configuration payload.'
- }
- />
- </div>
- )}
- </LemonField>
- )}
- <div className="flex gap-2">
- <Group name={['filters', 'payloads']}>
- <LemonField name="true" className="grow">
- <JSONEditorInput
- readOnly={
- readOnly ||
- (featureFlag.has_encrypted_payloads &&
- Boolean(featureFlag.filters?.payloads?.['true']))
- }
- placeholder={'Examples: "A string", 2500, {"key": "value"}'}
- />
- </LemonField>
- </Group>
- {featureFlag.has_encrypted_payloads && (
- <LemonButton
- className="grow-0"
- icon={<IconTrash />}
- type="secondary"
- size="small"
- status="danger"
- onClick={confirmEncryptedPayloadReset}
- >
- Reset
- </LemonButton>
- )}
- </div>
- {featureFlag.is_remote_configuration && (
- <div className="text-sm text-secondary mt-4">
- Note: remote config flags must be accessed through payloads, e.g.{' '}
- <span className="font-mono font-bold">
- {featureFlag.has_encrypted_payloads
- ? 'getRemoteConfigPayload'
- : 'getFeatureFlagPayload'}
- </span>
- . Using standard SDK methods such as{' '}
- <span className="font-mono font-bold">getFeatureFlag</span> or{' '}
- <span className="font-mono font-bold">isFeatureEnabled</span> will
- always return <span className="font-mono font-bold">true</span>
- </div>
- )}
- </div>
- )}
- </SceneSection>
-
- {readOnly && !featureFlag.is_remote_configuration && (
- <>
- <SceneDivider />
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
- <SceneSection
- title="Recordings"
- description="Watch recordings of people who have been exposed to the feature flag."
- >
- <ViewRecordingsPlaylistButton
- filters={recordingFilterForFlag}
- type="secondary"
- size="small"
- data-attr="feature-flag-view-recordings"
- onClick={() => {
- reportViewRecordingsClicked()
- addProductIntentForCrossSell({
- from: ProductKey.FEATURE_FLAGS,
- to: ProductKey.SESSION_REPLAY,
- intent_context:
- ProductIntentContext.FEATURE_FLAG_VIEW_RECORDINGS,
- })
- }}
- />
- </SceneSection>
-
- {onGetFeedback && (
- <>
- <SceneDivider className="md:hidden" />
- <UserFeedbackSection
- featureFlag={featureFlag}
- onGetFeedback={onGetFeedback}
- />
- </>
- )}
- </div>
- </>
- )}
- </>
- )}
- {!readOnly && multivariateEnabled && (
- <>
- <LemonDivider className="my-0" />
- <SceneSection
- title="Variant keys"
- description="The rollout percentage of feature flag variants must add up to 100%"
- >
- <FeatureFlagVariantsForm
- variants={variants}
- payloads={featureFlag.filters?.payloads}
- filterGroups={filterGroups}
- onAddVariant={addVariant}
- onRemoveVariant={removeVariant}
- onDistributeEqually={distributeVariantsEqually}
- canEditVariant={canEditVariant}
- hasExperiment={hasExperiment ?? false}
- experimentId={experiment?.id}
- experimentName={experiment?.name}
- isDraftExperiment={isDraftExperiment}
- onVariantChange={(index, field, value) => {
- const currentVariants = [...variants]
- currentVariants[index] = {
- ...currentVariants[index],
- [field]: value,
- }
- setFeatureFlag({
- ...featureFlag,
- filters: {
- ...featureFlag.filters,
- multivariate: {
- ...featureFlag.filters.multivariate,
- variants: currentVariants,
- },
- },
- })
- }}
- onPayloadChange={(index, value) => {
- const currentPayloads = { ...featureFlag.filters.payloads }
- if (value === undefined) {
- delete currentPayloads[index]
- } else {
- currentPayloads[index] = value
- }
- setFeatureFlag({
- ...featureFlag,
- filters: {
- ...featureFlag.filters,
- payloads: currentPayloads,
- },
- })
- }}
- onGetFeedback={onGetFeedback}
- surveys={featureFlag.surveys ?? []}
- variantErrors={variantErrors}
- />
- </SceneSection>
- </>
- )}
- </>
- )}
- {readOnly && !multivariateEnabled && (
- <div className="flex flex-col gap-y-4">
- <SceneSection title="Payload">
- {readOnly ? (
- featureFlag.filters.payloads?.['true'] ? (
- <JSONEditorInput readOnly={readOnly} value={featureFlag.filters.payloads?.['true']} />
- ) : (
- <span className="text-secondary">No payload associated with this flag</span>
- )
- ) : (
- <div className="w-1/2">
- <div className="text-secondary mb-4">
- {featureFlag.is_remote_configuration ? (
- <>
- Specify a valid JSON payload to be returned for the config flag. Read more
- in the{' '}
- <Link to="https://posthog.com/docs/feature-flags/creating-feature-flags#payloads">
- payload documentation
- </Link>
- .
- </>
- ) : (
- <>
- Optionally specify a valid JSON payload to be returned when the served value
- is{' '}
- <strong>
- <code>true</code>
- </strong>
- . Read more in the{' '}
- <Link to="https://posthog.com/docs/feature-flags/creating-feature-flags#payloads">
- payload documentation
- </Link>
- .
- </>
- )}
- </div>
- {featureFlag.is_remote_configuration && (
- <LemonField name="has_encrypted_payloads">
- {({ value, onChange }) => (
- <div className="border rounded mb-4 p-4">
- <LemonCheckbox
- id="flag-payload-encrypted-checkbox"
- label="Encrypt remote configuration payload"
- onChange={() => onChange(!value)}
- checked={value}
- data-attr="feature-flag-payload-encrypted-checkbox"
- disabledReason={
- hasEncryptedPayloadBeenSaved &&
- 'An encrypted payload has already been saved for this flag. Reset the payload or create a new flag to create an unencrypted configuration payload.'
- }
- />
- </div>
- )}
- </LemonField>
- )}
- <div className="flex gap-2">
- <Group name={['filters', 'payloads']}>
- <LemonField name="true" className="grow">
- <JSONEditorInput
- readOnly={
- readOnly ||
- (featureFlag.has_encrypted_payloads &&
- Boolean(featureFlag.filters?.payloads?.['true']))
- }
- placeholder='Examples: "A string", 2500, {"key": "value"}'
- />
- </LemonField>
- </Group>
- {featureFlag.has_encrypted_payloads && (
- <LemonButton
- className="grow-0"
- icon={<IconTrash />}
- type="secondary"
- size="small"
- status="danger"
- onClick={confirmEncryptedPayloadReset}
- >
- Reset
- </LemonButton>
- )}
- </div>
- {featureFlag.is_remote_configuration && (
- <div className="text-sm text-secondary mt-4">
- Note: remote config flags must be accessed through payloads, e.g.{' '}
- <span className="font-mono font-bold">
- {featureFlag.has_encrypted_payloads
- ? 'getRemoteConfigPayload'
- : 'getFeatureFlagPayload'}
- </span>
- . Using standard SDK methods such as{' '}
- <span className="font-mono font-bold">getFeatureFlag</span> or{' '}
- <span className="font-mono font-bold">isFeatureEnabled</span> will always return{' '}
- <span className="font-mono font-bold">true</span>
- </div>
- )}
- </div>
- )}
- </SceneSection>
- {readOnly && featureFlag.tags && featureFlag.tags.length > 0 && (
- <>
- <SceneDivider />
- <SceneSection title="Tags">
- {featureFlags[FEATURE_FLAGS.FLAG_EVALUATION_TAGS] ? (
- <FeatureFlagEvaluationContexts
- tags={featureFlag.tags}
- evaluationContexts={featureFlag.evaluation_contexts || []}
- flagId={featureFlag.id}
- context="static"
- />
- ) : (
- <ObjectTags tags={featureFlag.tags} staticOnly />
- )}
- </SceneSection>
- </>
- )}
- {readOnly && !featureFlag.is_remote_configuration && (
- <>
- <SceneDivider />
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
- <SceneSection
- title="Recordings"
- description="Watch recordings of people who have been exposed to the feature flag."
- >
- <ViewRecordingsPlaylistButton
- filters={recordingFilterForFlag}
- type="secondary"
- size="small"
- className="w-fit"
- data-attr="feature-flag-view-recordings"
- onClick={() => {
- reportViewRecordingsClicked()
- addProductIntentForCrossSell({
- from: ProductKey.FEATURE_FLAGS,
- to: ProductKey.SESSION_REPLAY,
- intent_context: ProductIntentContext.FEATURE_FLAG_VIEW_RECORDINGS,
- })
- }}
- />
- </SceneSection>
- {onGetFeedback && (
- <>
- <SceneDivider className="md:hidden" />
- <UserFeedbackSection featureFlag={featureFlag} onGetFeedback={onGetFeedback} />
- </>
- )}
- </div>
- </>
- )}
- </div>
- )}
- </SceneContent>
- )
-}
diff --git a/frontend/src/scenes/feature-flags/FeatureFlagForm.tsx b/frontend/src/scenes/feature-flags/FeatureFlagForm.tsx
index 562e1b2d628b..d52c0171a81a 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlagForm.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlagForm.tsx
@@ -50,13 +50,11 @@ import {
import { approvalsGateLogic } from 'lib/approvals/approvalsGateLogic'
import { ObjectTags } from 'lib/components/ObjectTags/ObjectTags'
-import { FEATURE_FLAGS } from 'lib/constants'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { IconArrowDown, IconArrowUp, SortableDragIcon } from 'lib/lemon-ui/icons'
import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
import { LemonField } from 'lib/lemon-ui/LemonField'
import 'lib/lemon-ui/Lettermark'
-import { featureFlagLogic as enabledFeaturesLogic } from 'lib/logic/featureFlagLogic'
import { alphabet } from 'lib/utils'
import { ApprovalActionKey } from 'scenes/approvals/utils'
import { JSONEditorInput } from 'scenes/feature-flags/JSONEditorInput'
@@ -181,10 +179,8 @@ export function FeatureFlagForm({ id }: FeatureFlagLogicProps): JSX.Element {
resetEncryptedPayload,
} = useActions(featureFlagLogic)
const { tags: availableTags } = useValues(tagsModel)
- const { featureFlags } = useValues(enabledFeaturesLogic)
const { isApprovalRequired } = useValues(approvalsGateLogic)
const hasEvaluationContexts = useFeatureFlag('FLAG_EVALUATION_TAGS') // NB: the tag was named "flag-evaluation-tags" before we renamed the concept – i.e. this powers evaluation contexts even though the name implies tags
- const featureFlagsV2Enabled = !!featureFlags[FEATURE_FLAGS.FEATURE_FLAGS_V2]
const isNewFeatureFlag = id === 'new' || id === undefined
const implementationRef = useRef<HTMLDivElement>(null)
@@ -389,7 +385,7 @@ export function FeatureFlagForm({ id }: FeatureFlagLogicProps): JSX.Element {
type: featureFlag.active ? 'feature_flag' : 'feature_flag_off',
}}
forceBackTo={
- isNewFeatureFlag && featureFlagsV2Enabled
+ isNewFeatureFlag
? {
key: 'FeatureFlagTemplates',
name: 'Templates',
diff --git a/frontend/src/scenes/feature-flags/FeatureFlagOverviewV2.tsx b/frontend/src/scenes/feature-flags/FeatureFlagOverview.tsx
similarity index 97%
rename from frontend/src/scenes/feature-flags/FeatureFlagOverviewV2.tsx
rename to frontend/src/scenes/feature-flags/FeatureFlagOverview.tsx
index 92670e72f289..34cada81c2b0 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlagOverviewV2.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlagOverview.tsx
@@ -22,7 +22,7 @@ import { FeatureFlagVariantsSection } from './FeatureFlagVariantsSection'
import { JSONEditorInput } from './JSONEditorInput'
import { RecentFeatureFlagInsights } from './RecentFeatureFlagInsightsCard'
-interface FeatureFlagOverviewV2Props {
+interface FeatureFlagOverviewProps {
featureFlag: FeatureFlagType
}
@@ -53,13 +53,9 @@ function TagsDisplay({ tags, evaluationContexts, flagId, hasEvaluationContexts }
}
/**
- * V2 readonly overview for feature flags, gated behind FEATURE_FLAGS_V2.
- *
- * NOTE: This component is currently rendered conditionally in FeatureFlag.tsx
- * based on the useFormUI flag. If other entry points need to render this overview,
- * ensure the gate is checked there as well.
+ * Readonly overview for feature flags, rendered as the Overview tab in FeatureFlag.tsx.
*/
-export function FeatureFlagOverviewV2({ featureFlag }: FeatureFlagOverviewV2Props): JSX.Element {
+export function FeatureFlagOverview({ featureFlag }: FeatureFlagOverviewProps): JSX.Element {
const { featureFlags } = useValues(enabledFeaturesLogic)
const { recordingFilterForFlag, featureFlagActiveUpdateLoading } = useValues(featureFlagLogic)
const { toggleFeatureFlagActive } = useActions(featureFlagLogic)
diff --git a/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditionsCollapsible.tsx b/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditionsCollapsible.tsx
index 5d65f1ffbed1..e4c35dffcf11 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditionsCollapsible.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditionsCollapsible.tsx
@@ -627,6 +627,7 @@ const ConditionContent = ({
}}
suffix={<span>%</span>}
className="w-20"
+ data-attr="rollout-percentage"
/>
</div>
{group.sort_key && affectedCounts[group.sort_key] !== undefined ? (
diff --git a/frontend/src/scenes/feature-flags/FeatureFlagSchedule.tsx b/frontend/src/scenes/feature-flags/FeatureFlagSchedule.tsx
index d3d8f0578b98..7d9af6add1e1 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlagSchedule.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlagSchedule.tsx
@@ -14,16 +14,11 @@ import {
LemonBanner,
LemonButton,
LemonCalendarSelectInput,
- LemonCheckbox,
LemonCollapse,
- LemonDivider,
LemonInput,
LemonModal,
LemonSelect,
LemonSwitch,
- LemonTable,
- LemonTableColumn,
- LemonTableColumns,
LemonTag,
LemonTagType,
Link,
@@ -32,8 +27,6 @@ import {
import { TZLabel } from 'lib/components/TZLabel'
import { FEATURE_FLAGS } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
-import { More } from 'lib/lemon-ui/LemonButton/More'
-import { createdAtColumn, createdByColumn } from 'lib/lemon-ui/LemonTable/columnUtils'
import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { featureFlagLogic as enabledFeaturesLogic } from 'lib/logic/featureFlagLogic'
@@ -51,14 +44,12 @@ import {
} from '~/types'
import {
- byScheduledAt,
describeCron,
featureFlagLogic,
PAIRED_PRESETS,
validateFeatureFlagKey,
variantKeyToIndexFeatureFlagPayloads,
} from './featureFlagLogic'
-import { FeatureFlagReleaseConditions } from './FeatureFlagReleaseConditions'
import { FeatureFlagReleaseConditionsCollapsible } from './FeatureFlagReleaseConditionsCollapsible'
import { groupFilters } from './FeatureFlags'
import { featureFlagScheduleEditLogic } from './featureFlagScheduleEditLogic'
@@ -402,9 +393,7 @@ function ScheduleCard({
)
}
-// --- V2 main component ---
-
-function FeatureFlagScheduleV2(): JSX.Element {
+export default function FeatureFlagSchedule(): JSX.Element {
const {
featureFlag,
scheduledChangesLoading,
@@ -1135,490 +1124,3 @@ function FeatureFlagScheduleV2(): JSX.Element {
</div>
)
}
-
-// --- Legacy component (pre-V2 UI) ---
-
-function FeatureFlagScheduleLegacy(): JSX.Element {
- const {
- featureFlag,
- scheduledChanges,
- scheduledChangeOperation,
- scheduleDateMarker,
- schedulePayload,
- schedulePayloadErrors,
- isRecurring,
- recurrenceInterval,
- endDate,
- } = useValues(featureFlagLogic)
- const {
- deleteScheduledChange,
- setScheduleDateMarker,
- setSchedulePayload,
- setScheduledChangeOperation,
- createScheduledChange,
- setIsRecurring,
- setRecurrenceInterval,
- setEndDate,
- stopRecurringScheduledChange,
- resumeRecurringScheduledChange,
- } = useActions(featureFlagLogic)
- const { aggregationLabel } = useValues(groupsModel)
- const { featureFlags } = useValues(enabledFeaturesLogic)
- const { currentTeam } = useValues(teamLogic)
- const tz = currentTeam?.timezone || 'UTC'
-
- const aggregationGroupTypeIndex = featureFlag.filters.aggregation_group_type_index
-
- const scheduleFilters = { ...schedulePayload.filters, aggregation_group_type_index: aggregationGroupTypeIndex }
-
- const { variants: displayVariants, payloads: displayPayloads } = getScheduledVariantsPayloads(
- featureFlag,
- schedulePayload
- )
-
- const variantErrors = displayVariants.map(({ key: variantKey }) => ({
- key: validateFeatureFlagKey(variantKey),
- }))
-
- const columns: LemonTableColumns<ScheduledChangeType> = [
- {
- title: 'Change',
- dataIndex: 'payload',
- render: function Render(_, scheduledChange: ScheduledChangeType) {
- const { payload } = scheduledChange
-
- if (payload.operation === ScheduledChangeOperationType.UpdateStatus) {
- const isEnabled = payload.value
- return (
- <LemonTag type={isEnabled ? 'success' : 'default'} className="uppercase">
- {isEnabled ? 'Enable' : 'Disable'}
- </LemonTag>
- )
- } else if (payload.operation === ScheduledChangeOperationType.AddReleaseCondition) {
- const releaseText = groupFilters(payload.value, undefined, aggregationLabel)
- return (
- <div className="inline-flex leading-8">
- <span className="mr-2">
- <b>Add release condition:</b>
- </span>
- {typeof releaseText === 'string' && releaseText.startsWith('100% of') ? (
- <LemonTag type="highlight">{releaseText}</LemonTag>
- ) : (
- releaseText
- )}
- </div>
- )
- } else if (payload.operation === ScheduledChangeOperationType.UpdateVariants) {
- const variantCount = payload.value?.variants?.length || 0
- return (
- <div className="inline-flex leading-8">
- <span className="mr-2">
- <b>Update variants:</b>
- </span>
- <LemonTag type="highlight">
- {variantCount} variant{variantCount !== 1 ? 's' : ''}
- </LemonTag>
- </div>
- )
- }
-
- return JSON.stringify(payload)
- },
- },
- {
- title: 'Scheduled at',
- dataIndex: 'scheduled_at',
- sorter: byScheduledAt,
- render: function Render(_, scheduledChange: ScheduledChangeType) {
- const scheduledAt = dayjs(scheduledChange.scheduled_at).tz(tz)
- const tzShort = shortTimeZone(tz, scheduledAt.toDate()) ?? tz
- const formattedDate = `${scheduledAt.format(DAYJS_FORMAT)} (${tzShort})`
- const timeStr = scheduledAt.format('h:mm A')
- const isPaused = !scheduledChange.is_recurring && !!scheduledChange.recurrence_interval
-
- if (scheduledChange.recurrence_interval) {
- let recurringDescription: string
- switch (scheduledChange.recurrence_interval) {
- case RecurrenceInterval.Daily:
- recurringDescription = `Every day at ${timeStr}`
- break
- case RecurrenceInterval.Weekly:
- recurringDescription = `Every ${scheduledAt.format('dddd')} at ${timeStr}`
- break
- case RecurrenceInterval.Monthly: {
- const dayOfMonth = scheduledAt.date()
- const dayText = dayOfMonth >= 29 ? 'last day' : scheduledAt.format('Do')
- recurringDescription = `Monthly on the ${dayText} at ${timeStr}`
- break
- }
- case RecurrenceInterval.Yearly:
- recurringDescription = `Yearly on ${scheduledAt.format('MMMM Do')} at ${timeStr}`
- break
- default:
- recurringDescription = `Every ${scheduledChange.recurrence_interval}`
- }
-
- if (isPaused) {
- return (
- <Tooltip title={`Was: ${recurringDescription}. Resume to continue.`}>
- <span className="text-muted">—</span>
- </Tooltip>
- )
- }
-
- const endDateStr = scheduledChange.end_date
- ? `\nEnds: ${dayjs(scheduledChange.end_date).tz(tz).format('MMMM D, YYYY')}`
- : ''
- return (
- <Tooltip title={`Next: ${formattedDate}${endDateStr}`}>
- <span>{recurringDescription}</span>
- </Tooltip>
- )
- }
- return formattedDate
- },
- },
- {
- title: 'End date',
- dataIndex: 'end_date',
- render: function Render(_, scheduledChange: ScheduledChangeType) {
- if (!scheduledChange.is_recurring && !scheduledChange.recurrence_interval) {
- return <span className="text-muted">—</span>
- }
- if (!scheduledChange.end_date) {
- return <span className="text-muted">No end date</span>
- }
- return dayjs(scheduledChange.end_date).tz(tz).format('MMM D, YYYY')
- },
- },
- createdAtColumn() as LemonTableColumn<ScheduledChangeType, keyof ScheduledChangeType | undefined>,
- createdByColumn() as LemonTableColumn<ScheduledChangeType, keyof ScheduledChangeType | undefined>,
- {
- title: 'Status',
- dataIndex: 'executed_at',
- render: function Render(_, scheduledChange: ScheduledChangeType) {
- const { executed_at, failure_reason, is_recurring, recurrence_interval } = scheduledChange
- const isPaused = !is_recurring && !!recurrence_interval
-
- function getStatus(): { type: LemonTagType; text: string; tooltip?: string } {
- if (failure_reason) {
- return { type: 'danger', text: 'Error', tooltip: `Failed: ${failure_reason}` }
- } else if (executed_at) {
- const executedAt = dayjs(executed_at)
- const tzShort = shortTimeZone(tz, executedAt.toDate()) ?? tz
- return {
- type: 'completion',
- text: 'Complete',
- tooltip: `Completed: ${executedAt.tz(tz).format('MMMM D, YYYY h:mm A')} (${tzShort})`,
- }
- } else if (isPaused) {
- return {
- type: 'warning',
- text: 'Paused',
- tooltip: 'Recurring schedule is paused. It will not execute until resumed.',
- }
- } else if (is_recurring) {
- return { type: 'highlight', text: 'Recurring' }
- }
- return { type: 'default', text: 'Scheduled' }
- }
- const { type, text, tooltip } = getStatus()
- return (
- <Tooltip title={tooltip}>
- <LemonTag type={type}>
- <b className="uppercase">{text}</b>
- </LemonTag>
- </Tooltip>
- )
- },
- },
- {
- width: 0,
- render: function Render(_, scheduledChange: ScheduledChangeType) {
- return (
- !scheduledChange.executed_at &&
- featureFlag.can_edit && (
- <More
- overlay={
- <>
- {scheduledChange.is_recurring && (
- <LemonButton
- onClick={() => stopRecurringScheduledChange(scheduledChange.id)}
- fullWidth
- >
- Pause recurring
- </LemonButton>
- )}
- {!scheduledChange.is_recurring && scheduledChange.recurrence_interval && (
- <LemonButton
- onClick={() => resumeRecurringScheduledChange(scheduledChange.id)}
- fullWidth
- >
- Resume recurring
- </LemonButton>
- )}
- <LemonButton
- status="danger"
- onClick={() => deleteScheduledChange(scheduledChange.id)}
- fullWidth
- >
- Delete scheduled change
- </LemonButton>
- </>
- }
- />
- )
- )
- },
- },
- ]
-
- return (
- <div>
- {featureFlag.can_edit ? (
- <div>
- <h3 className="l3">Add a scheduled change</h3>
- <div className="mb-6">Automatically change flag properties at a future point in time.</div>
- <div className="flex flex-wrap gap-x-10 gap-y-4 mb-8">
- <div>
- <div className="font-semibold leading-6 h-6 mb-1">Change type</div>
- <LemonSelect<ScheduledChangeOperationType>
- className="w-50"
- placeholder="Select variant"
- value={scheduledChangeOperation}
- onChange={(value) => value && setScheduledChangeOperation(value)}
- options={[
- { label: 'Change status', value: ScheduledChangeOperationType.UpdateStatus },
- {
- label: 'Add a condition',
- value: ScheduledChangeOperationType.AddReleaseCondition,
- },
- ...(featureFlags[FEATURE_FLAGS.SCHEDULE_FEATURE_FLAG_VARIANTS_UPDATE] &&
- featureFlag.filters.multivariate
- ? [
- {
- label: 'Update variants',
- value: ScheduledChangeOperationType.UpdateVariants,
- },
- ]
- : []),
- ]}
- />
- </div>
- <div className="w-50">
- <div className="font-semibold leading-6 h-6 mb-1">
- Date and time <ScheduleTimezoneHint />
- </div>
- <LemonCalendarSelectInput
- value={scheduleDateMarker}
- onChange={(value) => setScheduleDateMarker(value)}
- placeholder="Select date"
- selectionPeriod="upcoming"
- granularity="minute"
- />
- </div>
- {scheduledChangeOperation === ScheduledChangeOperationType.UpdateStatus && (
- <div>
- <div className="font-semibold leading-6 h-6 mb-1">Repeat</div>
- <div className="flex flex-col gap-2">
- <LemonCheckbox
- id="recurring-checkbox"
- label="Make recurring"
- onChange={(checked) => {
- setIsRecurring(checked)
- if (!checked) {
- setRecurrenceInterval(null)
- setEndDate(null)
- }
- }}
- checked={isRecurring}
- />
- <LemonSelect
- className="w-40"
- placeholder="Select interval"
- value={recurrenceInterval}
- onChange={setRecurrenceInterval}
- disabled={!isRecurring}
- options={[
- { value: RecurrenceInterval.Daily, label: 'Daily' },
- { value: RecurrenceInterval.Weekly, label: 'Weekly' },
- { value: RecurrenceInterval.Monthly, label: 'Monthly' },
- { value: RecurrenceInterval.Yearly, label: 'Yearly' },
- ]}
- />
- </div>
- </div>
- )}
- {isRecurring && (
- <div className="w-50">
- <div className="font-semibold leading-6 h-6 mb-1 flex items-center gap-1">
- End date (optional)
- <Tooltip
- interactive
- title={
- <>
- Schedule will run through end of this day in the{' '}
- <Link
- to={urls.settings('environment-customization', 'date-and-time')}
- target="_blank"
- >
- project's timezone
- </Link>
- </>
- }
- >
- <IconInfo className="text-muted text-base" />
- </Tooltip>
- </div>
- <LemonCalendarSelectInput
- value={endDate}
- onChange={(value) => setEndDate(value)}
- placeholder="No end date"
- selectionPeriod="upcoming"
- granularity="day"
- clearable
- />
- </div>
- )}
- </div>
-
- <div className="deprecated-space-y-4">
- {scheduledChangeOperation === ScheduledChangeOperationType.UpdateStatus && (
- <div className="border rounded p-4">
- <LemonCheckbox
- id="flag-enabled-checkbox"
- label={schedulePayload.active ? 'Flag will be enabled' : 'Flag will be disabled'}
- onChange={(value) => {
- setSchedulePayload(null, value)
- }}
- checked={schedulePayload.active}
- />
- </div>
- )}
- {scheduledChangeOperation === ScheduledChangeOperationType.AddReleaseCondition && (
- <FeatureFlagReleaseConditions
- id={`schedule-release-conditions-${featureFlag.id}`}
- filters={scheduleFilters}
- onChange={(value, errors) => setSchedulePayload(value, null, errors, null, null)}
- hideMatchOptions
- />
- )}
- {scheduledChangeOperation === ScheduledChangeOperationType.UpdateVariants &&
- featureFlags[FEATURE_FLAGS.SCHEDULE_FEATURE_FLAG_VARIANTS_UPDATE] &&
- (() => {
- return (
- <div className="border rounded p-4">
- <FeatureFlagVariantsForm
- variants={displayVariants}
- payloads={displayPayloads}
- onAddVariant={() => {
- const { variants: currentVariants, payloads: currentPayloads } =
- getScheduledVariantsPayloads(featureFlag, schedulePayload)
- const newVariants = [
- ...currentVariants,
- { key: '', name: '', rollout_percentage: 0 },
- ]
- setSchedulePayload(null, null, null, newVariants, currentPayloads)
- }}
- onRemoveVariant={(index) => {
- const { variants: currentVariants, payloads: currentPayloads } =
- getScheduledVariantsPayloads(featureFlag, schedulePayload)
- const newVariants = currentVariants.filter((_, i) => i !== index)
- const newPayloads = { ...currentPayloads }
- delete newPayloads[index]
- setSchedulePayload(null, null, null, newVariants, newPayloads)
- }}
- onDistributeEqually={() => {
- const { variants: currentVariants, payloads: currentPayloads } =
- getScheduledVariantsPayloads(featureFlag, schedulePayload)
- const equalPercentage = Math.floor(100 / currentVariants.length)
- let remainder = 100 - equalPercentage * currentVariants.length
- const distributedVariants = currentVariants.map((variant, index) => ({
- ...variant,
- rollout_percentage: equalPercentage + (index === 0 ? remainder : 0),
- }))
- setSchedulePayload(
- null,
- null,
- null,
- distributedVariants,
- currentPayloads
- )
- }}
- onVariantChange={(index, field, value) => {
- const { variants: currentVariants, payloads: currentPayloads } =
- getScheduledVariantsPayloads(featureFlag, schedulePayload)
- const newVariants = [...currentVariants]
- newVariants[index] = { ...newVariants[index], [field]: value }
- setSchedulePayload(null, null, null, newVariants, currentPayloads)
- }}
- onPayloadChange={(index, value) => {
- const { variants: currentVariants, payloads: currentPayloads } =
- getScheduledVariantsPayloads(featureFlag, schedulePayload)
- const newPayloads = { ...currentPayloads }
- if (value === undefined) {
- delete newPayloads[index]
- } else {
- newPayloads[index] = value
- }
- setSchedulePayload(null, null, null, currentVariants, newPayloads)
- }}
- variantErrors={variantErrors}
- />
- </div>
- )
- })()}
- <div className="flex items-center justify-end">
- <LemonButton
- type="primary"
- onClick={createScheduledChange}
- disabledReason={
- !scheduleDateMarker
- ? 'Select the scheduled date and time'
- : isRecurring && !recurrenceInterval
- ? 'Select a repeat interval'
- : hasFormErrors(schedulePayloadErrors)
- ? 'Fix release condition errors'
- : scheduledChangeOperation ===
- ScheduledChangeOperationType.UpdateVariants &&
- variantErrors.some((error) => error.key != null)
- ? 'Fix schedule variant changes errors'
- : undefined
- }
- >
- Schedule
- </LemonButton>
- </div>
- <LemonDivider className="" />
- </div>
- </div>
- ) : (
- <LemonBanner type="info" className="mb-2">
- You don't have the necessary permissions to schedule changes to this flag. Contact your
- administrator to request editing rights.
- </LemonBanner>
- )}
- <LemonTable
- rowClassName={(record) => (record.executed_at ? 'opacity-75' : '')}
- className="mt-4"
- loading={false}
- dataSource={scheduledChanges}
- columns={columns}
- defaultSorting={{
- columnKey: 'scheduled_at',
- order: 1,
- }}
- emptyState="You do not have any scheduled changes"
- />
- </div>
- )
-}
-
-// --- Gated default export ---
-
-export default function FeatureFlagSchedule(): JSX.Element {
- const { featureFlags } = useValues(enabledFeaturesLogic)
- const useV2 = !!featureFlags[FEATURE_FLAGS.FEATURE_FLAGS_V2]
-
- return useV2 ? <FeatureFlagScheduleV2 /> : <FeatureFlagScheduleLegacy />
-}
diff --git a/frontend/src/scenes/feature-flags/FeatureFlags.tsx b/frontend/src/scenes/feature-flags/FeatureFlags.tsx
index d83fb156f68b..8515e674088e 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlags.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlags.tsx
@@ -353,9 +353,7 @@ export function OverviewTab({
const { featureFlagsLoading, displayedFlags, pagination, filters, shouldShowEmptyState, filtersChanged } =
useValues(flagLogic)
const { setFeatureFlagsFilters } = useActions(flagLogic)
- const { featureFlags: enabledFeatureFlags } = useValues(enabledFeaturesLogic)
- const featureFlagsV2Enabled = !!enabledFeatureFlags[FEATURE_FLAGS.FEATURE_FLAGS_V2]
- const newFeatureFlagUrl = featureFlagsV2Enabled ? urls.featureFlagTemplates() : urls.featureFlag('new')
+ const newFeatureFlagUrl = urls.featureFlagTemplates()
const isProductIntroVisible = shouldShowEmptyState || !user?.has_seen_product_intro_for?.[ProductKey.FEATURE_FLAGS]
const { currentProjectId } = useValues(projectLogic)
@@ -683,8 +681,7 @@ export function FeatureFlags(): JSX.Element {
const { activeTab } = useValues(featureFlagsLogic)
const { setActiveTab } = useActions(featureFlagsLogic)
const { featureFlags: enabledFeatureFlags } = useValues(enabledFeaturesLogic)
- const featureFlagsV2Enabled = !!enabledFeatureFlags[FEATURE_FLAGS.FEATURE_FLAGS_V2]
- const newFeatureFlagUrl = featureFlagsV2Enabled ? urls.featureFlagTemplates() : urls.featureFlag('new')
+ const newFeatureFlagUrl = urls.featureFlagTemplates()
const showNotificationsTab = !!enabledFeatureFlags[FEATURE_FLAGS.FEATURE_FLAG_NOTIFICATIONS]
const showProjectsTab = !!enabledFeatureFlags[FEATURE_FLAGS.FEATURE_FLAGS_ACROSS_PROJECTS_INDEX]
diff --git a/frontend/src/scenes/feature-flags/featureFlagLogic.ts b/frontend/src/scenes/feature-flags/featureFlagLogic.ts
index 4e2d9d7b027b..0aa3641b7d18 100644
--- a/frontend/src/scenes/feature-flags/featureFlagLogic.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagLogic.ts
@@ -906,7 +906,18 @@ export const featureFlagLogic = kea<featureFlagLogicType>([
}
return {
...state,
- features: [...(state.features || []), newEarlyAccessFeature],
+ features: [
+ ...(state.features || []),
+ {
+ id: newEarlyAccessFeature.id,
+ name: newEarlyAccessFeature.name,
+ description: newEarlyAccessFeature.description,
+ stage: newEarlyAccessFeature.stage,
+ documentationUrl: newEarlyAccessFeature.documentation_url,
+ flagKey: newEarlyAccessFeature.feature_flag?.key ?? null,
+ payload: newEarlyAccessFeature.payload,
+ },
+ ],
}
},
createSurveySuccess: (state, { newSurvey }) => {
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index bd626233c8a3..4ced2b65d109 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -4153,7 +4153,7 @@ export interface FeatureFlagType extends Omit<FeatureFlagBasicType, 'id' | 'team
last_modified_by: UserBasicType | null
experiment_set: number[] | null
experiment_set_metadata: { id: number; name: string }[] | null
- features: EarlyAccessFeatureType[] | null
+ features: MinimalEarlyAccessFeatureType[] | null
surveys: Survey[] | null
can_edit: boolean
tags: string[]
@@ -4250,6 +4250,17 @@ export interface NewEarlyAccessFeatureType extends Omit<EarlyAccessFeatureType,
feature_flag_id: number | undefined
}
+/** Shape served by MinimalEarlyAccessFeatureSerializer (camelCase keys), e.g. as `FeatureFlagType.features`. */
+export interface MinimalEarlyAccessFeatureType {
+ id: string
+ name: string
+ description: string
+ stage: EarlyAccessFeatureStage
+ documentationUrl: string
+ flagKey: string | null
+ payload?: Record<string, any>
+}
+
export interface UserBlastRadiusType {
affected: number
total: number
diff --git a/playwright/e2e/surveys/quickcreate.spec.ts b/playwright/e2e/surveys/quickcreate.spec.ts
index 704d85413599..a6e5882fdf43 100644
--- a/playwright/e2e/surveys/quickcreate.spec.ts
+++ b/playwright/e2e/surveys/quickcreate.spec.ts
@@ -47,9 +47,10 @@ const expectEvents = async (page: Page, events: string[]): Promise<void> => {
const addTwoVariants = async (page: Page): Promise<void> => {
await page.getByText('Multiple variants with rollout percentages (A/B/n test)').click()
- // Default multivariate now includes control/test at 50/50, so just rename them
- await page.locator('[data-attr="feature-flag-variant-key"][data-key-index="0"]').fill('test-1')
- await page.locator('[data-attr="feature-flag-variant-key"][data-key-index="1"]').fill('test-2')
+ // Default multivariate includes control/test at 50/50, each in a collapsed row, so expand then rename them
+ await page.getByRole('button', { name: 'Expand all' }).click()
+ await page.locator('[data-attr="feature-flag-variant-key-0"]').fill('test-1')
+ await page.locator('[data-attr="feature-flag-variant-key-1"]').fill('test-2')
}
const clickCreateSurvey = async (page: Page, name: string): Promise<void> => {
@@ -116,6 +117,7 @@ test.describe('Quick create survey from feature flag', () => {
// start ff creation
await page.locator('[data-attr="new-feature-flag"]').click()
+ await page.locator('[data-attr="blank-feature-flag-template"]').click()
await page.locator('[data-attr="feature-flag-key"]').fill(name)
await page.locator('[data-attr="rollout-percentage"]').fill('100')
})
diff --git a/products/feature_flags/frontend/FeatureFlagTemplatesScene.tsx b/products/feature_flags/frontend/FeatureFlagTemplatesScene.tsx
index 56a96c91a52a..7a9bcb9a0779 100644
--- a/products/feature_flags/frontend/FeatureFlagTemplatesScene.tsx
+++ b/products/feature_flags/frontend/FeatureFlagTemplatesScene.tsx
@@ -191,13 +191,9 @@ function IntentStep({ template }: { template: SelectedTemplate }): JSX.Element {
}
export function FeatureFlagTemplatesScene(): JSX.Element {
- const { featureFlagsV2Enabled, intentsEnabled, selectedTemplate } = useValues(featureFlagTemplatesSceneLogic)
+ const { intentsEnabled, selectedTemplate } = useValues(featureFlagTemplatesSceneLogic)
const { selectTemplate } = useActions(featureFlagTemplatesSceneLogic)
- if (!featureFlagsV2Enabled) {
- return <></>
- }
-
return (
<div className="flex flex-col items-center justify-center py-8 min-h-[80vh]">
<div className="w-full max-w-5xl px-4">
diff --git a/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.test.ts b/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.test.ts
index faaf00e5bac1..0879e7be2477 100644
--- a/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.test.ts
+++ b/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.test.ts
@@ -1,4 +1,3 @@
-import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
import { FEATURE_FLAGS } from 'lib/constants'
@@ -27,9 +26,6 @@ describe('featureFlagTemplatesSceneLogic', () => {
{ name: 'sets template to blank', template: 'blank' as const },
{ name: 'resets template to null', template: null },
])('$name', async ({ template }) => {
- enabledFeaturesLogic.actions.setFeatureFlags([], {
- [FEATURE_FLAGS.FEATURE_FLAGS_V2]: true,
- })
logic = featureFlagTemplatesSceneLogic()
logic.mount()
@@ -47,9 +43,7 @@ describe('featureFlagTemplatesSceneLogic', () => {
{ name: 'false when feature flag is off', flagValue: false, expected: false },
{ name: 'false when feature flag is absent', flagValue: undefined, expected: false },
])('$name', async ({ flagValue, expected }) => {
- const flags: Record<string, boolean> = {
- [FEATURE_FLAGS.FEATURE_FLAGS_V2]: true,
- }
+ const flags: Record<string, boolean> = {}
if (flagValue !== undefined) {
flags[FEATURE_FLAGS.FEATURE_FLAG_CREATION_INTENTS] = flagValue
}
@@ -62,33 +56,4 @@ describe('featureFlagTemplatesSceneLogic', () => {
})
})
})
-
- describe('afterMount redirect', () => {
- it('redirects to new flag page when V2 is disabled', async () => {
- enabledFeaturesLogic.actions.setFeatureFlags([], {})
- logic = featureFlagTemplatesSceneLogic()
- logic.mount()
-
- await expectLogic(router).toMatchValues({
- location: expect.objectContaining({
- pathname: expect.stringContaining('/feature_flags/new'),
- }),
- })
- })
-
- it('does not redirect when V2 is enabled', async () => {
- enabledFeaturesLogic.actions.setFeatureFlags([], {
- [FEATURE_FLAGS.FEATURE_FLAGS_V2]: true,
- })
- const currentPath = router.values.location.pathname
- logic = featureFlagTemplatesSceneLogic()
- logic.mount()
-
- await expectLogic(router).toMatchValues({
- location: expect.objectContaining({
- pathname: currentPath,
- }),
- })
- })
- })
})
diff --git a/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.ts b/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.ts
index c4e97b6cede8..01d0b79b9a23 100644
--- a/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.ts
+++ b/products/feature_flags/frontend/featureFlagTemplatesSceneLogic.ts
@@ -1,4 +1,4 @@
-import { actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import { actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
import { combineUrl, router } from 'kea-router'
import posthog from 'posthog-js'
@@ -45,10 +45,6 @@ export const featureFlagTemplatesSceneLogic = kea<featureFlagTemplatesSceneLogic
],
}),
selectors({
- featureFlagsV2Enabled: [
- (s) => [s.featureFlags],
- (featureFlags) => !!featureFlags[FEATURE_FLAGS.FEATURE_FLAGS_V2],
- ],
intentsEnabled: [
(s) => [s.featureFlags],
(featureFlags) => !!featureFlags[FEATURE_FLAGS.FEATURE_FLAG_CREATION_INTENTS],
@@ -65,10 +61,4 @@ export const featureFlagTemplatesSceneLogic = kea<featureFlagTemplatesSceneLogic
}
},
})),
- afterMount(({ values }) => {
- if (!values.featureFlagsV2Enabled) {
- const { searchParams } = router.values
- router.actions.replace(combineUrl(urls.featureFlag('new'), searchParams).url)
- }
- }),
])