: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 { useActions, useValues } from 'kea'
import { IconChevronDown } from '@posthog/icons'
import { LemonButton } from '@posthog/lemon-ui'
import { LemonMenu } from 'lib/lemon-ui/LemonMenu/LemonMenu'
import { repoScopeLogic } from '../scenes/repoScopeLogic'
/** The one place to change repository: a button beside the repository title. With one repository there is
* nothing to switch to, so it renders nothing. */
export function RepoSwitcher(): JSX.Element | null {
const { hasMultipleSources, sourceOptions, selectedScope } = useValues(repoScopeLogic)
const { switchRepo } = useActions(repoScopeLogic)
if (!hasMultipleSources) {
return null
}
return (
<LemonMenu
items={sourceOptions.map((option) => ({
label: option.label,
active: option.value === selectedScope,
onClick: () => switchRepo(option.value),
}))}
>
<LemonButton
type="secondary"
size="small"
sideIcon={<IconChevronDown />}
// pinned: data-attr of the repository picker this button replaces; autocapture insights use it.
data-attr="engineering-analytics-source-select"
>
Switch repository
</LemonButton>
</LemonMenu>
)
}