: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 { Avatar, AvatarFallback, AvatarImage } from '@posthog/quill'
import { cn } from 'lib/utils/css-classes'
import { gravatarUrl } from 'lib/utils/gravatar'
export interface AvatarUser {
email?: string | null
first_name?: string | null
last_name?: string | null
}
function initials(user: AvatarUser): string {
const name = [user.first_name, user.last_name].filter(Boolean).join(' ').trim()
const source = name || user.email || '?'
return source
.split(/[\s@._-]+/)
.filter(Boolean)
.slice(0, 2)
.map((part) => part[0]?.toUpperCase() ?? '')
.join('')
}
/** A person's gravatar with their initials behind it, for comment and viewer lists. */
export function QuillUserAvatar({
user,
size = 'sm',
className,
}: {
user: AvatarUser | null | undefined
size?: 'xs' | 'sm' | 'default'
className?: string
}): JSX.Element {
const email = user?.email ?? undefined
return (
<Avatar size={size} className={cn('ph-no-capture', className)}>
{email && <AvatarImage src={gravatarUrl(email)} alt="" />}
<AvatarFallback>{user ? initials(user) : '?'}</AvatarFallback>
</Avatar>
)
}