: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
import { MOCK_DEFAULT_USER } from 'lib/api.mock'
import { Meta, StoryFn } from '@storybook/react'
import { useMountedLogic } from 'kea'
import { useEffect } from 'react'
import { userLogic } from 'scenes/userLogic'
import { mswDecorator } from '~/mocks/browser'
import { OrganizationType, UserType } from '~/types'
import { WelcomeDialog } from './WelcomeDialog'
import { welcomeDialogLogic } from './welcomeDialogLogic'
const FULL_PAYLOAD = {
organization_name: 'Hedgebox Inc',
inviter: { name: 'Amelia', email: '[email protected]' },
team_members: [
{ name: 'Amelia', email: '[email protected]', avatar: null, role: 'Member', last_active: 'today' },
{ name: 'Jonas', email: '[email protected]', avatar: null, role: 'Member', last_active: 'today' },
{
name: 'Employee 427',
email: '[email protected]',
avatar: null,
role: 'Administrator',
last_active: 'this_week',
},
{ name: 'Linnea', email: '[email protected]', avatar: null, role: 'Member', last_active: 'inactive' },
],
recent_activity: [
{
type: 'FeatureFlag.created',
actor_name: 'Employee 427',
entity_name: 'onboarding-mobile-install-helper',
entity_url: '/project/1/feature_flags/123',
timestamp: new Date(Date.now() - 1000 * 60 * 60 * 2).toISOString(),
},
{
type: 'Dashboard.created',
actor_name: 'Employee 427',
entity_name: 'Generated Dashboard: toolbar-ai Usage',
entity_url: '/project/1/dashboard/42',
timestamp: new Date(Date.now() - 1000 * 60 * 60 * 5).toISOString(),
},
{
type: 'Experiment.created',
actor_name: 'Jonas',
entity_name: 'Pricing page CTA test',
entity_url: '/project/1/experiments/7',
timestamp: new Date(Date.now() - 1000 * 60 * 60 * 24).toISOString(),
},
{
type: 'Survey.created',
actor_name: 'Amelia',
entity_name: 'NPS Q1',
entity_url: '/project/1/surveys/3',
timestamp: new Date(Date.now() - 1000 * 60 * 60 * 24 * 3).toISOString(),
},
{
type: 'Insight.created',
actor_name: 'Linnea',
entity_name: 'Signups by week',
entity_url: '/project/1/insights/abc',
timestamp: new Date(Date.now() - 1000 * 60 * 60 * 24 * 5).toISOString(),
},
],
popular_dashboards: [
{
id: 1,
name: 'Key metrics',
description: 'Company overview.',
team_id: 1,
url: '/project/1/dashboard/1',
},
{
id: 2,
name: 'Generated Dashboard: toolbar-ai Usage',
description: 'This dashboard was generated by the feature flag with key (toolbar-ai)',
team_id: 1,
url: '/project/1/dashboard/2',
},
],
products_in_use: ['product_analytics', 'session_replay', 'feature_flags', 'experiments', 'surveys'],
suggested_next_steps: [
{
label: 'Watch a recent recording',
href: '/project/1/replay/home',
reason: 'Your team uses Session replay',
docs_href: 'https://posthog.com/docs/session-replay',
product_key: 'session_replay',
},
{
label: 'See active feature flags',
href: '/project/1/feature_flags',
reason: 'Your team uses Feature flags',
docs_href: 'https://posthog.com/docs/feature-flags',
product_key: 'feature_flags',
},
],
is_organization_first_user: false,
}
const EMPTY_PAYLOAD = {
organization_name: 'Brand-new Org',
inviter: null,
team_members: [],
recent_activity: [],
popular_dashboards: [],
products_in_use: [],
suggested_next_steps: [
{
label: 'Explore the project home',
href: '/',
reason: 'A good place to start',
docs_href: 'https://posthog.com/docs',
product_key: 'product_analytics',
},
],
is_organization_first_user: false,
}
// The dialog only opens in the first weeks of org membership, so join the day before `mockDate`.
const RECENTLY_JOINED_ORGANIZATION: OrganizationType = {
...MOCK_DEFAULT_USER.organization!,
membership_joined_at: '2026-04-16T00:00:00Z',
}
const INVITED_USER: UserType = {
...MOCK_DEFAULT_USER,
organization: RECENTLY_JOINED_ORGANIZATION,
first_name: 'Fern',
is_organization_first_user: false,
}
// A partner-provisioned account: no inviter (first org user), onboarding skipped as 'provisioned'.
const PROVISIONED_USER: UserType = {
...MOCK_DEFAULT_USER,
organization: RECENTLY_JOINED_ORGANIZATION,
first_name: 'Robin',
is_organization_first_user: true,
onboarding_skipped_reason: 'provisioned',
}
const meta: Meta = {
title: 'Scenes-Other/Welcome Dialog',
component: WelcomeDialog,
parameters: {
layout: 'fullscreen',
viewMode: 'story',
mockDate: '2026-04-17',
},
decorators: [
mswDecorator({
get: {
'/api/users/@me/': INVITED_USER,
},
}),
],
}
export default meta
function Template(): JSX.Element {
useMountedLogic(userLogic)
useEffect(() => {
// Force-mount the dialog logic so the story renders independent of the home page wrapper.
welcomeDialogLogic.mount()
}, [])
return <WelcomeDialog />
}
export const Default: StoryFn = () => <Template />
Default.decorators = [
mswDecorator({
get: { '/api/organizations/@current/welcome/current/': FULL_PAYLOAD },
}),
]
export const EmptyOrganization: StoryFn = () => <Template />
EmptyOrganization.decorators = [
mswDecorator({
get: { '/api/organizations/@current/welcome/current/': EMPTY_PAYLOAD },
}),
]
export const NoInviter: StoryFn = () => <Template />
NoInviter.decorators = [
mswDecorator({
get: { '/api/organizations/@current/welcome/current/': { ...FULL_PAYLOAD, inviter: null } },
}),
]
// Partner-provisioned account: the dialog leads with the flagship product tour (a different card
// order than invited users get).
function ProvisionedTemplate(): JSX.Element {
useMountedLogic(userLogic)
useEffect(() => {
welcomeDialogLogic.mount()
}, [])
return <WelcomeDialog />
}
export const Provisioned: StoryFn = () => <ProvisionedTemplate />
Provisioned.decorators = [
mswDecorator({
get: {
'/api/users/@me/': PROVISIONED_USER,
'/api/organizations/@current/welcome/current/': { ...FULL_PAYLOAD, inviter: null },
},
}),
]