: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(subscriptions): improve report discovery (#73324)
Matt Puaae512140539c
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 72ddb3ec852a..9764eb66a90c 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -1792,42 +1792,6 @@ snapshots:hash: v1.k794b7964.173067780026a31bcbd328a0e5a49417da614e9a7283ac96deee462f4264b5f4.PrHHHFIdmzwaKRJ22Ws7bY9ytpe5sqUavscBvrUhkcIcomponents-sso-select--sso-select--light:hash: v1.k794b7964.a53e97cb122fd5f1c1ebeafc7f3711094334bedbfc57d3a5edb61305fa9b7fd5.sWZP2Xf1ZHvG-3zB-I5poEQvHnqMjEVOBVEbYzNYLfc- components-subscriptions--subscription-at-ai-summary-limit--dark:- hash: v1.k794b7964.f311eeee76a344bb3e5d6f821bfc39eaed7084676ed8303b75f72bc7a1b07850.OG5oagYOX-YdE_uuALBpZ0XnpKUWBxR0tg5t-QkSHIY- components-subscriptions--subscription-at-ai-summary-limit--light:- hash: v1.k794b7964.5811e86e8e76821927d62745628b48be1c326808cdcb74a9df4391cbbd699267.1g0Ui2rQZi3A5BTK587dS2Ub5cmJodiiHnHlryX4Ypc- components-subscriptions--subscription-no-integrations--dark:- hash: v1.k794b7964.e6331066f5581a9fb274858fc8b1d680bc830856000c5f7313baa857e4d80cf7.UoMnvRaSYrBFiWRG0yXh1ON8kgc5dFLiakUr57kWFRc- components-subscriptions--subscription-no-integrations--light:- hash: v1.k794b7964.1d81095d9f3e559c7e0c9888e5e5633c7ea78d61b156983c4b8dcdf86e590522.1wlbv02BG2FOCiRP9tcYU5tiZbNMl_K2gMY3uFuKups- components-subscriptions--subscriptions--dark:- hash: v1.k794b7964.29bdf80867c8ea5ac4cd22db82f1de2a85b6abc668c54549a7c5796e2a0d88fb.JhmMnIpOHOLA-rZUHKlFL3o9BZaa076RRs819fS5J_0- components-subscriptions--subscriptions--light:- hash: v1.k794b7964.190dae50134f9c6e97cbaa89bc1ef20af0b0fa1906c265f64f06fbca1e2bf3a7.BR5ZMkdkYEF89q5H-5VEEjWAq3wbTD0Jq7HUqoG1CIY- components-subscriptions--subscriptions-edit--dark:- hash: v1.k794b7964.6400968f5984a0e590c6da9c375a74e29b21a1b8412904757f12b5c8b81c93d8.Kl2_HZbKUxV0wFUpKub7d3fp_2vMvc9MeSgFer_KpPU- components-subscriptions--subscriptions-edit--light:- hash: v1.k794b7964.cda28c1f47746476c6d4d226f55fb21dc032c49a04917ee738178d4214b390fd.4gLWUZ9IhlqKOns_wtGrT4N71RqOa7kqyWF4QDMF1Ao- components-subscriptions--subscriptions-empty--dark:- hash: v1.k794b7964.d8851cce11bb043fb1826b75e58a625dc42c485634fd03cbc015d90c00ef0867.jMy7Y347ZmcIyPvSHFIH8LGxLVa7ebjVBFWL_c8tHJo- components-subscriptions--subscriptions-empty--light:- hash: v1.k794b7964.4741de4c6e53cadf340e18e25b7363fa8b19834165e224f00ebfc35f69bd36e3.VdR976zptd0BsK_uJxEdTGsnF0tu4r8tLNNbxgL23To- components-subscriptions--subscriptions-new--dark:- hash: v1.k794b7964.f311eeee76a344bb3e5d6f821bfc39eaed7084676ed8303b75f72bc7a1b07850.wrgev2PJ3oA6tjAy87wPNrzBWZ5zZ6t1VzbGM0MHQvI- components-subscriptions--subscriptions-new--light:- hash: v1.k794b7964.5811e86e8e76821927d62745628b48be1c326808cdcb74a9df4391cbbd699267.N5AxNAkXbCKwfxtrF1yDtD_NZ2SQ_G9Pr1WIPWJxYmo- components-subscriptions--subscriptions-new-free-at-limit--dark:- hash: v1.k794b7964.9f3333111f3d966404dda85a5b31ec40ab38e817bb61506144a5a13850d5714f.zm_fwavL51Xt_v932vmSHzXu2Zky7BrDCfn76ejB1os- components-subscriptions--subscriptions-new-free-at-limit--light:- hash: v1.k794b7964.73777e7f5b880d59e78d99675e3c235da1e5c171e4c732c5b80ce732e23a9505.abF-3QCC4joptEiOpAPa-5Fl5bNmMKygoIExYM169Tk- components-subscriptions--subscriptions-new-free-under-limit--dark:- hash: v1.k794b7964.f311eeee76a344bb3e5d6f821bfc39eaed7084676ed8303b75f72bc7a1b07850.tZL-FFNFMJcqKgxtVQ426AUs7kPn-eIBWFBFmU6eA9M- components-subscriptions--subscriptions-new-free-under-limit--light:- hash: v1.k794b7964.5811e86e8e76821927d62745628b48be1c326808cdcb74a9df4391cbbd699267.O-3UjKNxThBJf5B1xg7HxN4_1E3Sb-rQ5vI6ko0BO_E- components-subscriptions--subscriptions-tabbed--dark:- hash: v1.k794b7964.5ab4848e98d0e3782b8e08d03e947319bf3e0d733056a29ef9179c3e37e6facd.jg95MiA7A-g8IH1--HCt1ABLUFBbnODt_bGiy0Hbj58- components-subscriptions--subscriptions-tabbed--light:- hash: v1.k794b7964.151d3a1c18a9631558afc699790debe6d5c39401edff2d3170bf91169a2c2adb.7jhan5AEplszZtWpR4LyHLMNyFMD5Bpow9VKGY2cj1Icomponents-table-preview--default--dark:hash: v1.k794b7964.874fae2dfa767a71abbd43aff3ee6197c9ae1934601bfbe911d564c2ad6f8ac2.hsTFVeAPvG-h0bVqGrZ15OciFEfhyHIahDYpyxyxyWwcomponents-table-preview--default--light:@@ -4850,6 +4814,46 @@ snapshots:hash: v1.k794b7964.ab407d100e82b2804ac63958c38fc48af75120b67e9158c9b280487b2245687e.kZn1-gur30DNFrP7TDua5UGXGu6HziGnAVPc9Zz3wMUproducts-posthog-ai-virtualizedthread--long-thread--light:hash: v1.k794b7964.ea4454f7d7d4dc076ff61362f178cfa010fda1c721696790f03057e864699826.drgUhmxnD0Dt_wm7kKiSeLzeU3WrrNcDJPwFY_rxnec+ products-subscriptions-subscription-delivery-history--empty--dark:+ hash: v1.k794b7964.267363ce3a0453be58b96ef2c00446ae4aaf5ed42b02472c495b3c468f25e18f.PjabhWWV-dc6vzuSl_wdoaQ2VAB35IG84kOVKe5eaA4+ products-subscriptions-subscription-delivery-history--empty--light:+ hash: v1.k794b7964.3c29a7e8a6ea51f198398ecf0dbede063bcc76ebe7ffe9cb845a10e29a546b42.rcDQZJOLa6VvsGSQ7dli7bQKfMcP37D62bGHRC1RxB4+ products-subscriptions-subscription-delivery-history--with-deliveries--dark:+ hash: v1.k794b7964.a4eec8ebddff1a14ea03a8eebfcc37e9c72c79813c42a30f1820f081b0e8c865.k45rW1Y29l_7mgeerTRAU15UEZG0sPxPSWcCeLvkQqA+ products-subscriptions-subscription-delivery-history--with-deliveries--light:+ hash: v1.k794b7964.ba95c5a833ef7dae5b452bfa017e4137569815aa6ed992a446573ce6ab750a56.kOt7J7rBOwnM2w1SrZlUwZql3Lrf_-B8SBpOzVDrD3s+ products-subscriptions-subscription-delivery-history--with-expanded-ai-report--dark:+ hash: v1.k794b7964.97fcc8d80e221fe797031b6305839d6eab0a541ecd0b25c44f4cdc5cc87ebf24.bwex_AJU92hp189meQnsGtKMxG_bE6cHz4ttkuRidJI+ products-subscriptions-subscription-delivery-history--with-expanded-ai-report--light:+ hash: v1.k794b7964.abb8a6720e2c7721af4bee507fd0c8541e9ac3fff7f31e5656832b1b15d059a5.qUzovkPIA8XLDBf8m97cGPr7OcISB3fQhlB97WEW8R0+ products-subscriptions-subscription-delivery-history--with-expanded-summary--dark:+ hash: v1.k794b7964.9d825454b80602e3cca17fa872553832e01b929728eb3b554b98a7f0d63b01be.Amp7jiLWQltIcWNKpEimC7DjTEsQ4cc1mtxoGU_hEFs+ products-subscriptions-subscription-delivery-history--with-expanded-summary--light:+ hash: v1.k794b7964.e8ea5acdf82c72e927990f4672e1615f9b8269abc31a3feb639fa9b993babad0.5j1v9u_2-7CyIDaD0INwHMOAarvZot8UsqYDMVc0UAE+ products-subscriptions-subscriptions-modal--dashboard-with-subscriptions--dark:+ hash: v1.k794b7964.1ae6a6c0560d62ca0da0cf9a02def707fb9b3b3bc001939c9620166dc939fbe2.pMjl3SECFIOBsFl3jPWgyXYrkv2K3iZ9bBNQUIY76wo+ products-subscriptions-subscriptions-modal--dashboard-with-subscriptions--light:+ hash: v1.k794b7964.398a5230923a38b8834bb9749e5270b4ab1aa0738125a283ddc8e344685bc1f9.q-X32n0nnoJodi4QZqWKTJPhS5HQXOHinGgM4A8xwag+ products-subscriptions-subscriptions-modal--insight-with-subscriptions--dark:+ hash: v1.k794b7964.ef43b021b9269ec1653be0fc79eab667e180a863c59ecd607179ca9091201727.N95_Ukn3XqWeWdHz1KuT-Dm_NouF9xWLwC5YXCo-D7Q+ products-subscriptions-subscriptions-modal--insight-with-subscriptions--light:+ hash: v1.k794b7964.dbd17c0ed3d7f831b200da0dc5c868b72f23263264fca9b5a7ac45a58427896e.gvc4udyAOG_t9HTleL9upzG9L3Uj45wZNcYRiDLvsT8+ products-subscriptions-subscriptions-modal--subscriptions-new--dark:+ hash: v1.k794b7964.f311eeee76a344bb3e5d6f821bfc39eaed7084676ed8303b75f72bc7a1b07850.kivXKHF2HMr1zM8HTo7oNgN81xKNFTmqPgYVxW1za90+ products-subscriptions-subscriptions-modal--subscriptions-new--light:+ hash: v1.k794b7964.5811e86e8e76821927d62745628b48be1c326808cdcb74a9df4391cbbd699267.JFnGN37k4aWrIGrYAWOlc54BaWHhy0cHDBbEHRxQFqE+ products-subscriptions-subscriptions-modal--subscriptions-tabbed--dark:+ hash: v1.k794b7964.1f9aa8adee753b12e1b50c143ed4e2eed36a5ceaea7f934a43cb16b16ff9974a.KtXqx6ZGFgLFGRPjRxGd10KmRLwCgZPyMSowVK2PPKg+ products-subscriptions-subscriptions-modal--subscriptions-tabbed--light:+ hash: v1.k794b7964.91be617dbb895598296bf9370e60fb6406ea394392bb5d8a0a85a1991c91962c.2EVEcja1V1g6msLBVlGDWjDKr5VTuFGqt5byG97YtTA+ products-subscriptions-subscriptions-table--default--dark:+ hash: v1.k794b7964.53cf84a8e66f2c6598a8b17644138403b0b118cd36d2c87e070516f235f0998c.OIIaEVja8iIKsAUIxOpPy6o-5Ior7lV4Fb7nbcPIkzs+ products-subscriptions-subscriptions-table--default--light:+ hash: v1.k794b7964.2ccaa6eccf2aed09baf7ef5a95bffe65defd3e0a4206a6d29be49b64be709d96.aTkvzMdEsn_fzv-XuKfo8fcA1hoIQz7wzLfXPGepmrk+ products-subscriptions-subscriptions-table--with-pagination--dark:+ hash: v1.k794b7964.79b55888f68b8fdecde60eb59f9941838eed95754b51bd361ab65be360277270.lJwqiaG6UTf6bczX7v1jw_bImsnq7LK-tuxsBFZt2F4+ products-subscriptions-subscriptions-table--with-pagination--light:+ hash: v1.k794b7964.c54c1003b71f29a08808fa1e4e7413ee7c61f514eb1198c924d936cc95c834e5.1PL1n6t2LsJ6X33Z6txXpmifcmqNP6HrVtrLhnMrWMAproducts-workflows-customerioimportmodal--all-steps-completed--dark:hash: v1.k794b7964.da9d1ebf1836700267307224631511bd8fe3b9fb0906654a383e545e1c6f98f1.lPijIVizKAMxsGEVt28x0Y5izfhcfnbjbPhoHzriWFgproducts-workflows-customerioimportmodal--all-steps-completed--light:@@ -7122,38 +7126,6 @@ snapshots:hash: v1.k794b7964.28a02f4270bc87964944d614522f6512c530906de7c72ac635f8154e802943d0.GQNNBUsCcwGYXzNSgZXeGTXZ2RZLL_Q4y2VUodztSfIscenes-app-sidepanels--side-panel-support--light:hash: v1.k794b7964.6f4d33da3ded2438fd7c5bd5b618cc1caf2e355b004b421e78120d33d2c15f8b.6tfLPSZ6q3T8jCH-J6mWbTwIolu2uJ3zyRDL7A3Lpto- scenes-app-subscriptions-subscription-delivery-history--empty--dark:- hash: v1.k794b7964.267363ce3a0453be58b96ef2c00446ae4aaf5ed42b02472c495b3c468f25e18f.PmJd-8ou979ieSrNpJQ2DxtM8Tnqs7jtvU6k-2rpr2w- scenes-app-subscriptions-subscription-delivery-history--empty--light:- hash: v1.k794b7964.3c29a7e8a6ea51f198398ecf0dbede063bcc76ebe7ffe9cb845a10e29a546b42.CR678XpTQlJgVQS_shJF51dcPQhOg_lZKNuDzEstzbU- scenes-app-subscriptions-subscription-delivery-history--with-deliveries--dark:- hash: v1.k794b7964.a4eec8ebddff1a14ea03a8eebfcc37e9c72c79813c42a30f1820f081b0e8c865.6e0q6GiTDR-BGZhMt9cf0loRZddPkr2ierQk8s1DXeE- scenes-app-subscriptions-subscription-delivery-history--with-deliveries--light:- hash: v1.k794b7964.ba95c5a833ef7dae5b452bfa017e4137569815aa6ed992a446573ce6ab750a56.5adBLBJYoAidGzoM0E5NP2ON7563AEDCoAFlBhFNias- scenes-app-subscriptions-subscription-delivery-history--with-expanded-ai-report--dark:- hash: v1.k794b7964.97fcc8d80e221fe797031b6305839d6eab0a541ecd0b25c44f4cdc5cc87ebf24.uUrtZ2bLDU7BxMLUWBa7q5sqig9oh_Gorhfn94F4RTY- scenes-app-subscriptions-subscription-delivery-history--with-expanded-ai-report--light:- hash: v1.k794b7964.abb8a6720e2c7721af4bee507fd0c8541e9ac3fff7f31e5656832b1b15d059a5.dWFBMlLGfxqAiPKo5oz1OAa5-jonJCyE-Rr_mNCW8e0- scenes-app-subscriptions-subscription-delivery-history--with-expanded-summary--dark:- hash: v1.k794b7964.9d825454b80602e3cca17fa872553832e01b929728eb3b554b98a7f0d63b01be.0yatf93qe--xfQgkYLmnt1cT1GfWryPJQWCRNHvTESQ- scenes-app-subscriptions-subscription-delivery-history--with-expanded-summary--light:- hash: v1.k794b7964.e8ea5acdf82c72e927990f4672e1615f9b8269abc31a3feb639fa9b993babad0.IRJkilIOj_v_8XjyFVxmWECDo8vBzlepnIV0yABpTt0- scenes-app-subscriptions-subscription-summary--dashboard-many-destinations--dark:- hash: v1.k794b7964.d8cc3d07d97916c815948be5aec81b895def2c9b5e34eece4fb05bfcbb4fe751.vj4u5-fIXtMDGIsQvXpW_WCCN_7gGt_7R9k5RlXS7fg- scenes-app-subscriptions-subscription-summary--dashboard-many-destinations--light:- hash: v1.k794b7964.a5f401ee1a2cafa618fa8ab88ddf614ef010a05260a8425c74cca13e55be0fce.Wu0EGA6-UBwZlTitCnNT1TCxhuMNI6gh3bUWwXwA2EQ- scenes-app-subscriptions-subscription-summary--insight-many-destinations--dark:- hash: v1.k794b7964.6913114ffa5afff5567cb4e45433868d5d73e8d5f959cac65cef93ab2733faa0.AY_9EQ3GbZANGDUzG4bwKAADYtotr_P2nahsRkeCQ3M- scenes-app-subscriptions-subscription-summary--insight-many-destinations--light:- hash: v1.k794b7964.eb34475293fb102b84cfc962b490871057e55fbe39f9da3cafb7a4fbe18318c6.kcxovkcf_MlaHeVv6-LR3THc0KAQSyHJAXkXhPDLOXw- scenes-app-subscriptions-subscriptionstable--default--dark:- hash: v1.k794b7964.53cf84a8e66f2c6598a8b17644138403b0b118cd36d2c87e070516f235f0998c.gSjp-3f_RU5aHPTbMQLiJCr_8fzJ-CSnf0wxzi52UHs- scenes-app-subscriptions-subscriptionstable--default--light:- hash: v1.k794b7964.2ccaa6eccf2aed09baf7ef5a95bffe65defd3e0a4206a6d29be49b64be709d96.F3KG-dI8iIsMC9PM0C5ITqtwIRJdQBowsu2AM9mbS3Q- scenes-app-subscriptions-subscriptionstable--with-pagination--dark:- hash: v1.k794b7964.79b55888f68b8fdecde60eb59f9941838eed95754b51bd361ab65be360277270.gdJDRFEsPrun3XyeVxwqqkDNnbpgQfGeDSVCUoYx_qE- scenes-app-subscriptions-subscriptionstable--with-pagination--light:- hash: v1.k794b7964.c54c1003b71f29a08808fa1e4e7413ee7c61f514eb1198c924d936cc95c834e5.e_wdbXm_cupH2fKZTdBeX-vKr22qNdG2Yw7VKDTQ4aIscenes-app-surveys--new-multi-question-survey-section--dark:hash: v1.k794b7964.e4c838e9c192c01eab518de2435a2fef6d3ed65b727fe4c05af61eee010bf03d.yIm_bRCN_65TxDwWd9qVeapTEfZ5QAYSmpJbKKle8Hwscenes-app-surveys--new-multi-question-survey-section--light:diff --git a/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.stories.tsx b/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.stories.tsxindex 7e06e7c66db9..fa592f78f7af 100644--- a/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.stories.tsx+++ b/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.stories.tsx@@ -9,72 +9,218 @@ import { uuid } from 'lib/utils/dom'import { useStorybookMocks } from '~/mocks/browser'import preflightJson from '~/mocks/fixtures/_preflight.json'-import { createMockSubscription, mockIntegration, mockSlackChannels } from '~/test/mocks'-import { DashboardType, InsightShortId, Realm } from '~/types'+import { createMockSubscription, mockBasicUser, mockIntegration, mockSlackChannels } from '~/test/mocks'+import { DashboardType, InsightShortId, Realm, SubscriptionType } from '~/types'import { SubscriptionsModal, SubscriptionsModalProps } from './SubscriptionsModal'type StoryArgs = SubscriptionsModalProps & {- noIntegrations?: boolean- aiSummaryAtLimit?: boolean- // Team-wide subscription count for the free-tier create gate (under the limit → form, at/over → upsell).- freeTierSubscriptionCount?: number+ formScenario?: 'default' | 'ai-summary-limit' | 'free-tier-limit'+}++const DASHBOARD = {+ id: 1,+ name: 'Weekly metrics',+ tiles: [+ { id: 1, insight: { id: 11, short_id: 'ins11' as InsightShortId } },+ { id: 2, insight: { id: 12, short_id: 'ins12' as InsightShortId } },+ ],+} as unknown as DashboardType++const DASHBOARD_SUBSCRIPTIONS = [+ createMockSubscription({+ id: 11,+ resource_type: 'dashboard',+ dashboard: 1,+ title: 'Weekly dashboard snapshot',+ target_type: 'slack',+ target_value: 'C123|#product-updates',+ summary: 'sent every week on monday',+ created_by: mockBasicUser,+ }),+ createMockSubscription({+ id: 12,+ resource_type: 'dashboard',+ dashboard: 1,+ title: 'Daily metrics email',+ target_type: 'email',+ target_value: '[email protected]',+ summary: 'sent every day',+ created_by: mockBasicUser,+ }),+ createMockSubscription({+ id: 13,+ resource_type: 'dashboard',+ dashboard: 1,+ title: 'Monthly leadership report',+ summary: 'sent every month on the first day',+ target_type: 'email',+ created_by: mockBasicUser,+ }),+ createMockSubscription({+ id: 14,+ resource_type: 'dashboard',+ dashboard: 1,+ title: 'Friday product review',+ target_type: 'slack',+ target_value: 'C456|#product-review',+ summary: 'sent every week on friday',+ created_by: mockBasicUser,+ }),+ createMockSubscription({+ id: 15,+ resource_type: 'dashboard',+ dashboard: 1,+ title: 'Paused dashboard digest',+ summary: 'sent every week on monday',+ target_type: 'email',+ target_value: '[email protected]',+ enabled: false,+ created_by: mockBasicUser,+ }),+]++const INSIGHT_SUBSCRIPTIONS = [+ createMockSubscription({+ id: 21,+ resource_type: 'insight',+ insight: 11,+ insight_short_id: 'ins11',+ resource_name: 'Weekly active users',+ title: 'Weekly active users snapshot',+ target_type: 'slack',+ target_value: 'C111|#growth-metrics',+ created_by: mockBasicUser,+ }),+ createMockSubscription({+ id: 22,+ resource_type: 'insight',+ insight: 12,+ insight_short_id: 'ins12',+ resource_name: 'Activation rate',+ title: 'Daily activation update',+ target_type: 'email',+ target_value: '[email protected]',+ summary: 'sent every day',+ created_by: mockBasicUser,+ }),+ createMockSubscription({+ id: 23,+ resource_type: 'insight',+ insight: 13,+ insight_short_id: 'ins13',+ resource_name: 'Customer retention',+ title: 'Monthly retention review',+ target_type: 'email',+ target_value: '[email protected],[email protected]',+ summary: 'sent every month on the first day',+ created_by: mockBasicUser,+ }),+ createMockSubscription({+ id: 24,+ resource_type: 'insight',+ insight: 14,+ insight_short_id: 'ins14',+ resource_name: 'Revenue growth',+ title: 'Friday revenue snapshot',+ target_type: 'slack',+ target_value: 'C789|#revenue',+ summary: 'sent every week on friday',+ created_by: mockBasicUser,+ }),+ createMockSubscription({+ id: 25,+ resource_type: 'insight',+ insight: 15,+ insight_short_id: 'ins15',+ resource_name: 'Trial conversion',+ title: 'Paused conversion report',+ target_type: 'slack',+ target_value: 'C222|#conversion-alerts,C333|#growth-review',+ enabled: false,+ created_by: mockBasicUser,+ }),+]++const AI_PROMPT_SUBSCRIPTIONS = [+ createMockSubscription({+ id: 21,+ resource_type: 'ai_prompt',+ title: 'Weekly product health report',+ prompt: 'Summarize activation, retention, and revenue changes from the last week.',+ target_type: 'slack',+ target_value: 'C123|#product-updates',+ summary: 'sent every week on monday',+ created_by: mockBasicUser,+ }),+ createMockSubscription({+ id: 22,+ resource_type: 'ai_prompt',+ title: 'Daily anomaly check',+ prompt: 'Find unusual changes in our key product metrics and explain likely causes.',+ summary: 'sent every day',+ created_by: { ...mockBasicUser, first_name: 'Ada', email: '[email protected]' },+ }),+]++const AI_PROMPT_PARAMETERS = {+ featureFlags: {+ [FEATURE_FLAGS.SUBSCRIPTION_AI_PROMPT]: true,+ },}const meta: Meta<StoryArgs> = {- title: 'Components/Subscriptions',+ title: 'Products/Subscriptions/Subscriptions modal',component: SubscriptionsModal,parameters: {layout: 'fullscreen',viewMode: 'story',mockDate: '2023-01-31 12:00:00',},+ argTypes: {+ formScenario: {+ control: 'select',+ options: ['default', 'ai-summary-limit', 'free-tier-limit'],+ },+ },render: (args) => {- const { noIntegrations = false, aiSummaryAtLimit = false, freeTierSubscriptionCount, ...props } = args+ const { formScenario = 'default', ...props } = args+ const aiSummaryAtLimit = formScenario === 'ai-summary-limit'+ const freeTierSubscriptionCount = formScenario === 'free-tier-limit' ? 5 : undefinedconst insightShortIdRef = useRef(props.insightShortId || (uuid() as InsightShortId))// Dashboard-context stories must not also pass an insight, or the modal renders the insight flow.const insightShortId = props.dashboard ? undefined : insightShortIdRef.currentconst [modalOpen, setModalOpen] = useState(false)+ const contextualSubscriptions: SubscriptionType[] = props.dashboard+ ? DASHBOARD_SUBSCRIPTIONS+ : INSIGHT_SUBSCRIPTIONS+ const dashboardInsightSubscriptions: SubscriptionType[] = INSIGHT_SUBSCRIPTIONSuseStorybookMocks({get: {'/_preflight': {...preflightJson,realm: Realm.Cloud,- email_service_available: noIntegrations ? false : true,- slack_service: noIntegrations- ? { available: false }- : { available: true, client_id: 'test-client-id' },- site_url: noIntegrations ? 'bad-value' : window.location.origin,+ email_service_available: true,+ slack_service: { available: true, client_id: 'test-client-id' },+ site_url: window.location.origin,},- ...(aiSummaryAtLimit- ? {- '/api/organizations/@current/': {- ...MOCK_DEFAULT_ORGANIZATION,- is_ai_data_processing_approved: true,- },- }- : {}),- '/api/environments/:id/subscriptions': {- results:- insightShortIdRef.current === 'empty'- ? []- : [- createMockSubscription(),- createMockSubscription({- title: 'Weekly C-level report',- target_value: '[email protected]',- frequency: 'weekly',- interval: 1,- }),- createMockSubscription({- title: 'Daily Slack report',- target_type: 'slack',- target_value: 'C123|#general',- frequency: 'weekly',- interval: 1,- }),- ],+ '/api/organizations/@current/': {+ ...MOCK_DEFAULT_ORGANIZATION,+ is_ai_data_processing_approved: true,+ },+ '/api/environments/:id/subscriptions': ({ request }) => {+ const searchParams = new URL(request.url).searchParams+ let results = contextualSubscriptions++ if (searchParams.get('resource_type') === 'ai_prompt') {+ results = AI_PROMPT_SUBSCRIPTIONS+ } else if (searchParams.has('dashboard_tiles')) {+ results = dashboardInsightSubscriptions+ }++ return { count: results.length, results }},'/api/environments/:id/subscriptions/:subId': createMockSubscription(),...(freeTierSubscriptionCount !== undefined@@ -83,7 +229,7 @@ const meta: Meta<StoryArgs> = {'/api/projects/:id/subscriptions/summary_quota': aiSummaryAtLimit? { active_count: 10, limit: 10, at_limit: true }: { active_count: 0, limit: 10, at_limit: false },- '/api/projects/:id/integrations': { results: !noIntegrations ? [mockIntegration] : [] },+ '/api/projects/:id/integrations': { results: [mockIntegration] },'/api/projects/:id/integrations/:intId/channels': { channels: mockSlackChannels },},})@@ -123,36 +269,8 @@ export default metatype Story = StoryObj<StoryArgs>-export const Subscriptions_: Story = {}--export const SubscriptionsEmpty: Story = {- args: { insightShortId: 'empty' as InsightShortId },-}-export const SubscriptionsNew: Story = {- args: { subscriptionId: 'new' },-}--export const SubscriptionNoIntegrations: Story = {- args: { subscriptionId: 'new', noIntegrations: true },-}--export const SubscriptionsEdit: Story = {- args: { subscriptionId: 1 },-}--export const SubscriptionAtAISummaryLimit: Story = {- args: { subscriptionId: 'new', aiSummaryAtLimit: true },-}--// Freemium gate: a free org under the 5-subscription limit sees the normal create form.-export const SubscriptionsNewFreeUnderLimit: Story = {- args: { subscriptionId: 'new', freeTierSubscriptionCount: 2 },-}--// Freemium gate: a free org at the limit sees the upgrade paywall instead of the create form.-export const SubscriptionsNewFreeAtLimit: Story = {- args: { subscriptionId: 'new', freeTierSubscriptionCount: 5 },+ args: { subscriptionId: 'new', formScenario: 'default' },}// Tabbed overview (feature flag on), dashboard context: This dashboard / Insights / AI prompt reports tabs.@@ -164,13 +282,16 @@ export const SubscriptionsTabbed: Story = {},},args: {- dashboard: {- id: 1,- name: 'Weekly metrics',- tiles: [- { id: 1, insight: { id: 11, short_id: 'ins11' as InsightShortId } },- { id: 2, insight: { id: 12, short_id: 'ins12' as InsightShortId } },- ],- } as unknown as DashboardType,+ dashboard: DASHBOARD,},}++export const DashboardWithSubscriptions: Story = {+ parameters: AI_PROMPT_PARAMETERS,+ args: { dashboard: DASHBOARD },+}++export const InsightWithSubscriptions: Story = {+ parameters: AI_PROMPT_PARAMETERS,+ args: { insightShortId: 'ins11' as InsightShortId },+}diff --git a/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.tsx b/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.tsxindex ab7a2034b4b5..401ed4e1d8ea 100644--- a/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.tsx+++ b/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.tsx@@ -68,13 +68,23 @@ export function SubscriptionsModal(props: SubscriptionsModalProps): JSX.ElementactiveTab={activeTab}onChangeTab={setActiveTab}onCancel={closeModal}- onSelect={(id) => push(urlForSubscription(id, baseProps))}+ onSelect={(id, resourceType) =>+ push(+ urlForSubscription(id, baseProps),+ resourceType ? { resource_type: resourceType } : undefined+ )+ }/>) : (<ManageSubscriptions{...baseProps}onCancel={closeModal}- onSelect={(id) => push(urlForSubscription(id, baseProps))}+ onSelect={(id, resourceType) =>+ push(+ urlForSubscription(id, baseProps),+ resourceType ? { resource_type: resourceType } : undefined+ )+ }/>)) : (diff --git a/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.test.ts b/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.test.tsindex 6fd877efd773..4d5d94e6cb7c 100644--- a/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.test.ts+++ b/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.test.ts@@ -131,6 +131,14 @@ describe('subscriptionLogic', () => {})})+ it('preselects an AI prompt report from the new-subscription URL', async () => {+ router.actions.push('/insights/123/subscriptions/new?resource_type=ai_prompt')++ await expectLogic(newLogic).toFinishListeners()++ expect(newLogic.values.subscription.resource_type).toBe('ai_prompt')+ })+it('sets the type from query params', async () => {router.actions.push('/insights/123/subscriptions/new?target_type=slack')await expectLogic(newLogic).toFinishListeners()diff --git a/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.ts b/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.tsindex 961f0977bdf2..e0536568c6af 100644--- a/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.ts+++ b/products/subscriptions/frontend/components/Subscriptions/subscriptionLogic.ts@@ -684,6 +684,9 @@ export const subscriptionLogic = kea<subscriptionLogicType>([urlToAction(({ actions, props, cache, values }) => ({'/*/*/subscriptions/new': (_, searchParams) => {actions.loadSubscriptionSuccess({ ...NEW_SUBSCRIPTION })+ if (searchParams.resource_type === SubscriptionResourceTypes.AiPrompt) {+ actions.setSubscriptionValue('resource_type', SubscriptionResourceTypes.AiPrompt)+ }// ?prefill=nudge is set by the subscribe-nudge notification / toast, possibly opened in a// fresh session days later — the prefill is built here from URL + context, not kea state.if (diff --git a/products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic.test.ts b/products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic.test.tsindex 1e01e34fc415..6efd94892bc4 100644--- a/products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic.test.ts+++ b/products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic.test.ts@@ -1,8 +1,5 @@import { expectLogic } from 'kea-test-utils'-import { FEATURE_FLAGS } from 'lib/constants'-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'-import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'import {@@ -53,11 +50,9 @@ function fixtureInsightResponse(id: number, data?: Partial<InsightModel>): Partidescribe('subscriptionsLogic', () => {let logic: ReturnType<typeof subscriptionsLogic.build>let subscriptions: SubscriptionType[] = []- let aiSubscriptions: SubscriptionType[] = []let tileSubscriptions: SubscriptionType[] = []beforeEach(async () => {subscriptions = [fixtureSubscriptionResponse(1), fixtureSubscriptionResponse(2)]- aiSubscriptions = [fixtureSubscriptionResponse(10, { resource_type: 'ai_prompt', prompt: 'Weekly report' })]tileSubscriptions = [fixtureSubscriptionResponse(20)]useMocks({get: {@@ -73,12 +68,9 @@ describe('subscriptionsLogic', () => {const url = new URL(request.url)const insightIds = url.searchParams.get('insights')?.split(',') ?? []const dashboardTiles = url.searchParams.get('dashboard_tiles')- const resourceType = url.searchParams.get('resource_type')let results: SubscriptionType[] = []- if (resourceType === 'ai_prompt') {- results = aiSubscriptions- } else if (dashboardTiles === '9') {+ if (dashboardTiles === '9') {results = tileSubscriptions} else if (insightIds.includes(Insight2)) {results = subscriptions@@ -134,29 +126,4 @@ describe('subscriptionsLogic', () => {insightSubscriptionsLoading: false,})})-- it('does not load AI subscriptions when the flag is off', async () => {- await expectLogic(logic).toFinishListeners().toMatchValues({- aiSubscriptions: [],- aiSubscriptionsLoading: false,- })- })-- it('loads AI subscriptions separately when the flag is on', async () => {- featureFlagLogic.mount()- featureFlagLogic.actions.setFeatureFlags([], {- [FEATURE_FLAGS.SUBSCRIPTION_AI_PROMPT]: true,- })-- // Distinct key so afterMount fetches fresh with the flag now on.- logic = subscriptionsLogic({- insightShortId: Insight2,- })- logic.mount()-- await expectLogic(logic).toFinishListeners().toMatchValues({- aiSubscriptions: aiSubscriptions,- aiSubscriptionsLoading: false,- })- })})diff --git a/products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic.ts b/products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic.tsindex 690d215ad446..71d9c93d2e62 100644--- a/products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic.ts+++ b/products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic.ts@@ -1,36 +1,18 @@-import {- MakeLogicType,- BreakPointFunction,- actions,- afterMount,- connect,- kea,- key,- listeners,- path,- props,- reducers,-} from 'kea'+import { MakeLogicType, BreakPointFunction, actions, afterMount, kea, key, listeners, path, props, reducers } from 'kea'import { loaders } from 'kea-loaders'import api from 'lib/api'-import { FEATURE_FLAGS } from 'lib/constants'-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { deleteWithUndo } from 'lib/utils/deleteWithUndo'import { getInsightId } from 'scenes/insights/utils'-import { SubscriptionResourceTypes, SubscriptionType } from '~/types'+import { SubscriptionType } from '~/types'-import type { FeatureFlagsSet } from '../../../../../frontend/src/lib/logic/featureFlagLogic'import { runSubscriptionTestDelivery } from './runSubscriptionTestDelivery'import { toggleSubscriptionEnabled } from './toggleSubscriptionEnabled'import { SubscriptionsLogicProps } from './utils'// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface subscriptionsLogicValues {- featureFlags: FeatureFlagsSet // featureFlagLogic- aiSubscriptions: SubscriptionType[]- aiSubscriptionsLoading: booleandeliveringSubscriptionId: number | nullinsightSubscriptions: SubscriptionType[]insightSubscriptionsLoading: boolean@@ -53,21 +35,6 @@ export interface subscriptionsLogicActions {deliverSubscriptionSuccess: () => {value: true}- loadAiSubscriptions: (_?: any) => any- loadAiSubscriptionsFailure: (- error: string,- errorObject?: any- ) => {- error: string- errorObject?: any- }- loadAiSubscriptionsSuccess: (- aiSubscriptions: SubscriptionType[],- payload?: any- ) => {- aiSubscriptions: SubscriptionType[]- payload?: any- }loadAllSubscriptions: () => {value: true}@@ -134,7 +101,6 @@ export const subscriptionsLogic = kea<subscriptionsLogicType>([key(({ insightShortId, dashboardId }) =>insightShortId ? `insight-${insightShortId}` : dashboardId ? `dashboard-${dashboardId}` : 'subscriptions'),- connect({ values: [featureFlagLogic, ['featureFlags']] }),actions({loadAllSubscriptions: true,deleteSubscription: (id: number) => ({ id }),@@ -146,7 +112,7 @@ export const subscriptionsLogic = kea<subscriptionsLogicType>([setSubscriptionEnabledFailure: true,}),- loaders(({ props, values }) => ({+ loaders(({ props }) => ({subscriptions: {__default: [] as SubscriptionType[],loadSubscriptions: async (_?: any, breakpoint?: BreakPointFunction) => {@@ -165,21 +131,6 @@ export const subscriptionsLogic = kea<subscriptionsLogicType>([return response.results},},- // AI subscriptions are project-scoped (not tied to a specific insight/dashboard), so they're- // fetched separately and rendered in their own section. Gated behind the AI prompt flag.- aiSubscriptions: {- __default: [] as SubscriptionType[],- loadAiSubscriptions: async (_?: any, breakpoint?: BreakPointFunction) => {- const inResourceContext = !!props.dashboardId || !!props.insightShortId- if (!inResourceContext || !values.featureFlags[FEATURE_FLAGS.SUBSCRIPTION_AI_PROMPT]) {- return []- }- breakpoint?.()- const response = await api.subscriptions.list({ resourceType: SubscriptionResourceTypes.AiPrompt })- breakpoint?.()- return response.results- },- },// Subscriptions on the dashboard's insight tiles. The backend resolves the tile set from// dashboardId, so the count doesn't depend on the dashboard's tiles being loaded client-side.insightSubscriptions: {@@ -200,9 +151,6 @@ export const subscriptionsLogic = kea<subscriptionsLogicType>([subscriptions: {deleteSubscription: (state, { id }) => state.filter((a) => a.id !== id),},- aiSubscriptions: {- deleteSubscription: (state, { id }) => state.filter((a) => a.id !== id),- },insightSubscriptions: {deleteSubscription: (state, { id }) => state.filter((a) => a.id !== id),},@@ -227,7 +175,6 @@ export const subscriptionsLogic = kea<subscriptionsLogicType>([listeners(({ actions }) => ({loadAllSubscriptions: () => {actions.loadSubscriptions()- actions.loadAiSubscriptions()actions.loadInsightSubscriptions()},deleteSubscription: async ({ id }) => {diff --git a/products/subscriptions/frontend/components/Subscriptions/utils.tsx b/products/subscriptions/frontend/components/Subscriptions/utils.tsxindex d2fd9c14020f..d6b89b7062d9 100644--- a/products/subscriptions/frontend/components/Subscriptions/utils.tsx+++ b/products/subscriptions/frontend/components/Subscriptions/utils.tsx@@ -3,7 +3,6 @@ import { RRule } from 'rrule'import { IconLetter } from '@posthog/icons'import { LemonSelectOption, LemonSelectOptionLeaf, LemonSelectOptions } from '@posthog/lemon-ui'-import { dayjs } from 'lib/dayjs'import { IconSlack } from 'lib/lemon-ui/icons'import { range } from 'lib/utils/arrays'import { urls } from 'scenes/urls'@@ -20,10 +19,6 @@ export interface SubscriptionBaseProps {export type SubscriptionsLogicProps = SubscriptionBaseProps-export function formatNextDeliveryDate(date: string | Date): string {- return dayjs(date).format('ddd, MMM D [at] HH:mm')-}-export const urlForSubscriptions = ({ dashboardId, insightShortId }: SubscriptionBaseProps): string => {if (insightShortId) {return urls.insightSubcriptions(insightShortId)diff --git a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsxindex 37b0c2089791..237f8ba84e4e 100644--- a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx+++ b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx@@ -7,6 +7,7 @@ import { LemonCheckbox, LemonInput, LemonTextArea, Link } from '@posthog/lemon-uimport { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'import { FlaggedFeature } from 'lib/components/FlaggedFeature'import { UsageLimitPaywall } from 'lib/components/PayGateMini/UsageLimitPaywall'+import { TZLabel } from 'lib/components/TZLabel'import { UserActivityIndicator } from 'lib/components/UserActivityIndicator/UserActivityIndicator'import { usersLemonSelectOptions } from 'lib/components/UserSelectItem'import { FEATURE_FLAGS } from 'lib/constants'@@ -46,7 +47,6 @@ import {bysetposOptions,frequencyOptionsPlural,frequencyOptionsSingular,- formatNextDeliveryDate,getAiSubscriptionGate,getNextDeliveryDate,intervalOptions,@@ -738,7 +738,13 @@ function EditSubscriptionForm({</div>{nextDeliveryDate && (<div className="text-xs text-secondary mt-1">- Next delivery: {formatNextDeliveryDate(nextDeliveryDate)}+ Next delivery:{' '}+ <TZLabel+ time={dayjs(nextDeliveryDate)}+ formatDate="ddd, MMM D"+ formatTime="HH:mm"+ timestampStyle="absolute"+ /></div>)}</div>@@ -822,7 +828,19 @@ function EditSubscriptionForm({<p className="text-xs text-secondary mt-1 mb-0">On save we send this report once to the destination above, so you can confirm itlooks right. Turn this off to wait for the next scheduled delivery- {nextDeliveryDate ? ` (${formatNextDeliveryDate(nextDeliveryDate)})` : ''}.+ {nextDeliveryDate && (+ <>+ {' ('}+ <TZLabel+ time={dayjs(nextDeliveryDate)}+ formatDate="ddd, MMM D"+ formatTime="HH:mm"+ timestampStyle="absolute"+ />+ )+ </>+ )}+ .</p></div></div>diff --git a/products/subscriptions/frontend/components/Subscriptions/views/ManageSubscriptions.tsx b/products/subscriptions/frontend/components/Subscriptions/views/ManageSubscriptions.tsxindex 12149a07824e..fd3a7fdefe3f 100644--- a/products/subscriptions/frontend/components/Subscriptions/views/ManageSubscriptions.tsx+++ b/products/subscriptions/frontend/components/Subscriptions/views/ManageSubscriptions.tsx@@ -1,144 +1,23 @@import { useActions, useValues } from 'kea'-import { IconEllipsis } from '@posthog/icons'-import { LemonTag, Link, Tooltip } from '@posthog/lemon-ui'--import { IconSlack } from 'lib/lemon-ui/icons'+import { MailHog } from 'lib/components/hedgehogs'+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { LemonButton } from 'lib/lemon-ui/LemonButton'import { LemonModal } from 'lib/lemon-ui/LemonModal'import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'-import { ProfileBubbles } from 'lib/lemon-ui/ProfilePicture'-import { Spinner } from 'lib/lemon-ui/Spinner'import { capitalizeFirstLetter, pluralize } from 'lib/utils/strings'+import { organizationLogic } from 'scenes/organizationLogic'import { urls } from 'scenes/urls'-import { SubscriptionResourceTypes, SubscriptionType } from '~/types'+import { SubscriptionResourceType, SubscriptionType } from '~/types'-import { isSubscriptionEnabled } from '../../../scenes/components/SubscriptionsTable'import { subscriptionsLogic } from '../subscriptionsLogic'-import { SubscriptionBaseProps, formatNextDeliveryDate } from '../utils'--const PROMPT_PREVIEW_MAX_CHARS = 80-// AI subscriptions are supplementary context in this modal, so only a few are shown inline —-// the rest are reachable via the full subscriptions list.-const AI_PREVIEW_LIMIT = 3--interface SubscriptionListItemProps {- subscription: SubscriptionType- onClick: () => void- onDelete?: () => void- onDeliver?: () => void- onToggleEnabled?: (enabled: boolean) => void- isDelivering?: boolean- isToggling?: boolean-}--export function SubscriptionListItem({- subscription,- onClick,- onDelete,- onDeliver,- onToggleEnabled,- isDelivering,- isToggling,-}: SubscriptionListItemProps): JSX.Element {- const selectedInsightsCount = subscription.dashboard_export_insights?.length- const enabled = isSubscriptionEnabled(subscription)- const sideActionBusy = isDelivering || isToggling-- const aiPrompt = subscription.resource_type === SubscriptionResourceTypes.AiPrompt ? subscription.prompt : null- const aiPromptTruncated = aiPrompt && aiPrompt.length > PROMPT_PREVIEW_MAX_CHARS- const aiPromptPreview = aiPromptTruncated ? `${aiPrompt.slice(0, PROMPT_PREVIEW_MAX_CHARS)}…` : aiPrompt-- return (- <LemonButton- type="secondary"- onClick={onClick}- data-attr="subscription-list-item"- fullWidth- sideAction={{- icon: sideActionBusy ? <Spinner /> : <IconEllipsis />,- disabled: sideActionBusy,- dropdown: {- overlay: (- <>- {onToggleEnabled && (- <LemonButton- onClick={() => onToggleEnabled(!enabled)}- data-attr="subscription-list-item-toggle-enabled"- fullWidth- disabled={isToggling}- >- {enabled ? 'Disable subscription' : 'Enable subscription'}- </LemonButton>- )}- {onDeliver && enabled && (- <LemonButton- onClick={onDeliver}- data-attr="subscription-list-item-manual-deliver"- fullWidth- disabled={isDelivering}- >- Test delivery- </LemonButton>- )}- {onDelete && (- <LemonButton- onClick={onDelete}- data-attr="subscription-list-item-delete"- status="danger"- fullWidth- >- Delete subscription- </LemonButton>- )}- </>- ),- },- }}- >- <div className="flex justify-between flex-auto items-center p-2">- <div>- <div className={`font-medium ${enabled ? 'text-link' : 'text-muted'}`}>{subscription.title}</div>- {aiPrompt ? (- <Tooltip title={aiPromptTruncated ? aiPrompt : undefined}>- <div className="text-sm text-muted italic">{`"${aiPromptPreview}"`}</div>- </Tooltip>- ) : null}- {subscription.resource_type === SubscriptionResourceTypes.Insight && subscription.resource_name ? (- <div className="text-sm text-muted">{subscription.resource_name}</div>- ) : null}- <div className="text-sm text-text-3000">- {capitalizeFirstLetter(subscription.summary)}- {selectedInsightsCount- ? ` · ${pluralize(selectedInsightsCount, 'insight', 'insights', true)}`- : null}- </div>- {!enabled ? (- <LemonTag type="danger" size="small" className="mt-1">- Disabled- </LemonTag>- ) : subscription.next_delivery_date ? (- <div className="text-xs text-secondary">- Next delivery: {formatNextDeliveryDate(subscription.next_delivery_date)}- </div>- ) : null}- </div>- {subscription.target_type === 'email' ? (- <ProfileBubbles- limit={4}- people={subscription.target_value.split(',').map((email) => ({ email }))}- />- ) : null}- {subscription.target_type === 'slack' ? <IconSlack /> : null}- </div>- </LemonButton>- )-}+import { SubscriptionBaseProps } from '../utils'+import { AIPromptReportsLink, SubscriptionEmptyState, SubscriptionListItem } from './SubscriptionOverviewComponents'interface ManageSubscriptionsProps extends SubscriptionBaseProps {onCancel: () => void- onSelect: (value: number | 'new') => void+ onSelect: (value: number | 'new', resourceType?: SubscriptionResourceType) => void}export function ManageSubscriptions({@@ -152,20 +31,18 @@ export function ManageSubscriptions({dashboardId,})- const {- subscriptions,- subscriptionsLoading,- aiSubscriptions,- aiSubscriptionsLoading,- deliveringSubscriptionId,- togglingEnabledId,- } = useValues(logic)+ const { subscriptions, subscriptionsLoading, deliveringSubscriptionId, togglingEnabledId } = useValues(logic)const { deleteSubscription, deliverSubscription, setSubscriptionEnabled } = useActions(logic)const subscriptionResourceNoun = !insightShortId && dashboardId ? 'dashboard' : 'insight'const hasResourceSubs = subscriptions.length > 0- const hasAiSubs = aiSubscriptions.length > 0- const loading = (subscriptionsLoading || aiSubscriptionsLoading) && !hasResourceSubs && !hasAiSubs+ const aiPromptReportsEnabled = useFeatureFlag('SUBSCRIPTION_AI_PROMPT')+ const { currentOrganization } = useValues(organizationLogic)+ const showAiPromptReportsLink =+ aiPromptReportsEnabled &&+ !!currentOrganization?.is_ai_data_processing_approved &&+ (!!insightShortId || !!dashboardId)+ const loading = subscriptionsLoading && !hasResourceSubsconst renderItem = (sub: SubscriptionType): JSX.Element => (<SubscriptionListItem@@ -183,7 +60,12 @@ export function ManageSubscriptions({return (<><LemonModal.Header>- <h3> Manage Subscriptions</h3>+ <div>+ <h3>Manage subscriptions</h3>+ <p className="text-sm text-secondary mb-0">+ Subscriptions automatically send snapshots and reports to Slack or email on a schedule.+ </p>+ </div></LemonModal.Header><LemonModal.Content>{loading ? (@@ -191,16 +73,6 @@ export function ManageSubscriptions({<LemonSkeleton className="w-1/2 h-4" /><LemonSkeleton.Row repeat={2} /></div>- ) : !hasResourceSubs && !hasAiSubs ? (- <div className="flex flex-col p-4 items-center text-center">- <h3>There are no subscriptions for this {subscriptionResourceNoun}</h3>-- <p>Once subscriptions are created they will display here. </p>-- <LemonButton type="primary" onClick={() => onSelect('new')}>- Add subscription- </LemonButton>- </div>) : (<div className="deprecated-space-y-4"><div className="deprecated-space-y-2">@@ -210,48 +82,35 @@ export function ManageSubscriptions({<strong>{subscriptions.length}</strong>{' '}{pluralize(subscriptions.length, 'subscription', 'subscriptions', false)}</div>- <div className="max-h-[50vh] overflow-y-auto flex flex-col gap-2">+ <div className="max-h-[60vh] overflow-y-auto flex flex-col gap-2">{subscriptions.map(renderItem)}</div></>) : (- <div className="text-muted">- No subscriptions for this {subscriptionResourceNoun} yet.- </div>+ <SubscriptionEmptyState+ illustration={<MailHog className="object-contain shrink-0 w-24 h-20" />}+ title={`${capitalizeFirstLetter(subscriptionResourceNoun)} subscriptions`}+ description={`Send an up-to-date snapshot of this ${subscriptionResourceNoun} to Slack or email on a schedule.`}+ actionLabel="Create subscription"+ actionType="primary"+ prominence="featured"+ onAction={() => onSelect('new')}+ />)}</div>- {hasAiSubs ? (- <div className="deprecated-space-y-2">- <div>- <strong>{aiSubscriptions.length}</strong>{' '}- {pluralize(- aiSubscriptions.length,- 'prompt subscription',- 'prompt subscriptions',- false- )}- <div className="text-xs text-muted">- Not tied to this {subscriptionResourceNoun}, shared across your project.- </div>- </div>- <div className="flex flex-col gap-2">- {aiSubscriptions.slice(0, AI_PREVIEW_LIMIT).map(renderItem)}- </div>- {aiSubscriptions.length > AI_PREVIEW_LIMIT ? (- <Link to={urls.subscriptions()} className="text-xs">- View all {aiSubscriptions.length} prompt subscriptions- </Link>- ) : null}+ {showAiPromptReportsLink && (+ <div className="border-t pt-3">+ <AIPromptReportsLink /></div>- ) : null}+ )}</div>)}</LemonModal.Content><LemonModal.Footer><div className="flex-1 flex gap-2">- {hasResourceSubs || hasAiSubs ? (+ {hasResourceSubs ? (<LemonButton type="secondary" onClick={() => onSelect('new')}>Add subscription</LemonButton>diff --git a/products/subscriptions/frontend/components/Subscriptions/views/SubscriptionOverviewComponents.tsx b/products/subscriptions/frontend/components/Subscriptions/views/SubscriptionOverviewComponents.tsxnew file mode 100644index 000000000000..091d46afea4b--- /dev/null+++ b/products/subscriptions/frontend/components/Subscriptions/views/SubscriptionOverviewComponents.tsx@@ -0,0 +1,273 @@+import type { ReactNode } from 'react'++import { IconAI, IconEllipsis, IconGraph, IconLetter, IconPause, IconPlay, IconTrash } from '@posthog/icons'+import { LemonTag, Tooltip } from '@posthog/lemon-ui'++import { TZLabel } from 'lib/components/TZLabel'+import { IconSlack } from 'lib/lemon-ui/icons'+import { LemonButton } from 'lib/lemon-ui/LemonButton'+import { LemonCard } from 'lib/lemon-ui/LemonCard'+import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'+import { Spinner } from 'lib/lemon-ui/Spinner'+import { capitalizeFirstLetter, pluralize } from 'lib/utils/strings'+import { urls } from 'scenes/urls'++import { SubscriptionResourceTypes, SubscriptionType } from '~/types'++import { isSubscriptionEnabled } from '../../../scenes/components/SubscriptionsTable'++const PROMPT_PREVIEW_MAX_CHARS = 80++interface SubscriptionListItemProps {+ subscription: SubscriptionType+ onClick: () => void+ onDelete?: () => void+ onDeliver?: () => void+ onToggleEnabled?: (enabled: boolean) => void+ isDelivering?: boolean+ isToggling?: boolean+}++function subscriptionDestination(subscription: SubscriptionType): { label: string; title: string } {+ const destinations = subscription.target_value+ .split(',')+ .map((destination) => destination.trim())+ .filter(Boolean)++ if (subscription.target_type === 'email') {+ return {+ label: destinations.length === 1 ? destinations[0] : `${destinations.length} recipients`,+ title: destinations.join(', '),+ }+ }++ const channels = destinations.map((destination) => destination.split('|')[1] || destination)+ return {+ label: channels.length === 1 ? channels[0] : `${channels.length} channels`,+ title: channels.join(', '),+ }+}++export function SubscriptionEmptyState({+ icon,+ illustration,+ title,+ description,+ actionLabel,+ actionType = 'secondary',+ prominence = 'compact',+ onAction,+}: {+ icon?: ReactNode+ illustration?: ReactNode+ title: string+ description: string+ actionLabel: string+ actionType?: 'primary' | 'secondary'+ prominence?: 'featured' | 'compact'+ onAction: () => void+}): JSX.Element {+ const isFeatured = prominence === 'featured'++ if (!isFeatured) {+ return (+ <LemonCard hoverEffect={false} className="p-2 bg-fill-secondary border-transparent">+ <div className="flex gap-2 items-center">+ <div className="flex items-center justify-center rounded bg-surface-primary size-8 text-base shrink-0">+ {icon}+ </div>+ <div className="min-w-0 flex-1">+ <div className="text-sm font-medium">{title}</div>+ <div className="text-xs text-secondary">{description}</div>+ </div>+ <LemonButton type="tertiary" size="xsmall" onClick={onAction} className="shrink-0">+ {actionLabel}+ </LemonButton>+ </div>+ </LemonCard>+ )+ }++ return (+ <LemonCard hoverEffect={false} className="p-6">+ <div className="flex gap-3 items-start">+ {illustration ? (+ illustration+ ) : (+ <div className="flex items-center justify-center rounded bg-surface-primary shrink-0 size-12 text-2xl">+ {icon}+ </div>+ )}+ <div className="flex flex-col gap-2 min-w-0">+ <div>+ <div className="font-semibold text-lg">{title}</div>+ <div className="text-sm text-secondary">{description}</div>+ </div>+ <LemonButton type={actionType} size="small" onClick={onAction} className="self-start">+ {actionLabel}+ </LemonButton>+ </div>+ </div>+ </LemonCard>+ )+}++export function AIPromptReportsLink(): JSX.Element {+ return (+ <LemonCard hoverEffect={false} className="p-3 bg-fill-secondary border-transparent">+ <div className="flex gap-3 items-center">+ <div className="flex items-center justify-center rounded bg-surface-primary size-9 text-lg shrink-0">+ <IconAI />+ </div>+ <div className="min-w-0 flex-1">+ <div className="text-sm font-medium">Automate recurring analysis</div>+ <div className="text-xs text-secondary">+ Write a prompt once and get scheduled answers about your project in Slack or email.+ </div>+ </div>+ <LemonButton+ type="tertiary"+ size="xsmall"+ to={`${urls.subscriptions()}?tab=ai_prompt`}+ className="shrink-0"+ >+ Explore AI prompt reports+ </LemonButton>+ </div>+ </LemonCard>+ )+}++export function SubscriptionListItem({+ subscription,+ onClick,+ onDelete,+ onDeliver,+ onToggleEnabled,+ isDelivering,+ isToggling,+}: SubscriptionListItemProps): JSX.Element {+ const selectedInsightsCount = subscription.dashboard_export_insights?.length+ const enabled = isSubscriptionEnabled(subscription)+ const sideActionBusy = isDelivering || isToggling++ const aiPrompt = subscription.resource_type === SubscriptionResourceTypes.AiPrompt ? subscription.prompt : null+ const aiPromptTruncated = aiPrompt && aiPrompt.length > PROMPT_PREVIEW_MAX_CHARS+ const aiPromptPreview = aiPromptTruncated ? `${aiPrompt.slice(0, PROMPT_PREVIEW_MAX_CHARS)}…` : aiPrompt+ const destination = subscriptionDestination(subscription)++ return (+ <LemonButton+ type="secondary"+ onClick={onClick}+ data-attr="subscription-list-item"+ fullWidth+ sideAction={{+ icon: sideActionBusy ? <Spinner /> : <IconEllipsis />,+ disabled: sideActionBusy,+ dropdown: {+ overlay: (+ <>+ {onToggleEnabled && (+ <LemonButton+ icon={enabled ? <IconPause /> : <IconPlay />}+ onClick={() => onToggleEnabled(!enabled)}+ data-attr="subscription-list-item-toggle-enabled"+ fullWidth+ disabled={isToggling}+ >+ {enabled ? 'Disable subscription' : 'Enable subscription'}+ </LemonButton>+ )}+ {onDeliver && enabled && (+ <LemonButton+ icon={<IconPlay />}+ onClick={onDeliver}+ data-attr="subscription-list-item-manual-deliver"+ fullWidth+ disabled={isDelivering}+ >+ Test delivery+ </LemonButton>+ )}+ {onDelete && (+ <LemonButton+ icon={<IconTrash />}+ onClick={onDelete}+ data-attr="subscription-list-item-delete"+ status="danger"+ fullWidth+ >+ Delete subscription+ </LemonButton>+ )}+ </>+ ),+ },+ }}+ >+ <div className="flex-auto p-2 min-w-0">+ <div className="flex flex-col gap-1 min-w-0">+ <div className="flex items-center justify-between gap-4">+ <div className="flex items-center gap-2 min-w-0">+ <div className={`font-medium truncate ${enabled ? 'text-link' : 'text-muted'}`}>+ {subscription.title}+ </div>+ {!enabled && (+ <LemonTag type="danger" size="small">+ Disabled+ </LemonTag>+ )}+ </div>+ <div+ className="flex items-center gap-1 text-xs text-secondary shrink-0"+ title={destination.title}+ >+ {subscription.target_type === 'email' && <IconLetter />}+ {subscription.target_type === 'slack' && <IconSlack />}+ <span className="max-w-40 truncate">{destination.label}</span>+ </div>+ </div>+ {aiPrompt ? (+ <Tooltip title={aiPromptTruncated ? aiPrompt : undefined}>+ <div className="text-sm text-muted italic">{`"${aiPromptPreview}"`}</div>+ </Tooltip>+ ) : null}+ {subscription.resource_type === SubscriptionResourceTypes.Insight && subscription.resource_name ? (+ <div className="flex items-center gap-1 text-xs text-secondary">+ <IconGraph />+ <span>+ Insight: <span className="font-medium">{subscription.resource_name}</span>+ </span>+ </div>+ ) : null}+ <div className="text-xs text-secondary">+ {capitalizeFirstLetter(subscription.summary)}+ {selectedInsightsCount+ ? ` · ${pluralize(selectedInsightsCount, 'insight', 'insights', true)}`+ : null}+ </div>+ <div className="flex items-center justify-between gap-3 min-h-5 whitespace-nowrap">+ {enabled && subscription.next_delivery_date && (+ <div className="text-xs text-secondary shrink-0">+ Next delivery:{' '}+ <TZLabel+ time={subscription.next_delivery_date}+ formatDate="ddd, MMM D"+ formatTime="HH:mm"+ timestampStyle="absolute"+ />+ </div>+ )}+ {subscription.created_by ? (+ <div className="flex items-center gap-1 text-xs text-tertiary ml-auto opacity-60 min-w-0 overflow-hidden">+ <span>Created by</span>+ <ProfilePicture user={subscription.created_by} size="xs" showName />+ </div>+ ) : null}+ </div>+ </div>+ </div>+ </LemonButton>+ )+}diff --git a/products/subscriptions/frontend/components/Subscriptions/views/TabbedManageSubscriptions.tsx b/products/subscriptions/frontend/components/Subscriptions/views/TabbedManageSubscriptions.tsxindex 5340f8276562..4c95802b30dc 100644--- a/products/subscriptions/frontend/components/Subscriptions/views/TabbedManageSubscriptions.tsx+++ b/products/subscriptions/frontend/components/Subscriptions/views/TabbedManageSubscriptions.tsx@@ -1,23 +1,26 @@import { useActions, useValues } from 'kea'import { useMemo } from 'react'+import type { ReactNode } from 'react'+import { MailHog } from 'lib/components/hedgehogs'+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { LemonButton } from 'lib/lemon-ui/LemonButton'import { LemonModal } from 'lib/lemon-ui/LemonModal'import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'import { LemonTab, LemonTabs } from 'lib/lemon-ui/LemonTabs'import { PaginationControl, usePagination } from 'lib/lemon-ui/PaginationControl'+import { organizationLogic } from 'scenes/organizationLogic'import { urls } from 'scenes/urls'-import { SubscriptionType } from '~/types'+import { SubscriptionResourceType, SubscriptionType } from '~/types'import { isSubscriptionEnabled } from '../../../scenes/components/SubscriptionsTable'import { subscriptionsLogic } from '../subscriptionsLogic'import { SubscriptionsLogicProps } from '../utils'-import { SubscriptionListItem } from './ManageSubscriptions'+import { AIPromptReportsLink, SubscriptionEmptyState, SubscriptionListItem } from './SubscriptionOverviewComponents'const PAGE_SIZE = 10--export type SubscriptionTabKey = 'resource' | 'insights' | 'ai'+export type SubscriptionTabKey = 'resource' | 'insights'interface SubscriptionTabConfig {key: SubscriptionTabKey@@ -25,11 +28,14 @@ interface SubscriptionTabConfig {subscriptions: SubscriptionType[]loading: booleanemptyMessage: string+ description?: string+ footer?: ReactNode+ emptyState?: ReactNode}interface TabbedManageSubscriptionsProps extends SubscriptionsLogicProps {onCancel: () => void- onSelect: (value: number | 'new') => void+ onSelect: (value: number | 'new', resourceType?: SubscriptionResourceType) => void// Tab state is owned by the parent modal: this component unmounts while a subscription// is being edited, so local state would snap back to the first tab on return.activeTab: SubscriptionTabKey@@ -42,6 +48,9 @@ interface SubscriptionTabListProps {subscriptions: SubscriptionType[]loading: booleanemptyMessage: string+ description?: string+ footer?: ReactNode+ emptyState?: ReactNodeonSelect: (id: number) => void}@@ -53,6 +62,9 @@ function SubscriptionTabList({subscriptions,loading,emptyMessage,+ description,+ footer,+ emptyState,onSelect,}: SubscriptionTabListProps): JSX.Element {const logic = subscriptionsLogic(logicProps)@@ -67,19 +79,30 @@ function SubscriptionTabList({if (loading && subscriptions.length === 0) {return (- <div className="deprecated-space-y-2 py-2">- <LemonSkeleton.Row repeat={3} />+ <div className="flex flex-col gap-2 py-2">+ {description ? <div className="text-sm text-secondary">{description}</div> : null}+ <div className="deprecated-space-y-2">+ <LemonSkeleton.Row repeat={3} />+ </div>+ {footer}</div>)}if (subscriptions.length === 0) {- return <div className="text-secondary py-6 text-center">{emptyMessage}</div>+ return (+ <div className="flex flex-col gap-2">+ {description ? <div className="text-sm text-secondary">{description}</div> : null}+ {emptyState || <div className="text-secondary py-6 text-center">{emptyMessage}</div>}+ {footer}+ </div>+ )}return (<div className="flex flex-col gap-2">- <div className="max-h-[50vh] overflow-y-auto flex flex-col gap-2">+ {description ? <div className="text-sm text-secondary">{description}</div> : null}+ <div className="max-h-[60vh] overflow-y-auto flex flex-col gap-2">{pagination.dataSourcePage.map((sub) => (<SubscriptionListItemkey={sub.id}@@ -94,6 +117,7 @@ function SubscriptionTabList({))}</div><PaginationControl {...pagination} nouns={['subscription', 'subscriptions']} />+ {footer}</div>)}@@ -107,14 +131,12 @@ export function TabbedManageSubscriptions({onChangeTab,}: TabbedManageSubscriptionsProps): JSX.Element {const logicProps: SubscriptionsLogicProps = { insightShortId, dashboardId }- const {- subscriptions,- subscriptionsLoading,- insightSubscriptions,- insightSubscriptionsLoading,- aiSubscriptions,- aiSubscriptionsLoading,- } = useValues(subscriptionsLogic(logicProps))+ const { subscriptions, subscriptionsLoading, insightSubscriptions, insightSubscriptionsLoading } = useValues(+ subscriptionsLogic(logicProps)+ )+ const { currentOrganization } = useValues(organizationLogic)+ const aiPromptReportsAvailable =+ useFeatureFlag('SUBSCRIPTION_AI_PROMPT') && !!currentOrganization?.is_ai_data_processing_approvedconst isInsightContext = !!insightShortId@@ -125,26 +147,40 @@ export function TabbedManageSubscriptions({label: isInsightContext ? 'This insight' : 'This dashboard',subscriptions,loading: subscriptionsLoading,- emptyMessage: `No subscriptions for this ${isInsightContext ? 'insight' : 'dashboard'} yet.`,+ emptyMessage: `No subscriptions for this ${+ isInsightContext ? 'insight' : 'dashboard'+ } yet. Add one to send an up-to-date snapshot to Slack or email on a schedule.`,+ emptyState: (+ <SubscriptionEmptyState+ illustration={<MailHog className="object-contain shrink-0 w-24 h-20" />}+ title={`${isInsightContext ? 'Insight' : 'Dashboard'} subscriptions`}+ description={`Send an up-to-date snapshot of this ${+ isInsightContext ? 'insight' : 'dashboard'+ } to Slack or email on a schedule.`}+ actionLabel="Create subscription"+ actionType="primary"+ prominence="featured"+ onAction={() => onSelect('new')}+ />+ ),+ footer: aiPromptReportsAvailable ? (+ <div className="border-t pt-3">+ <AIPromptReportsLink />+ </div>+ ) : undefined,},!isInsightContext && {key: 'insights',label: 'Insights',subscriptions: insightSubscriptions,loading: insightSubscriptionsLoading,- emptyMessage: "No subscriptions on this dashboard's insights yet.",- },- {- key: 'ai',- label: 'AI prompt reports',- subscriptions: aiSubscriptions,- loading: aiSubscriptionsLoading,- emptyMessage: 'No AI prompt reports yet.',+ emptyMessage:+ "No subscriptions on this dashboard's insights yet. Open an insight on this dashboard to create one.",},]const tabs: LemonTab<SubscriptionTabKey>[] = tabConfigs.filter((tab): tab is SubscriptionTabConfig => !!tab)- .map(({ key, label, subscriptions, loading, emptyMessage }) => ({+ .map(({ key, label, subscriptions, loading, emptyMessage, description, footer, emptyState }) => ({key,// No count during the initial fetch — "(0)" would read as empty rather than loading.label: loading && subscriptions.length === 0 ? label : `${label} (${subscriptions.length})`,@@ -155,6 +191,9 @@ export function TabbedManageSubscriptions({subscriptions={subscriptions}loading={loading}emptyMessage={emptyMessage}+ description={description}+ footer={footer}+ emptyState={emptyState}onSelect={onSelect}/>),@@ -163,7 +202,12 @@ export function TabbedManageSubscriptions({return (<><LemonModal.Header>- <h3>Subscriptions</h3>+ <div>+ <h3>Subscriptions</h3>+ <p className="text-sm text-secondary mb-0">+ Subscriptions automatically send snapshots and reports to Slack or email on a schedule.+ </p>+ </div></LemonModal.Header><LemonModal.Content><LemonTabs@@ -173,9 +217,11 @@ export function TabbedManageSubscriptions({data-attr="manage-subscriptions-tabs"rightSlotClassName="bg-transparent"rightSlot={- <LemonButton type="primary" onClick={() => onSelect('new')} data-attr="add-subscription">- Add subscription- </LemonButton>+ activeTab === 'resource' ? (+ <LemonButton type="primary" onClick={() => onSelect('new')} data-attr="add-subscription">+ Add subscription+ </LemonButton>+ ) : undefined}/></LemonModal.Content>diff --git a/products/subscriptions/frontend/scenes/SubscriptionsScene.tsx b/products/subscriptions/frontend/scenes/SubscriptionsScene.tsxindex f25e6a45384d..8511fd7541e8 100644--- a/products/subscriptions/frontend/scenes/SubscriptionsScene.tsx+++ b/products/subscriptions/frontend/scenes/SubscriptionsScene.tsx@@ -7,7 +7,6 @@ import { LemonButton, LemonMenu, LemonModal, Link } from '@posthog/lemon-ui'import { pngHoggie } from 'lib/brand/hoggies'import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'-import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { LemonTab, LemonTabs } from 'lib/lemon-ui/LemonTabs'import { Spinner } from 'lib/lemon-ui/Spinner'import { deleteWithUndo } from 'lib/utils/deleteWithUndo'@@ -108,9 +107,9 @@ export function SubscriptionsScene(): JSX.Element {subscriptionsSorting,targetTypeFilter,subscriptionModalId,+ aiSubscriptionsAvailable,} = useValues(subscriptionsSceneLogic)const { setCurrentTab, setSubscriptionsSorting } = useActions(subscriptionsSceneLogic)- const aiSubscriptionsEnabled = useFeatureFlag('SUBSCRIPTION_AI_PROMPT')const isFiltered =Boolean(search.trim()) ||@@ -123,10 +122,25 @@ export function SubscriptionsScene(): JSX.Element {{ key: SubscriptionsTab.Mine, label: 'My subscriptions' },{ key: SubscriptionsTab.Dashboard, label: 'Dashboard' },{ key: SubscriptionsTab.Insight, label: 'Insight' },- ...(aiSubscriptionsEnabled ? [{ key: SubscriptionsTab.AI, label: 'Prompt' }] : []),+ ...(aiSubscriptionsAvailable ? [{ key: SubscriptionsTab.AI, label: 'AI prompt' }] : []),]const showProductIntroduction =subscriptions.length === 0 && !subscriptionsLoading && !isFiltered && !subscriptionsListAwaitingDebouncedFetch+ const emptyStateDescription = aiSubscriptionsAvailable+ ? 'Send scheduled dashboard and insight snapshots, or use an AI prompt to generate a recurring report. Deliver subscriptions to Slack or email.'+ : 'Get recurring email or Slack digests, or scheduled exports from insights and dashboards. Use them for weekly rollups, stakeholder updates, or wiring metrics into your own systems.'+ const emptyStateAction = aiSubscriptionsAvailable ? (+ <span className="italic">+ <Link to={urls.subscriptionNew()}>Create an AI prompt subscription</Link>, or open a{' '}+ <Link to={urls.dashboards()}>dashboard</Link> or <Link to={urls.insights()}>saved insight</Link> to schedule+ a snapshot.+ </span>+ ) : (+ <span className="italic">+ Open a <Link to={urls.dashboards()}>dashboard</Link> or <Link to={urls.insights()}>saved insight</Link> to+ schedule a snapshot.+ </span>+ )return (<SceneContent>@@ -135,7 +149,7 @@ export function SubscriptionsScene(): JSX.Element {description={sceneConfigurations[Scene.Subscriptions].description}resourceType={{ type: 'inbox' }}actions={- aiSubscriptionsEnabled ? (+ aiSubscriptionsAvailable ? (<LemonButtontype="primary"data-attr="new-subscription-button"@@ -159,19 +173,13 @@ export function SubscriptionsScene(): JSX.Element {productKey={ProductKey.SUBSCRIPTIONS}thingName="subscription"titleOverride="No subscriptions yet"- description="Get recurring email or Slack digests, or scheduled exports from insights and dashboards. Use them for weekly rollups, stakeholder updates, or wiring metrics into your own systems."+ description={emptyStateDescription}isEmptycustomHog={HedgehogMagnifyingGlass}hogLayout="responsive"useMainContentContainerQueriesdocsURL="https://posthog.com/docs/user-guides/subscriptions"- actionElementOverride={- <span className="italic">- Open a <Link to={urls.dashboards()}>dashboard</Link> or{' '}- <Link to={urls.insights()}>saved insight</Link>, open the side panel, and click{' '}- "Subscribe" to configure the options.- </span>- }+ actionElementOverride={emptyStateAction}/>) : (<>diff --git a/products/subscriptions/frontend/scenes/components/SubscriptionDeliveryHistory.stories.tsx b/products/subscriptions/frontend/scenes/components/SubscriptionDeliveryHistory.stories.tsxindex d8c60a378884..f5cf959afa37 100644--- a/products/subscriptions/frontend/scenes/components/SubscriptionDeliveryHistory.stories.tsx+++ b/products/subscriptions/frontend/scenes/components/SubscriptionDeliveryHistory.stories.tsx@@ -14,7 +14,7 @@ const noopTestDelivery = (): void => undefinedconst meta: Meta<typeof SubscriptionDeliveryHistory> = {component: SubscriptionDeliveryHistory,- title: 'Scenes-App/Subscriptions/Subscription delivery history',+ title: 'Products/Subscriptions/Subscription delivery history',parameters: {mockDate: '2026-04-07',},diff --git a/products/subscriptions/frontend/scenes/components/SubscriptionSummary.stories.tsx b/products/subscriptions/frontend/scenes/components/SubscriptionSummary.stories.tsxdeleted file mode 100644index 910f9632fa08..000000000000--- a/products/subscriptions/frontend/scenes/components/SubscriptionSummary.stories.tsx+++ /dev/null@@ -1,32 +0,0 @@-import { Meta, StoryObj } from '@storybook/react'--import {- MOCK_SUBSCRIPTION_DASHBOARD_MANY_DESTINATIONS,- MOCK_SUBSCRIPTION_INSIGHT_MANY_DESTINATIONS,-} from './subscriptionStoryFixtures'-import { SubscriptionSummary } from './SubscriptionSummary'--const meta: Meta<typeof SubscriptionSummary> = {- component: SubscriptionSummary,- title: 'Scenes-App/Subscriptions/Subscription summary',- parameters: {- mockDate: '2026-04-07',- },-}--export default meta--type Story = StoryObj<typeof SubscriptionSummary>--/** Label is the resource kind; value is always the resource name (many destinations only affect Destination). */-export const InsightManyDestinations: Story = {- args: {- sub: MOCK_SUBSCRIPTION_INSIGHT_MANY_DESTINATIONS,- },-}--export const DashboardManyDestinations: Story = {- args: {- sub: MOCK_SUBSCRIPTION_DASHBOARD_MANY_DESTINATIONS,- },-}diff --git a/products/subscriptions/frontend/scenes/components/SubscriptionsTable.stories.tsx b/products/subscriptions/frontend/scenes/components/SubscriptionsTable.stories.tsxindex fa47ac06a4b3..575e1033a8c6 100644--- a/products/subscriptions/frontend/scenes/components/SubscriptionsTable.stories.tsx+++ b/products/subscriptions/frontend/scenes/components/SubscriptionsTable.stories.tsx@@ -201,7 +201,7 @@ function buildMockSubscriptions(total: number): SubscriptionApi[] {const MOCK_SUBSCRIPTIONS_MULTI_PAGE = buildMockSubscriptions(45)const meta: Meta<typeof SubscriptionsTable> = {- title: 'Scenes-App/Subscriptions/SubscriptionsTable',+ title: 'Products/Subscriptions/Subscriptions table',component: SubscriptionsTable,parameters: {layout: 'padded',diff --git a/products/subscriptions/frontend/scenes/subscriptionsSceneLogic.test.ts b/products/subscriptions/frontend/scenes/subscriptionsSceneLogic.test.tsindex 09c76ab87cbc..2dfbcb4277f9 100644--- a/products/subscriptions/frontend/scenes/subscriptionsSceneLogic.test.ts+++ b/products/subscriptions/frontend/scenes/subscriptionsSceneLogic.test.ts@@ -1,8 +1,11 @@-import { MOCK_DEFAULT_USER, MOCK_USER_UUID } from 'lib/api.mock'+import { MOCK_DEFAULT_ORGANIZATION, MOCK_DEFAULT_USER, MOCK_USER_UUID } from 'lib/api.mock'import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { organizationLogic } from 'scenes/organizationLogic'import { sceneLogic } from 'scenes/sceneLogic'import { Scene } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'@@ -87,6 +90,11 @@ describe('subscriptionsSceneLogic', () => {it('sends resource_type=ai_prompt on AI reports tab', async () => {await expectLogic(logic).toDispatchActions(['loadSubscriptionsSuccess'])subscriptionRequestUrls.length = 0+ organizationLogic.actions.loadCurrentOrganizationSuccess({+ ...MOCK_DEFAULT_ORGANIZATION,+ is_ai_data_processing_approved: true,+ })+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.SUBSCRIPTION_AI_PROMPT]: true })await expectLogic(logic, () => {logic.actions.setCurrentTab(SubscriptionsTab.AI)@@ -97,6 +105,20 @@ describe('subscriptionsSceneLogic', () => {expect(params.get('resource_type')).toBe('ai_prompt')})+ it('ignores an AI reports URL when AI subscriptions are unavailable', async () => {+ await expectLogic(logic).toDispatchActions(['loadSubscriptionsSuccess'])+ subscriptionRequestUrls.length = 0++ await expectLogic(logic, () => {+ router.actions.push(`${urls.subscriptions()}?tab=ai_prompt`)+ })+ .toFinishAllListeners()+ .toMatchValues({ currentTab: SubscriptionsTab.All })++ expect(subscriptionRequestUrls).toHaveLength(1)+ expect(subscriptionListParamsFromUrl(subscriptionRequestUrls[0]).has('resource_type')).toBe(false)+ })+it('sends created_by for Mine tab', async () => {await expectLogic(logic).toDispatchActions(['loadSubscriptionsSuccess'])subscriptionRequestUrls.length = 0diff --git a/products/subscriptions/frontend/scenes/subscriptionsSceneLogic.tsx b/products/subscriptions/frontend/scenes/subscriptionsSceneLogic.tsxindex 4c179627fb38..8b922cdedf67 100644--- a/products/subscriptions/frontend/scenes/subscriptionsSceneLogic.tsx+++ b/products/subscriptions/frontend/scenes/subscriptionsSceneLogic.tsx@@ -4,8 +4,11 @@ import { router, urlToAction } from 'kea-router'import { Sorting } from '@posthog/lemon-ui'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic, type FeatureFlagsSet } from 'lib/logic/featureFlagLogic'import { trackedActionToUrl } from 'lib/logic/scenes/trackedActionToUrl'import { getCurrentTeamId } from 'lib/utils/getAppContext'+import { organizationLogic } from 'scenes/organizationLogic'import { sceneConfigurations } from 'scenes/scenes'import { Scene } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'@@ -21,7 +24,7 @@ import {type SubscriptionsListTargetType,} from 'products/subscriptions/frontend/generated/api.schemas'-import type { UserType } from '../../../../frontend/src/types'+import type { OrganizationType, UserType } from '../../../../frontend/src/types'import { runSubscriptionTestDelivery } from '../components/Subscriptions/runSubscriptionTestDelivery'import { toggleSubscriptionEnabled } from '../components/Subscriptions/toggleSubscriptionEnabled'import type { SubscriptionApi } from '../generated/api.schemas'@@ -193,7 +196,11 @@ function buildSubscriptionsListOrdering(sorting: Sorting | null): string {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface subscriptionsSceneLogicValues {+ featureFlags: FeatureFlagsSet // featureFlagLogic+ receivedFeatureFlags: boolean // featureFlagLogic+ currentOrganization: OrganizationType | null // organizationLogicuser: UserType | null // userLogic+ aiSubscriptionsAvailable: booleanbreadcrumbs: Breadcrumb[]createdByUuid: string | nullcurrentTab: SubscriptionsTab@@ -296,6 +303,11 @@ export interface subscriptionsSceneLogicActions {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface subscriptionsSceneLogicMeta {__keaTypeGenInternalSelectorTypes: {+ aiSubscriptionsAvailable: (+ featureFlags: FeatureFlagsSet,+ receivedFeatureFlags: boolean,+ currentOrganization: OrganizationType | null+ ) => booleansubscriptions: (subscriptionsResponse: PaginatedSubscriptionListApi | null) => SubscriptionApi[]subscriptionsLoading: (subscriptionsResponseLoading: boolean) => booleanpagination: (@@ -321,7 +333,16 @@ export type subscriptionsSceneLogicType = MakeLogicType<export const subscriptionsSceneLogic = kea<subscriptionsSceneLogicType>([path(['scenes', 'subscriptions', 'subscriptionsSceneLogic']),- connect(() => ({ values: [userLogic, ['user']] })),+ connect(() => ({+ values: [+ userLogic,+ ['user'],+ featureFlagLogic,+ ['featureFlags', 'receivedFeatureFlags'],+ organizationLogic,+ ['currentOrganization'],+ ],+ })),actions({loadSubscriptions: true,setSearch: (search: string) => ({ search }),@@ -462,6 +483,17 @@ export const subscriptionsSceneLogic = kea<subscriptionsSceneLogicType>([],})),selectors({+ aiSubscriptionsAvailable: [+ (s) => [s.featureFlags, s.receivedFeatureFlags, s.currentOrganization],+ (+ featureFlags: FeatureFlagsSet,+ receivedFeatureFlags: boolean,+ currentOrganization: OrganizationType | null+ ) =>+ receivedFeatureFlags &&+ Boolean(featureFlags[FEATURE_FLAGS.SUBSCRIPTION_AI_PROMPT]) &&+ Boolean(currentOrganization?.is_ai_data_processing_approved),+ ],subscriptions: [(s) => [s.subscriptionsResponse],(subscriptionsResponse: PaginatedSubscriptionListApi | null) => subscriptionsResponse?.results ?? [],@@ -500,17 +532,39 @@ export const subscriptionsSceneLogic = kea<subscriptionsSceneLogicType>([},],})),- listeners(({ actions }) => ({+ listeners(({ actions, values }) => ({setSearch: async (_, breakpoint) => {await breakpoint(300)actions.loadSubscriptions()},setPage: () => actions.loadSubscriptions(),setCreatedByFilter: () => actions.loadSubscriptions(),- setCurrentTab: () => actions.loadSubscriptions(),+ setCurrentTab: ({ tab }) => {+ if (tab === SubscriptionsTab.AI && !values.aiSubscriptionsAvailable) {+ actions.setCurrentTab(SubscriptionsTab.All)+ return+ }+ actions.loadSubscriptions()+ },setSubscriptionsSorting: () => actions.loadSubscriptions(),setTargetTypeFilter: () => actions.loadSubscriptions(),- applySubscriptionsQueryFromUrl: () => actions.loadSubscriptions(),+ applySubscriptionsQueryFromUrl: () => {+ if (values.currentTab === SubscriptionsTab.AI && !values.aiSubscriptionsAvailable) {+ actions.setCurrentTab(SubscriptionsTab.All)+ return+ }+ actions.loadSubscriptions()+ },+ [featureFlagLogic.actionTypes.setFeatureFlags]: () => {+ if (values.currentTab === SubscriptionsTab.AI && !values.aiSubscriptionsAvailable) {+ actions.setCurrentTab(SubscriptionsTab.All)+ }+ },+ [organizationLogic.actionTypes.loadCurrentOrganizationSuccess]: () => {+ if (values.currentTab === SubscriptionsTab.AI && !values.aiSubscriptionsAvailable) {+ actions.setCurrentTab(SubscriptionsTab.All)+ }+ },deleteSubscriptionSuccess: () => actions.loadSubscriptions(),deliverSubscription: async ({ id }) => {const result = await runSubscriptionTestDelivery(() =>