: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(signals): open a self-driving intro modal from the Code badge (#92966)
Rafael Audibert019cd3d374b1
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex f80dbea1d0f2..25f7a275ac71 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -5540,6 +5540,10 @@ snapshots:hash: v1.k794b7964.c4ebc83f695831769cc95475925e983a71d5909636818ff2153e2dc7df5450a1.9VcSQPoSe9fMttmpga5INPhkJySlhF35v8dHEs52L90products-posthog-ai-virtualizedthread--streaming--light:hash: v1.k794b7964.e731151aea72bc9d5f4248dd2548e03fe07336fb29b2110d1e348020985ef9d1.NMSw9HS1VJuLZsmgp29MVPo708vTot8RLCqFv8IC7RQ+ products-signals-self-driving-intro-modal--default--dark:+ hash: v1.k794b7964.e72031a3a874ed6a1825089edff6147a3ea0d74c20c74951f8b5d38d92f54464.WQmsYZby7Raw1OaQn_oKtu1eASs_te6AgRALWXM6xLE+ products-signals-self-driving-intro-modal--default--light:+ hash: v1.k794b7964.602b1235812b95a5a5e1b8394fcb0bf613698958302c0d8555e89c587e258c36.00YN2IU5qnM8hUXbxAhMv5wX7Hiwrxw4vYXXOWKu1Isproducts-subscriptions-subscription-delivery-history--empty--dark:hash: v1.k794b7964.267363ce3a0453be58b96ef2c00446ae4aaf5ed42b02472c495b3c468f25e18f.PjabhWWV-dc6vzuSl_wdoaQ2VAB35IG84kOVKe5eaA4products-subscriptions-subscription-delivery-history--empty--light:diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 7e1aff37dc89..e6126f598429 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -283,6 +283,7 @@ export const FEATURE_FLAGS = {CDP_PERSON_UPDATES: 'cdp-person-updates', // owner: #team-workflows-cdpCDP_VERCEL_LOG_DRAIN: 'cdp-vercel-log-drain', // owner: #team-workflows-cdpCLEARABLE_NOTIFICATIONS: 'clearable-notifications', // owner: @jordanm-posthog #team-web-analytics+ CODE_BADGE_SELF_DRIVING_LABEL: 'code-badge-self-driving-label', // owner: #team-self-driving, experiment: label the Code badge "Self-driving" and compare setup activationsCOHORT_INLINE_CALCULATION: 'inline-cohort-calculation', // owner: #team-analytics-platform, inlines fast dynamic cohort queries instead of using precomputed cohortpeople tableCOHORTS_TAXONOMIC_BASIC_LIST: 'cohorts-taxonomic-basic-list', // owner: @adamleith, picker sends ?basic=true to the cohorts list endpoint (trimmed payload: no query/groups/last_error_message/experiment_set; filters is kept)CONDENSED_FILTER_BAR: 'condensed_filter_bar', // owner: @jordanm-posthog #team-web-analyticsdiff --git a/frontend/src/scenes/max/components/TopicBadges.tsx b/frontend/src/scenes/max/components/TopicBadges.tsxindex c881557237c9..42a50632759d 100644--- a/frontend/src/scenes/max/components/TopicBadges.tsx+++ b/frontend/src/scenes/max/components/TopicBadges.tsx@@ -1,14 +1,19 @@-import { useEffect, useRef } from 'react'+import { useValues } from 'kea'+import { useEffect, useRef, useState } from 'react'import { IconCode } from '@posthog/icons'import { LemonButton, LemonTag } from '@posthog/lemon-ui'+import { FEATURE_FLAGS } from 'lib/constants'import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { cn } from 'lib/utils/css-classes'import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'import { FileSystemIconType } from '~/queries/schema/schema-general'+import { SelfDrivingIntroModal } from 'products/signals/frontend/inbox/components/onboarding/SelfDrivingIntroModal'+import { CODE_BADGE, SuggestionTopic, TopicSuggestion } from '../suggestionTopics'import { nextTypingDelayMs } from '../utils/typing'import { SuggestionCard } from './SuggestionCard'@@ -40,6 +45,17 @@ export interface TopicBadgesProps {/** Row of PostHog AI topic badges (+ the Desktop beta badge). Selection is owned by the parent. */export function TopicBadges({ topics, selectedKey, onSelect, className }: TopicBadgesProps): JSX.Element | null {const isProductAutonomyEnabled = useFeatureFlag('PRODUCT_AUTONOMY')+ const { featureFlags } = useValues(featureFlagLogic)+ // Intro-modal visibility is pure view state, so it stays local instead of in a logic+ const [codeIntroOpen, setCodeIntroOpen] = useState(false)++ // Experiment: does labeling the badge by outcome beat the neutral "Code" for self-driving+ // setup? Short-circuit on the autonomy gate so the flag (and its exposure event) is only+ // evaluated for users who actually see the badge.+ const codeBadgeLabel =+ isProductAutonomyEnabled && featureFlags[FEATURE_FLAGS.CODE_BADGE_SELF_DRIVING_LABEL] === 'self-driving'+ ? 'Self-driving'+ : CODE_BADGE.labelif (!topics.length) {return null@@ -68,20 +84,24 @@ export function TopicBadges({ topics, selectedKey, onSelect, className }: TopicB))}{isProductAutonomyEnabled && (- <LemonButton- size="small"- type="secondary"- to={CODE_BADGE.to}- icon={<IconCode />}- data-attr="capability-badge-code"- >- <span className="flex items-center gap-1.5">- {CODE_BADGE.label}- <LemonTag type="warning" size="small">- Beta- </LemonTag>- </span>- </LemonButton>+ <>+ <LemonButton+ size="small"+ type="secondary"+ onClick={() => setCodeIntroOpen(true)}+ icon={<IconCode />}+ data-attr="capability-badge-code"+ >+ <span className="flex items-center gap-1.5">+ {codeBadgeLabel}+ <LemonTag type="warning" size="small">+ Beta+ </LemonTag>+ </span>+ </LemonButton>++ <SelfDrivingIntroModal isOpen={codeIntroOpen} onClose={() => setCodeIntroOpen(false)} />+ </>)}</div>)diff --git a/frontend/src/scenes/max/suggestionTopics.tsx b/frontend/src/scenes/max/suggestionTopics.tsxindex 06c5e339b61f..f732cf76d2de 100644--- a/frontend/src/scenes/max/suggestionTopics.tsx+++ b/frontend/src/scenes/max/suggestionTopics.tsx@@ -1,7 +1,5 @@import { IconBook } from '@posthog/icons'-import { urls } from 'scenes/urls'-import { FileSystemIconType } from '~/queries/schema/schema-general'/** One suggestion inside a topic. `content` is the prompt sent to PostHog AI. */@@ -41,18 +39,17 @@ export interface SuggestionTopic {suggestions: TopicSuggestion[]}-/** Shared across both experiment arms — routes to the PostHog Desktop beta in the inbox. */+/** The Code badge rendered next to the topics; opens the self-driving intro modal. */export const CODE_BADGE = {key: 'code',label: 'Code',- to: urls.inbox(),beta: true as const,}/**- * A few docs prompts included in every arm so newcomers can learn about PostHog. The sidebar- * renders these as a plain question list (docs variant), matching the Docs suggestions we show- * in production; the homepage suggestion cards use the title/description pair instead.+ * A few docs prompts so newcomers can learn about PostHog. The sidebar renders these as a+ * plain question list (docs variant), matching the Docs suggestions we show in production;+ * the homepage suggestion cards use the title/description pair instead.*/const LEARN_TOPIC: SuggestionTopic = {key: 'learn',diff --git a/products/signals/frontend/inbox/components/onboarding/InboxWelcome.tsx b/products/signals/frontend/inbox/components/onboarding/InboxWelcome.tsxindex 063ad83e8e89..34cba717321a 100644--- a/products/signals/frontend/inbox/components/onboarding/InboxWelcome.tsx+++ b/products/signals/frontend/inbox/components/onboarding/InboxWelcome.tsx@@ -4,13 +4,12 @@ import { useActions, useMountedLogic, useValues } from 'kea'import { combineUrl } from 'kea-router'import { useEffect, useRef, useState } from 'react'-import { IconCheck, IconRewindPlay, IconWarning } from '@posthog/icons'-import { LemonButton, LemonCard, LemonSkeleton, LemonTag } from '@posthog/lemon-ui'+import { IconCheck } from '@posthog/icons'+import { LemonButton, LemonSkeleton, LemonTag } from '@posthog/lemon-ui'import { Logomark } from 'lib/brand'import { FEATURE_FLAGS } from 'lib/constants'import { integrationsLogic } from 'lib/integrations/integrationsLogic'-import { IconSlack } from 'lib/lemon-ui/icons'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { copyToClipboard } from 'lib/utils/copyToClipboard'import { GithubIntegration } from 'scenes/integrations/components/GithubIntegration'@@ -18,6 +17,7 @@ import { urls } from 'scenes/urls'import { captureInboxWelcomeCommandCopied, captureInboxWelcomeViewed } from '../../inboxAnalytics'import { inboxOnboardingLogic } from '../../logics/inboxOnboardingLogic'+import { LoopDiagram } from './LoopDiagram'/** The one command that sets up self-driving. The whole onboarding orbits this string. */export const SELF_DRIVING_WIZARD_COMMAND = 'npx -y @posthog/wizard@latest self-driving'@@ -134,108 +134,6 @@ function ManualSetupAction(): JSX.Element {)}-function StageLabel({ children }: { children: string }): JSX.Element {- return <div className="text-center text-xs font-semibold text-secondary">{children}</div>-}--/** A card in the loop diagram, lighting up at its stage's moment in the 9s sequence. */-function StageCard({- stage,- className,- children,-}: {- stage: 'signals' | 'pipeline' | 'inbox'- className?: string- children: React.ReactNode-}): JSX.Element {- return (- <LemonCard- hoverEffect={false}- className={`InboxWelcome__stage InboxWelcome__stage--${stage} ${className ?? ''}`}- >- {children}- </LemonCard>- )-}--function Arrow({ second = false }: { second?: boolean }): JSX.Element {- return (- <div- className={`InboxWelcome__arrow ${- second ? 'InboxWelcome__arrow--second ' : ''- }hidden pt-5 text-center text-2xl text-border-secondary md:block`}- aria-hidden="true"- >- →- </div>- )-}--/**- * The illustrative loop: signal sources -> scouts & pipeline -> a PR in your inbox. Never interactive- * (pointer-events-none on the whole grid); the cards and the Review button are props, not UI.- */-function LoopDiagram(): JSX.Element {- return (- <div className="pointer-events-none select-none grid grid-cols-1 items-center gap-x-1.5 gap-y-4 md:grid-cols-[1fr_34px_1fr_34px_1.2fr]">- <div className="flex flex-col gap-2">- <StageLabel>Signal sources</StageLabel>- <StageCard stage="signals" className="flex items-center gap-2 px-3 py-2.5">- <span className="flex size-5 shrink-0 items-center justify-center">- <IconRewindPlay className="text-sm text-[var(--color-product-session-replay-light)] dark:text-[var(--color-product-session-replay-dark)]" />- </span>- <span className="truncate text-xs">Rage clicks in checkout replay</span>- </StageCard>- <StageCard stage="signals" className="flex items-center gap-2 px-3 py-2.5">- <span className="flex size-5 shrink-0 items-center justify-center">- <IconWarning className="text-sm text-[var(--color-product-error-tracking-light)] dark:text-[var(--color-product-error-tracking-dark)]" />- </span>- <span className="truncate font-mono text-xs">TypeError in checkout</span>- </StageCard>- <StageCard stage="signals" className="flex items-center gap-2 px-3 py-2.5">- <span className="flex size-5 shrink-0 items-center justify-center">- <IconSlack className="size-4" />- </span>- <span className="truncate text-xs">"checkout hangs on Safari"</span>- </StageCard>- </div>- <Arrow />- <div className="flex flex-col gap-2">- <StageLabel>Scouts & pipeline</StageLabel>- <StageCard stage="pipeline" className="flex flex-col gap-1.5 px-3.5 py-3">- <div className="flex items-center gap-2 text-[13px] font-semibold">- <span className="size-[7px] shrink-0 rounded-full bg-success" />- Reproduced the bug, wrote the fix- </div>- <div className="flex items-center gap-2">- <span className="font-mono text-xs font-semibold text-success">+142</span>- <span className="font-mono text-xs font-semibold text-danger">−38</span>- <LemonTag type="success">Tests passing</LemonTag>- </div>- </StageCard>- </div>- <Arrow second />- <div className="flex flex-col gap-2">- <StageLabel>Your inbox</StageLabel>- <StageCard stage="inbox" className="flex items-center gap-2.5 px-3.5 py-3">- <span className="flex size-[26px] shrink-0 items-center justify-center rounded-md bg-fill-warning-highlight font-mono text-[11px] font-bold text-warning">- P1- </span>- <div className="flex min-w-0 flex-1 flex-col gap-0.5">- <div className="text-[13px] font-semibold">- <code>fix(checkout)</code> restore Safari encode- </div>- <div className="text-[11.5px] text-tertiary">#486 · ready to merge</div>- </div>- <LemonButton type="primary" size="small" className="shrink-0">- Review- </LemonButton>- </StageCard>- </div>- </div>- )-}-/*** Self-driving welcome takeover, shown when self-driving isn't set up and there's nothing in the* inbox yet. Leads with the payoff, makes the wizard command the one CTA, and explains signaldiff --git a/products/signals/frontend/inbox/components/onboarding/LoopDiagram.tsx b/products/signals/frontend/inbox/components/onboarding/LoopDiagram.tsxnew file mode 100644index 000000000000..527b1fcd9e10--- /dev/null+++ b/products/signals/frontend/inbox/components/onboarding/LoopDiagram.tsx@@ -0,0 +1,113 @@+// The stage/arrow animation classes live in InboxWelcome.scss, imported here too so the+// diagram animates wherever it renders (the welcome takeover and the intro modal).+import './InboxWelcome.scss'++import { IconRewindPlay, IconWarning } from '@posthog/icons'+import { LemonButton, LemonCard, LemonTag } from '@posthog/lemon-ui'++import { IconSlack } from 'lib/lemon-ui/icons'++function StageLabel({ children }: { children: string }): JSX.Element {+ return <div className="text-center text-xs font-semibold text-secondary">{children}</div>+}++/** A card in the loop diagram, lighting up at its stage's moment in the 9s sequence. */+function StageCard({+ stage,+ className,+ children,+}: {+ stage: 'signals' | 'pipeline' | 'inbox'+ className?: string+ children: React.ReactNode+}): JSX.Element {+ return (+ <LemonCard+ hoverEffect={false}+ className={`InboxWelcome__stage InboxWelcome__stage--${stage} ${className ?? ''}`}+ >+ {children}+ </LemonCard>+ )+}++function Arrow({ second = false }: { second?: boolean }): JSX.Element {+ return (+ <div+ className={`InboxWelcome__arrow ${+ second ? 'InboxWelcome__arrow--second ' : ''+ }hidden pt-5 text-center text-2xl text-border-secondary md:block`}+ aria-hidden="true"+ >+ →+ </div>+ )+}++/**+ * The illustrative loop: signal sources -> scouts & pipeline -> a PR in your inbox. Never interactive+ * (pointer-events-none on the whole grid); the cards and the Review button are props, not UI.+ */+export function LoopDiagram(): JSX.Element {+ return (+ // text-left so the mock UI stays left-aligned even inside a text-center hero (the intro modal)+ <div className="pointer-events-none select-none grid grid-cols-1 items-center gap-x-1.5 gap-y-4 text-left md:grid-cols-[1fr_34px_1fr_34px_1.2fr]">+ <div className="flex flex-col gap-2">+ <StageLabel>Signal sources</StageLabel>+ <StageCard stage="signals" className="flex items-center gap-2 px-3 py-2.5">+ <span className="flex size-5 shrink-0 items-center justify-center">+ <IconRewindPlay className="text-sm text-[var(--color-product-session-replay-light)] dark:text-[var(--color-product-session-replay-dark)]" />+ </span>+ <span className="truncate text-xs">Rage clicks in checkout replay</span>+ </StageCard>+ <StageCard stage="signals" className="flex items-center gap-2 px-3 py-2.5">+ <span className="flex size-5 shrink-0 items-center justify-center">+ <IconWarning className="text-sm text-[var(--color-product-error-tracking-light)] dark:text-[var(--color-product-error-tracking-dark)]" />+ </span>+ <span className="truncate font-mono text-xs">TypeError in checkout</span>+ </StageCard>+ <StageCard stage="signals" className="flex items-center gap-2 px-3 py-2.5">+ <span className="flex size-5 shrink-0 items-center justify-center">+ <IconSlack className="size-4" />+ </span>+ <span className="truncate text-xs">"checkout hangs on Safari"</span>+ </StageCard>+ </div>+ <Arrow />+ <div className="flex flex-col gap-2">+ <StageLabel>Scouts & pipeline</StageLabel>+ <StageCard stage="pipeline" className="flex flex-col gap-1.5 px-3.5 py-3">+ {/* items-start + margin keeps the dot on the first line when the text wraps+ in narrower hosts (the intro modal) instead of floating between lines */}+ <div className="flex items-start gap-2 text-[13px] font-semibold">+ <span className="mt-1.5 size-[7px] shrink-0 rounded-full bg-success" />+ <span className="min-w-0">Reproduced the bug, wrote the fix</span>+ </div>+ <div className="flex items-center gap-2">+ <span className="font-mono text-xs font-semibold text-success">+142</span>+ <span className="font-mono text-xs font-semibold text-danger">−38</span>+ <LemonTag type="success">Tests passing</LemonTag>+ </div>+ </StageCard>+ </div>+ <Arrow second />+ <div className="flex flex-col gap-2">+ <StageLabel>Your inbox</StageLabel>+ <StageCard stage="inbox" className="flex items-center gap-2.5 px-3.5 py-3">+ <span className="flex size-[26px] shrink-0 items-center justify-center rounded-md bg-fill-warning-highlight font-mono text-[11px] font-bold text-warning">+ P1+ </span>+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">+ <div className="text-[13px] font-semibold">+ <code>fix(checkout)</code> restore Safari encode+ </div>+ <div className="text-[11.5px] text-tertiary">#486 · ready to merge</div>+ </div>+ <LemonButton type="primary" size="small" className="shrink-0">+ Review+ </LemonButton>+ </StageCard>+ </div>+ </div>+ )+}diff --git a/products/signals/frontend/inbox/components/onboarding/SelfDrivingIntroModal.stories.tsx b/products/signals/frontend/inbox/components/onboarding/SelfDrivingIntroModal.stories.tsxnew file mode 100644index 000000000000..6b5e86c03f8f--- /dev/null+++ b/products/signals/frontend/inbox/components/onboarding/SelfDrivingIntroModal.stories.tsx@@ -0,0 +1,20 @@+import { Meta, StoryObj } from '@storybook/react'++import { SelfDrivingIntroModal } from './SelfDrivingIntroModal'++const meta: Meta<typeof SelfDrivingIntroModal> = {+ title: 'Products/Signals/Self-driving intro modal',+ component: SelfDrivingIntroModal,+ tags: ['autodocs'],+}+export default meta++type Story = StoryObj<typeof SelfDrivingIntroModal>++export const Default: Story = {+ args: {+ isOpen: true,+ inline: true,+ onClose: () => {},+ },+}diff --git a/products/signals/frontend/inbox/components/onboarding/SelfDrivingIntroModal.tsx b/products/signals/frontend/inbox/components/onboarding/SelfDrivingIntroModal.tsxnew file mode 100644index 000000000000..fe54f0cb3220--- /dev/null+++ b/products/signals/frontend/inbox/components/onboarding/SelfDrivingIntroModal.tsx@@ -0,0 +1,68 @@+import { useEffect } from 'react'++import { LemonButton, LemonModal } from '@posthog/lemon-ui'++import { Logomark } from 'lib/brand'+import { urls } from 'scenes/urls'++import { captureSelfDrivingIntroModalViewed } from '../../inboxAnalytics'+import { LoopDiagram } from './LoopDiagram'++export interface SelfDrivingIntroModalProps {+ isOpen: boolean+ onClose: () => void+ /** Render the modal content without the portal/overlay, for Storybook snapshots. */+ inline?: boolean+}++/**+ * A short introduction to self-driving, shown before sending someone to the inbox: the same+ * headline, explainer, and animated loop diagram as the inbox welcome takeover, with the setup+ * details left to the inbox itself.+ */+export function SelfDrivingIntroModal({ isOpen, onClose, inline }: SelfDrivingIntroModalProps): JSX.Element {+ useEffect(() => {+ if (isOpen) {+ captureSelfDrivingIntroModalViewed()+ }+ }, [isOpen])++ return (+ <LemonModal+ isOpen={isOpen}+ onClose={onClose}+ width={880}+ inline={inline}+ footer={+ <>+ <LemonButton type="secondary" onClick={onClose} data-attr="self-driving-intro-modal-dismiss">+ Maybe later+ </LemonButton>+ <LemonButton+ type="primary"+ to={urls.inbox()}+ onClick={onClose}+ data-attr="self-driving-intro-modal-open-inbox"+ >+ Open inbox+ </LemonButton>+ </>+ }+ >+ <div className="flex flex-col items-center py-4 text-center">+ <div className="mb-5">+ <Logomark size="xl" />+ </div>+ <h2 className="mb-3 text-2xl font-bold leading-[1.1] tracking-[-0.02em]">Ship fixes while you sleep</h2>+ <p className="mb-8 max-w-[560px] text-[15px] leading-[1.55] text-secondary">+ PostHog watches your session replays, errors, and Slack. When it finds something worth fixing, it+ writes the pull request. You review and merge.+ </p>+ <LoopDiagram />+ <p className="mt-6 text-xs text-tertiary">+ Your first 3 PRs each month are free, then $15 per PR. Reports are always free.+ </p>+ </div>+ </LemonModal>+ )+}diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.tsindex 75e5bf4bea90..2b22fcbfea98 100644--- a/products/signals/frontend/inbox/inboxAnalytics.ts+++ b/products/signals/frontend/inbox/inboxAnalytics.ts@@ -26,6 +26,7 @@ export const INBOX_EVENTS = {WELCOME_VIEWED: 'Inbox welcome viewed',WELCOME_COMMAND_COPIED: 'Inbox welcome command copied',WELCOME_MANUAL_SETUP_CLICKED: 'Inbox welcome manual setup clicked',+ INTRO_MODAL_VIEWED: 'Inbox intro modal viewed',PANEL_VIEWED: 'Inbox panel viewed',QUERY_CHANGED: 'Inbox query changed',REPORTS_IMPRESSED: 'Inbox reports impressed',@@ -286,6 +287,15 @@ export function captureInboxWelcomeManualSetupClicked(): void {captureInboxEvent(INBOX_EVENTS.WELCOME_MANUAL_SETUP_CLICKED, {})}+/**+ * The self-driving intro modal rendered (opened from the Code badge next to PostHog AI). The+ * click-through to the inbox is recoverable as this event followed by an inbox view in the same+ * session, so the modal only needs its own top-of-funnel marker.+ */+export function captureSelfDrivingIntroModalViewed(): void {+ captureInboxEvent(INBOX_EVENTS.INTRO_MODAL_VIEWED, {})+}+/*** The report list settled for the first time in a tab mount. `report_count` / `total_count` describe* the active tab's list only (and `report_count` is capped at the loaded page), so the headline