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.

950 B
Raw Blame
import { createSetupDetectionLogic } from 'lib/components/ProductEmptyState/setupDetectionLogic'
import { projectLogic } from 'scenes/projectLogic'

import { ProductKey } from '~/queries/schema/schema-general'

import { actionsList } from '../generated/api'

/**
 * Setup detection for the actions empty state. Actions are a creation-first
 * product, so "set up" simply means the project has at least one action - no event
 * or traffic signal involved.
 */
export const actionsSetupLogic = createSetupDetectionLogic({
    productKey: ProductKey.ACTIONS,
    path: ['products', 'actions', 'frontend', 'emptyState', 'actionsSetupLogic'],
    cacheHasData: true,
    revalidateCachedHasData: true,
    detect: async () => {
        const projectId = String(projectLogic.findMounted()?.values.currentProjectId)
        const response = await actionsList(projectId, { limit: 1 })
        return response.count > 0 ? 'has-data' : 'needs-setup'
    },
})