: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
chore(onboarding): remove the weekly ai reports onboarding step (#115618)
Rafael Audibert3cc7e49d8f68
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 36c4bd6d07c1..581573ae71bb 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -14966,22 +14966,6 @@ snapshots:hash: v1.k794b7964.b60ec49c9c54425935da72dee08b9af582389d080594a5ab04047940ea3d2ca0.5slgGa-IfOpuzeaG9ZhdnxIzZsVmazqvHffcaAuJdF8scenes-other-onboarding-legacy-product-selection--base--light:hash: v1.k794b7964.e5c1b8b7d8fee3b4c6a4cc3703ee0e1b2f7b00a89209abe8f6ce3a24e4fa8c39.hb-GH8yGKVGBsp8eHzSgd9Q1VnKVRqFRnPCgqc7bxTY- scenes-other-onboarding-legacy-weekly-reports--engineering-report--dark:- hash: v1.k794b7964.f9ba2a1e387636c5b36ce2b533fd85b91cd0f35f7d8ed02832534f2f873dc227.M77didUOFmt-7YdC2yuAmlbX6D3ZS1b0jpAzRbLdWt0- scenes-other-onboarding-legacy-weekly-reports--engineering-report--light:- hash: v1.k794b7964.3f0e00c4c70ee0d96ad4a41f15599faa1d923ed6dde65844423d28b78d0cde24.irjcemXMJrJT_bQiAg15LWn6_aUEzTRq6tknxdWYynA- scenes-other-onboarding-legacy-weekly-reports--generic-report-without-role--dark:- hash: v1.k794b7964.060eebc43da180bc7216c9a6de69dd93b94ef4907bbce067ec623b0e79f26d96.ZOIHuHBupiyMbINazWOV4xiBr-GVSiGzMWhxURMG-4Y- scenes-other-onboarding-legacy-weekly-reports--generic-report-without-role--light:- hash: v1.k794b7964.aee23e7614347711b86d67ec3249d6f11d88303d9b42d4afc84a902cc9ff3050.Wd9YYJw8KRHuZa-Gx8jmrVabo2BU34r3CNhbxNMpdqw- scenes-other-onboarding-legacy-weekly-reports--leadership-report--dark:- hash: v1.k794b7964.9ec18a9fd3ab997fafc945ef559932ff4d6a4280932d2f47f04244ef214aaa50.tKKaLHMfbUzgLdknJtNzA3OvI8-GdCZepYK3RqbFjt8- scenes-other-onboarding-legacy-weekly-reports--leadership-report--light:- hash: v1.k794b7964.e52e25ab0dccc6e385a8f2feed6fcdf465009197bcdb8924a7a25e81c595cd8c.tUNS2IQIO4Od_cN0oeodL8Z1KVVDgfgAv031Nd0jjf8- scenes-other-onboarding-legacy-weekly-reports--marketing-report--dark:- hash: v1.k794b7964.5b47c52c9275f618a5203cb05f2876ad61ef64dae3ed55286154206c86cdf84e.8KldnpVAu_TUUsKF0DUTDc8YOcJJRyncAQYtgzZZQXI- scenes-other-onboarding-legacy-weekly-reports--marketing-report--light:- hash: v1.k794b7964.2e1c2b338c858ba1afa778e51b61fad7c178a736945ad29a99350728fa1c3219.Nw-xZ40poAjRD67k0oJ2OcUvu7ivKaEoqm1nCHoksccscenes-other-onboarding-self-driving--use-cases-dark--dark:hash: v1.k794b7964.13ed270c2382666d6706206318fe89909f9e4fa55e4d078ac6533d9de1d9cc4d.-Px7mb7nBZKF4CgZh6LeUu2HigFFY9Ekz7q058_eAoIscenes-other-onboarding-self-driving--use-cases-light--light:diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex d815a8baa6c5..95a9ac85945f 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -457,7 +457,6 @@ export const FEATURE_FLAGS = {NOTEBOOK_JUPYTER_MODE: 'notebook-jupyter-mode', // owner: #team-data-tools, lays notebooks out and drives them like JupyterLabNOTEBOOK_SANDBOX_FREE_COMPUTE: 'notebook-sandbox-free-compute', // owner: #team-data-tools, shows the notebook sandbox rate crossed out at $0.00 / hNOTEBOOK_SHARING: 'notebook-sharing', // owner: @reecejones #team-platform-features- ONBOARDING_AI_REPORTS: 'onboarding-role-notifications', // owner: @joethreepwood #team-growth multivariate=control,test — offers a role-tailored weekly AI report step at the end of onboarding; code additionally gates on AI subscriptions being available, so keep the flag at 100% rollout (key predates the AI-reports naming; it's bound to the live experiment)ONBOARDING_DATA_WAREHOUSE_VALUE_PROP: 'onboarding-data-warehouse-value-prop', // owner: @fercgomes #team-growth multivariate=control,table,queryONBOARDING_FLOW_VARIANT: 'onboarding-flow-variant', // owner: @fercgomes #team-growth multivariate=control,self-driving — selects the whole onboarding experience; control is the existing flow (the historical `legacy` value is an alias of control)ONBOARDING_HIDE_BREADCRUMBS: 'onboarding-hide-breadcrumbs', // owner: @fercgomes #team-growth, multivariate=true, hides breadcrumbs during onboarding to reduce distractionsdiff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.tsindex 6c1123272286..f1151a69288b 100644--- a/frontend/src/lib/utils/eventUsageLogic.ts+++ b/frontend/src/lib/utils/eventUsageLogic.ts@@ -1444,24 +1444,6 @@ export interface eventUsageLogicActions {itemType: string | null | undefinedsection: string}- reportOnboardingAIReportRemoved: (- role: string | null,- reportKey: string,- experimentArm: string | null- ) => {- experimentArm: string | null- reportKey: string- role: string | null- }- reportOnboardingAIReportSubscribed: (- role: string | null,- reportKey: string,- experimentArm: string | null- ) => {- experimentArm: string | null- reportKey: string- role: string | null- }reportOnboardingCompleted: (productKey: string,properties?: OnboardingEventProperties@@ -2186,16 +2168,6 @@ export const eventUsageLogic = kea<eventUsageLogicType>([productKey,properties,}),- reportOnboardingAIReportSubscribed: (role: string | null, reportKey: string, experimentArm: string | null) => ({- role,- reportKey,- experimentArm,- }),- reportOnboardingAIReportRemoved: (role: string | null, reportKey: string, experimentArm: string | null) => ({- role,- reportKey,- experimentArm,- }),reportOnboardingCompleted: (productKey: string, properties?: OnboardingEventProperties) => ({productKey,properties,@@ -3077,22 +3049,6 @@ export const eventUsageLogic = kea<eventUsageLogicType>([...properties,})},- reportOnboardingAIReportSubscribed: ({ role, reportKey, experimentArm }) => {- posthog.capture('onboarding ai report subscribed', {- role,- report_key: reportKey,- experiment_arm: experimentArm,- ...LEGACY_ONBOARDING_EVENT_PROPS,- })- },- reportOnboardingAIReportRemoved: ({ role, reportKey, experimentArm }) => {- posthog.capture('onboarding ai report removed', {- role,- report_key: reportKey,- experiment_arm: experimentArm,- ...LEGACY_ONBOARDING_EVENT_PROPS,- })- },reportOnboardingCompleted: ({ productKey, properties }) => {posthog.capture('onboarding completed', {product_key: productKey,diff --git a/frontend/src/scenes/onboarding/legacy/notifications/OnboardingAIReports.stories.tsx b/frontend/src/scenes/onboarding/legacy/notifications/OnboardingAIReports.stories.tsxdeleted file mode 100644index 9876596881f7..000000000000--- a/frontend/src/scenes/onboarding/legacy/notifications/OnboardingAIReports.stories.tsx+++ /dev/null@@ -1,100 +0,0 @@-import { MOCK_DEFAULT_USER } from 'lib/api.mock'--import { Meta, StoryObj } from '@storybook/react'-import { useActions, useMountedLogic } from 'kea'-import { router } from 'kea-router'--import { FEATURE_FLAGS } from 'lib/constants'-import { useDelayedOnMountEffect } from 'lib/hooks/useOnMountEffect'-import { App } from 'scenes/App'-import { availableOnboardingProducts } from 'scenes/onboarding/shared/utils'-import { urls } from 'scenes/urls'--import { mswDecorator, useStorybookMocks } from '~/mocks/browser'-import { billingJson } from '~/mocks/fixtures/_billing'-import preflightJson from '~/mocks/fixtures/_preflight.json'-import { ProductKey } from '~/queries/schema/schema-general'-import { OnboardingStepKey, UserRole } from '~/types'--import { onboardingLogic } from '../onboardingLogic'--const meta: Meta = {- title: 'Scenes-Other/Onboarding/Legacy/Weekly reports',- parameters: {- layout: 'fullscreen',- viewMode: 'story',- mockDate: '2023-05-25',- featureFlags: {- [FEATURE_FLAGS.ONBOARDING_AI_REPORTS]: 'test',- [FEATURE_FLAGS.SUBSCRIPTION_AI_PROMPT]: true,- },- testOptions: { waitForSelector: '[data-attr="onboarding-ai-report-subscribe"]' },- },- decorators: [- mswDecorator({- get: {- '/_preflight': {- ...preflightJson,- cloud: true,- realm: 'cloud',- },- '/api/billing/': {- ...billingJson,- },- },- post: {- '/api/projects/:team_id/subscriptions/': () => [201, { id: 123 }],- },- patch: {- '/api/environments/:team_id/add_product_intent/': {},- },- }),- ],-}-export default meta--type Story = StoryObj<{}>--function StepForRole({ role }: { role: UserRole | null }): JSX.Element {- useMountedLogic(onboardingLogic)- const { setProduct } = useActions(onboardingLogic)-- useStorybookMocks({- get: {- '/api/users/@me/': () => [200, { ...MOCK_DEFAULT_USER, role_at_organization: role }],- },- })-- useDelayedOnMountEffect(() => {- setProduct(availableOnboardingProducts[ProductKey.PRODUCT_ANALYTICS])- router.actions.push(- urls.onboarding({- productKey: ProductKey.PRODUCT_ANALYTICS,- // Namespaced id so currentFlowStep resolves via exact match — the step is- // appended by a flag-gated flow rebuild (same race as the billing step).- step: `${OnboardingStepKey.AI_REPORTS}:${ProductKey.PRODUCT_ANALYTICS}`,- })- )- })-- return <App />-}--// One story per report family, not per role: founder/engineering share a report, and the-// remaining roles differ only in card copy drawn from aiReportDefinitions.--export const EngineeringReport: Story = {- render: () => <StepForRole role={UserRole.Engineering} />,-}--export const MarketingReport: Story = {- render: () => <StepForRole role={UserRole.Marketing} />,-}--export const LeadershipReport: Story = {- render: () => <StepForRole role={UserRole.Leadership} />,-}--export const GenericReportWithoutRole: Story = {- render: () => <StepForRole role={null} />,-}diff --git a/frontend/src/scenes/onboarding/legacy/notifications/OnboardingAIReports.tsx b/frontend/src/scenes/onboarding/legacy/notifications/OnboardingAIReports.tsxdeleted file mode 100644index 1f6dbafeaec4..000000000000--- a/frontend/src/scenes/onboarding/legacy/notifications/OnboardingAIReports.tsx+++ /dev/null@@ -1,81 +0,0 @@-import { useActions, useValues } from 'kea'--import { IconCheckCircle } from '@posthog/icons'-import { LemonButton, LemonCard, LemonCollapse } from '@posthog/lemon-ui'--import { userLogic } from 'scenes/userLogic'--import { OnboardingStepKey } from '~/types'--import { OnboardingStepComponentType } from '../onboardingLogic'-import { OnboardingStep } from '../OnboardingStep'-import { onboardingAIReportsLogic } from './onboardingAIReportsLogic'--export const OnboardingAIReports: OnboardingStepComponentType = () => {- const { user } = useValues(userLogic)- const { report, createdSubscriptionId, createdSubscriptionIdLoading } = useValues(onboardingAIReportsLogic)- const { createReportSubscription, removeReportSubscription } = useActions(onboardingAIReportsLogic)-- const subscribed = createdSubscriptionId !== null-- return (- <OnboardingStep- title="Get a weekly report"- subtitle="We can email you a written summary every week, based on what you told us you do. Reports start once your data is flowing, so it's fine to set this up before you've sent any events."- stepKey={OnboardingStepKey.AI_REPORTS}- continueText={subscribed ? undefined : 'Skip for now'}- >- <LemonCard hoverEffect={false} className="flex flex-col gap-2 p-4">- <div className="flex items-start justify-between gap-2">- <div className="min-w-0">- <h3 className="m-0 text-base font-semibold">{report.headline}</h3>- <p className="m-0 text-sm text-muted">{report.lead}</p>- </div>- {!subscribed && (- <LemonButton- type="primary"- onClick={() => createReportSubscription()}- loading={createdSubscriptionIdLoading}- data-attr="onboarding-ai-report-subscribe"- >- Email me this weekly- </LemonButton>- )}- </div>-- {subscribed ? (- <div className="flex items-center justify-between gap-2 rounded border bg-surface-primary p-2">- <div className="flex items-center gap-2">- <IconCheckCircle className="text-success shrink-0 text-lg" />- <span className="text-sm">- Done. Your first report arrives next week at {user?.email}. You can change or cancel it- anytime in Notifications & alerts.- </span>- </div>- <LemonButton- size="small"- onClick={() => removeReportSubscription()}- loading={createdSubscriptionIdLoading}- data-attr="onboarding-ai-report-undo"- >- Undo- </LemonButton>- </div>- ) : (- <LemonCollapse- size="small"- panels={[- {- key: 'prompt',- header: 'What it covers',- content: <p className="m-0 text-sm">{report.prompt}</p>,- },- ]}- />- )}- </LemonCard>- </OnboardingStep>- )-}--OnboardingAIReports.stepKey = OnboardingStepKey.AI_REPORTSdiff --git a/frontend/src/scenes/onboarding/legacy/notifications/aiReportDefinitions.test.ts b/frontend/src/scenes/onboarding/legacy/notifications/aiReportDefinitions.test.tsdeleted file mode 100644index 184781c215f3..000000000000--- a/frontend/src/scenes/onboarding/legacy/notifications/aiReportDefinitions.test.ts+++ /dev/null@@ -1,32 +0,0 @@-import { UserRole } from '~/types'--import { AI_REPORTS_BY_ROLE, reportForRole } from './aiReportDefinitions'--describe('aiReportDefinitions', () => {- // Catches a new UserRole enum value silently losing its mapping at runtime (the Record type- // enforces it at compile time, but `reportForRole` takes an untyped string from the user object).- it.each([...Object.values(UserRole), null, undefined, 'not-a-role'])(- 'returns a complete definition for role %s',- (role) => {- const report = reportForRole(role)- expect(report.key).toBeTruthy()- expect(report.title).toBeTruthy()- expect(report.headline).toBeTruthy()- expect(report.prompt.length).toBeGreaterThan(100)- }- )-- it('gives founders and engineers the same revenue and growth report', () => {- expect(AI_REPORTS_BY_ROLE[UserRole.Founder]).toBe(AI_REPORTS_BY_ROLE[UserRole.Engineering])- })-- // "Self-driving" is an existing onboarding variant and brand term; this copy must never be- // mistaken for it (explicit request from the feature discussion).- it('never uses the term self-driving in any user-facing string', () => {- for (const report of Object.values(AI_REPORTS_BY_ROLE)) {- for (const text of [report.headline, report.lead, report.title, report.prompt]) {- expect(text.toLowerCase()).not.toContain('self-driving')- }- }- })-})diff --git a/frontend/src/scenes/onboarding/legacy/notifications/aiReportDefinitions.ts b/frontend/src/scenes/onboarding/legacy/notifications/aiReportDefinitions.tsdeleted file mode 100644index 37c19d009f2e..000000000000--- a/frontend/src/scenes/onboarding/legacy/notifications/aiReportDefinitions.ts+++ /dev/null@@ -1,156 +0,0 @@-import { FEATURE_FLAGS } from 'lib/constants'-import { FeatureFlagsSet } from 'lib/logic/featureFlagLogic'--import { UserRole } from '~/types'--export interface AIReportDefinition {- key: string- headline: string- lead: string- title: string- /**- * Handed to the AI-subscription planner, which writes and runs its own HogQL. Names concrete- * event properties so it queries the right ones rather than guessing, and tells it to say so- * plainly when the project doesn't have the data yet (most subscribers set this up before- * they've instrumented anything).- */- prompt: string-}--// Founders and engineers get the same report: per the role mapping decision, both care most-// about whether the business is growing, not about a role-specific slice.-const REVENUE_SIGNUPS: AIReportDefinition = {- key: 'revenue-signups',- headline: 'Revenue and sign-up growth',- lead: 'New sign-ups and revenue movement this week, compared with last week.',- title: 'Weekly revenue and sign-up growth',- prompt: [- 'Summarize business growth for the last 7 days compared with the previous 7 days.',- 'Count new sign-ups: persons whose first event ever was in the last 7 days, plus any',- 'explicit sign-up events if the project has them (event names containing "sign" or "register").',- 'If the project has revenue or payment events (names containing "purchase", "payment",',- '"subscription" or "checkout"), report their volume and unique payers week over week.',- 'If none exist, say so plainly and skip revenue rather than inventing numbers.',- 'Close with the single most important growth change and a plausible reason for it.',- ].join(' '),-}--const GENERIC_USAGE_DIGEST: AIReportDefinition = {- key: 'usage-digest',- headline: 'How your product was used',- lead: 'Active users, top pages and top events for the week, with what moved.',- title: 'Weekly product usage digest',- prompt: [- 'Summarize product usage for the last 7 days using this project’s events.',- 'Report weekly active users (unique persons), total events, and $pageview volume,',- 'each compared with the previous 7 days.',- 'List the top 10 pages by $pageview count using the $pathname property,',- 'and the top custom events (exclude event names starting with $).',- 'Call out anything that moved more than 20% week over week,',- 'and finish with the single most notable change and a plausible reason for it.',- 'If the project has little or no data yet, say so plainly instead of inventing numbers.',- ].join(' '),-}--export const AI_REPORTS_BY_ROLE: Record<UserRole, AIReportDefinition> = {- [UserRole.Leadership]: {- key: 'aarrr-funnel',- headline: 'Your funnel at a glance',- lead: 'Acquisition, activation, retention, referral and revenue for the week.',- title: 'Weekly funnel summary',- prompt: [- 'Produce an AARRR summary for the last 7 days, each stage compared with the previous 7 days.',- 'Acquisition: unique persons with a $pageview, and the top $referring_domain values.',- 'Activation: persons whose first event ever was this week who then performed any custom',- 'event (names not starting with $).',- 'Retention: share of persons active in the previous 7 days who returned this week.',- 'Referral: events or UTM parameters (utm_source on $pageview) suggesting shared or referred traffic.',- 'Revenue: volume of purchase, payment or subscription events if the project has them.',- 'For any stage where the project has no data yet, say so plainly rather than inventing numbers.',- 'End with the weakest stage this week and one suggestion to investigate it.',- ].join(' '),- },- [UserRole.Marketing]: {- key: 'traffic-pages',- headline: 'What people visited and how traffic changed',- lead: 'Most popular pages this week and shifts in where visitors come from.',- title: 'Weekly pages and traffic changes',- prompt: [- 'Report on web traffic for the last 7 days compared with the previous 7 days using $pageview events.',- 'List the top 10 pages by $pathname with unique visitors and week-over-week change.',- 'Break down traffic sources using $referring_domain and utm_source, and call out any source',- 'that moved more than 20%.',- 'Note changes in bounce-like behavior: persons with exactly one $pageview in a session.',- 'If the project has little or no traffic data yet, say so plainly instead of inventing numbers.',- 'Finish with the most notable traffic shift and a plausible cause.',- ].join(' '),- },- [UserRole.Sales]: {- key: 'new-signups',- headline: 'Who signed up this week',- lead: 'New sign-ups this week, where they came from, and how the pace is trending.',- title: 'Weekly new sign-ups',- prompt: [- 'Report new sign-ups for the last 7 days compared with the previous 7 days.',- 'Count persons whose first event ever was in the last 7 days, plus explicit sign-up events',- 'if the project has them (event names containing "sign" or "register").',- 'Show sign-ups per day to reveal the trend, and the top acquisition sources for new persons',- 'using $referring_domain and utm_source on their first $pageview.',- 'If the project has no sign-up data yet, say so plainly instead of inventing numbers.',- 'Close with whether the sign-up pace is accelerating or slowing and by how much.',- ].join(' '),- },- [UserRole.Founder]: REVENUE_SIGNUPS,- [UserRole.Engineering]: REVENUE_SIGNUPS,- [UserRole.Product]: {- key: 'feature-retention',- headline: 'Feature usage and retention',- lead: 'Which features got used this week and whether users are coming back.',- title: 'Weekly feature usage and retention',- prompt: [- 'Summarize feature usage for the last 7 days compared with the previous 7 days.',- 'Rank the top 10 custom events (names not starting with $) by unique persons, with change.',- 'Report retention: share of persons active in the previous 7 days who returned this week,',- 'and the same for persons whose first event ever was in the previous week.',- 'Call out any feature whose unique users moved more than 20% week over week.',- 'If the project has little or no data yet, say so plainly instead of inventing numbers.',- 'End with the feature most worth attention this week and why.',- ].join(' '),- },- [UserRole.Data]: {- key: 'events-volume',- headline: 'Top events and volume changes',- lead: 'The biggest event streams and what moved week over week.',- title: 'Weekly event volume changes',- prompt: [- 'Compare event volume for the last 7 days against the previous 7 days for every event name',- 'in this project, excluding internal events starting with $ (but keep $pageview).',- 'Rank the top 10 events by volume, and separately the five fastest-growing and five',- 'fastest-declining by relative change, ignoring events under 100 occurrences in both windows.',- 'For each big mover, note whether unique persons moved with volume, since volume rising on',- 'flat users means heavier use rather than more reach.',- 'If the project has little or no data yet, say so plainly instead of inventing numbers.',- 'Close with anything that looks like an instrumentation problem, such as an event that',- 'vanished or spiked.',- ].join(' '),- },- [UserRole.Student]: GENERIC_USAGE_DIGEST,- [UserRole.Other]: GENERIC_USAGE_DIGEST,-}--/** An unset or unrecognized role gets the generic digest, so the step never dead-ends on role. */-export function reportForRole(role: string | null | undefined): AIReportDefinition {- return AI_REPORTS_BY_ROLE[role as UserRole] ?? GENERIC_USAGE_DIGEST-}--export type AIReportsExperimentArm = 'control' | 'test'--/**- * The user's experiment arm, or null when they are not enrolled: an unset/boolean flag value (not- * rolled out, targeting excludes them, flags not loaded yet) must NOT be collapsed into `control`,- * or never-enrolled users pollute the control cohort and bias the readout toward "no effect".- */-export function resolveAIReportsArm(featureFlags: FeatureFlagsSet): AIReportsExperimentArm | null {- const value = featureFlags[FEATURE_FLAGS.ONBOARDING_AI_REPORTS]- return value === 'test' || value === 'control' ? value : null-}diff --git a/frontend/src/scenes/onboarding/legacy/notifications/onboardingAIReportsLogic.test.ts b/frontend/src/scenes/onboarding/legacy/notifications/onboardingAIReportsLogic.test.tsdeleted file mode 100644index ef06daf3a2cc..000000000000--- a/frontend/src/scenes/onboarding/legacy/notifications/onboardingAIReportsLogic.test.ts+++ /dev/null@@ -1,91 +0,0 @@-import { expectLogic } from 'kea-test-utils'--import { lemonToast } from '@posthog/lemon-ui'--import { dayjs } from 'lib/dayjs'--import { initKeaTests } from '~/test/init'--import { subscriptionsCreate, subscriptionsPartialUpdate } from 'products/subscriptions/frontend/generated/api'--import { onboardingAIReportsLogic } from './onboardingAIReportsLogic'--jest.mock('products/subscriptions/frontend/generated/api', () => ({- subscriptionsCreate: jest.fn(),- subscriptionsPartialUpdate: jest.fn(),-}))--const mockedCreate = jest.mocked(subscriptionsCreate)-const mockedPartialUpdate = jest.mocked(subscriptionsPartialUpdate)--describe('onboardingAIReportsLogic', () => {- let logic: ReturnType<typeof onboardingAIReportsLogic.build>-- beforeEach(() => {- initKeaTests()- mockedCreate.mockReset().mockResolvedValue({ id: 123 } as any)- mockedPartialUpdate.mockReset().mockResolvedValue({ id: 123 } as any)- jest.spyOn(lemonToast, 'error').mockImplementation(() => 'toast-id')-- logic = onboardingAIReportsLogic()- logic.mount()- })-- afterEach(() => {- logic.unmount()- jest.restoreAllMocks()- })-- // Catches payload drift the backend would reject at runtime (dropping `interval`), and- // `send_test_now` flipping back to its server default of true, which would immediately- // mail an AI report over a project that likely has no events yet.- it('creates a weekly email subscription with a start date about a week out', async () => {- await expectLogic(logic, () => logic.actions.createReportSubscription()).toFinishAllListeners()-- expect(mockedCreate).toHaveBeenCalledTimes(1)- const [, payload] = mockedCreate.mock.calls[0]- expect(payload).toMatchObject({- target_type: 'email',- frequency: 'weekly',- interval: 1,- send_test_now: false,- })- expect(payload.prompt).toBeTruthy()- expect(payload.title).toBeTruthy()- const daysOut = dayjs(payload.start_date).diff(dayjs(), 'day', true)- expect(daysOut).toBeGreaterThan(6)- expect(daysOut).toBeLessThan(8)- expect(logic.values.createdSubscriptionId).toBe(123)- })-- it('does not create a second subscription while one exists', async () => {- await expectLogic(logic, () => logic.actions.createReportSubscription()).toFinishAllListeners()- await expectLogic(logic, () => logic.actions.createReportSubscription()).toFinishAllListeners()-- expect(mockedCreate).toHaveBeenCalledTimes(1)- })-- // The error leg of the double-submit guard: a failed create must leave the button usable- // (loading reset, no phantom created state) and tell the user where to recover.- it('resets state and shows a toast when creation fails', async () => {- mockedCreate.mockRejectedValue(new Error('quota'))-- await expectLogic(logic, () => logic.actions.createReportSubscription()).toFinishAllListeners()-- expect(logic.values.createdSubscriptionId).toBeNull()- expect(logic.values.createdSubscriptionIdLoading).toBe(false)- expect(lemonToast.error).toHaveBeenCalled()- })-- it('undo soft-deletes the created subscription and clears the created state', async () => {- await expectLogic(logic, () => logic.actions.createReportSubscription()).toFinishAllListeners()-- await expectLogic(logic, () => logic.actions.removeReportSubscription()).toFinishAllListeners()-- expect(mockedPartialUpdate).toHaveBeenCalledTimes(1)- const [, id, payload] = mockedPartialUpdate.mock.calls[0]- expect(id).toBe(123)- expect(payload).toEqual({ deleted: true })- expect(logic.values.createdSubscriptionId).toBeNull()- })-})diff --git a/frontend/src/scenes/onboarding/legacy/notifications/onboardingAIReportsLogic.ts b/frontend/src/scenes/onboarding/legacy/notifications/onboardingAIReportsLogic.tsdeleted file mode 100644index 4963d9883f07..000000000000--- a/frontend/src/scenes/onboarding/legacy/notifications/onboardingAIReportsLogic.ts+++ /dev/null@@ -1,168 +0,0 @@-import { MakeLogicType, connect, kea, path, selectors } from 'kea'-import { loaders } from 'kea-loaders'--import { lemonToast } from '@posthog/lemon-ui'--import { dayjs } from 'lib/dayjs'-import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'-import { eventUsageLogic } from 'lib/utils/eventUsageLogic'-import { projectLogic } from 'scenes/projectLogic'-import { userLogic } from 'scenes/userLogic'--import { UserType } from '~/types'--import { subscriptionsCreate, subscriptionsPartialUpdate } from 'products/subscriptions/frontend/generated/api'--import { AIReportDefinition, reportForRole, resolveAIReportsArm } from './aiReportDefinitions'--// Generated by kea-typegen. Update if you're an agent, ignore if you're human.-export interface onboardingAIReportsLogicValues {- featureFlags: FeatureFlagsSet // featureFlagLogic- currentProjectId: number | null // projectLogic- user: UserType | null // userLogic- createdSubscriptionId: number | null- createdSubscriptionIdLoading: boolean- report: AIReportDefinition-}--// Generated by kea-typegen. Update if you're an agent, ignore if you're human.-export interface onboardingAIReportsLogicActions {- reportOnboardingAIReportRemoved: (- role: string | null,- reportKey: string,- experimentArm: string | null- ) => {- experimentArm: string | null- reportKey: string- role: string | null- } // eventUsageLogic- reportOnboardingAIReportSubscribed: (- role: string | null,- reportKey: string,- experimentArm: string | null- ) => {- experimentArm: string | null- reportKey: string- role: string | null- } // eventUsageLogic- createReportSubscription: () => any- createReportSubscriptionFailure: (- error: string,- errorObject?: any- ) => {- error: string- errorObject?: any- }- createReportSubscriptionSuccess: (- createdSubscriptionId: number | null,- payload?: any- ) => {- createdSubscriptionId: number | null- payload?: any- }- removeReportSubscription: () => any- removeReportSubscriptionFailure: (- error: string,- errorObject?: any- ) => {- error: string- errorObject?: any- }- removeReportSubscriptionSuccess: (- createdSubscriptionId: number | null,- payload?: any- ) => {- createdSubscriptionId: number | null- payload?: any- }-}--// Generated by kea-typegen. Update if you're an agent, ignore if you're human.-export interface onboardingAIReportsLogicMeta {- __keaTypeGenInternalSelectorTypes: {- report: (user: UserType | null) => AIReportDefinition- }-}--export type onboardingAIReportsLogicType = MakeLogicType<- onboardingAIReportsLogicValues,- onboardingAIReportsLogicActions,- Record<string, any>,- onboardingAIReportsLogicMeta->--export const onboardingAIReportsLogic = kea<onboardingAIReportsLogicType>([- path(['scenes', 'onboarding', 'legacy', 'notifications', 'onboardingAIReportsLogic']),- connect(() => ({- values: [userLogic, ['user'], projectLogic, ['currentProjectId'], featureFlagLogic, ['featureFlags']],- actions: [eventUsageLogic, ['reportOnboardingAIReportSubscribed', 'reportOnboardingAIReportRemoved']],- })),- selectors({- report: [- (s) => [s.user],- (user: UserType | null): AIReportDefinition => reportForRole(user?.role_at_organization),- ],- }),- loaders(({ actions, values }) => ({- createdSubscriptionId: [- null as number | null,- {- createReportSubscription: async (): Promise<number | null> => {- if (values.createdSubscriptionId !== null || !values.currentProjectId) {- return values.createdSubscriptionId- }- const report = values.report- try {- const created = await subscriptionsCreate(String(values.currentProjectId), {- // resource_type derives to 'ai_prompt' server-side from the prompt- prompt: report.prompt,- title: report.title,- target_type: 'email',- target_value: values.user?.email ?? '',- frequency: 'weekly',- interval: 1,- // A week out: the user declares interest now, the first report fires- // once there's been time to instrument and collect data.- start_date: dayjs().add(7, 'day').hour(9).minute(0).second(0).toISOString(),- // Defaults to true on create, which would deliver an AI report over a- // project that likely has no events yet.- send_test_now: false,- })- actions.reportOnboardingAIReportSubscribed(- values.user?.role_at_organization ?? null,- report.key,- resolveAIReportsArm(values.featureFlags)- )- return created.id- } catch {- lemonToast.error(- 'Could not set up the report. You can add it later from Notifications & alerts.'- )- return values.createdSubscriptionId- }- },- removeReportSubscription: async (): Promise<number | null> => {- const subscriptionId = values.createdSubscriptionId- if (subscriptionId === null || !values.currentProjectId) {- return values.createdSubscriptionId- }- try {- // Subscriptions have no hard delete; setting `deleted` soft-deletes.- await subscriptionsPartialUpdate(String(values.currentProjectId), subscriptionId, {- deleted: true,- })- actions.reportOnboardingAIReportRemoved(- values.user?.role_at_organization ?? null,- values.report.key,- resolveAIReportsArm(values.featureFlags)- )- return null- } catch {- lemonToast.error('Could not undo. You can remove the report from Notifications & alerts.')- return values.createdSubscriptionId- }- },- },- ],- })),-])diff --git a/frontend/src/scenes/onboarding/legacy/onboardingFlowUtils.ts b/frontend/src/scenes/onboarding/legacy/onboardingFlowUtils.tsindex cdcb2b14d05c..848cc64d3807 100644--- a/frontend/src/scenes/onboarding/legacy/onboardingFlowUtils.ts+++ b/frontend/src/scenes/onboarding/legacy/onboardingFlowUtils.ts@@ -5,8 +5,6 @@ import { OnboardingStepKey } from '~/types'const STEP_KEY_TITLE_OVERRIDES: Partial<Record<OnboardingStepKey, string>> = {[OnboardingStepKey.LINK_DATA]: 'Import data',- // The default derivation would read "Ai reports" — wrong casing, and the step is weekly.- [OnboardingStepKey.AI_REPORTS]: 'Weekly reports',}export const stepKeyToTitle = (stepKey?: OnboardingStepKey): undefined | string => {diff --git a/frontend/src/scenes/onboarding/legacy/onboardingLogic.test.ts b/frontend/src/scenes/onboarding/legacy/onboardingLogic.test.tsindex fb20cfa4c7e9..a3723bfce82c 100644--- a/frontend/src/scenes/onboarding/legacy/onboardingLogic.test.ts+++ b/frontend/src/scenes/onboarding/legacy/onboardingLogic.test.ts@@ -1,12 +1,9 @@-import { MOCK_DEFAULT_ORGANIZATION } from 'lib/api.mock'-import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'import { SetupTaskId } from 'lib/components/ProductSetup'import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'-import { organizationLogic } from 'scenes/organizationLogic'import { urls } from 'scenes/urls'import { ProductKey } from '~/queries/schema/schema-general'@@ -770,55 +767,4 @@ describe('onboardingLogic — flow composition', () => {expect(flowStepKeys()).not.toContain(OnboardingStepKey.LINK_DATA)})})-- // Gate regressions here invalidate the experiment: leaking the step to control users breaks the- // readout, hiding it from test users ships a dead experiment.- describe('AI reports step gating', () => {- const setFlags = (variants: Record<string, string | boolean>): void => {- featureFlagLogic.findMounted()?.actions.setFeatureFlags(Object.keys(variants), variants)- }-- it('includes the step last when AI subscriptions are available and the arm is test', () => {- setFlags({- [FEATURE_FLAGS.SUBSCRIPTION_AI_PROMPT]: true,- [FEATURE_FLAGS.ONBOARDING_AI_REPORTS]: 'test',- })- // The org load is async in the test env; the gate needs is_ai_data_processing_approved.- organizationLogic.findMounted()?.actions.loadCurrentOrganizationSuccess(MOCK_DEFAULT_ORGANIZATION)- logic.actions.setProductKey(ProductKey.PRODUCT_ANALYTICS)-- expect(flowIds()[flowIds().length - 1]).toBe('ai_reports:product_analytics')- })-- it.each([- ['the arm is control', { [FEATURE_FLAGS.ONBOARDING_AI_REPORTS]: 'control' }],- ['the experiment flag is unset', {}],- [- 'AI subscriptions are unavailable',- {- [FEATURE_FLAGS.SUBSCRIPTION_AI_PROMPT]: false,- [FEATURE_FLAGS.ONBOARDING_AI_REPORTS]: 'test',- },- ],- ])('excludes the step when %s', (_label, extraVariants) => {- setFlags({ [FEATURE_FLAGS.SUBSCRIPTION_AI_PROMPT]: true, ...extraVariants })- logic.actions.setProductKey(ProductKey.PRODUCT_ANALYTICS)-- expect(flowStepKeys()).not.toContain(OnboardingStepKey.AI_REPORTS)- })-- it('excludes the step when the organization has not approved AI data processing', async () => {- setFlags({- [FEATURE_FLAGS.SUBSCRIPTION_AI_PROMPT]: true,- [FEATURE_FLAGS.ONBOARDING_AI_REPORTS]: 'test',- })- organizationLogic.findMounted()?.actions.loadCurrentOrganizationSuccess({- ...MOCK_DEFAULT_ORGANIZATION,- is_ai_data_processing_approved: false,- })- logic.actions.setProductKey(ProductKey.PRODUCT_ANALYTICS)-- expect(flowStepKeys()).not.toContain(OnboardingStepKey.AI_REPORTS)- })- })})diff --git a/frontend/src/scenes/onboarding/legacy/onboardingLogic.tsx b/frontend/src/scenes/onboarding/legacy/onboardingLogic.tsxindex 32cb07ee6354..164794984d5b 100644--- a/frontend/src/scenes/onboarding/legacy/onboardingLogic.tsx+++ b/frontend/src/scenes/onboarding/legacy/onboardingLogic.tsx@@ -6,7 +6,7 @@ import { lemonToast } from '@posthog/lemon-ui'import { type SetupTaskId } from 'lib/components/ProductSetup'import { globalSetupLogic } from 'lib/components/ProductSetup/globalSetupLogic'-import { FEATURE_FLAGS, OrganizationMembershipLevel } from 'lib/constants'+import { OrganizationMembershipLevel } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { eventUsageLogic } from 'lib/utils/eventUsageLogic'import { isKeyOf } from 'lib/utils/guards'@@ -80,7 +80,6 @@ export interface onboardingLogicValues {productKey: ProductKey | nullsecondaryProductKeys: ProductKey[]shouldShowBillingStep: boolean- showAIReportsStep: booleanstepId: stringsubscribedDuringOnboarding: booleantotalOnboardingSteps: number@@ -173,7 +172,6 @@ export interface onboardingLogicMeta {__keaTypeGenInternalSelectorTypes: {onboardingFlowVariant: (featureFlags: FeatureFlagsSet) => stringcanInviteTeammates: (currentOrganization: OrganizationType | null, user: UserType | null) => boolean- showAIReportsStep: (featureFlags: FeatureFlagsSet, currentOrganization: OrganizationType | null) => booleanbillingProduct: (billing: BillingType | null, productKey: ProductKey | null) => BillingProductV2Type | nullshouldShowBillingStep: (subscribedDuringOnboarding: boolean,@@ -192,8 +190,7 @@ export interface onboardingLogicMeta {isCloudOrDev: boolean | undefined,subscribedDuringOnboarding: boolean,canInviteTeammates: boolean,- featureFlags: FeatureFlagsSet,- showAIReportsStep: boolean+ featureFlags: FeatureFlagsSet) => OnboardingStepDescriptor[]onboardingStepKeys: (flow: OnboardingStepDescriptor[]) => OnboardingStepKey[]currentFlowStep: (flow: OnboardingStepDescriptor[], stepId: string) => OnboardingStepDescriptor | null@@ -372,26 +369,6 @@ export const onboardingLogic = kea<onboardingLogicType>([return typeof level === 'number' && level >= OrganizationMembershipLevel.Admin},],- showAIReportsStep: [- (s) => [s.featureFlags, s.currentOrganization],- (- featureFlags: FeatureFlagsSet,- currentOrganization: null | import('~/types').OrganizationType- ): boolean => {- // Eligibility first: reading the experiment flag records exposure, so users who- // could never see the step (AI subscriptions unavailable) must not reach that read.- // Both gates hold for new users by default — the ai-subscriptions flag is GA at 100%- // and new orgs default is_ai_data_processing_approved=true — so this only excludes- // orgs that explicitly opted out of AI data processing.- if (- !featureFlags[FEATURE_FLAGS.SUBSCRIPTION_AI_PROMPT] ||- !currentOrganization?.is_ai_data_processing_approved- ) {- return false- }- return featureFlags[FEATURE_FLAGS.ONBOARDING_AI_REPORTS] === 'test'- },- ],billingProduct: [(s) => [s.billing, s.productKey],(billing: null | import('~/types').BillingType, productKey: ProductKey | null) =>@@ -434,7 +411,6 @@ export const onboardingLogic = kea<onboardingLogicType>([s.subscribedDuringOnboarding,s.canInviteTeammates,s.featureFlags,- s.showAIReportsStep,],(primary: ProductKey | null,@@ -446,8 +422,7 @@ export const onboardingLogic = kea<onboardingLogicType>([isCloudOrDev: boolean | undefined,subscribedDuringOnboarding: boolean,canInviteTeammates: boolean,- featureFlags: FeatureFlagsSet,- showAIReportsStep: boolean+ featureFlags: FeatureFlagsSet): OnboardingStepDescriptor[] => {if (!primary) {return []@@ -462,7 +437,6 @@ export const onboardingLogic = kea<onboardingLogicType>([subscribedDuringOnboarding,canInviteTeammates,featureFlags,- showAIReportsStep,}const productSteps = orderedProducts.flatMap((p, i) => {const provider = onboardingProviderRegistry[p]diff --git a/frontend/src/scenes/onboarding/legacy/sharedSteps.tsx b/frontend/src/scenes/onboarding/legacy/sharedSteps.tsxindex 1401dc9a3d9f..e4812921c4ea 100644--- a/frontend/src/scenes/onboarding/legacy/sharedSteps.tsx+++ b/frontend/src/scenes/onboarding/legacy/sharedSteps.tsx@@ -4,20 +4,15 @@ import { OnboardingStepKey } from '~/types'import { OnboardingUpgradeStep } from './billing/OnboardingUpgradeStep'import { OnboardingDataWarehouseSourcesStep } from './data-warehouse/OnboardingDataWarehouseSourcesStep'-import { OnboardingAIReports } from './notifications/OnboardingAIReports'import { OnboardingInviteTeammates } from './OnboardingInviteTeammates'import { OnboardingFlowContext, OnboardingStepDescriptor } from './types'// The only step keys that join a flow after it first renders. Each is gated on data that arrives-// asynchronously (billing, organization, feature flags), so a URL targeting one has to be held+// asynchronously (billing, organization), so a URL targeting one has to be held// open until that data settles. `link_data` is deliberately absent: it is gated on the primary and// secondary product keys alone, both of which are set from the URL before the step is, so it is// either in the flow immediately or never. Keep in sync with the pushes below.-const ASYNC_TRAILING_STEP_KEYS = new Set<string>([- OnboardingStepKey.PLANS,- OnboardingStepKey.INVITE_TEAMMATES,- OnboardingStepKey.AI_REPORTS,-])+const ASYNC_TRAILING_STEP_KEYS = new Set<string>([OnboardingStepKey.PLANS, OnboardingStepKey.INVITE_TEAMMATES])/*** Whether a stepId could still be appended to the flow, so an unresolved URL targeting it is@@ -73,17 +68,5 @@ export function appendSharedTrailingSteps(})}- // Last on purpose: the lowest-stakes step, so any drop-off it causes shows up in the- // completion metric without blocking higher-value steps.- if (ctx.showAIReportsStep) {- result.push({- id: `${OnboardingStepKey.AI_REPORTS}:${ctx.primary}`,- productKey: ctx.primary,- stepKey: OnboardingStepKey.AI_REPORTS,- role: 'primary',- render: () => <OnboardingAIReports />,- })- }-return result}diff --git a/frontend/src/scenes/onboarding/legacy/stepProviderRegistry.test.ts b/frontend/src/scenes/onboarding/legacy/stepProviderRegistry.test.tsindex db01612348fb..0ce73b74910c 100644--- a/frontend/src/scenes/onboarding/legacy/stepProviderRegistry.test.ts+++ b/frontend/src/scenes/onboarding/legacy/stepProviderRegistry.test.ts@@ -16,7 +16,6 @@ function context(primary: ProductKey): OnboardingFlowContext {subscribedDuringOnboarding: false,canInviteTeammates: true,featureFlags: {},- showAIReportsStep: false,}}diff --git a/frontend/src/scenes/onboarding/legacy/types.ts b/frontend/src/scenes/onboarding/legacy/types.tsindex 15c9776431de..94b430eae595 100644--- a/frontend/src/scenes/onboarding/legacy/types.ts+++ b/frontend/src/scenes/onboarding/legacy/types.ts@@ -70,8 +70,6 @@ export interface OnboardingFlowContext {* via `featureFlagLogic.findMounted()` (an imperative read never re-fires the flow).*/featureFlags: FeatureFlagsSet- /** Experiment arm + AI-subscription availability — drives the trailing weekly-report step. */- showAIReportsStep: boolean}export type StepProvider = (ctx: OnboardingFlowContext) => OnboardingStepDescriptor[]diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex e52b5cb338f3..e1e4dc1b3e4d 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -8145,7 +8145,6 @@ export enum OnboardingStepKey {SOURCE_MAPS = 'source_maps',ALERTS = 'alerts',PATH_CLEANING = 'path_cleaning',- AI_REPORTS = 'ai_reports',}// Managed viewset