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.

886 B
Raw Blame
import { match } from 'ts-pattern'

import type { ExperimentMetric } from '~/queries/schema/schema-general'
import { isExperimentFunnelMetric } from '~/queries/schema/schema-general'
import { StepOrderValue } from '~/types'

/**
 * Only for funnel metrics
 */
export type MetricStepOrderProps = {
    metric: ExperimentMetric
}

export const MetricStepOrder = ({ metric }: MetricStepOrderProps): JSX.Element | null => {
    if (!isExperimentFunnelMetric(metric)) {
        return null
    }

    const orderLabel = match(metric.funnel_order_type)
        .with(StepOrderValue.ORDERED, () => 'Sequential')
        .with(StepOrderValue.UNORDERED, () => 'Any order')
        .otherwise(() => 'Sequential')

    return (
        <div className="text-xs">
            <span className="text-muted">Step order:</span> <span className="font-semibold">{orderLabel}</span>
        </div>
    )
}