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.0 KB
Raw Blame
import { useValues } from 'kea'

import { Spinner } from '@posthog/lemon-ui'

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

import { metricRecentActivityLogic } from './metricRecentActivityLogic'

export type MetricRecentActivityProps = {
    metric: ExperimentMetric
    filterTestAccounts: boolean
}

export const MetricRecentActivity = ({ metric, filterTestAccounts }: MetricRecentActivityProps): JSX.Element => {
    const { eventCount, eventCountLoading } = useValues(metricRecentActivityLogic({ metric, filterTestAccounts }))

    if (eventCountLoading) {
        return (
            <div className="text-xs text-muted">
                <Spinner className="mr-1" />
                Loading...
            </div>
        )
    }

    const count = eventCount ?? 0

    return (
        <div className="flex flex-col gap-1">
            <span className="text-muted">events in the past 14 days</span>
            <span className="text-2xl font-semibold text-right">{count.toLocaleString()}</span>
        </div>
    )
}