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.1 KB
Raw Blame
import { WebAnalyticsDigestNotification } from 'lib/components/NotificationsMenu/WebAnalyticsDigestNotification'

import { InAppNotification } from '~/types'

export interface NotificationDescriberProps {
    notification: InAppNotification
    onNavigate?: () => void
}

export interface NotificationDescriber {
    takesOverRow?: boolean
    Component: (props: NotificationDescriberProps) => JSX.Element | null
}

function WebAnalyticsDigestDescriber({ notification }: NotificationDescriberProps): JSX.Element | null {
    // metadata is a free-form JSON blob — one malformed row would otherwise crash the whole panel
    if (!notification.metadata?.metrics) {
        return null
    }

    return <WebAnalyticsDigestNotification metadata={notification.metadata} />
}

export const NOTIFICATION_DESCRIBERS: Record<string, NotificationDescriber> = {
    web_analytics_digest: { takesOverRow: true, Component: WebAnalyticsDigestDescriber },
}

export function getNotificationDescriber(notification: InAppNotification): NotificationDescriber | undefined {
    return NOTIFICATION_DESCRIBERS[notification.notification_type]
}