: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 { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
import posthog from 'posthog-js'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic, type FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
import { preflightLogic } from 'lib/logic/preflightLogic'
import { teamLogic } from 'scenes/teamLogic'
import { userLogic } from 'scenes/userLogic'
import type { PreflightStatus, TeamPublicType, TeamType, UserType } from '~/types'
import type { WizardOnboardingCloudRunProps } from 'products/wizard/frontend/views/onboarding/wizardOnboardingCloudRunLogic'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface wizardInstallStepLogicValues {
featureFlags: FeatureFlagsSet // featureFlagLogic
preflight: PreflightStatus | null // preflightLogic
currentTeam: TeamPublicType | TeamType | null // teamLogic
user: UserType | null // userLogic
cloudRunEnabled: boolean
cloudRunProps: WizardOnboardingCloudRunProps | null
manualModalOpen: boolean
sdkInstructionsOpen: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface wizardInstallStepLogicActions {
setManualModalOpen: (open: boolean) => {
open: boolean
}
setSdkInstructionsOpen: (open: boolean) => {
open: boolean
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface wizardInstallStepLogicMeta {
__keaTypeGenInternalSelectorTypes: {
cloudRunEnabled: (featureFlags: FeatureFlagsSet, preflight: PreflightStatus | null) => boolean
cloudRunProps: (
cloudRunEnabled: boolean,
currentTeam: TeamPublicType | TeamType | null,
user: UserType | null
) => WizardOnboardingCloudRunProps | null
}
}
export type wizardInstallStepLogicType = MakeLogicType<
wizardInstallStepLogicValues,
wizardInstallStepLogicActions,
Record<string, any>,
wizardInstallStepLogicMeta
>
export const wizardInstallStepLogic = kea<wizardInstallStepLogicType>([
path(['scenes', 'onboarding', 'wizardInstallStepLogic']),
connect({
values: [
featureFlagLogic,
['featureFlags'],
preflightLogic,
['preflight'],
teamLogic,
['currentTeam'],
userLogic,
['user'],
],
}),
actions({
setManualModalOpen: (open: boolean) => ({ open }),
setSdkInstructionsOpen: (open: boolean) => ({ open }),
}),
reducers({
manualModalOpen: [
false,
{
setManualModalOpen: (_, { open }) => open,
},
],
sdkInstructionsOpen: [
false,
{
setSdkInstructionsOpen: (_, { open }) => open,
},
],
}),
selectors({
cloudRunEnabled: [
(s) => [s.featureFlags, s.preflight],
(flags: FeatureFlagsSet, preflight: PreflightStatus | null): boolean =>
flags[FEATURE_FLAGS.WIZARD_ONBOARDING_CLOUD_RUNS_ENABLED] === true &&
!!preflight?.wizard_cloud_run_available &&
!!(preflight.cloud || preflight.is_debug),
],
cloudRunProps: [
(s) => [s.cloudRunEnabled, s.currentTeam, s.user],
(
enabled: boolean,
team: TeamType | TeamPublicType | null,
user: UserType | null
): WizardOnboardingCloudRunProps | null =>
enabled && team && user ? { projectId: String(team.id), userId: user.id } : null,
],
}),
listeners({
setManualModalOpen: ({ open }) => {
if (open) {
posthog.capture('wizard manual setup opened', { event_source: 'wizard_ui', location: 'onboarding' })
}
},
}),
])