: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 api from 'lib/api'
import { createSetupDetectionLogic } from 'lib/components/ProductEmptyState/setupDetectionLogic'
import { retryWithBackoff } from 'lib/utils/async'
import { ProductKey } from '~/queries/schema/schema-general'
/**
* Setup detection for the tracing empty state. Binary: the team has ingested at
* least one span, or it hasn't - there is no "instrumented but quiet" signal to
* read, so no waiting-for-data state.
*/
export const tracingSetupLogic = createSetupDetectionLogic({
productKey: ProductKey.TRACING,
path: ['products', 'tracing', 'frontend', 'emptyState', 'tracingSetupLogic'],
detect: async () => {
const hasSpans = await retryWithBackoff(() => api.tracing.hasSpans(), { maxAttempts: 3 })
return hasSpans ? 'has-data' : 'needs-setup'
},
// The first span usually lands moments after the collector restarts, so
// re-check often enough for the flip to feel immediate.
pollIntervalMs: 5000,
cacheHasData: true,
})