: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 { useMemo, useState } from 'react'
import { LemonButton, LemonModal, LemonSelect, LemonSkeleton } from '@posthog/lemon-ui'
import { Link } from 'lib/lemon-ui/Link'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { OnboardingDocsContentWrapper } from 'scenes/onboarding/shared/OnboardingDocsContentWrapper'
import SetupWizardBanner from 'scenes/onboarding/shared/SetupWizardBanner'
import { teamLogic } from 'scenes/teamLogic'
import { SDKKey } from '~/types'
import { buildSDKSelectOptions, filterRequiredSteps, SDK_CONFIGS } from './SDKSetupInstructions'
const PROXY_SDK_OPTIONS = buildSDKSelectOptions(['web', 'mobile'])
export function ProxySDKSetup(): JSX.Element {
const { currentTeam, currentTeamLoading } = useValues(teamLogic)
const [selectedSDK, setSelectedSDK] = useState<SDKKey>(SDKKey.JS_WEB)
const [showFullSetup, setShowFullSetup] = useState(false)
const { reportSDKSetupInstructionsSDKSelected } = useActions(eventUsageLogic)
const config = useMemo(() => SDK_CONFIGS[selectedSDK], [selectedSDK])
if (currentTeamLoading && !currentTeam) {
return (
<div className="space-y-4">
<LemonSkeleton className="w-1/2 h-4" />
<LemonSkeleton repeat={3} />
</div>
)
}
if (!config) {
return <></>
}
const { Installation, snippets, wizardIntegrationName, docsLink, name } = config
return (
<div className="space-y-4 max-w-200">
<LemonSelect
value={selectedSDK}
onChange={(value) => {
setSelectedSDK(value)
setShowFullSetup(false)
reportSDKSetupInstructionsSDKSelected(value, 'settings_reverse_proxy_setup')
}}
options={PROXY_SDK_OPTIONS}
className="max-w-80"
/>
<OnboardingDocsContentWrapper snippets={snippets} minimal useReverseProxy>
<Installation modifySteps={filterRequiredSteps} />
</OnboardingDocsContentWrapper>
<div className="flex items-center gap-2">
<LemonButton type="secondary" size="small" onClick={() => setShowFullSetup(true)}>
View full setup instructions
</LemonButton>
<Link to={docsLink} target="_blank" className="text-sm">
{name} docs
</Link>
</div>
<LemonModal
isOpen={showFullSetup}
onClose={() => setShowFullSetup(false)}
title={`${name} setup`}
width={640}
>
{wizardIntegrationName && <SetupWizardBanner integrationName={wizardIntegrationName} />}
<OnboardingDocsContentWrapper snippets={snippets} useReverseProxy>
<Installation />
</OnboardingDocsContentWrapper>
<div className="mt-4">
<Link to={docsLink} target="_blank">
View full {name} documentation
</Link>
</div>
</LemonModal>
</div>
)
}