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.

1.6 KB
Raw Blame
import { useActions, useValues } from 'kea'

import { IconArrowRight } from '@posthog/icons'
import { LemonButton } from '@posthog/lemon-ui'

import { reportOnboardingStepCompleted, reportOnboardingStepSkipped } from 'scenes/onboarding/onboardingUsage'

import { OnboardingStepKey } from '~/types'

import { onboardingLogic } from '../../onboardingLogic'

interface NextButtonProps {
    installationComplete: boolean
    size?: 'small' | 'medium'
}

export const NextButton = ({ installationComplete, size = 'medium' }: NextButtonProps): JSX.Element => {
    const { hasNextStep, currentStepProductKey } = useValues(onboardingLogic)
    const { completeOnboarding, goToNextStep } = useActions(onboardingLogic)

    const advance = !hasNextStep ? completeOnboarding : goToNextStep
    const skipInstallation = (): void => {
        reportOnboardingStepSkipped(OnboardingStepKey.INSTALL, currentStepProductKey ?? undefined)
        advance()
    }

    const continueInstallation = (): void => {
        reportOnboardingStepCompleted(OnboardingStepKey.INSTALL, currentStepProductKey ?? undefined)
        advance()
    }

    if (!installationComplete) {
        return (
            <LemonButton type="secondary" size={size} onClick={skipInstallation}>
                Skip installation
            </LemonButton>
        )
    }

    return (
        <LemonButton
            data-attr="sdk-continue"
            sideIcon={hasNextStep ? <IconArrowRight /> : null}
            type="primary"
            status="alt"
            onClick={continueInstallation}
        >
            Next
        </LemonButton>
    )
}