: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, path, props } from 'kea'
import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { LinkedInAdsAccountType, LinkedInAdsConversionRuleType } from '~/types'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface linkedInAdsIntegrationLogicValues {
linkedInAdsAccounts: LinkedInAdsAccountType[] | null
linkedInAdsAccountsLoading: boolean
linkedInAdsConversionRules: LinkedInAdsConversionRuleType[] | null
linkedInAdsConversionRulesLoading: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface linkedInAdsIntegrationLogicActions {
loadLinkedInAdsAccounts: () => {
value: true
}
loadLinkedInAdsAccountsFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
loadLinkedInAdsAccountsSuccess: (
linkedInAdsAccounts: LinkedInAdsAccountType[],
payload?: {
value: true
}
) => {
linkedInAdsAccounts: LinkedInAdsAccountType[]
payload?: {
value: true
}
}
loadLinkedInAdsConversionRules: (accountId: string) => string
loadLinkedInAdsConversionRulesFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
loadLinkedInAdsConversionRulesSuccess: (
linkedInAdsConversionRules: LinkedInAdsConversionRuleType[],
payload?: string
) => {
linkedInAdsConversionRules: LinkedInAdsConversionRuleType[]
payload?: string
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface linkedInAdsIntegrationLogicProps {
id: number
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface linkedInAdsIntegrationLogicMeta {
key: number
}
export type linkedInAdsIntegrationLogicType = MakeLogicType<
linkedInAdsIntegrationLogicValues,
linkedInAdsIntegrationLogicActions,
linkedInAdsIntegrationLogicProps,
linkedInAdsIntegrationLogicMeta
>
export const linkedInAdsIntegrationLogic = kea<linkedInAdsIntegrationLogicType>([
props({} as { id: number }),
key((props) => props.id),
path((key) => ['lib', 'integrations', 'linkedInAdsIntegrationLogic', key]),
actions({
loadLinkedInAdsConversionRules: (accountId: string) => accountId,
loadLinkedInAdsAccounts: true,
}),
loaders(({ props }) => ({
linkedInAdsConversionRules: [
null as LinkedInAdsConversionRuleType[] | null,
{
loadLinkedInAdsConversionRules: async (customerId: string) => {
const res = await api.integrations.linkedInAdsConversionRules(props.id, customerId)
return res.conversionRules
},
},
],
linkedInAdsAccounts: [
null as LinkedInAdsAccountType[] | null,
{
loadLinkedInAdsAccounts: async () => {
const res = await api.integrations.linkedInAdsAccounts(props.id)
return res.adAccounts
},
},
],
})),
])