: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 { useActions, useValues } from 'kea'
import { router } from 'kea-router'
import posthog from 'posthog-js'
import { IconBell } from '@posthog/icons'
import { Button } from '@posthog/quill'
import { dashboardLogic } from 'scenes/dashboard/dashboardLogic'
import { subscriptionsLogic } from 'products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic'
import { urlForSubscriptions } from 'products/subscriptions/frontend/components/Subscriptions/utils'
import { SubscriptionCountBadge } from './SubscriptionCountBadge'
export function QuillDashboardSubscribeButton(): JSX.Element | null {
const { dashboard, canEditDashboard, tiles } = useValues(dashboardLogic)
const { push } = useActions(router)
if (!dashboard || !canEditDashboard || tiles.length === 0) {
return null
}
const dashboardId = dashboard.id
return (
<Button
variant="default"
data-attr="dashboard-subscribe-prominent-button"
onClick={() => {
posthog.capture('dashboard subscribe clicked', {
dashboard_id: dashboardId,
})
push(urlForSubscriptions({ dashboardId }))
}}
>
<IconBell />
Subscribe
{/* Read the count only when the logic is already mounted, so a dashboard view does not load subscriptions */}
{subscriptionsLogic.isMounted({ dashboardId }) && <SubscriptionCountBadge dashboardId={dashboardId} />}
</Button>
)
}