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(subscriptions): make the creation wizard the default (#103885)

Matt Puadac21711924e
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 96bcf3b00c28..5cc5bebed5b5 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6428,14 +6428,10 @@ snapshots:
hash: v1.k794b7964.4248b9034e799f5515f79e1ce1be94acbf161108a113024a695378bbf6f91964.nU8G1dPefUfme1EtuazK3GPd4iK3QnD3f1z8N9F6FwI
products-subscriptions-subscriptions-modal--long-ai-prompt--light:
hash: v1.k794b7964.85b384652aa5b517eed36632295946d61480bcb5532cbda74aeec4842cec02a3.e-ZcvcwAErz7aFdzJ467YrWnVuqNq34A89JytLtG45A
- products-subscriptions-subscriptions-modal--subscription-wizard-new--dark:
- hash: v1.k794b7964.e5aa7358fd68838279ee1a054c4da58e139de7f8cdf7cc31fc55858cf62db633.2cy5yElBtv75-dE9TsJ5XINpT4QnHYAf_g405VzPZ2I
- products-subscriptions-subscriptions-modal--subscription-wizard-new--light:
- hash: v1.k794b7964.a25e52c871d0eda0d3aa152eae70692b6e7afdce17781140e344d9118222c5a0.p4Ekexj90QTVLPreWagC3oRfB1Eo5TzfTRrLBba2ASU
products-subscriptions-subscriptions-modal--subscriptions-new--dark:
- hash: v1.k794b7964.689c2da7432f8fa3420601743c883ae66267aa7f506a84d1480984ec4e858eea.UKt2PmN2WWy_glphF6O-ypRyF5yqWfKv0n1xusY4cZY
+ hash: v1.k794b7964.e5aa7358fd68838279ee1a054c4da58e139de7f8cdf7cc31fc55858cf62db633.zjHhhU29ByaVqoK5Qntq_qzZv7oRTuF3wFGHHiWWvRA
products-subscriptions-subscriptions-modal--subscriptions-new--light:
- hash: v1.k794b7964.fc5e1a3a8bfaa345888181c9e9374d64c3c734333f7a67910635fc4cd3ff3379.Tf36g4kzJf_s9TcM1AEk4gnGPkNQh_ntQcr-ZR1TsQs
+ hash: v1.k794b7964.a25e52c871d0eda0d3aa152eae70692b6e7afdce17781140e344d9118222c5a0.Gkor9YbakPCnaMSX1yE-zSLAdW5BiqviNdUEPOid_40
products-subscriptions-subscriptions-modal--subscriptions-tabbed--dark:
hash: v1.k794b7964.1f9aa8adee753b12e1b50c143ed4e2eed36a5ceaea7f934a43cb16b16ff9974a.KtXqx6ZGFgLFGRPjRxGd10KmRLwCgZPyMSowVK2PPKg
products-subscriptions-subscriptions-modal--subscriptions-tabbed--light:
@@ -8677,9 +8673,9 @@ snapshots:
scenes-app-inbox-detail-follow-up-checks--narrow-rail--light:
hash: v1.k794b7964.71bc62198aef8af9b48673b29376bcffd9c5bae62712d1943b41f80a62997a5a.Ia8n2VymOvs9rUVdnKT4V1pBnd93dPTsCQ6B8SRZ4wo
scenes-app-inbox-detail-follow-up-checks--running--dark:
- hash: v1.k794b7964.6140d13ee22cd970b554499942fb4c0086384855d2fd98b07733ff7bec069cf3.HwCZ5Wv5rEJK15jPx0_owBQB0Ejwlr41XkeMMFUPV8g
+ hash: v1.k794b7964.7c9c84d49f542f37fb20a337d4e097ceac512f7916476f8313f52403a0c8272e.Qbic0TtjJ_u8tITXga4NzK-pjvZVxEv_eDiiDbAZ6To
scenes-app-inbox-detail-follow-up-checks--running--light:
- hash: v1.k794b7964.7b607a184b4dac5f92fff1d8dd160b515ccd339e4eecc9c8fe38885eb97e6544.rznFhlEfGozAGcFKqSiE7V9Lqfnm-KkfU29YEkxb4yM
+ hash: v1.k794b7964.a5e08bb11b3723765e5cc33b4afb36d6ad9217d9a8975497677cf4b2fc513071.Kvc9DMV6mta5XCyUg5mxeDQrjWC5zatz04E4OgsVWpc
scenes-app-inbox-detail-suggested-reviewers-mockup--code-history--dark:
hash: v1.k794b7964.855dc499453a42a73a88ddc6af003e54fca17d6d9c15b77cb16decd61c2e2135.nWuYyTY6x1XdFhfeQyv9vqmZ1QXoegdJaG2TYfhr7B8
scenes-app-inbox-detail-suggested-reviewers-mockup--code-history--light:
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 90507b452061..02b496408616 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -506,7 +506,6 @@ export const FEATURE_FLAGS = {
SSO_SETTINGS_REDESIGN: 'sso-settings-redesign', // owner: @reecejones #team-platform-features
STREAMLIT_APPS: 'streamlit-apps', // owner: @sakce
SUBSCRIPTION_AI_PROMPT: 'ai-subscriptions', // owner: #team-analytics-platform, gates AI prompt-based subscriptions
- SUBSCRIPTION_CREATION_WIZARD: 'subscription-creation-wizard', // owner: #team-analytics-platform, experiment=control,test
SUBSCRIPTION_SLACK_GALLERY: 'subscription-slack-gallery', // owner: #team-analytics-platform, enables gallery delivery after the worker rollout completes
SURVEY_HEADLINE_SUMMARY: 'survey-headline-summary', // owner: @adboio #team-surveys
SURVEYS_ERROR_TRACKING_CROSS_SELL: 'surveys-in-error-tracking', // owner: @adboio #team-surveys
diff --git a/frontend/src/scenes/dashboard/DashboardModals.tsx b/frontend/src/scenes/dashboard/DashboardModals.tsx
index 4c63820085b4..786752629e72 100644
--- a/frontend/src/scenes/dashboard/DashboardModals.tsx
+++ b/frontend/src/scenes/dashboard/DashboardModals.tsx
@@ -69,8 +69,7 @@ export function DashboardModals({ dashboard }: { dashboard: DashboardType<QueryB
isOpen={showSubscriptions}
closeModal={() => push(urls.dashboard(dashboard.id))}
dashboard={dashboard}
- isCreating={subscriptionId === 'new'}
- subscriptionId={subscriptionId === 'new' ? null : subscriptionId}
+ subscriptionId={subscriptionId === 'new' ? undefined : subscriptionId}
/>
<SharingModal
title="Dashboard permissions & sharing"
diff --git a/frontend/src/scenes/insights/InsightModals.tsx b/frontend/src/scenes/insights/InsightModals.tsx
index 8a857cfc2c61..a2c402636611 100644
--- a/frontend/src/scenes/insights/InsightModals.tsx
+++ b/frontend/src/scenes/insights/InsightModals.tsx
@@ -67,8 +67,7 @@ function InsightSubscriptionsModalWrapper({
closeModal={() => push(urls.insightView(insight.short_id as InsightShortId))}
insightShortId={insight.short_id}
insightName={insight.name || insight.derived_name || 'Untitled insight'}
- isCreating={isNewSubscription}
- subscriptionId={itemId}
+ subscriptionId={isNewSubscription ? undefined : itemId}
/>
)
}
diff --git a/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.stories.tsx b/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.stories.tsx
index 5b29971fab5e..cbd36410740f 100644
--- a/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.stories.tsx
+++ b/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.stories.tsx
@@ -286,16 +286,7 @@ export default meta
type Story = StoryObj<StoryArgs>
export const SubscriptionsNew: Story = {
- args: { isCreating: true, formScenario: 'default' },
-}
-
-export const SubscriptionWizardNew: Story = {
- parameters: {
- featureFlags: {
- [FEATURE_FLAGS.SUBSCRIPTION_CREATION_WIZARD]: 'test',
- },
- },
- args: { isCreating: true, formScenario: 'default' },
+ args: { formScenario: 'default' },
}
export const LongAiPrompt: Story = {
diff --git a/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.tsx b/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.tsx
index 88e8330036dd..9b9b844e8b7a 100644
--- a/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.tsx
+++ b/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.tsx
@@ -3,7 +3,6 @@ import { router } from 'kea-router'
import posthog from 'posthog-js'
import { useEffect, useRef, useState } from 'react'
-import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { LemonModal } from 'lib/lemon-ui/LemonModal'
import { Spinner } from 'lib/lemon-ui/Spinner/Spinner'
import { userLogic } from 'scenes/userLogic'
@@ -25,7 +24,6 @@ export interface SubscriptionsModalProps {
isOpen: boolean
closeModal: () => void
subscriptionId?: number | null
- isCreating?: boolean
inline?: boolean
insightShortId?: InsightShortId
insightName?: string
@@ -39,7 +37,6 @@ export function SubscriptionsModal(props: SubscriptionsModalProps): JSX.Element
dashboard,
insightShortId,
insightName,
- isCreating = false,
subscriptionId,
isOpen,
inline,
@@ -48,27 +45,26 @@ export function SubscriptionsModal(props: SubscriptionsModalProps): JSX.Element
const { push } = useActions(router)
const { userLoading } = useValues(userLogic)
const { searchParams } = useValues(router)
- const subscriptionWizardExperimentEnabled = useFeatureFlag('SUBSCRIPTION_CREATION_WIZARD', 'test')
const dashboardId = dashboard?.id
const isAiPrompt = searchParams.resource_type === SubscriptionResourceTypes.AiPrompt
const baseProps: SubscriptionBaseProps = { insightShortId, dashboardId }
- const isWizard = isCreating && (insightShortId || dashboard || isAiPrompt) && subscriptionWizardExperimentEnabled
+ const isWizard = subscriptionId === undefined
const modalWasOpen = useRef(false)
useEffect(() => {
if (!isOpen) {
modalWasOpen.current = false
return
}
- if (!isCreating || modalWasOpen.current) {
+ if (!isWizard || modalWasOpen.current) {
return
}
modalWasOpen.current = true
posthog.capture('subscription creation modal opened', {
- creation_source: isWizard ? 'wizard' : 'editor',
+ creation_source: 'wizard',
resource_type: isAiPrompt ? 'ai' : dashboard ? 'dashboard' : 'insight',
})
- }, [dashboard, isAiPrompt, isCreating, isOpen, isWizard])
+ }, [dashboard, isAiPrompt, isOpen, isWizard])
const cancelWizard = (): void => push(urlForSubscriptions(baseProps))
const requestWizardCancel = (): void => {
const wizardForm = subscriptionLogic.findMounted({
@@ -104,34 +100,34 @@ export function SubscriptionsModal(props: SubscriptionsModalProps): JSX.Element
inline={inline}
data-attr={dataAttr}
>
- {!isCreating && subscriptionId === null ? (
- <TabbedManageSubscriptions
- {...baseProps}
- activeTab={activeTab}
- onChangeTab={setActiveTab}
- onCancel={closeModal}
- onSelect={(id, resourceType) =>
- push(
- urlForSubscription(id, baseProps),
- resourceType ? { resource_type: resourceType } : undefined
- )
- }
- />
- ) : isWizard ? (
+ {isWizard ? (
<SubscriptionWizard
insightShortId={insightShortId}
insightName={insightName}
dashboard={dashboard}
onCancel={cancelWizard}
/>
- ) : (
+ ) : subscriptionId != null ? (
<EditSubscription
- id={subscriptionId ?? 'new'}
+ id={subscriptionId}
insightShortId={insightShortId}
dashboard={dashboard}
onCancel={() => push(urlForSubscriptions(baseProps))}
onDelete={() => push(urlForSubscriptions(baseProps))}
/>
+ ) : (
+ <TabbedManageSubscriptions
+ {...baseProps}
+ activeTab={activeTab}
+ onChangeTab={setActiveTab}
+ onCancel={closeModal}
+ onSelect={(id, resourceType) =>
+ push(
+ urlForSubscription(id, baseProps),
+ resourceType ? { resource_type: resourceType } : undefined
+ )
+ }
+ />
)}
</LemonModal>
)
diff --git a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx
index 1a5765478531..5e69e2cc5885 100644
--- a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx
+++ b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx
@@ -112,26 +112,13 @@ function LastDeliveryStatus({
}
interface EditSubscriptionProps {
- id: number | 'new'
+ id: number
insightShortId?: InsightShortId
dashboard?: DashboardType<any> | null
onCancel: () => void
onDelete: () => void
}
-export function EditSubscription(props: EditSubscriptionProps): JSX.Element {
- const isCreating = props.id === 'new'
-
- if (!isCreating) {
- return <EditSubscriptionForm {...props} />
- }
- return (
- <SubscriptionCreationGate onCancel={props.onCancel}>
- <EditSubscriptionForm {...props} />
- </SubscriptionCreationGate>
- )
-}
-
export function SubscriptionCreationGate({
onCancel,
children,
@@ -239,7 +226,7 @@ function DashboardInsightsField({
)
}
-function EditSubscriptionForm({
+export function EditSubscription({
id,
insightShortId,
dashboard,
@@ -292,32 +279,33 @@ function EditSubscriptionForm({
const isParentless = !insightShortId && !dashboardId
const availableFrequencyOptions = subscription?.interval === 1 ? frequencyOptionsSingular : frequencyOptionsPlural
- // For new subscriptions, show InsightSelector immediately (useEffect will auto-select)
- // For editing, wait until subscription data has loaded from API (target_type exists)
- // We check target_type instead of dashboard_export_insights because old subscriptions
- // may have no insights selected yet
- const isEditing = id !== 'new'
const aiGate = getAiSubscriptionGate({
isAiPrompt,
isParentless,
- isEditing,
+ isEditing: true,
aiConsentApproved: Boolean(currentOrganization?.is_ai_data_processing_approved),
isCloud: Boolean(preflight?.cloud),
isDebug: Boolean(preflight?.is_debug),
aiFlagEnabled: Boolean(aiSubscriptionsEnabled),
})
const subscriptionLoaded = !!subscription?.target_type
- const selectionReady = !isEditing || subscriptionLoaded
- if (subscriptionLoading || (isEditing && !subscriptionLoaded)) {
+ if (subscriptionLoading) {
return <SubscriptionFormSkeleton />
}
+ if (!subscriptionLoaded) {
+ return (
+ <div className="p-4 text-center">
+ <h2>Not found</h2>
+ <p>This subscription could not be found. It may have been deleted.</p>
+ </div>
+ )
+ }
+
const _onDelete = (): void => {
- if (isEditing) {
- deleteSubscription(id)
- onDelete()
- }
+ deleteSubscription(id)
+ onDelete()
}
const formatter = new Intl.DateTimeFormat('en-US', { timeZoneName: 'shortGeneric' })
@@ -329,7 +317,7 @@ function EditSubscriptionForm({
if (aiGate.submitBlocked) {
saveDisabledReason = AI_NOT_ALLOWED_REASON
} else if (!subscriptionChanged) {
- saveDisabledReason = id === 'new' ? 'Nothing to create yet' : 'No changes to save'
+ saveDisabledReason = 'No changes to save'
}
return (
@@ -344,7 +332,7 @@ function EditSubscriptionForm({
<div className="flex items-center gap-2">
<LemonButton icon={<IconChevronLeft />} onClick={onCancel} size="xsmall" />
- <h3>{id === 'new' ? 'New' : 'Edit '} Subscription</h3>
+ <h3>Edit subscription</h3>
</div>
</LemonModal.Header>
@@ -443,7 +431,7 @@ function EditSubscriptionForm({
</LemonField>
)}
- {dashboard?.tiles && selectionReady && !isAiPrompt && (
+ {dashboard?.tiles && !isAiPrompt && (
<DashboardInsightsField
dashboard={dashboard}
onDefaultsApplied={applyDefaultSelectedInsights}
@@ -784,34 +772,32 @@ function EditSubscriptionForm({
{currentTimezone}
</div>
)}
- {id !== 'new' && (
- <div className="flex items-center justify-between gap-2 mt-1">
- <div className="text-sm text-secondary">
- <LastDeliveryStatus
- lastDelivery={lastDelivery}
- loading={lastDeliveryLoading}
- failed={lastDeliveryLoadFailed}
- currentTimezone={currentTimezone}
- />
- {' · '}
- <Link to={urls.subscription(id)}>View history</Link>
- </div>
- <LemonButton
- type="secondary"
- size="small"
- icon={<IconSend />}
- onClick={sendTestDelivery}
- loading={testDeliveryLoading}
- disabledReason={
- subscription.enabled === false
- ? 'Re-enable this subscription before sending a test delivery'
- : undefined
- }
- >
- Send test delivery
- </LemonButton>
+ <div className="flex items-center justify-between gap-2 mt-1">
+ <div className="text-sm text-secondary">
+ <LastDeliveryStatus
+ lastDelivery={lastDelivery}
+ loading={lastDeliveryLoading}
+ failed={lastDeliveryLoadFailed}
+ currentTimezone={currentTimezone}
+ />
+ {' · '}
+ <Link to={urls.subscription(id)}>View history</Link>
</div>
- )}
+ <LemonButton
+ type="secondary"
+ size="small"
+ icon={<IconSend />}
+ onClick={sendTestDelivery}
+ loading={testDeliveryLoading}
+ disabledReason={
+ subscription.enabled === false
+ ? 'Re-enable this subscription before sending a test delivery'
+ : undefined
+ }
+ >
+ Send test delivery
+ </LemonButton>
+ </div>
</div>
{/*
@@ -946,7 +932,7 @@ function EditSubscriptionForm({
<LemonModal.Footer>
<div className="flex-1">
- {subscription && id !== 'new' && (
+ {subscription && (
<LemonButton
type="secondary"
status="danger"
@@ -966,7 +952,7 @@ function EditSubscriptionForm({
loading={isSubscriptionSubmitting}
disabledReason={saveDisabledReason}
>
- {id === 'new' ? 'Create subscription' : 'Save'}
+ Save
</LemonButton>
</LemonModal.Footer>
</Form>
diff --git a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.unsavedChanges.test.tsx b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.unsavedChanges.test.tsx
index 0cd64f558734..c7ed9bbc37d3 100644
--- a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.unsavedChanges.test.tsx
+++ b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.unsavedChanges.test.tsx
@@ -77,6 +77,36 @@ describe('EditSubscription unsaved changes', () => {
afterEach(() => cleanup())
+ it('shows a missing-subscription message after its request fails', async () => {
+ useMocks({
+ get: {
+ '/api/environments/:team/subscriptions/1': () => [404, { detail: 'Not found' }],
+ '/api/environments/:team/subscriptions': { count: 0, results: [] },
+ '/api/projects/:team/subscriptions/1/deliveries/': { next: null, previous: null, results: [] },
+ '/api/projects/:team/integrations': { count: 0, results: [] },
+ '/api/projects/:team/integrations/:intId/channels': { channels: [] },
+ '/api/environments/:team/subscriptions/summary_quota': {
+ active_count: 0,
+ limit: null,
+ at_limit: false,
+ },
+ '/api/organizations/@current/': MOCK_DEFAULT_ORGANIZATION,
+ '/api/organizations/@current/members/': { count: 0, results: [] },
+ },
+ })
+ initKeaTests()
+ userLogic.mount()
+ userLogic.actions.loadUserSuccess(MOCK_DEFAULT_USER)
+
+ render(
+ <Provider>
+ <EditSubscription id={1} dashboard={DASHBOARD} onCancel={jest.fn()} onDelete={jest.fn()} />
+ </Provider>
+ )
+
+ expect(await screen.findByText('Not found')).toBeInTheDocument()
+ })
+
it.each([
[
'an email destination',
diff --git a/products/subscriptions/frontend/scenes/components/SubscriptionsSceneModal.tsx b/products/subscriptions/frontend/scenes/components/SubscriptionsSceneModal.tsx
index 69f5e5906c1e..0cf0c5c9e8a5 100644
--- a/products/subscriptions/frontend/scenes/components/SubscriptionsSceneModal.tsx
+++ b/products/subscriptions/frontend/scenes/components/SubscriptionsSceneModal.tsx
@@ -3,7 +3,6 @@ import { router } from 'kea-router'
import { LemonModal } from '@posthog/lemon-ui'
-import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { urls } from 'scenes/urls'
import { subscriptionLogic } from '../../components/Subscriptions/subscriptionLogic'
@@ -27,9 +26,8 @@ export function SubscriptionsSceneModal(): JSX.Element | null {
dashboardLoading: newSubscriptionDashboardLoading,
} = useValues(newSubscriptionTargetLogic)
const { reset: resetNewSubscriptionTarget } = useActions(newSubscriptionTargetLogic)
- const subscriptionWizardExperimentEnabled = useFeatureFlag('SUBSCRIPTION_CREATION_WIZARD', 'test')
- const isWizard = subscriptionModalId === 'new' && subscriptionWizardExperimentEnabled
+ const isWizard = subscriptionModalId === 'new'
const insightTarget = newSubscriptionTarget?.kind === 'insight' ? newSubscriptionTarget : null
const dashboardTargetPending = newSubscriptionTarget?.kind === 'dashboard' && !newSubscriptionDashboard
// A dashboard that failed to load leaves nothing to send, so the picker comes back.