: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 { MakeLogicType, actions, kea, key, listeners, path, props, reducers } from 'kea'
import { MessageAudience, MessageAudienceDestination, captureMessageAudienceClicked } from './messageAudience'
import { openMessageAudience } from './messageAudienceWarnings'
export interface MessageAudienceOpenLogicProps {
audience: MessageAudience
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface messageAudienceOpenLogicValues {
opening: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface messageAudienceOpenLogicActions {
open: (destination: MessageAudienceDestination) => {
destination: MessageAudienceDestination
}
openFinished: () => {
value: true
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface messageAudienceOpenLogicMeta {
key: string
}
export type messageAudienceOpenLogicType = MakeLogicType<
messageAudienceOpenLogicValues,
messageAudienceOpenLogicActions,
MessageAudienceOpenLogicProps,
messageAudienceOpenLogicMeta
>
export const messageAudienceOpenLogic = kea<messageAudienceOpenLogicType>([
path((key) => ['products', 'workflows', 'frontend', 'MessageAudience', 'messageAudienceOpenLogic', key]),
props({} as MessageAudienceOpenLogicProps),
key((props) => `${props.audience.source}:${JSON.stringify(props.audience.properties)}`),
actions({
open: (destination: MessageAudienceDestination) => ({ destination }),
openFinished: true,
}),
reducers({
opening: [
false,
{
open: () => true,
openFinished: () => false,
},
],
}),
listeners(({ actions, props }) => ({
open: async ({ destination }) => {
captureMessageAudienceClicked(props.audience.source, destination)
try {
await openMessageAudience(props.audience, destination)
} finally {
actions.openFinished()
}
},
})),
])