: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): explain github access in an onboarding popover (#129430)
Mikayla Thompsonf50cb547075a
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex e6aaffb8431b..869b5da5c872 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -12494,6 +12494,10 @@ snapshots:hash: v1.k794b7964.e0f8ccaf099a26d2c9e5a01759d4335c4f3874920c0cc87629cc18c08f2a186d.lnU6n7PM5IpNBHL67GnkE0i4bNWz6D-LrnJ4FsPH15Iscenes-app-inbox-focused-setup--github-optional--light:hash: v1.k794b7964.ebc3621a8d2898cd4e684d6c38a53231543158f2463b72e1564526f85c663ff6.4ETAHoDCK1k-fG_TyUe7a67SitYAcFPIi7VBfxuwHM8+ scenes-app-inbox-focused-setup--github-with-access-explanation--dark:+ hash: v1.k794b7964.24b17cd83be424daec8534b58b6591674485f369d228db934a9d5c429a5de947.lZIRbQ66gvG-t6CjV9m_p8Fu0h7RBHI0DYh6b0EwIMU+ scenes-app-inbox-focused-setup--github-with-access-explanation--light:+ hash: v1.k794b7964.67f721146a39a1354ec52ff5ee7bdb8202b54cbde999fc5b129416de26748cc4.atNPB2sNVhCSG3mdhWLmfTCt1aivg9rImZvCHmU6J20scenes-app-inbox-focused-setup--github-without-automatic-implementation--dark:hash: v1.k794b7964.81248bc9725853d60f6abaa48b7dfd3da16e12b2a0737dc24e9528ce6bc7f92b.obY1rKohrnBvh71Ep3wJZzs8J56ZUo98dlJDXlzwj-Escenes-app-inbox-focused-setup--github-without-automatic-implementation--light:@@ -12530,6 +12534,10 @@ snapshots:hash: v1.k794b7964.94d4d56e6f378ac1850c7e09331a0fb870bb597ac292bbd40892c6e4ff5d4d04.03SQ74HJv_m8omrJAVReZf42a6uESkf5H7X2vpipDNkscenes-app-inbox-focused-setup--quick-entry--light:hash: v1.k794b7964.0ac93666c22ddf7eb27f107e4beef5f9aa5d09c47c44400f90e89259a03a614d.NGCt5LoiAK7ZJ9ic7mJL4RCKMiugT4aRNdRhr6PTrEE+ scenes-app-inbox-focused-setup--quick-entry-with-github-access-explanation--dark:+ hash: v1.k794b7964.c0bfa77fd2b9a82c9b3816a0a6ef3c4f23e85992a0f61cccf32c1b74bd81cd34.cXAnxksUBN-V48atEibmiEZt-IjAxqdQZWOplQjolP0+ scenes-app-inbox-focused-setup--quick-entry-with-github-access-explanation--light:+ hash: v1.k794b7964.2f4846be4a8ec30b104e38f605c7b9fbbf24cf8973f2ae6b19f388dfa9a4be6a.Kx-LNWSEQLurzR6DIKSgX1MKeCMnOkavH2CPP4DemGoscenes-app-inbox-focused-setup--scouts--dark:hash: v1.k794b7964.6fd8aa35755ed0ad8bfdee5e82fd3ae4bb2b66b185c5ad8ce8762291e9242c81.EseOEIZLSBk_G1Dlr44lR9ulG4RFO6cCcKKY8bCOLH4scenes-app-inbox-focused-setup--scouts--light:diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsxindex 31eede46f9ac..852e823777ca 100644--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx@@ -1,8 +1,6 @@import { useActions, useValues } from 'kea'import { useEffect } from 'react'-import { IconBook, IconGear } from '@posthog/icons'-import { AccessControlAction } from 'lib/components/AccessControlAction'import { TerminalCard } from 'lib/components/CommandBlock/TerminalCard'import { RestrictionScope, useRestrictedArea } from 'lib/components/RestrictedArea'@@ -13,6 +11,7 @@ import { cn } from 'lib/utils/css-classes'import { useWizardCommand } from 'scenes/onboarding/shared/useWizardCommand'import { teamLogic } from 'scenes/teamLogic'+import { ProductEmptyStateFooter } from './ProductEmptyStateFooter'import { productSetupStatusLogic } from './productSetupStatusLogic'import type {ProductEmptyStateConfig,@@ -275,43 +274,14 @@ export function ProductEmptyState({ config: baseConfig, mode, preview = false }:{config.statusIndicator ? <div className="text-xs">{config.statusIndicator}</div> : null}- <div className="flex flex-wrap items-center gap-x-4 gap-y-2">- {showWizard && !primaryActionButton && !config.PrimaryAction && manualUrl ? (- <LemonButton- type="secondary"- icon={<IconGear />}- to={manualUrl}- targetBlank- onClick={() => captureClick('manual setup clicked')}- data-attr="product-empty-state-manual-setup"- >- Configure manually- </LemonButton>- ) : null}- {config.docsUrl ? (- <LemonButton- size="xsmall"- type="tertiary"- icon={<IconBook />}- to={config.docsUrl}- targetBlank- onClick={() => captureClick('docs clicked')}- data-attr="product-empty-state-docs"- >- Read the docs- </LemonButton>- ) : null}- {config.skippable !== false ? (- <LemonButton- size="xsmall"- type="tertiary"- onClick={skipEmptyState}- data-attr="product-empty-state-skip"- >- Skip for now- </LemonButton>- ) : null}- </div>+ <ProductEmptyStateFooter+ config={config}+ manualSetupUrl={manualUrl}+ showManualSetup={showWizard && !primaryActionButton && !config.PrimaryAction}+ onManualSetup={() => captureClick('manual setup clicked')}+ onDocs={() => captureClick('docs clicked')}+ onSkip={skipEmptyState}+ /></div></div>diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateFooter.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateFooter.tsxnew file mode 100644index 000000000000..2c4571b98a07--- /dev/null+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateFooter.tsx@@ -0,0 +1,62 @@+import { IconBook, IconGear } from '@posthog/icons'++import { LemonButton } from 'lib/lemon-ui/LemonButton'++import type { ProductEmptyStateConfig } from './types'++export function ProductEmptyStateFooter({+ config,+ manualSetupUrl,+ showManualSetup,+ onManualSetup,+ onDocs,+ onSkip,+}: {+ config: ProductEmptyStateConfig+ manualSetupUrl: string | undefined+ showManualSetup: boolean+ onManualSetup: () => void+ onDocs: () => void+ onSkip: () => void+}): JSX.Element {+ const links = (+ <>+ {showManualSetup && manualSetupUrl ? (+ <LemonButton+ type="secondary"+ icon={<IconGear />}+ to={manualSetupUrl}+ targetBlank+ onClick={onManualSetup}+ data-attr="product-empty-state-manual-setup"+ >+ Configure manually+ </LemonButton>+ ) : null}+ {config.docsUrl ? (+ <LemonButton+ size="xsmall"+ type="tertiary"+ icon={<IconBook />}+ to={config.docsUrl}+ targetBlank+ onClick={onDocs}+ data-attr="product-empty-state-docs"+ >+ Read the docs+ </LemonButton>+ ) : null}+ {config.skippable !== false ? (+ <LemonButton size="xsmall" type="tertiary" onClick={onSkip} data-attr="product-empty-state-skip">+ Skip for now+ </LemonButton>+ ) : null}+ </>+ )++ return (+ <div className="flex flex-wrap items-center gap-x-4 gap-y-2">+ {config.FooterActions ? <config.FooterActions>{links}</config.FooterActions> : links}+ </div>+ )+}diff --git a/frontend/src/lib/components/ProductEmptyState/README.md b/frontend/src/lib/components/ProductEmptyState/README.mdindex face0a5e7ff2..1ddddf1073be 100644--- a/frontend/src/lib/components/ProductEmptyState/README.md+++ b/frontend/src/lib/components/ProductEmptyState/README.md@@ -12,6 +12,8 @@ Products detectable from event definitions also declare a `setupProbe` in theirTo review an empty state on a project that already has data, add `?empty_state=1` to the scene URL. It forces the `needs-setup` screen past detection and past a local skip, `?empty_state=waiting-for-data` forces the other mode, and dropping the param gives the real scene back. Use it for design review and screenshots instead of clearing a project.+Products can provide a `FooterActions` component for contextual help beside "Read the docs". It receives the standard footer links as `children` so it can place help on either side, and can use the product's own hooks to control visibility. Always render `children`, including when the contextual help is hidden.+**To adopt this for your product, follow the `building-product-empty-states` skill** (`.agents/skills/building-product-empty-states/SKILL.md`). Reference adoption: `products/mcp_analytics/frontend/emptyState/`.## ProductEmptyState or ProductIntroduction?diff --git a/frontend/src/lib/components/ProductEmptyState/types.ts b/frontend/src/lib/components/ProductEmptyState/types.tsindex 2a27d1a970d7..cad172d63ea5 100644--- a/frontend/src/lib/components/ProductEmptyState/types.ts+++ b/frontend/src/lib/components/ProductEmptyState/types.ts@@ -144,6 +144,7 @@ export interface ProductEmptyStateConfig {PrimaryAction?: ComponentType/** Product-specific installation options below the primary setup action. */SetupActions?: ComponentType<{ mode: ProductEmptyStateMode; preview: boolean }>+ FooterActions?: ComponentType<{ children: ReactNode }>docsUrl?: string/** Target of the small "Or configure manually" link; falls back to `docsUrl` */manualSetupUrl?: stringdiff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 340bc497db1e..4fa637cf8e08 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -222,6 +222,7 @@ export const FEATURE_FLAGS = {SCOUTS_MODEL_CONFIG: 'scouts-model-config', // owner: #team-self-driving, gates the per-scout model pin in the inbox scout settings (also checked server-side)SCOUTS_TOOL_ACCESS: 'scouts-tool-access', // owner: #team-self-driving, gates the per-scout MCP tool list in the inbox scout settings (also checked server-side)SELF_DRIVING_FREE_TRIAL: 'self-driving-free-trial', // owner: #team-self-driving, the org is on a Self-driving free trial: reports only, no pull requests (also checked server-side)+ SELF_DRIVING_GITHUB_ACCESS_EXPLANATION: 'self-driving-github-access-explanation',SELF_DRIVING_GITHUB_OPTIONAL: 'self-driving-github-optional',SELF_DRIVING_QUOTA_ENFORCEMENT: 'self-driving-quota-enforcement', // owner: #team-self-driving, gates self-driving PR-limit enforcement (also checked server-side)SELF_DRIVING_UBP: 'self-driving-ubp', // owner: #team-self-drivingdiff --git a/products/signals/frontend/inbox/components/onboarding/InboxGithubAccessExplanation.tsx b/products/signals/frontend/inbox/components/onboarding/InboxGithubAccessExplanation.tsxnew file mode 100644index 000000000000..301d8d4dd56a--- /dev/null+++ b/products/signals/frontend/inbox/components/onboarding/InboxGithubAccessExplanation.tsx@@ -0,0 +1,127 @@+import { useValues } from 'kea'+import { type ReactNode, useCallback, useId, useRef, useState } from 'react'++import { IconLock, IconQuestion, IconX } from '@posthog/icons'+import { LemonButton, Popover } from '@posthog/lemon-ui'++import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'++import { inboxSetupLogic } from '../../logics/inboxSetupLogic'++export function InboxGithubAccessExplanation({ children }: { children?: ReactNode }): JSX.Element {+ const { featureFlags } = useValues(featureFlagLogic)+ const { hasGithubIntegration, isGithubOptionalSetup } = useValues(inboxSetupLogic)+ const [visible, setVisible] = useState(false)+ const triggerRef = useRef<HTMLButtonElement>(null)+ const contentId = useId()+ const focusContent = useCallback((element: HTMLDivElement | null) => {+ element?.focus({ preventScroll: true })+ }, [])++ if (+ hasGithubIntegration ||+ isGithubOptionalSetup ||+ featureFlags[FEATURE_FLAGS.SELF_DRIVING_GITHUB_ACCESS_EXPLANATION] !== 'test'+ ) {+ return <>{children}</>+ }++ return (+ <>+ <Popover+ visible={visible}+ placement="bottom-start"+ padded={false}+ onClickOutside={(event) => {+ setVisible(false)+ if (event.type === 'keydown') {+ triggerRef.current?.focus({ preventScroll: true })+ }+ }}+ overlay={+ <div+ id={contentId}+ ref={focusContent}+ role="dialog"+ aria-label="Why do we ask for GitHub access?"+ tabIndex={-1}+ className="flex w-128 max-w-full flex-col gap-3 p-4 text-sm text-secondary"+ >+ <div className="flex items-start justify-between gap-3">+ <p className="m-0 font-semibold text-default">+ We use GitHub access to research issues and may automatically open pull requests with+ proposed fixes.+ </p>+ <LemonButton+ size="xsmall"+ type="tertiary"+ icon={<IconX />}+ aria-label="Close GitHub access explanation"+ data-attr="inbox-github-access-explanation-close"+ onClick={() => {+ setVisible(false)+ triggerRef.current?.focus({ preventScroll: true })+ }}+ />+ </div>+ <ul className="m-0 list-none space-y-3 p-0">+ <li>+ <h4 className="m-0 text-sm font-semibold text-default">Find root causes</h4>+ <p className="m-0">+ Code access allows us to accurately identify root causes by comparing the behavior+ we see in your product with its implementation.+ </p>+ </li>+ <li>+ <h4 className="m-0 text-sm font-semibold text-default">Find the change behind a bug</h4>+ <p className="m-0">+ Code history allows us to correlate changes in behavior with changes in the code.+ Our reports are more useful if we can point to a specific PR that may have+ introduced a user-affecting bug.+ </p>+ </li>+ <li>+ <h4 className="m-0 text-sm font-semibold text-default">Reach the right people</h4>+ <p className="m-0">+ GitHub commit history lets us assign reports more accurately because we can tell+ which team members care about an issue.+ </p>+ </li>+ <li>+ <h4 className="m-0 text-sm font-semibold text-default">Automatic fixes</h4>+ <p className="m-0">We can open PRs to fix issues we've researched automatically.</p>+ </li>+ </ul>+ </div>+ }+ >+ <LemonButton+ ref={triggerRef}+ size="xsmall"+ type="tertiary"+ icon={<IconQuestion />}+ sideIcon={null}+ aria-haspopup="dialog"+ aria-expanded={visible}+ aria-controls={visible ? contentId : undefined}+ data-attr="inbox-github-access-explanation"+ onClick={() => setVisible(!visible)}+ >+ Why GitHub access?+ </LemonButton>+ </Popover>+ {children}+ <LemonButton+ size="xsmall"+ type="tertiary"+ icon={<IconLock />}+ to="https://posthog.com/docs/self-driving/security"+ targetBlank+ data-attr="inbox-github-access-security"+ >+ Security+ </LemonButton>+ </>+ )+}diff --git a/products/signals/frontend/inbox/components/onboarding/InboxSetupEmptyState.tsx b/products/signals/frontend/inbox/components/onboarding/InboxSetupEmptyState.tsxindex 83daf5cf6921..9ae439e994e8 100644--- a/products/signals/frontend/inbox/components/onboarding/InboxSetupEmptyState.tsx+++ b/products/signals/frontend/inbox/components/onboarding/InboxSetupEmptyState.tsx@@ -7,6 +7,7 @@ import { IconSelfDriving } from 'lib/lemon-ui/icons'import { ProductKey } from '~/queries/schema/schema-general'+import { InboxGithubAccessExplanation } from './InboxGithubAccessExplanation'import { InboxReportPreview } from './InboxReportPreview'import { InboxSetupActions } from './InboxSetupActions'@@ -27,6 +28,7 @@ const INBOX_SETUP_EMPTY_STATE: ProductEmptyStateConfig = {},},PrimaryAction: InboxSetupActions,+ FooterActions: InboxGithubAccessExplanation,docsUrl: 'https://posthog.com/docs/self-driving',previewLabel: 'Example report',previewClassName: 'items-center [&>*]:w-full [&>*]:max-w-120',diff --git a/products/signals/frontend/inbox/components/onboarding/InboxSetupFlow.stories.tsx b/products/signals/frontend/inbox/components/onboarding/InboxSetupFlow.stories.tsxindex af9b7cd808e7..58d47dc578eb 100644--- a/products/signals/frontend/inbox/components/onboarding/InboxSetupFlow.stories.tsx+++ b/products/signals/frontend/inbox/components/onboarding/InboxSetupFlow.stories.tsx@@ -1,14 +1,14 @@import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'import type { Meta, StoryObj } from '@storybook/react'-import { waitFor } from '@testing-library/dom'+import { waitFor, within } from '@testing-library/dom'import { useValues } from 'kea'import { FEATURE_FLAGS, TeamMembershipLevel } from 'lib/constants'import { mswDecorator, useStorybookMocks } from '~/mocks/browser'-import { expect } from 'storybook/test'+import { expect, userEvent } from 'storybook/test'import type { InboxOnboardingDraftApi } from '../../../generated/api.schemas'import { mockScoutSuggestionSet, mockScoutConfigs } from '../../__mocks__/scoutConfigs'@@ -345,6 +345,39 @@ export const QuickEntry = {],} satisfies Story+export const QuickEntryWithGithubAccessExplanation: Story = {+ ...QuickEntry,+ name: 'Welcome with GitHub access explanation',+ parameters: {+ featureFlags: { [FEATURE_FLAGS.SELF_DRIVING_GITHUB_ACCESS_EXPLANATION]: 'test' },+ },+ play: async ({ canvas }) => {+ const explanation = await canvas.findByText('Why GitHub access?')+ const controls = [+ explanation,+ canvas.getByText('Connect GitHub'),+ canvas.queryByText('Start manually'),+ canvas.queryByText('Read the docs'),+ ].filter((element): element is HTMLElement => element !== null)+ const positions = controls.map((element) => element.getBoundingClientRect().y)+ await userEvent.click(explanation)+ const accessSummary = await within(document.body).findByText(+ 'We use GitHub access to research issues and may automatically open pull requests with proposed fixes.'+ )+ await waitFor(() => expect(accessSummary).toBeVisible())+ controls.forEach((element, index) => {+ expect(element.getBoundingClientRect().y).toBe(positions[index])+ })+ },+}++export const GithubWithAccessExplanation: Story = {+ ...Github,+ name: 'Review with GitHub access explanation',+ parameters: QuickEntryWithGithubAccessExplanation.parameters,+ play: QuickEntryWithGithubAccessExplanation.play,+}+export const NarrowWelcomeEntry: Story = {...QuickEntry,name: 'Narrow welcome',diff --git a/products/signals/frontend/inbox/components/onboarding/InboxSetupGithubStep.tsx b/products/signals/frontend/inbox/components/onboarding/InboxSetupGithubStep.tsxindex 09e472f7c0df..b0b1d74202ac 100644--- a/products/signals/frontend/inbox/components/onboarding/InboxSetupGithubStep.tsx+++ b/products/signals/frontend/inbox/components/onboarding/InboxSetupGithubStep.tsx@@ -10,6 +10,7 @@ import { IntegrationAccessRequest } from 'scenes/integrations/components/Integraimport { urls } from 'scenes/urls'import { inboxSetupLogic } from '../../logics/inboxSetupLogic'+import { InboxGithubAccessExplanation } from './InboxGithubAccessExplanation'import { InboxSetupImplementation } from './InboxSetupImplementation'export function InboxSetupGithubStep(): JSX.Element {@@ -43,6 +44,11 @@ export function InboxSetupGithubStep(): JSX.Element {/>)}</GuidedWizardSection>+ {!hasGithubIntegration && (+ <div className="flex flex-wrap items-center gap-x-4 gap-y-2 empty:hidden">+ <InboxGithubAccessExplanation />+ </div>+ )}{featureFlags[FEATURE_FLAGS.SELF_DRIVING_UBP] && <InboxSetupImplementation />}</>)