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.

feat(flags): ship disable-and-archive dialog to everyone (#81490)

ruby childs291643d5ac61
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 6e6fa680f49f..959bf6dbe964 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -7953,7 +7953,7 @@ snapshots:
scenes-app-settings-user--settings-user-danger-zone--light:
hash: v1.k794b7964.96846d7823357e89a9d91350f6f435373fe287f713250b59ccce2dbd31b6f69c.kl21kygOhH1SlNOJ6VekMMlGUuyNg5Ka7NXFoHcG6M0
scenes-app-settings-user--settings-user-navigation--dark:
- hash: v1.k794b7964.7c5a5bdb7736062bcb70e36f20fc683eb9c014a0409dddb546a345fba91894b5.lMpgtqpaZZZsixseHxd_CxR4u_ZR5SnnrrOixJUvesM
+ hash: v1.k794b7964.ac90874ccf3cb7e926aae17e3c1bfdbe2fccf6ef1dd756dbcdc3bf7cf4e4f328.SKhKpZICGxDYJzWEFXhBj1XzJ9ttVHEhEmKZZkoXUcE
scenes-app-settings-user--settings-user-navigation--light:
hash: v1.k794b7964.384ac6e1638edb3f361ff8d137589816bfcd3309e9861eba95a83ff6fbe57809.xxyxmKQQ4llOtJ1zB86Vos3B_NTYd4mNvlLeexQlz4U
scenes-app-settings-user--settings-user-notifications--dark:
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index dc0924c984f3..18dea6c433e4 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -179,7 +179,6 @@ export const FEATURE_FLAGS = {
// UX flags, used to control the UX of the app
CMD_K_NAV_EXPERIMENT: 'cmd-k-nav-experiment', // owner: @rafaeelaudibert #team-platform-ux multivariate=control,search-bar,footer-hint,tools-row,footer-callout - surfaces the Cmd+K command menu more prominently in the left nav: search-bar = full-width search field below the nav header, footer-hint = extra Search row in the nav footer, tools-row = Search row after the Tools item in the Project section, footer-callout = dismissible callout card in the nav ad slot for users a few days after signup
CREATE_BUTTON_NAV_EXPERIMENT: 'create-button-nav-experiment', // owner: #team-platform-ux multivariate=control,test — adds a Create dropdown to the top of the Browse tab in the left nav
- FEATURE_FLAG_DISABLE_AND_ARCHIVE_EXPERIMENT: 'feature-flag-disable-and-archive-experiment', // owner: #team-feature-flags multivariate=control,test, adds a destructive "Disable and archive" option alongside "Disable only" in the disable-flag confirmation dialog, control keeps the plain disable confirmation
INBOX_SELF_DRIVING_EMPTY_STATE: 'inbox-self-driving-empty-state',
STARRED_REORDER: 'starred-reorder', // owner: #team-platform-ux, drag-and-drop reorder of starred shortcuts in the side panel
UX_HIDE_PROJECT_NOTICE: 'ux-hide-project-notice', // owner: #team-platform-ux, hides the project notice banner across all scenes
diff --git a/frontend/src/scenes/feature-flags/featureFlagConfirmationLogic.ts b/frontend/src/scenes/feature-flags/featureFlagConfirmationLogic.ts
index 9f898e31e639..a111f01db115 100644
--- a/frontend/src/scenes/feature-flags/featureFlagConfirmationLogic.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagConfirmationLogic.ts
@@ -148,16 +148,14 @@ export function checkFeatureFlagConfirmation(
onCancel: onCancelModal,
})
- // Disabling can offer "Disable and archive" behind the disable-and-archive experiment.
- // Deliberately below the confirmation gate: a flag with dependents, or a team that set up
- // its own confirmation, gets that modal instead. Losing an experiment exposure beats
- // archiving a flag others read from.
+ // Disabling offers "Disable and archive" alongside "Disable only". Deliberately below the
+ // confirmation gate: a flag with dependents, or a team that set up its own confirmation,
+ // gets that modal instead.
if (!updatedFlag.active && onDisableAndArchive) {
openFeatureFlagDisableDialog({
source: 'feature-flag-detail',
onDisable: onConfirm,
onDisableAndArchive,
- openControlDialog: openStatusConfirmationModal,
})
return true
}
diff --git a/frontend/src/scenes/feature-flags/featureFlagDisableDialog.test.ts b/frontend/src/scenes/feature-flags/featureFlagDisableDialog.test.ts
index cdfa4e840658..796c08ba43b2 100644
--- a/frontend/src/scenes/feature-flags/featureFlagDisableDialog.test.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagDisableDialog.test.ts
@@ -2,34 +2,20 @@ import posthog from 'posthog-js'
import { LemonDialog } from '@posthog/lemon-ui'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic as enabledFeaturesLogic } from 'lib/logic/featureFlagLogic'
-
-import { initKeaTests } from '~/test/init'
-
import { FeatureFlagDisableDialogOption, openFeatureFlagDisableDialog } from './featureFlagDisableDialog'
jest.mock('posthog-js')
-const EXPERIMENT_KEY = FEATURE_FLAGS.FEATURE_FLAG_DISABLE_AND_ARCHIVE_EXPERIMENT
-
describe('openFeatureFlagDisableDialog', () => {
- let flagsLogic: ReturnType<typeof enabledFeaturesLogic.build>
let onDisable: jest.Mock
let onDisableAndArchive: jest.Mock
- let openControlDialog: jest.Mock
let openDialog: jest.SpyInstance
- const setVariant = (variant: string | boolean): void => {
- flagsLogic.actions.setFeatureFlags([EXPERIMENT_KEY], { [EXPERIMENT_KEY]: variant })
- }
-
const open = (): void =>
openFeatureFlagDisableDialog({
source: 'feature-flags-list',
onDisable,
onDisableAndArchive,
- openControlDialog,
})
const optionCapturesOf = (option: FeatureFlagDisableDialogOption): any[][] =>
@@ -38,78 +24,40 @@ describe('openFeatureFlagDisableDialog', () => {
)
beforeEach(() => {
- initKeaTests()
- flagsLogic = enabledFeaturesLogic()
- flagsLogic.mount()
onDisable = jest.fn()
onDisableAndArchive = jest.fn()
- openControlDialog = jest.fn()
openDialog = jest.spyOn(LemonDialog, 'open').mockImplementation(() => {})
;(posthog.capture as jest.Mock).mockClear()
})
afterEach(() => {
- flagsLogic.unmount()
jest.restoreAllMocks()
})
- describe('variant routing', () => {
- it('offers "Disable and archive" to the test variant', () => {
- setVariant('test')
- open()
-
- expect(openControlDialog).not.toHaveBeenCalled()
- expect(openDialog.mock.calls[0][0].primaryButton.children).toBe('Disable only')
- expect(openDialog.mock.calls[0][0].secondaryButton).toMatchObject({
- children: 'Disable and archive',
- status: 'danger',
- })
- })
-
- it.each<[string, string | boolean]>([
- ['control', 'control'],
- ['an unset flag', false],
- ['an unexpected variant', 'holdout'],
- ])("falls back to the caller's own dialog for %s", (_label, variant) => {
- setVariant(variant)
- open()
+ it('makes "Disable only" the primary action and "Disable and archive" a danger secondary', () => {
+ open()
- expect(openDialog).not.toHaveBeenCalled()
- expect(openControlDialog).toHaveBeenCalledTimes(1)
+ expect(openDialog.mock.calls[0][0].primaryButton.children).toBe('Disable only')
+ expect(openDialog.mock.calls[0][0].secondaryButton).toMatchObject({
+ children: 'Disable and archive',
+ status: 'danger',
})
})
- describe('option telemetry', () => {
- // A fresh dialog per case, so each one can assert the other callback stayed untouched.
- it.each<[FeatureFlagDisableDialogOption, 'primaryButton' | 'secondaryButton' | 'tertiaryButton']>([
- ['disable', 'primaryButton'],
- ['disable_and_archive', 'secondaryButton'],
- ['cancel', 'tertiaryButton'],
- ])('reports %s and runs only its own callback', (option, button) => {
- setVariant('test')
- open()
-
- openDialog.mock.calls[0][0][button].onClick()
-
- expect(optionCapturesOf(option)).toEqual([
- ['feature flag disable confirmation option selected', { source: 'feature-flags-list', option }],
- ])
- expect(onDisableAndArchive).toHaveBeenCalledTimes(option === 'disable_and_archive' ? 1 : 0)
- expect(onDisable).toHaveBeenCalledTimes(option === 'disable' ? 1 : 0)
- })
-
- it('wraps the control dialog callbacks so control reports the same options', () => {
- setVariant('control')
- open()
- const [confirm, cancel] = openControlDialog.mock.calls[0]
-
- confirm()
- expect(optionCapturesOf('disable')).toHaveLength(1)
- expect(onDisable).toHaveBeenCalledTimes(1)
-
- cancel()
- expect(optionCapturesOf('cancel')).toHaveLength(1)
- expect(onDisableAndArchive).not.toHaveBeenCalled()
- })
+ // A fresh dialog per case, so each one can assert the other callback stayed untouched.
+ it.each<[FeatureFlagDisableDialogOption, 'primaryButton' | 'secondaryButton' | 'tertiaryButton']>([
+ ['disable', 'primaryButton'],
+ ['disable_and_archive', 'secondaryButton'],
+ ['cancel', 'tertiaryButton'],
+ ])('reports %s and runs only its own callback', (option, button) => {
+ open()
+
+ openDialog.mock.calls[0][0][button].onClick()
+
+ expect(optionCapturesOf(option)).toEqual([
+ ['feature flag disable confirmation option selected', { source: 'feature-flags-list', option }],
+ ])
+ expect(onDisableAndArchive).toHaveBeenCalledTimes(option === 'disable_and_archive' ? 1 : 0)
+ expect(onDisable).toHaveBeenCalledTimes(option === 'disable' ? 1 : 0)
})
})
diff --git a/frontend/src/scenes/feature-flags/featureFlagDisableDialog.tsx b/frontend/src/scenes/feature-flags/featureFlagDisableDialog.tsx
index 64848e9504a8..22566da7de69 100644
--- a/frontend/src/scenes/feature-flags/featureFlagDisableDialog.tsx
+++ b/frontend/src/scenes/feature-flags/featureFlagDisableDialog.tsx
@@ -2,9 +2,6 @@ import posthog from 'posthog-js'
import { LemonDialog } from '@posthog/lemon-ui'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic as enabledFeaturesLogic } from 'lib/logic/featureFlagLogic'
-
export type FeatureFlagDisableDialogSource = 'feature-flags-list' | 'feature-flag-detail'
export type FeatureFlagDisableDialogOption = 'disable' | 'disable_and_archive' | 'cancel'
@@ -17,31 +14,19 @@ export function reportFeatureFlagDisableDialogOptionSelected(
}
/**
- * Opens the disable confirmation dialog for a feature flag. The test variant of the
- * disable-and-archive experiment gets "Disable only" as the primary CTA alongside a destructive
- * "Disable and archive" option; control keeps each caller's pre-existing dialog, with this dialog's own
- * option-selected telemetry wrapped around the caller's confirm/cancel. The experiment flag is
- * read here rather than at render so the exposure lines up with the dialog actually opening.
+ * Opens the disable confirmation dialog for a feature flag. "Disable only" is the primary action;
+ * "Disable and archive" sits alongside it as a destructive secondary, so the more destructive
+ * option reads as destructive and isn't the default click.
*/
export function openFeatureFlagDisableDialog({
source,
onDisable,
onDisableAndArchive,
- openControlDialog,
}: {
source: FeatureFlagDisableDialogSource
onDisable: () => void
onDisableAndArchive: () => void
- /** The pre-experiment dialog, shown to the control variant. Called with confirm/cancel
- * callbacks that already report the selected option — the caller only needs to wire them
- * into its own dialog's primary/secondary buttons. */
- openControlDialog: (onConfirm?: () => void, onCancel?: () => void) => void
}): void {
- const inTestVariant =
- enabledFeaturesLogic.findMounted()?.values.featureFlags[
- FEATURE_FLAGS.FEATURE_FLAG_DISABLE_AND_ARCHIVE_EXPERIMENT
- ] === 'test'
-
posthog.capture('feature flag disable confirmation shown', { source })
const selectDisable = (): void => {
@@ -54,11 +39,6 @@ export function openFeatureFlagDisableDialog({
onDisableAndArchive()
}
- if (!inTestVariant) {
- openControlDialog(selectDisable, selectCancel)
- return
- }
-
LemonDialog.open({
title: 'Disable this flag?',
description:
diff --git a/frontend/src/scenes/feature-flags/featureFlagLogic.test.ts b/frontend/src/scenes/feature-flags/featureFlagLogic.test.ts
index 328663301904..4445dbf872e2 100644
--- a/frontend/src/scenes/feature-flags/featureFlagLogic.test.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagLogic.test.ts
@@ -11,11 +11,9 @@ import { expectLogic, partial } from 'kea-test-utils'
import posthog from 'posthog-js'
import api from 'lib/api'
-import { FEATURE_FLAGS } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
-import { featureFlagLogic as enabledFeaturesLogic } from 'lib/logic/featureFlagLogic'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { urls } from 'scenes/urls'
@@ -2163,24 +2161,21 @@ describe('featureFlagLogic', () => {
expect(dialogOpenSpy).toHaveBeenCalledTimes(1)
const dialogProps = dialogOpenSpy.mock.calls[0][0]
- expect(dialogProps.title).toBe('Disable feature flag "test-flag"?')
- expect(dialogProps.primaryButton?.children).toBe('Disable flag')
+ expect(dialogProps.title).toBe('Disable this flag?')
+ expect(dialogProps.primaryButton?.children).toBe('Disable only')
dialogOpenSpy.mockRestore()
})
// onDisableAndArchive is optional at every hop between this listener and
// checkFeatureFlagConfirmation, so dropping it anywhere still compiles and would silently
- // put test-variant users back on the control dialog.
- it('offers disable and archive to the test variant, archiving via the disable confirmation', async () => {
+ // fall back to the plain status confirmation without the archive option.
+ it('offers disable and archive, archiving via the disable confirmation', async () => {
const dialogOpenSpy = jest.spyOn(LemonDialog, 'open').mockImplementation(() => {})
jest.spyOn(api, 'update').mockResolvedValueOnce({
...MOCK_FEATURE_FLAG,
archived: true,
active: false,
})
- enabledFeaturesLogic.actions.setFeatureFlags([FEATURE_FLAGS.FEATURE_FLAG_DISABLE_AND_ARCHIVE_EXPERIMENT], {
- [FEATURE_FLAGS.FEATURE_FLAG_DISABLE_AND_ARCHIVE_EXPERIMENT]: 'test',
- })
logic.actions.setFeatureFlag({ ...MOCK_FEATURE_FLAG, active: true })
await expectLogic(logic, () => logic.actions.toggleFeatureFlagActive(false)).toFinishAllListeners()
diff --git a/frontend/src/scenes/feature-flags/featureFlagsLogic.test.ts b/frontend/src/scenes/feature-flags/featureFlagsLogic.test.ts
index 483945943ddd..9d2e55f1fc32 100644
--- a/frontend/src/scenes/feature-flags/featureFlagsLogic.test.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagsLogic.test.ts
@@ -3,9 +3,7 @@ import { expectLogic } from 'kea-test-utils'
import posthog from 'posthog-js'
import api from 'lib/api'
-import { FEATURE_FLAGS } from 'lib/constants'
import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
-import { featureFlagLogic as enabledFeaturesLogic } from 'lib/logic/featureFlagLogic'
import { showApprovalRequiredToast } from 'scenes/approvals/ApprovalRequiredBanner'
import { NEW_FLAG } from 'scenes/feature-flags/featureFlagLogic'
import {
@@ -431,16 +429,11 @@ describe('updateFeatureFlagArchived', () => {
expect(logic.values.featureFlagsUpdating[1]).toBeUndefined()
})
- // The list arm of the disable-and-archive experiment: the row toggle has to reach
- // updateFeatureFlagArchived with the list's own via, not the archive dialog's.
- it('archives via the disable confirmation when the test variant picks it', async () => {
+ // The list arm of the disable-and-archive dialog: picking "Disable and archive" from the row
+ // toggle has to reach updateFeatureFlagArchived with the list's own via, not the archive dialog's.
+ it('archives via the disable confirmation when disable and archive is picked', async () => {
const openDialog = jest.spyOn(LemonDialog, 'open').mockImplementation(() => {})
jest.spyOn(api, 'update').mockResolvedValueOnce({ id: 1, key: 'test-flag', archived: true, active: false })
- const flagsLogic = enabledFeaturesLogic()
- flagsLogic.mount()
- flagsLogic.actions.setFeatureFlags([FEATURE_FLAGS.FEATURE_FLAG_DISABLE_AND_ARCHIVE_EXPERIMENT], {
- [FEATURE_FLAGS.FEATURE_FLAG_DISABLE_AND_ARCHIVE_EXPERIMENT]: 'test',
- })
logic.actions.toggleFeatureFlagActive(1, false)
expect(openDialog.mock.calls[0][0].secondaryButton?.children).toBe('Disable and archive')
diff --git a/frontend/src/scenes/feature-flags/featureFlagsLogic.ts b/frontend/src/scenes/feature-flags/featureFlagsLogic.ts
index 88cfbafa0bf7..d9dbc58e222c 100644
--- a/frontend/src/scenes/feature-flags/featureFlagsLogic.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagsLogic.ts
@@ -640,35 +640,30 @@ export const featureFlagsLogic = kea<featureFlagsLogicType>([
updateFlagActive: ({ id, active }) => {
actions.updateFeatureFlag({ id, payload: { active } })
},
- // Mirrors featureFlagLogic's listener of the same name, so both surfaces of the
- // disable-and-archive experiment are driven from a logic rather than from the row component.
+ // Mirrors featureFlagLogic's listener of the same name, so both the list and the detail
+ // view drive the toggle from a logic rather than from the row component.
toggleFeatureFlagActive: ({ id, active }) => {
const applyUpdate = (payload: Partial<FeatureFlagType>): void => {
actions.updateFeatureFlag({ id, payload })
}
- const openControlDialog = (onConfirm?: () => void, onCancel?: () => void): void => {
+
+ if (active) {
LemonDialog.open({
- title: `${active ? 'Enable' : 'Disable'} this flag?`,
- description: `This flag will be immediately ${
- active ? 'rolled out to' : 'rolled back from'
- } the users matching the release conditions.`,
+ title: 'Enable this flag?',
+ description:
+ 'This flag will be immediately rolled out to the users matching the release conditions.',
primaryButton: {
children: 'Confirm',
type: 'primary',
- onClick: onConfirm ?? (() => applyUpdate({ active })),
+ onClick: () => applyUpdate({ active: true }),
size: 'small',
},
secondaryButton: {
children: 'Cancel',
type: 'tertiary',
size: 'small',
- onClick: onCancel,
},
})
- }
-
- if (active) {
- openControlDialog()
return
}
@@ -677,7 +672,6 @@ export const featureFlagsLogic = kea<featureFlagsLogicType>([
onDisable: () => applyUpdate({ active: false }),
onDisableAndArchive: () =>
actions.updateFeatureFlagArchived({ id, archived: true, via: 'disable-confirmation' }),
- openControlDialog,
})
},
setFeatureFlagsFilters: async (_, breakpoint) => {