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 { Link } from '@posthog/lemon-ui'

import { TZLabel } from 'lib/components/TZLabel'
import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
import { urls } from 'scenes/urls'

import type { SubscriptionApi, SubscriptionSummaryApi } from 'products/subscriptions/frontend/generated/api.schemas'

import { TARGET_TYPE_LABEL } from '../../scenes/components/subscriptionLabels'

const TIME_FORMAT = { formatDate: 'MMM D, YYYY', formatTime: 'h:mm A', timestampStyle: 'absolute' } as const

export function SubscriptionSummaryEntry({ summary }: { summary: SubscriptionSummaryApi }): JSX.Element {
    const channel = TARGET_TYPE_LABEL[summary.target_type as SubscriptionApi['target_type']] ?? summary.target_type
    return (
        <div className="flex flex-col gap-1 min-w-0">
            <div className="flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-secondary">
                <Link
                    to={urls.subscription(summary.subscription)}
                    className="truncate"
                    data-attr="subscription-summary-subscription-link"
                >
                    {summary.subscription_title || 'Untitled subscription'}
                </Link>
                <span>·</span>
                <span>{channel}</span>
                <span>·</span>
                {summary.period_start ? (
                    <span>
                        Changes from <TZLabel time={summary.period_start} {...TIME_FORMAT} /> to{' '}
                        <TZLabel time={summary.created_at} {...TIME_FORMAT} />
                    </span>
                ) : (
                    <span>
                        Sent <TZLabel time={summary.created_at} {...TIME_FORMAT} />
                    </span>
                )}
            </div>
            {summary.change_summary ? (
                <LemonMarkdown className="text-sm" disableImages="all">
                    {summary.change_summary}
                </LemonMarkdown>
            ) : null}
        </div>
    )
}