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(dashboards): clean up feature flag dashboard-subscribe-nudge after experiment 383714 (#79430)

posthog[bot]3b99876d2816
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 44f57da17449..ff708b103035 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -281,7 +281,6 @@ export const FEATURE_FLAGS = {
DASHBOARD_AUTO_PREVIEW_LIMIT: 'dashboard-auto-preview-limit', // owner: @pauldambra #team-product-analytics
DASHBOARD_INLINE_TILE_INSERTION: 'dashboard-inline-tile-insertion', // owner: @MattPua #team-analytics-platform
DASHBOARD_LAYOUT_DISCARD_PROMPT: 'dashboard-layout-discard-prompt', // owner: @cory.s #team-analytics-platform
- DASHBOARD_SUBSCRIBE_NUDGE: 'dashboard-subscribe-nudge', // owner: #team-analytics-platform multivariate=control,test, nudges repeat dashboard viewers with no subscription toward setting one up
DASHBOARD_TEMPLATE_CHOOSER_EXPERIMENT: 'dashboard-template-chooser-experiment', // owner: @mattp #team-analytics-platform multivariate=control,simple,new
DASHBOARD_WIDGETS: 'dashboard-widgets', // owner: @mattp #team-analytics-platform
DASHBOARDS_LIST_VIEW: 'dashboards-list-view', // owner: @vdekrijger #team-product-analytics multivariate=control,tree
diff --git a/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.test.ts b/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.test.ts
index 4a9c2b9f7eac..222bc0851760 100644
--- a/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.test.ts
+++ b/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.test.ts
@@ -3,9 +3,7 @@ import { MOCK_DEFAULT_ORGANIZATION, MOCK_DEFAULT_USER } from 'lib/api.mock'
import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
-import { FEATURE_FLAGS } from 'lib/constants'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import posthog from 'lib/posthog-typed'
import { dashboardLogic } from 'scenes/dashboard/dashboardLogic'
import {
@@ -115,7 +113,6 @@ describe('dashboardSubscribeNudgeLogic', () => {
initKeaTests()
userLogic.mount()
userLogic.actions.loadUserSuccess(USER_WITH_SUBSCRIPTIONS_FEATURE)
- featureFlagLogic.mount()
dashboardLogic({
id: DASHBOARD_ID,
dashboard: mockDashboard(),
@@ -185,7 +182,6 @@ describe('dashboardSubscribeNudgeLogic', () => {
describe('free-tier subscription limit', () => {
beforeEach(() => {
userLogic.actions.loadUserSuccess(MOCK_DEFAULT_USER) // no available features -> free tier
- featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.DASHBOARD_SUBSCRIBE_NUDGE]: 'test' })
})
it.each([
@@ -245,21 +241,17 @@ describe('dashboardSubscribeNudgeLogic', () => {
expect(teamWideCalls).toHaveLength(0)
})
- describe('feature flag exposure gating and notification delivery', () => {
- beforeEach(() => {
- featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.DASHBOARD_SUBSCRIBE_NUDGE]: 'test' })
- })
-
- it('does not read the flag while the existing-subscription check is in flight', () => {
+ describe('notification delivery', () => {
+ it('stays hidden while the existing-subscription check is in flight', () => {
recordViews(DASHBOARD_SUBSCRIBE_NUDGE_VIEW_THRESHOLD)
// Synchronously after the threshold view: the check hasn't resolved yet.
expect(logic.values.hasExistingSubscription).toBeNull()
expect(logic.values.isEligible).toBe(false)
- expect(logic.values.flagVariant).toBeUndefined()
+ expect(logic.values.showNudge).toBe(false)
})
- it('suppresses the dashboard permanently when it already has a subscription, without reading the flag or notifying', async () => {
+ it('suppresses the dashboard permanently when it already has a subscription, without notifying', async () => {
mockSubscriptionsList.mockResolvedValue({ count: 1, results: [{ id: 7 }] })
await expectLogic(logic, () => {
@@ -268,7 +260,6 @@ describe('dashboardSubscribeNudgeLogic', () => {
expect(logic.values.isSuppressed).toBe(true)
expect(logic.values.isCandidate).toBe(false)
- expect(logic.values.flagVariant).toBeUndefined()
expect(mockSubscriptionsList).toHaveBeenCalledTimes(1)
expect(nudgePostCount).toBe(0)
@@ -405,33 +396,6 @@ describe('dashboardSubscribeNudgeLogic', () => {
})
})
- it('does not notify for the control variant', async () => {
- featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.DASHBOARD_SUBSCRIBE_NUDGE]: 'control' })
-
- await expectLogic(logic, () => {
- recordViews(DASHBOARD_SUBSCRIBE_NUDGE_VIEW_THRESHOLD)
- }).toFinishAllListeners()
-
- expect(logic.values.isEligible).toBe(true)
- expect(logic.values.showNudge).toBe(false)
- expect(nudgePostCount).toBe(0)
- })
-
- it('requests the notification when feature flags resolve only after the check completed', async () => {
- // No flag variant yet: the check resolves eligible but the nudge can't fire.
- await expectLogic(logic, () => {
- recordViews(DASHBOARD_SUBSCRIBE_NUDGE_VIEW_THRESHOLD)
- }).toFinishAllListeners()
- expect(nudgePostCount).toBe(0)
-
- // Flags arrive late — the nudge must still be delivered.
- featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.DASHBOARD_SUBSCRIBE_NUDGE]: 'test' })
- await expectLogic(logic).toFinishAllListeners()
-
- expect(nudgePostCount).toBe(1)
- expect(capturesOf('dashboard subscribe nudge shown')).toHaveLength(1)
- })
-
it.each([
[true, 1],
[false, 0],
@@ -450,7 +414,6 @@ describe('dashboardSubscribeNudgeLogic', () => {
subsLogic.mount()
await expectLogic(subsLogic).toFinishAllListeners()
- featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.DASHBOARD_SUBSCRIBE_NUDGE]: 'test' })
await expectLogic(logic, () => {
recordViews(DASHBOARD_SUBSCRIBE_NUDGE_VIEW_THRESHOLD)
}).toFinishAllListeners()
diff --git a/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.ts b/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.ts
index 957ff56649e5..016fc580ef0b 100644
--- a/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.ts
+++ b/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.ts
@@ -16,8 +16,6 @@ import { subscriptions } from 'kea-subscriptions'
import { dashboardsSubscribeNudgeCreate } from '@posthog/products-dashboards/frontend/generated/api'
import type { DashboardSubscribeNudgeResponseApi } from '@posthog/products-dashboards/frontend/generated/api.schemas'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import posthog from 'lib/posthog-typed'
import { getCurrentTeamId } from 'lib/utils/getAppContext'
import { dashboardLogic } from 'scenes/dashboard/dashboardLogic'
@@ -35,7 +33,6 @@ import { subscriptionsLogic } from 'products/subscriptions/frontend/components/S
import { isFreeTierCreateAtLimit } from 'products/subscriptions/frontend/components/Subscriptions/views/EditSubscription'
import { subscriptionsList } from 'products/subscriptions/frontend/generated/api'
-import type { FeatureFlagsSet } from '../../lib/logic/featureFlagLogic'
import type { DashboardType, QueryBasedInsightModel } from '../../types'
import type { DashboardViewLog } from './dashboardSubscribeNudgeStoreLogic'
@@ -53,9 +50,7 @@ export interface dashboardSubscribeNudgeLogicValues {
notifiedDashboardIds: number[] // dashboardSubscribeNudgeStoreLogic
suppressedDashboardIds: number[] // dashboardSubscribeNudgeStoreLogic
viewLog: DashboardViewLog // dashboardSubscribeNudgeStoreLogic
- featureFlags: FeatureFlagsSet // featureFlagLogic
hasAvailableFeature: (feature: AvailableFeature, currentUsage?: number | undefined) => boolean // userLogic
- flagVariant: boolean | string | undefined
freeTierSubscriptionCount: number | null
freeTierSubscriptionCountLoading: boolean
hasExistingSubscription: boolean | null
@@ -168,8 +163,7 @@ export interface dashboardSubscribeNudgeLogicMeta {
hasExistingSubscription: boolean | null,
isWithinSubscriptionLimit: boolean
) => boolean
- flagVariant: (isEligible: boolean, featureFlags: FeatureFlagsSet) => boolean | string | undefined
- showNudge: (flagVariant: boolean | string | undefined) => boolean
+ showNudge: (isEligible: boolean) => boolean
}
}
@@ -186,8 +180,6 @@ export const dashboardSubscribeNudgeLogic = kea<dashboardSubscribeNudgeLogicType
key((props) => props.dashboardId),
connect((props: DashboardSubscribeNudgeLogicProps) => ({
values: [
- featureFlagLogic,
- ['featureFlags'],
dashboardLogic({ id: props.dashboardId }),
['dashboard', 'canEditDashboard', 'placement'],
userLogic,
@@ -316,18 +308,7 @@ export const dashboardSubscribeNudgeLogic = kea<dashboardSubscribeNudgeLogicType
isWithinSubscriptionLimit: boolean
): boolean => isCandidate && hasExistingSubscription === false && isWithinSubscriptionLimit,
],
- // CRITICAL: `featureFlags[...]` is a proxy access that reports the flag's exposure event the
- // first time it's read. Only touch it once `isEligible` is true, so the experiment's exposure
- // ($feature_flag_called) fires only for the population that could actually receive the nudge.
- flagVariant: [
- (s) => [s.isEligible, s.featureFlags],
- (isEligible: boolean, featureFlags: FeatureFlagsSet): string | boolean | undefined =>
- isEligible ? featureFlags[FEATURE_FLAGS.DASHBOARD_SUBSCRIBE_NUDGE] : undefined,
- ],
- showNudge: [
- (s) => [s.flagVariant],
- (flagVariant: boolean | string | undefined): boolean => flagVariant === 'test',
- ],
+ showNudge: [(s) => [s.isEligible], (isEligible: boolean): boolean => isEligible],
}),
listeners(({ actions, values, props }) => ({
reportDashboardViewed: () => {
@@ -403,8 +384,8 @@ export const dashboardSubscribeNudgeLogic = kea<dashboardSubscribeNudgeLogicType
},
})),
subscriptions(({ actions, values, cache }) => ({
- // The nudge is requested off the fully-gated state itself (eligibility + test variant),
- // so it also fires when feature flags resolve after the subscription check completed.
+ // The nudge is requested off the gated eligibility state, which resolves asynchronously once
+ // the subscription checks complete, so subscribing here catches that late transition.
showNudge: (showNudge: boolean) => {
if (showNudge && !cache.nudgeRequested && !values.nudgeNotificationLoading) {
cache.nudgeRequested = true