: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 { useEffect } from 'react'
import { useHogfetti } from 'lib/components/Hogfetti/Hogfetti'
import { inStorybookTestRunner } from 'lib/utils/dom'
import { ProductKey } from '~/queries/schema/schema-general'
import { onboardingWelcomeLogic } from './onboardingWelcomeLogic'
function canCelebrate(): boolean {
return !inStorybookTestRunner() && !window.matchMedia('(prefers-reduced-motion: reduce)').matches
}
export function WelcomeCelebration({ productKey }: { productKey: ProductKey }): JSX.Element {
const { celebratedProductKeys } = useValues(onboardingWelcomeLogic)
const { markCelebrated } = useActions(onboardingWelcomeLogic)
const { trigger, HogfettiComponent } = useHogfetti({ count: 60 })
useEffect(() => {
if (celebratedProductKeys.includes(productKey)) {
return
}
markCelebrated(productKey)
if (canCelebrate()) {
trigger()
}
// Mount-only per product: the parent remounts this for each product it shows.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
return <HogfettiComponent />
}