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 {
    ActivityLogItem,
    ActivityLogUserName,
    HumanizedChange,
    activityLogSummary,
    defaultDescriber,
} from 'lib/components/ActivityLog/humanizeActivity'
import { Link } from 'lib/lemon-ui/Link'
import { urls } from 'scenes/urls'

export function exportedAssetActivityDescriber(logItem: ActivityLogItem, asNotification?: boolean): HumanizedChange {
    if (logItem.scope !== 'ExportedAsset') {
        console.error('exported asset describer received a non-export activity')
        return { description: null }
    }

    if (logItem.activity === 'exported') {
        const exportFormat = logItem.detail.changes?.[0]?.after
        let formatLabel = 'an export'
        if (typeof exportFormat === 'string') {
            formatLabel = `a ${exportFormat.split('/')[1] || exportFormat}`
        }

        return {
            summary: activityLogSummary(
                logItem,
                `Exported as ${formatLabel}`,
                <Link to={urls.exports()}>{logItem.detail.name || 'Export'}</Link>
            ),
            description: (
                <>
                    <ActivityLogUserName logItem={logItem} /> exported {asNotification ? 'your ' : ''}
                    <Link to={urls.exports()}>{logItem.detail.name || 'an export'}</Link> as {formatLabel}
                </>
            ),
        }
    }

    return defaultDescriber(logItem, asNotification)
}