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.4 KB
Raw Blame
import { clsx } from 'clsx'

import { AddMetricButton } from 'scenes/experiments/Metrics/AddMetricButton'

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

import type { MetricContext } from 'products/experiments/frontend/modals/ExperimentMetricModal/experimentMetricModalLogic'

import { MetricCard } from './MetricCard'

export type MetricListProps = {
    metrics: ExperimentMetric[]
    metricContext: MetricContext
    onDelete: (metric: ExperimentMetric, context: MetricContext) => void
    filterTestAccounts: boolean
    className?: string
}

export const MetricList = ({
    metrics,
    metricContext,
    onDelete,
    filterTestAccounts,
    className,
}: MetricListProps): JSX.Element => {
    return (
        <div className={clsx('space-y-3', className)}>
            <span className="font-medium text-default">
                {metricContext.type.charAt(0).toUpperCase() + metricContext.type.slice(1)} metrics
            </span>
            {metrics.map((metric) => (
                <MetricCard
                    key={metric.uuid}
                    metric={metric}
                    metricContext={metricContext}
                    onDelete={onDelete}
                    filterTestAccounts={filterTestAccounts}
                />
            ))}
            <div>
                <AddMetricButton metricContext={metricContext} />
            </div>
        </div>
    )
}