: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 } from 'kea'
import { LemonButton } from '@posthog/lemon-ui'
import { PayGateMini } from 'lib/components/PayGateMini/PayGateMini'
import { RestrictionScope, useRestrictedArea } from 'lib/components/RestrictedArea'
import { OrganizationMembershipLevel } from 'lib/constants'
import { AvailableFeature, CyclotronJobFiltersType, HogFunctionSubTemplateIdType } from '~/types'
import { HogFunctionList } from './HogFunctionsList'
import { hogFunctionsListLogic } from './hogFunctionsListLogic'
import { getFiltersFromSubTemplateId } from './LinkedHogFunctions'
import { NewNotificationDialog } from './NewNotificationDialog'
import { newNotificationDialogLogic } from './newNotificationDialogLogic'
export interface NotificationsPaneProps {
/** The sub-template ID that defines the filters, names, and message templates */
subTemplateId: HogFunctionSubTemplateIdType
/** Description shown above the notification list */
description: string
/** Title for the new notification dialog */
dialogTitle?: string
/** The billing feature required to use notifications. Defaults to AUDIT_LOGS. */
requiredFeature?: AvailableFeature
/** Where the back arrow on a notification's configuration page should return to */
returnTo?: string
}
export function NotificationsPane({
subTemplateId,
description,
dialogTitle,
requiredFeature = AvailableFeature.AUDIT_LOGS,
returnTo,
}: NotificationsPaneProps): JSX.Element {
const restrictedReason = useRestrictedArea({
scope: RestrictionScope.Project,
minimumAccessLevel: OrganizationMembershipLevel.Admin,
})
const hogFunctionFilterList = [getFiltersFromSubTemplateId(subTemplateId)].filter(
(f): f is CyclotronJobFiltersType => !!f
)
const listLogicProps = { forceFilterGroups: hogFunctionFilterList, type: 'internal_destination' as const }
const { loadHogFunctions } = useActions(hogFunctionsListLogic(listLogicProps))
const onCreated = (): void => {
loadHogFunctions()
}
const logicProps = { subTemplateId, onCreated }
const { openDialog } = useActions(newNotificationDialogLogic(logicProps))
return (
<PayGateMini feature={requiredFeature} featureDetail="hog-function-notifications">
<div>
<p>{description}</p>
<HogFunctionList
forceFilterGroups={hogFunctionFilterList}
type="internal_destination"
returnTo={returnTo}
extraControls={
<LemonButton
type="primary"
size="small"
disabledReason={restrictedReason ?? undefined}
onClick={openDialog}
>
New notification
</LemonButton>
}
/>
<NewNotificationDialog subTemplateId={subTemplateId} onCreated={onCreated} title={dialogTitle} />
</div>
</PayGateMini>
)
}