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.

fix(dashboards): address subscribe nudge review feedback (#71592)

Vasco de Krijgerc90d435cd800
diff --git a/frontend/src/initKea.ts b/frontend/src/initKea.ts
index 38e7c70a95d6..0d6bd8744d3a 100644
--- a/frontend/src/initKea.ts
+++ b/frontend/src/initKea.ts
@@ -37,7 +37,7 @@ const ERROR_FILTER_ALLOW_LIST = [
'loadSimilarIssues', // Gracefully handled in the similar issues list
'saveEarlyAccessFeature', // Field-level errors handled in earlyAccessFeatureLogic
'loadExistingSubscription', // Background eligibility check for the dashboard subscribe nudge
- 'loadTeamSubscriptionCount', // Background free-tier limit check for the dashboard subscribe nudge
+ 'loadFreeTierSubscriptionCount', // Background free-tier limit check for the dashboard subscribe nudge
'sendNudgeNotification', // Background delivery request for the dashboard subscribe nudge
]
diff --git a/frontend/src/layout/FeaturePreviews/featurePreviewsLogic.tsx b/frontend/src/layout/FeaturePreviews/featurePreviewsLogic.tsx
index be48a48f5f90..79b5a7c47337 100644
--- a/frontend/src/layout/FeaturePreviews/featurePreviewsLogic.tsx
+++ b/frontend/src/layout/FeaturePreviews/featurePreviewsLogic.tsx
@@ -34,11 +34,13 @@ export interface featurePreviewsLogicValues {
activeFeedbackFlagKey: string | null
activeFeedbackFlagKeyLoading: boolean
conceptEnrollments: Record<string, boolean>
+ conceptSurveySubmissions: Record<string, boolean>
earlyAccessFeatures: EnrichedEarlyAccessFeature[]
filteredEarlyAccessFeatures: EnrichedEarlyAccessFeature[]
rawEarlyAccessFeatures: EarlyAccessFeature[]
rawEarlyAccessFeaturesLoading: boolean
searchTerm: string
+ waitlistSurveysEnabled: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -51,6 +53,9 @@ export interface featurePreviewsLogicActions {
cancelEarlyAccessFeatureFeedback: () => {
value: true
}
+ conceptSurveySubmitted: (flagKey: string) => {
+ flagKey: string
+ }
copyExternalFeaturePreviewLink: (flagKey: string) => {
flagKey: string
}
@@ -72,6 +77,13 @@ export interface featurePreviewsLogicActions {
setSearchTerm: (searchTerm: string) => {
searchTerm: string
}
+ submitConceptSurvey: (
+ flagKey: string,
+ email: string
+ ) => {
+ email: string
+ flagKey: string
+ }
submitEarlyAccessFeatureFeedback: (message: string) => {
message: string
}
@@ -116,6 +128,7 @@ export interface featurePreviewsLogicMeta {
earlyAccessFeatures: EnrichedEarlyAccessFeature[],
searchTerm: string
) => EnrichedEarlyAccessFeature[]
+ waitlistSurveysEnabled: (featureFlags: FeatureFlagsSet) => boolean
}
}
@@ -342,7 +355,7 @@ export const featurePreviewsLogic = kea<featurePreviewsLogicType>([
// linked survey instead of the one-click enrollment.
waitlistSurveysEnabled: [
(s) => [s.featureFlags],
- (featureFlags): boolean => !!featureFlags[FEATURE_FLAGS.COMING_SOON_WAITLIST_SURVEYS],
+ (featureFlags: FeatureFlagsSet): boolean => !!featureFlags[FEATURE_FLAGS.COMING_SOON_WAITLIST_SURVEYS],
],
}),
])
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 5297fba68ad0..f0a7f09e2184 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -278,9 +278,7 @@ export const FEATURE_FLAGS = {
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_POSTHOG_AI_BUTTON_LABEL: 'dashboard-posthog-ai-button-label', // owner: @pauldambra #team-product-analytics multivariate=control,control_b,test
- DASHBOARD_QUICK_FILTERS_EXPERIMENT: 'dashboard-quick-filters-experiment', // owner: @vdekrijger #team-product-analytics multivariate=control,test
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_SUBSCRIBE_PLACEMENT: 'dashboard-subscribe-placement', // owner: @MattPua #team-analytics-platform multivariate=control,button,menu
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.ts b/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.ts
index 3607435e2540..957ff56649e5 100644
--- a/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.ts
+++ b/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.ts
@@ -56,6 +56,8 @@ export interface dashboardSubscribeNudgeLogicValues {
featureFlags: FeatureFlagsSet // featureFlagLogic
hasAvailableFeature: (feature: AvailableFeature, currentUsage?: number | undefined) => boolean // userLogic
flagVariant: boolean | string | undefined
+ freeTierSubscriptionCount: number | null
+ freeTierSubscriptionCountLoading: boolean
hasExistingSubscription: boolean | null
hasExistingSubscriptionLoading: boolean
hasSubscriptionsFeature: boolean
@@ -69,8 +71,6 @@ export interface dashboardSubscribeNudgeLogicValues {
nudgeNotification: DashboardSubscribeNudgeResponseApi | null
nudgeNotificationLoading: boolean
showNudge: boolean
- teamSubscriptionCount: number | null
- teamSubscriptionCountLoading: boolean
viewCount7d: number
}
@@ -103,19 +103,19 @@ export interface dashboardSubscribeNudgeLogicActions {
hasExistingSubscription: boolean
payload?: unknown
}
- loadTeamSubscriptionCount: (_?: unknown) => unknown
- loadTeamSubscriptionCountFailure: (
+ loadFreeTierSubscriptionCount: (_?: unknown) => unknown
+ loadFreeTierSubscriptionCountFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
- loadTeamSubscriptionCountSuccess: (
- teamSubscriptionCount: number,
+ loadFreeTierSubscriptionCountSuccess: (
+ freeTierSubscriptionCount: number,
payload?: unknown
) => {
- teamSubscriptionCount: number
+ freeTierSubscriptionCount: number
payload?: unknown
}
sendNudgeNotification: (_?: unknown) => unknown
@@ -151,7 +151,7 @@ export interface dashboardSubscribeNudgeLogicMeta {
placement: DashboardPlacement
) => boolean
hasSubscriptionsFeature: (
- hasAvailableFeature: (feature: AvailableFeature, currentUsage?: number | undefined) => boolean
+ hasAvailableFeature: (feature: AvailableFeature, currentUsage?: number | undefined) => boolean // userLogic
) => boolean
isCandidate: (
isPastViewThreshold: boolean,
@@ -159,7 +159,10 @@ export interface dashboardSubscribeNudgeLogicMeta {
isNotified: boolean,
isDashboardEligible: boolean
) => boolean
- isWithinSubscriptionLimit: (hasSubscriptionsFeature: boolean, teamSubscriptionCount: number | null) => boolean
+ isWithinSubscriptionLimit: (
+ hasSubscriptionsFeature: boolean,
+ freeTierSubscriptionCount: number | null
+ ) => boolean
isEligible: (
isCandidate: boolean,
hasExistingSubscription: boolean | null,
@@ -225,22 +228,17 @@ export const dashboardSubscribeNudgeLogic = kea<dashboardSubscribeNudgeLogicType
},
},
],
- // Team-wide subscription count, fetched only for free-tier candidates: those orgs can
- // create subscriptions until SubscriptionFreeTierLimit.COUNT, and nudging someone already
- // at the limit would push them straight into the create-form paywall.
- teamSubscriptionCount: [
+ // This team-wide count is separate from the dashboard-specific subscription check above.
+ freeTierSubscriptionCount: [
null as number | null,
{
- loadTeamSubscriptionCount: async (_?: unknown, breakpoint?: BreakPointFunction) => {
- // limit=1 keeps the payload tiny; `count` reflects the team's full total.
+ loadFreeTierSubscriptionCount: async (_?: unknown, breakpoint?: BreakPointFunction) => {
const response = await subscriptionsList(String(getCurrentTeamId()), { limit: 1 })
breakpoint?.()
return response.count ?? 0
},
},
],
- // Asks the backend to deliver the in-app nudge notification. The server dedupes per
- // (user, dashboard) and reports whether a notification was actually created.
nudgeNotification: [
null as DashboardSubscribeNudgeResponseApi | null,
{
@@ -305,10 +303,10 @@ export const dashboardSubscribeNudgeLogic = kea<dashboardSubscribeNudgeLogicType
// asked and the backend is the hard gate), a proactive nudge fails closed on an unknown
// count: don't advertise an action we can't confirm they can complete.
isWithinSubscriptionLimit: [
- (s) => [s.hasSubscriptionsFeature, s.teamSubscriptionCount],
- (hasSubscriptionsFeature: boolean, teamSubscriptionCount: number | null): boolean =>
+ (s) => [s.hasSubscriptionsFeature, s.freeTierSubscriptionCount],
+ (hasSubscriptionsFeature: boolean, freeTierSubscriptionCount: number | null): boolean =>
hasSubscriptionsFeature ||
- (teamSubscriptionCount !== null && !isFreeTierCreateAtLimit(teamSubscriptionCount)),
+ (freeTierSubscriptionCount !== null && !isFreeTierCreateAtLimit(freeTierSubscriptionCount)),
],
isEligible: [
(s) => [s.isCandidate, s.hasExistingSubscription, s.isWithinSubscriptionLimit],
@@ -344,10 +342,10 @@ export const dashboardSubscribeNudgeLogic = kea<dashboardSubscribeNudgeLogicType
}
if (
!values.hasSubscriptionsFeature &&
- values.teamSubscriptionCount === null &&
- !values.teamSubscriptionCountLoading
+ values.freeTierSubscriptionCount === null &&
+ !values.freeTierSubscriptionCountLoading
) {
- actions.loadTeamSubscriptionCount()
+ actions.loadFreeTierSubscriptionCount()
}
},
loadExistingSubscriptionSuccess: ({ hasExistingSubscription }) => {
@@ -367,7 +365,7 @@ export const dashboardSubscribeNudgeLogic = kea<dashboardSubscribeNudgeLogicType
error_message: error,
})
},
- loadTeamSubscriptionCountFailure: ({ error, errorObject }) => {
+ loadFreeTierSubscriptionCountFailure: ({ error, errorObject }) => {
// A failed count check silently excludes a free-tier user (fail closed) — capture it so
// the readout can tell that apart from genuinely being at the limit.
posthog.capture('dashboard subscribe nudge check failed', {
@@ -423,8 +421,8 @@ export const dashboardSubscribeNudgeLogic = kea<dashboardSubscribeNudgeLogicType
if (values.hasExistingSubscription === null) {
actions.loadExistingSubscription()
}
- if (!values.hasSubscriptionsFeature && values.teamSubscriptionCount === null) {
- actions.loadTeamSubscriptionCount()
+ if (!values.hasSubscriptionsFeature && values.freeTierSubscriptionCount === null) {
+ actions.loadFreeTierSubscriptionCount()
}
}),
])
diff --git a/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.test.ts b/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.test.ts
index 7b8a854adf35..6fd877efd773 100644
--- a/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.test.ts
+++ b/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.test.ts
@@ -231,7 +231,7 @@ describe('subscriptionLogic', () => {
router.actions.push(`/dashboard/9/subscriptions/new${search}`)
await expectLogic(testLogic).toFinishListeners()
- testLogic.actions.applyInsightSelectionDefaults([101, 102])
+ testLogic.actions.applyDefaultSelectedInsights([101, 102])
await expectLogic(testLogic).toFinishListeners()
expect(testLogic.values.subscription.dashboard_export_insights).toEqual([101, 102])
diff --git a/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.ts b/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.ts
index fe91b5aefc6f..961f0977bdf2 100644
--- a/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.ts
+++ b/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.ts
@@ -166,7 +166,7 @@ export interface subscriptionLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface subscriptionLogicActions {
- applyInsightSelectionDefaults: (selectedIds: number[]) => {
+ applyDefaultSelectedInsights: (selectedIds: number[]) => {
selectedIds: number[]
}
generatePreview: () => {
@@ -350,7 +350,7 @@ export const subscriptionLogic = kea<subscriptionLogicType>([
setPreviewLoading: (loading: boolean) => ({ loading }),
setPreviewError: (error: string | null) => ({ error }),
setPreviewImageUrl: (url: string | null) => ({ url }),
- applyInsightSelectionDefaults: (selectedIds: number[]) => ({ selectedIds }),
+ applyDefaultSelectedInsights: (selectedIds: number[]) => ({ selectedIds }),
selectAiExamplePrompt: (prompt: string, label: string, window?: AIWindowConfigApi) => ({
prompt,
label,
@@ -468,7 +468,6 @@ export const subscriptionLogic = kea<subscriptionLogicType>([
insight_short_id: props.insightShortId,
subscription_id: updatedSub.id,
target_type: updatedSub.target_type,
- // True when the nudge flow's deferred AI-summary default was applied to this form.
ai_summary_prefilled: cache.prefillBaseline?.summary_enabled === true,
})
}
@@ -492,7 +491,7 @@ export const subscriptionLogic = kea<subscriptionLogicType>([
recordRecentSlackChannel(subscription.integration_id, slackChannelId(subscription.target_value))
}
},
- applyInsightSelectionDefaults: ({ selectedIds }) => {
+ applyDefaultSelectedInsights: ({ selectedIds }) => {
if (cache.prefillBaseline) {
// Prefilled form: the auto-selection joins the programmatic baseline. A reset here
// would wipe the "changed" flag the prefill deliberately set (disabling Create), so
@@ -709,6 +708,7 @@ export const subscriptionLogic = kea<subscriptionLogicType>([
// default, so "Create subscription" doesn't require an extra no-op edit to enable.
actions.setSubscriptionValues(prefill)
cache.prefillBaseline = { ...NEW_SUBSCRIPTION, ...prefill }
+ // Both toast and notification links enter the nudge flow through this route.
posthog.capture('dashboard subscribe nudge clicked', {
dashboard_id: props.dashboardId,
prefilled: !!values.user?.email,
diff --git a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx
index 01cdda104b87..37b0c2089791 100644
--- a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx
+++ b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx
@@ -321,7 +321,7 @@ function DashboardInsightsField({
selectedInsightIds={value ?? []}
onChange={onChange}
// The logic decides whether the auto-selection resets the form to a clean state
- // or joins a prefill's baseline — see applyInsightSelectionDefaults.
+ // or joins a prefill's baseline — see applyDefaultSelectedInsights.
onDefaultsApplied={onDefaultsApplied}
/>
)}
@@ -353,7 +353,7 @@ function EditSubscriptionForm({
const { subscription, subscriptionLoading, isSubscriptionSubmitting, subscriptionChanged, summaryQuota } =
useValues(logic)
const { previewLoading, previewError, previewImageUrl } = useValues(logic)
- const { applyInsightSelectionDefaults, generatePreview } = useActions(logic)
+ const { applyDefaultSelectedInsights, generatePreview } = useActions(logic)
const { preflight, siteUrlMisconfigured } = useValues(preflightLogic)
const { currentOrganization } = useValues(organizationLogic)
const { deleteSubscription } = useActions(subscriptionslogic)
@@ -512,7 +512,7 @@ function EditSubscriptionForm({
{dashboard?.tiles && selectionReady && !isAiPrompt && (
<DashboardInsightsField
dashboard={dashboard}
- onDefaultsApplied={applyInsightSelectionDefaults}
+ onDefaultsApplied={applyDefaultSelectedInsights}
/>
)}