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.

2.0 KB
Raw Blame
import { LemonSkeleton } from '@posthog/lemon-ui'

import { TZLabel } from 'lib/components/TZLabel'
import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'

import { UserBasicType } from '~/types'

export function ModelMetadata({
    createdBy,
    createdByEmail,
    createdByLabel,
    createdAt,
    updatedAt,
    loading,
}: {
    createdBy?: UserBasicType | null
    createdByEmail?: string | null
    createdByLabel?: string | null
    createdAt?: string | null
    updatedAt?: string | null
    loading?: boolean
}): JSX.Element {
    return (
        <dl className="flex flex-wrap gap-x-8 gap-y-3 mb-0 text-sm" aria-label="Model metadata">
            <div>
                <dt className="text-secondary mb-1">Created by</dt>
                <dd className="mb-0">
                    {loading ? (
                        <LemonSkeleton className="h-5 w-20" />
                    ) : createdBy ? (
                        <ProfilePicture user={createdBy} showName size="sm" />
                    ) : createdByEmail ? (
                        <ProfilePicture user={{ email: createdByEmail }} showName size="sm" />
                    ) : (
                        (createdByLabel ?? 'Unknown')
                    )}
                </dd>
            </div>
            <div>
                <dt className="text-secondary mb-1">Created at</dt>
                <dd className="mb-0">
                    {loading ? (
                        <LemonSkeleton className="h-5 w-20" />
                    ) : createdAt ? (
                        <TZLabel time={createdAt} />
                    ) : (
                        'Unknown'
                    )}
                </dd>
            </div>
            {updatedAt && (
                <div>
                    <dt className="text-secondary mb-1">Updated at</dt>
                    <dd className="mb-0">
                        <TZLabel time={updatedAt} />
                    </dd>
                </div>
            )}
        </dl>
    )
}