Skip to content

: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.

feat(self-driving): Add a flagged github-first onboarding option to self-driving (#91853)

Mikayla Thompson6cd54f555797
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 4e979d4fefa8..c34a0a023dc7 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -182,6 +182,7 @@ export const FEATURE_FLAGS = {
// UX flags, used to control the UX of the app
CREATE_BUTTON_NAV_EXPERIMENT: 'create-button-nav-experiment', // owner: #team-platform-ux multivariate=control,test — adds a Create dropdown to the top of the Browse tab in the left nav
+ GITHUB_FIRST_SELF_DRIVING_ONBOARDING: 'github-first-self-driving-onboarding', // owner: #team-self-driving
INBOX_SELF_DRIVING_EMPTY_STATE: 'inbox-self-driving-empty-state',
STARRED_REORDER: 'starred-reorder', // owner: #team-platform-ux, drag-and-drop reorder of starred shortcuts in the side panel
UX_HIDE_PROJECT_NOTICE: 'ux-hide-project-notice', // owner: #team-platform-ux, hides the project notice banner across all scenes
diff --git a/frontend/src/lib/integrations/GitHubInstallRequestsBanner.tsx b/frontend/src/lib/integrations/GitHubInstallRequestsBanner.tsx
index b380023b9200..7bbeb69b0550 100644
--- a/frontend/src/lib/integrations/GitHubInstallRequestsBanner.tsx
+++ b/frontend/src/lib/integrations/GitHubInstallRequestsBanner.tsx
@@ -1,6 +1,6 @@
import { useActions, useValues } from 'kea'
-import { LemonBanner, LemonButton } from '@posthog/lemon-ui'
+import { LemonBanner, LemonButton, Link } from '@posthog/lemon-ui'
import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { githubInstallRequestsLogic } from 'lib/integrations/githubInstallRequestsLogic'
@@ -19,11 +19,13 @@ export function buildOrgOwnerMessage(installUrl: string): string {
export function GitHubInstallRequestsBanner({
onFinishConnecting,
finishConnectingUrl,
+ variant = 'default',
}: {
/** Runs the surface's own connect flow once an owner has approved the install. */
onFinishConnecting?: () => void
/** Alternative to `onFinishConnecting` for surfaces whose connect is a plain link. */
finishConnectingUrl?: string
+ variant?: 'default' | 'onboarding'
}): JSX.Element | null {
const { pendingInstallRequests, approvedInstallRequests, installUrl, dismissingRequestIds } =
useValues(githubInstallRequestsLogic)
@@ -58,14 +60,16 @@ export function GitHubInstallRequestsBanner({
>
Finish connecting
</LemonButton>
- <LemonButton
- type="tertiary"
- size="small"
- loading={dismissingRequestIds.includes(request.id)}
- onClick={() => dismissInstallRequest(request.id)}
- >
- Dismiss
- </LemonButton>
+ {variant === 'default' ? (
+ <LemonButton
+ type="tertiary"
+ size="small"
+ loading={dismissingRequestIds.includes(request.id)}
+ onClick={() => dismissInstallRequest(request.id)}
+ >
+ Dismiss
+ </LemonButton>
+ ) : null}
</div>
</div>
</LemonBanner>
@@ -83,36 +87,47 @@ export function GitHubInstallRequestsBanner({
) : null}{' '}
to your organization owners. Once an owner approves the PostHog app, we'll finish connecting
here.
+ {variant === 'onboarding' && installUrl ? (
+ <>
+ {' '}
+ <Link to={installUrl} target="_blank">
+ Open the approval page
+ </Link>
+ .
+ </>
+ ) : null}
</span>
- {installUrl ? (
+ {variant === 'default' && installUrl ? (
<code className="text-xs whitespace-normal break-words">
{buildOrgOwnerMessage(installUrl)}
</code>
) : null}
- <div className="flex flex-wrap gap-2">
- {installUrl ? (
+ {variant === 'default' ? (
+ <div className="flex flex-wrap gap-2">
+ {installUrl ? (
+ <LemonButton
+ type="secondary"
+ size="small"
+ onClick={() =>
+ void copyToClipboard(
+ buildOrgOwnerMessage(installUrl),
+ 'message for your org owner'
+ )
+ }
+ >
+ Copy message for your org owner
+ </LemonButton>
+ ) : null}
<LemonButton
- type="secondary"
+ type="tertiary"
size="small"
- onClick={() =>
- void copyToClipboard(
- buildOrgOwnerMessage(installUrl),
- 'message for your org owner'
- )
- }
+ loading={dismissingRequestIds.includes(request.id)}
+ onClick={() => dismissInstallRequest(request.id)}
>
- Copy message for your org owner
+ Dismiss
</LemonButton>
- ) : null}
- <LemonButton
- type="tertiary"
- size="small"
- loading={dismissingRequestIds.includes(request.id)}
- onClick={() => dismissInstallRequest(request.id)}
- >
- Dismiss
- </LemonButton>
- </div>
+ </div>
+ ) : null}
</div>
</LemonBanner>
))}
diff --git a/frontend/src/lib/integrations/integrationsLogic.ts b/frontend/src/lib/integrations/integrationsLogic.ts
index 56f47b7e7139..5960260b0ef6 100644
--- a/frontend/src/lib/integrations/integrationsLogic.ts
+++ b/frontend/src/lib/integrations/integrationsLogic.ts
@@ -932,17 +932,14 @@ export const integrationsLogic = kea<integrationsLogicType>([
// When the org has more than one installation the caller passes the chosen
// installationId, since the backend can't auto-resolve between them.
linkExistingGithubInstallation: async (installationId?: string) => {
- try {
- const integration = await api.integrations.githubLinkExisting(
- installationId ? { installation_id: installationId } : {}
- )
- lemonToast.success('Linked the existing GitHub installation to this project.')
- actions.loadIntegrations()
- return integration
- } catch (e) {
- toastApiError(e)
- throw e
- }
+ // The global kea-loaders failure handler shows the API detail. Do not add a
+ // local toast here because the rejected loader would then show both messages.
+ const integration = await api.integrations.githubLinkExisting(
+ installationId ? { installation_id: installationId } : {}
+ )
+ lemonToast.success('Linked the existing GitHub installation to this project.')
+ actions.loadIntegrations()
+ return integration
},
},
],
diff --git a/frontend/src/lib/integrations/utils.ts b/frontend/src/lib/integrations/utils.ts
index 960a6ade1752..637cf8a5cebc 100644
--- a/frontend/src/lib/integrations/utils.ts
+++ b/frontend/src/lib/integrations/utils.ts
@@ -61,6 +61,7 @@ export type IntegrationConnectSurface =
| 'missing_scopes_reconnect'
| 'warehouse_source_reconnect'
| 'onboarding_wizard'
+ | 'inbox_welcome'
| 'signals_agent_setup'
| 'task_composer'
| 'visual_review_settings'
diff --git a/frontend/src/scenes/integrations/components/GithubIntegration.tsx b/frontend/src/scenes/integrations/components/GithubIntegration.tsx
index 6f5dacaea1f9..f3a9f9ead728 100644
--- a/frontend/src/scenes/integrations/components/GithubIntegration.tsx
+++ b/frontend/src/scenes/integrations/components/GithubIntegration.tsx
@@ -1,11 +1,12 @@
import { useActions, useValues } from 'kea'
-import { IconChevronDown } from '@posthog/icons'
+import { IconChevronDown, IconGithub } from '@posthog/icons'
import { LemonBanner, LemonButton, Link } from '@posthog/lemon-ui'
import api from 'lib/api'
import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { GitHubInstallRequestsBanner } from 'lib/integrations/GitHubInstallRequestsBanner'
+import { githubInstallRequestsLogic } from 'lib/integrations/githubInstallRequestsLogic'
import { integrationsLogic } from 'lib/integrations/integrationsLogic'
import type { IntegrationConnectSurface } from 'lib/integrations/utils'
import { LemonMenu } from 'lib/lemon-ui/LemonMenu'
@@ -20,8 +21,14 @@ import { Integration, useIntegrations } from './Integration'
export function GithubIntegration({
next,
connectSurface,
+ connectText = 'Connect account',
+ emphasizeConnect = false,
+ showPersonalConnectionHelp = true,
}: {
next?: string
+ connectText?: string
+ emphasizeConnect?: boolean
+ showPersonalConnectionHelp?: boolean
/**
* Where this card is rendered, reported as the `surface` on `integration_connect_clicked`.
* Omit it only on the OAuth landing page, which reports every kind's connect click itself —
@@ -35,6 +42,7 @@ export function GithubIntegration({
const { linkExistingGithubInstallation, loadGithubAvailableInstallations, startPolling, stopPolling } =
useActions(integrationsLogic)
const { reportIntegrationConnectClicked } = useActions(eventUsageLogic)
+ const { hasPendingInstallRequests } = useValues(githubInstallRequestsLogic)
const githubIntegrations = useIntegrations('github')
// integrationsLogic is a singleton mounted from dozens of unrelated surfaces, so this fetch
@@ -56,6 +64,7 @@ export function GithubIntegration({
const isConnected = githubIntegrations.length > 0
const canLinkExisting = !isConnected && installations.length > 0
const multipleInstallations = installations.length > 1
+ const installRequestInProgress = hasPendingInstallRequests
// Silent without `connectSurface`, because the only card rendered without one sits on the OAuth
// landing page, which already reports every kind's connect click for itself.
@@ -73,6 +82,7 @@ export function GithubIntegration({
<GitHubInstallRequestsBanner
finishConnectingUrl={authorizationUrl}
onFinishConnecting={() => reportConnect('install_approved_banner')}
+ variant={emphasizeConnect ? 'onboarding' : 'default'}
/>
{/* An install GitHub already has is the exception, not a second way to connect, so it
reads as an aside with its own action rather than a button competing with the one
@@ -93,6 +103,7 @@ export function GithubIntegration({
<GitHubInstallationLink
installations={installations}
loading={linkedGithubInstallationLoading}
+ emphasizeInstallation={emphasizeConnect}
onLink={(installationId) => {
// Reusing an existing install never leaves PostHog, so it's a
// connect that skips GitHub entirely — worth separating from the
@@ -105,32 +116,55 @@ export function GithubIntegration({
</div>
</LemonBanner>
)}
- <div className="flex flex-wrap gap-2">
- {/* This leaves PostHog entirely, and a GitHub App installs at most once per
- account, so GitHub offers install where it's missing and configure where it
- isn't. "Connect account" matches the Linear and Jira cards, which name the
- third party's container. */}
- <LemonButton
- type="secondary"
- disableClientSideRouting
- to={authorizationUrl}
- onClick={() => reportConnect(isConnected ? 'settings_manage' : undefined)}
- >
- {isConnected ? 'Manage on GitHub' : 'Connect account'}
- </LemonButton>
- </div>
+ {installRequestInProgress ? null : emphasizeConnect && !isConnected ? (
+ <div className="flex w-full flex-col items-center gap-4">
+ <div className="flex flex-wrap justify-center gap-2">
+ <LemonButton
+ type={canLinkExisting ? 'secondary' : 'primary'}
+ icon={<IconGithub />}
+ disableClientSideRouting
+ to={authorizationUrl}
+ onClick={() => reportConnect()}
+ >
+ {canLinkExisting ? 'Connect a different organization or repository' : connectText}
+ </LemonButton>
+ </div>
+ <p className="m-0 max-w-[520px] text-center text-[13px] text-tertiary">
+ PostHog uses GitHub to create reports and pull requests based on your code. After connecting
+ GitHub, you can run Wizard in the background to complete setup.
+ </p>
+ </div>
+ ) : (
+ <div className="flex flex-wrap gap-2">
+ {/* This leaves PostHog entirely, and a GitHub App installs at most once per
+ account, so GitHub offers install where it's missing and configure where it
+ isn't. "Connect account" matches the Linear and Jira cards, which name the
+ third party's container. */}
+ <LemonButton
+ type="secondary"
+ disableClientSideRouting
+ to={authorizationUrl}
+ onClick={() => reportConnect(isConnected ? 'settings_manage' : undefined)}
+ >
+ {isConnected ? 'Manage on GitHub' : connectText}
+ </LemonButton>
+ </div>
+ )}
{isConnected && (
<p className="text-secondary text-xs mb-0">
Add the PostHog app to another GitHub account, or change which repositories it can see.
</p>
)}
- {!isConnected && installations.length === 0 && githubPersonalConnected === false && (
- <p className="text-secondary text-xs mb-0">
- Already installed the PostHog GitHub App but don't see it here? Connect your GitHub account
- under <Link to={urls.settings('user-personal-integrations')}>Personal integrations</Link> so
- PostHog can find it.
- </p>
- )}
+ {showPersonalConnectionHelp &&
+ !isConnected &&
+ installations.length === 0 &&
+ githubPersonalConnected === false && (
+ <p className="text-secondary text-xs mb-0">
+ Already installed the PostHog GitHub App but don't see it here? Connect your GitHub account
+ under <Link to={urls.settings('user-personal-integrations')}>Personal integrations</Link> so
+ PostHog can find it.
+ </p>
+ )}
</div>
</Integration>
)
@@ -147,12 +181,14 @@ export function GitHubInstallationLink({
loading,
onLink,
projectName,
+ emphasizeInstallation = false,
}: {
installations: GitHubAvailableInstallationApi[]
loading: boolean
onLink: (installationId?: string) => void
/** Named on the button, so it's clear which project the install lands in. */
projectName?: string
+ emphasizeInstallation?: boolean
}): JSX.Element | null {
if (installations.length === 0) {
return null
@@ -163,12 +199,14 @@ export function GitHubInstallationLink({
// backend to auto-resolve from a sibling project, which an orphan installation has none of.
return (
<LemonButton
- type="secondary"
+ type={emphasizeInstallation ? 'primary' : 'secondary'}
size="small"
loading={loading}
onClick={() => onLink(installations[0].installation_id)}
>
- Connect to {projectName ?? 'this project'}
+ {emphasizeInstallation
+ ? `Connect ${accountLabel(installations[0])}`
+ : `Connect to ${projectName ?? 'this project'}`}
</LemonButton>
)
}
@@ -182,8 +220,13 @@ export function GitHubInstallationLink({
onClick: () => onLink(installation.installation_id),
}))}
>
- <LemonButton type="secondary" size="small" loading={loading} sideIcon={<IconChevronDown />}>
- Choose an account
+ <LemonButton
+ type={emphasizeInstallation ? 'primary' : 'secondary'}
+ size="small"
+ loading={loading}
+ sideIcon={<IconChevronDown />}
+ >
+ {emphasizeInstallation ? 'Choose an existing installation' : 'Choose an account'}
</LemonButton>
</LemonMenu>
)
diff --git a/products/signals/frontend/inbox/components/onboarding/InboxWelcome.tsx b/products/signals/frontend/inbox/components/onboarding/InboxWelcome.tsx
index d39ad92529e0..063ad83e8e89 100644
--- a/products/signals/frontend/inbox/components/onboarding/InboxWelcome.tsx
+++ b/products/signals/frontend/inbox/components/onboarding/InboxWelcome.tsx
@@ -1,14 +1,20 @@
import './InboxWelcome.scss'
-import { useActions } from 'kea'
+import { useActions, useMountedLogic, useValues } from 'kea'
+import { combineUrl } from 'kea-router'
import { useEffect, useRef, useState } from 'react'
-import { IconRewindPlay, IconWarning } from '@posthog/icons'
-import { LemonButton, LemonCard, LemonTag } from '@posthog/lemon-ui'
+import { IconCheck, IconRewindPlay, IconWarning } from '@posthog/icons'
+import { LemonButton, LemonCard, 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'
+import { urls } from 'scenes/urls'
import { captureInboxWelcomeCommandCopied, captureInboxWelcomeViewed } from '../../inboxAnalytics'
import { inboxOnboardingLogic } from '../../logics/inboxOnboardingLogic'
@@ -63,6 +69,48 @@ function CommandCta(): JSX.Element {
)
}
+function GithubFirstCta(): JSX.Element {
+ useMountedLogic(integrationsLogic)
+ const { githubIntegrations, integrationsLoading } = useValues(integrationsLogic)
+ const hasGithubIntegration = githubIntegrations.some(
+ (integration) => integration.installation_status !== 'unavailable'
+ )
+
+ if (integrationsLoading) {
+ return <LemonSkeleton className="h-10 w-64 rounded" />
+ }
+
+ if (hasGithubIntegration) {
+ return (
+ <>
+ <div className="mb-4">
+ <LemonTag type="success" icon={<IconCheck />}>
+ GitHub connected
+ </LemonTag>
+ </div>
+ <h2 className="mb-4 text-lg font-semibold">Almost there</h2>
+ <CommandCta />
+ <p className="mt-3.5 max-w-[520px] text-[13px] text-tertiary">
+ Run the setup agent in your repo to pick the signal sources and scouts to watch. PRs start landing
+ in this inbox.
+ </p>
+ </>
+ )
+ }
+
+ return (
+ <div className="w-full max-w-[560px] text-left">
+ <GithubIntegration
+ next={combineUrl(urls.inbox(), { setup: 'github-first' }).url}
+ connectSurface="inbox_welcome"
+ connectText="Connect GitHub"
+ emphasizeConnect
+ showPersonalConnectionHelp={false}
+ />
+ </div>
+ )
+}
+
/** The escape hatch: skip the setup agent and turn sources and scouts on by hand. */
function ManualSetupAction(): JSX.Element {
const { requestManualSetup } = useActions(inboxOnboardingLogic)
@@ -195,6 +243,9 @@ function LoopDiagram(): JSX.Element {
* Rendered in place of the report list and without the tab bar: a full-pane welcome, not a tab.
*/
export function InboxWelcome(): JSX.Element {
+ const { featureFlags } = useValues(featureFlagLogic)
+ const githubFirst = !!featureFlags[FEATURE_FLAGS.GITHUB_FIRST_SELF_DRIVING_ONBOARDING]
+
useEffect(() => {
captureInboxWelcomeViewed()
}, [])
@@ -213,11 +264,17 @@ export function InboxWelcome(): JSX.Element {
PostHog watches your session replays, errors, and Slack. When it finds something worth fixing,
it writes the pull request. You review and merge.
</p>
- <CommandCta />
- <p className="mt-3.5 max-w-[520px] text-[13px] text-tertiary">
- Run it in your repo. That's the whole setup: it connects GitHub and picks the signal sources and
- scouts to watch. PRs start landing in this inbox.
- </p>
+ {githubFirst ? (
+ <GithubFirstCta />
+ ) : (
+ <>
+ <CommandCta />
+ <p className="mt-3.5 max-w-[520px] text-[13px] text-tertiary">
+ Run it in your repo. That's the whole setup: it connects GitHub and picks the signal
+ sources and scouts to watch. PRs start landing in this inbox.
+ </p>
+ </>
+ )}
<ManualSetupAction />
</div>
</div>
diff --git a/products/signals/frontend/inbox/logics/inboxOnboardingLogic.ts b/products/signals/frontend/inbox/logics/inboxOnboardingLogic.ts
index e3eba07aa7c5..08c6a86dacea 100644
--- a/products/signals/frontend/inbox/logics/inboxOnboardingLogic.ts
+++ b/products/signals/frontend/inbox/logics/inboxOnboardingLogic.ts
@@ -266,6 +266,7 @@ export interface inboxOnboardingLogicValues {
pullsCountLoading: boolean // reportListLogic
reportsCount: number | null // reportListLogic
reportsCountLoading: boolean // reportListLogic
+ searchParams: Record<string, any> // router
enabledScoutsCount: number // scoutFleetLogic
scoutConfigs: SignalScoutConfig[] | null // scoutFleetLogic
scoutConfigsLoading: boolean // scoutFleetLogic
@@ -379,7 +380,10 @@ export interface inboxOnboardingLogicMeta {
) => InboxSettledUiState | null
onboardingMode: (
resolvedOnboardingMode: InboxOnboardingMode,
- lastSettledUiState: InboxSettledUiState | null
+ lastSettledUiState: InboxSettledUiState | null,
+ searchParams: Record<string, any>,
+ isSelfDrivingSetUp: boolean,
+ isWizardRunning: boolean
) => InboxOnboardingMode
}
}
@@ -432,6 +436,8 @@ export const inboxOnboardingLogic = kea<inboxOnboardingLogicType>([
['receivedFeatureFlags'],
teamLogic,
['currentTeamId'],
+ router,
+ ['searchParams'],
],
actions: [
wizardActiveSessionDetectorLogic,
@@ -639,11 +645,25 @@ export const inboxOnboardingLogic = kea<inboxOnboardingLogicType>([
// What the scene renders: while the verdict is settling, fall back to what this team saw
// last visit instead of a skeleton, so the loading state only ever shows on a first visit.
onboardingMode: [
- (s) => [s.resolvedOnboardingMode, s.lastSettledUiState],
+ (s) => [
+ s.resolvedOnboardingMode,
+ s.lastSettledUiState,
+ s.searchParams,
+ s.isSelfDrivingSetUp,
+ s.isWizardRunning,
+ ],
(
resolvedOnboardingMode: InboxOnboardingMode,
- lastSettledUiState: InboxSettledUiState | null
- ): InboxOnboardingMode => resolveDisplayMode(resolvedOnboardingMode, lastSettledUiState),
+ lastSettledUiState: InboxSettledUiState | null,
+ searchParams: Record<string, unknown>,
+ isSelfDrivingSetUp: boolean,
+ isWizardRunning: boolean
+ ): InboxOnboardingMode => {
+ if (searchParams.setup === 'github-first' && !isSelfDrivingSetUp && !isWizardRunning) {
+ return 'takeover'
+ }
+ return resolveDisplayMode(resolvedOnboardingMode, lastSettledUiState)
+ },
],
}),