: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(onboarding): show product and opt-in status in Super Hog Powers (#79251)
Fernando Gomesc77bd0a79393
diff --git a/frontend/src/lib/components/Superpowers/Superpowers.tsx b/frontend/src/lib/components/Superpowers/Superpowers.tsxindex 782d68c02acc..a4fafa52a54c 100644--- a/frontend/src/lib/components/Superpowers/Superpowers.tsx+++ b/frontend/src/lib/components/Superpowers/Superpowers.tsx@@ -1,9 +1,11 @@import { useActions, useValues } from 'kea'+import { useState } from 'react'-import { IconTrash } from '@posthog/icons'+import { IconArrowLeft, IconChevronRight, IconTrash } from '@posthog/icons'import { LemonButton, LemonDivider, LemonSelect, LemonSwitch, LemonTag } from '@posthog/lemon-ui'import { SupermanHog } from 'lib/components/hedgehogs'+import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'import { LemonModal } from 'lib/lemon-ui/LemonModal'import { preflightLogic } from 'lib/logic/preflightLogic'import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'@@ -11,6 +13,11 @@ import { organizationLogic } from 'scenes/organizationLogic'import { teamLogic } from 'scenes/teamLogic'import { userLogic } from 'scenes/userLogic'+import { customProductsLogic } from '~/layout/panel-layout/ProjectTree/customProductsLogic'+import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'+import { getTreeItemsProducts } from '~/products'+import type { TeamType } from '~/types'+import { openCHQueriesDebugModal } from '../Shortcuts/utils/DebugCHQueries'import { FakeBillingAlert, FakeStatusOverride, superpowersLogic } from './superpowersLogic'@@ -19,7 +26,7 @@ export function SuperpowersModal(): JSX.Element | null {const { closeSuperpowers } = useActions(superpowersLogic)return (- <LemonModal title="" isOpen={isSuperpowersOpen} onClose={closeSuperpowers} width={500}>+ <LemonModal title="" isOpen={isSuperpowersOpen} onClose={closeSuperpowers} width={760}><SuperpowersContent /></LemonModal>)@@ -40,6 +47,213 @@ const BILLING_ALERT_OPTIONS: { value: FakeBillingAlert; label: string }[] = [{ value: 'error', label: 'Error' },]+function Section({+ title,+ description,+ children,+}: {+ title: React.ReactNode+ description?: string+ children: React.ReactNode+}): JSX.Element {+ return (+ <div>+ <h3 className="font-semibold mb-0.5">{title}</h3>+ {description && <p className="text-xs text-secondary mb-2">{description}</p>}+ <div className="space-y-2">{children}</div>+ </div>+ )+}++function SettingRow({+ title,+ description,+ control,+}: {+ title: string+ description: string+ control: React.ReactNode+}): JSX.Element {+ return (+ <div className="flex items-center justify-between gap-4 p-2 border rounded">+ <div className="min-w-0">+ <div className="font-medium text-sm">{title}</div>+ <div className="text-xs text-secondary">{description}</div>+ </div>+ <div className="shrink-0">{control}</div>+ </div>+ )+}++interface CaptureOption {+ label: string+ /** The team field (or path) behind the option, shown for PATCHing/debugging. */+ field: string+ get: (team: TeamType) => boolean+}++// Capture settings behind each product's data, keyed by products-registry path.+const PRODUCT_CAPTURE_OPTIONS: Record<string, CaptureOption[]> = {+ 'Product analytics': [+ { label: 'Autocapture', field: 'autocapture_opt_out', get: (t) => !t.autocapture_opt_out },+ { label: 'Heatmaps', field: 'heatmaps_opt_in', get: (t) => !!t.heatmaps_opt_in },+ { label: 'Dead clicks', field: 'capture_dead_clicks', get: (t) => !!t.capture_dead_clicks },+ { label: 'Web vitals', field: 'autocapture_web_vitals_opt_in', get: (t) => !!t.autocapture_web_vitals_opt_in },+ ],+ 'Session replay': [+ { label: 'Recording', field: 'session_recording_opt_in', get: (t) => !!t.session_recording_opt_in },+ { label: 'Console logs', field: 'capture_console_log_opt_in', get: (t) => !!t.capture_console_log_opt_in },+ {+ label: 'Network performance',+ field: 'capture_performance_opt_in',+ get: (t) => !!t.capture_performance_opt_in,+ },+ {+ label: 'Canvas recording',+ field: 'session_replay_config.record_canvas',+ get: (t) => !!t.session_replay_config?.record_canvas,+ },+ {+ label: 'Network payloads',+ field: 'session_recording_network_payload_capture_config',+ get: (t) => !!t.session_recording_network_payload_capture_config,+ },+ ],+ 'Error tracking': [+ {+ label: 'Exception autocapture',+ field: 'autocapture_exceptions_opt_in',+ get: (t) => !!t.autocapture_exceptions_opt_in,+ },+ ],+ 'Web analytics': [+ { label: 'Web vitals', field: 'autocapture_web_vitals_opt_in', get: (t) => !!t.autocapture_web_vitals_opt_in },+ { label: 'Heatmaps', field: 'heatmaps_opt_in', get: (t) => !!t.heatmaps_opt_in },+ {+ label: 'Network performance',+ field: 'capture_performance_opt_in',+ get: (t) => !!t.capture_performance_opt_in,+ },+ ],+ Heatmaps: [+ { label: 'Heatmaps', field: 'heatmaps_opt_in', get: (t) => !!t.heatmaps_opt_in },+ { label: 'Dead clicks', field: 'capture_dead_clicks', get: (t) => !!t.capture_dead_clicks },+ ],+ Surveys: [{ label: 'Survey popups', field: 'surveys_opt_in', get: (t) => !!t.surveys_opt_in }],+ Logs: [+ {+ label: 'Console log capture',+ field: 'logs_settings.capture_console_logs',+ get: (t) => !!(t.logs_settings as Record<string, any> | null)?.capture_console_logs,+ },+ ],+ Support: [+ { label: 'Conversations', field: 'conversations_enabled', get: (t) => !!t.conversations_enabled },+ {+ label: 'Widget',+ field: 'conversations_settings.widget_enabled',+ get: (t) => !!(t.conversations_settings as Record<string, any> | null)?.widget_enabled,+ },+ ],+}++function CaptureOptionDot({ option, team }: { option: CaptureOption; team: TeamType }): JSX.Element {+ const on = option.get(team)+ return (+ <span className="flex items-baseline gap-1.5 text-xs whitespace-nowrap min-w-0">+ <span className={`size-1.5 shrink-0 rounded-full self-center ${on ? 'bg-success' : 'bg-danger'}`} />+ <span>{option.label}</span>+ <code className="text-[10px] text-muted truncate">{option.field}</code>+ </span>+ )+}++function EnablementTag({ enabled }: { enabled: boolean }): JSX.Element {+ return enabled ? (+ <LemonTag type="success" className="shrink-0">+ Enabled+ </LemonTag>+ ) : (+ <LemonTag className="shrink-0">Disabled</LemonTag>+ )+}++function ProductsSection(): JSX.Element {+ const { customProducts, customProductsLoading } = useValues(customProductsLogic)+ const { loadCustomProducts } = useActions(customProductsLogic)+ const { currentTeam } = useValues(teamLogic)++ // The modal content unmounts on close, so each open refetches the sidebar list.+ useOnMountEffect(() => loadCustomProducts())++ const team = currentTeam as TeamType | null+ const enabledByPath = new Map(customProducts.map((item) => [item.product_path, item]))+ const products = getTreeItemsProducts()+ const withOptions = products.filter((item) => PRODUCT_CAPTURE_OPTIONS[item.path])+ const others = products.filter((item) => !PRODUCT_CAPTURE_OPTIONS[item.path])+ const enabledCount = products.filter((item) => enabledByPath.has(item.path)).length++ return (+ <Section+ title={+ <>+ Products{' '}+ <span className="font-normal text-secondary text-sm">+ ({enabledCount} of {products.length} in sidebar)+ </span>+ </>+ }+ description="Sidebar enablement per product (UserProductList), plus the team capture settings behind each tool. A red dot means the tool renders but captures nothing."+ >+ <div className="space-y-2">+ <div className="space-y-1.5">+ {withOptions.map((item) => {+ const listItem = enabledByPath.get(item.path)+ return (+ <div key={item.path} className="border rounded p-2.5 space-y-1.5">+ <div className="flex items-center gap-2">+ <span className="flex shrink-0 group/colorful-product-icons colorful-product-icons-true">+ {iconForType(item.iconType)}+ </span>+ <span className="flex-1 text-sm font-medium truncate">{item.path}</span>+ {listItem?.reason && (+ <span className="text-xs text-muted shrink-0">{listItem.reason}</span>+ )}+ <EnablementTag enabled={!!listItem} />+ </div>+ {team && (+ <div className="grid grid-cols-2 gap-x-4 gap-y-1 pl-6">+ {PRODUCT_CAPTURE_OPTIONS[item.path].map((option) => (+ <CaptureOptionDot key={option.field} option={option} team={team} />+ ))}+ </div>+ )}+ </div>+ )+ })}+ </div>+ {others.length > 0 && (+ <>+ <div className="text-xs text-muted font-medium pt-1">No capture settings</div>+ <div className="grid grid-cols-2 gap-1">+ {others.map((item) => (+ <div key={item.path} className="flex items-center gap-2 border rounded px-2 py-1">+ <span className="flex shrink-0 group/colorful-product-icons colorful-product-icons-true">+ {iconForType(item.iconType)}+ </span>+ <span className="flex-1 text-xs truncate">{item.path}</span>+ <EnablementTag enabled={enabledByPath.has(item.path)} />+ </div>+ ))}+ </div>+ </>+ )}+ </div>+ {customProductsLoading && <div className="text-xs text-secondary">Refreshing…</div>}+ </Section>+ )+}+function SuperpowersContent(): JSX.Element {const { currentTeam } = useValues(teamLogic)const { updateCurrentTeam } = useActions(teamLogic)@@ -60,14 +274,33 @@ function SuperpowersContent(): JSX.Element {openCHQueriesDebugModal()}+ const [view, setView] = useState<'home' | 'tools'>('home')++ if (view === 'tools') {+ return (+ <div className="space-y-4">+ <div className="flex items-center gap-2 -mt-2">+ <LemonButton+ icon={<IconArrowLeft />}+ size="small"+ onClick={() => setView('home')}+ aria-label="Back"+ />+ <h2 className="text-xl font-bold m-0">Tool status</h2>+ </div>+ <ProductsSection />+ </div>+ )+ }+return (- <div className="space-y-4">+ <div className="space-y-5">{/* Hero section */}<div className="flex items-center gap-4 -mt-2">- <SupermanHog className="w-24 h-24 shrink-0" />+ <SupermanHog className="w-20 h-20 shrink-0" /><div><h2 className="text-xl font-bold mb-1">Super Hog Powers</h2>- <p className="text-secondary text-sm">+ <p className="text-secondary text-sm m-0">With great power comes great responsibility. Use these wisely, fellow hog.</p></div>@@ -75,16 +308,30 @@ function SuperpowersContent(): JSX.Element {<LemonDivider />- <div>- <h3 className="font-semibold mb-2">Quick start / Onboarding</h3>- <div className="space-y-2">- <div className="flex items-center justify-between p-2 border rounded">- <div>- <div className="font-medium">Clear all onboarding tasks</div>- <div className="text-sm text-secondary">- Reset all quick start task progress for this team- </div>- </div>+ <Section title="Actions">+ <SettingRow+ title="Tool status"+ description="Every product's sidebar enablement and the team capture settings behind it"+ control={+ <LemonButton+ type="secondary"+ size="small"+ sideIcon={<IconChevronRight />}+ onClick={() => setView('tools')}+ >+ Open+ </LemonButton>+ }+ />+ </Section>++ <LemonDivider />++ <Section title="Quick start / Onboarding">+ <SettingRow+ title="Clear all onboarding tasks"+ description="Reset all quick start task progress for this team"+ control={<LemonButtontype="secondary"status="danger"@@ -94,95 +341,58 @@ function SuperpowersContent(): JSX.Element {>Clear</LemonButton>- </div>- <div className="text-xs text-secondary font-mono p-2 bg-surface-tertiary rounded max-h-40 overflow-auto whitespace-pre">- Current tasks: {JSON.stringify(currentTeam?.onboarding_tasks || {}, null, 2)}- </div>+ }+ />+ <div className="text-xs text-secondary font-mono p-2 bg-surface-tertiary rounded max-h-40 overflow-auto whitespace-pre">+ Current tasks: {JSON.stringify(currentTeam?.onboarding_tasks || {}, null, 2)}</div>- </div>+ </Section><LemonDivider />- <div>- <h3 className="font-semibold mb-2">PostHog status</h3>- <div className="space-y-2">- <div className="flex items-center justify-between p-2 border rounded">- <div>- <div className="font-medium">Fake status override</div>- <div className="text-sm text-secondary">- Simulate a status outage for testing the status indicator- </div>- </div>+ <Section title="Simulations" description="Fake states for testing surfaces that are hard to reproduce.">+ <SettingRow+ title="Fake status override"+ description="Simulate a status outage for testing the status indicator"+ control={<LemonSelectsize="small"value={fakeStatusOverride}options={STATUS_OPTIONS}onChange={setFakeStatusOverride}/>- </div>- </div>- </div>-- <LemonDivider />-- <div>- <h3 className="font-semibold mb-2">Billing</h3>- <div className="space-y-2">- <div className="flex items-center justify-between p-2 border rounded">- <div>- <div className="font-medium">Fake billing alert</div>- <div className="text-sm text-secondary">Simulate a billing alert banner for testing</div>- </div>+ }+ />+ <SettingRow+ title="Fake billing alert"+ description="Simulate a billing alert banner for testing"+ control={<LemonSelectsize="small"value={fakeBillingAlert}options={BILLING_ALERT_OPTIONS}onChange={setFakeBillingAlert}/>- </div>- </div>- </div>-- {isDev && (- <>- <LemonDivider />-- <div>- <h3 className="font-semibold mb-2">- AI <LemonTag size="small">Dev only</LemonTag>- </h3>- <div className="space-y-2">- <div className="flex items-center justify-between p-2 border rounded">- <div>- <div className="font-medium">Enable AI data processing</div>- <div className="text-sm text-secondary">- Toggle organization-level AI data processing approval- </div>- </div>- <LemonSwitch- checked={dataProcessingAccepted}- onChange={(checked) =>- updateOrganization({ is_ai_data_processing_approved: checked })- }- />- </div>- </div>- </div>- </>- )}+ }+ />+ </Section><LemonDivider />- <div>- <h3 className="font-semibold mb-2">MCP hints</h3>- <div className="space-y-2">- <div className="flex items-center justify-between p-2 border rounded">- <div>- <div className="font-medium">Re-enable MCP hints</div>- <div className="text-sm text-secondary">- Clear all dismissed surfaces, the global opt-out, and the cooldown so hints show again- </div>- </div>+ <Section title="Debug tools">+ <SettingRow+ title="ClickHouse queries"+ description="View recent ClickHouse queries for this user"+ control={+ <LemonButton type="secondary" size="small" onClick={handleOpenCHQueries}>+ Open+ </LemonButton>+ }+ />+ <SettingRow+ title="Re-enable MCP hints"+ description="Clear all dismissed surfaces, the global opt-out, and the cooldown so hints show again"+ control={<LemonButtontype="secondary"size="small"@@ -191,26 +401,21 @@ function SuperpowersContent(): JSX.Element {>Re-enable</LemonButton>- </div>- </div>- </div>-- <LemonDivider />-- <div>- <h3 className="font-semibold mb-2">Debug tools</h3>- <div className="space-y-2">- <div className="flex items-center justify-between p-2 border rounded">- <div>- <div className="font-medium">ClickHouse queries</div>- <div className="text-sm text-secondary">View recent ClickHouse queries for this user</div>- </div>- <LemonButton type="secondary" size="small" onClick={handleOpenCHQueries}>- Open- </LemonButton>- </div>- </div>- </div>+ }+ />+ {isDev && (+ <SettingRow+ title="Enable AI data processing"+ description="Toggle organization-level AI data processing approval (dev only)"+ control={+ <LemonSwitch+ checked={dataProcessingAccepted}+ onChange={(checked) => updateOrganization({ is_ai_data_processing_approved: checked })}+ />+ }+ />+ )}+ </Section><LemonDivider />