: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 { GoogleAdsConversionActionType } from '~/types'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface googleAdsIntegrationLogicValues {
googleAdsAccessibleAccounts:
| {
id: string
level: string
name: string
parent_id: string
}[]
| null
googleAdsAccessibleAccountsLoading: boolean
googleAdsConversionActions: GoogleAdsConversionActionType[] | null
googleAdsConversionActionsLoading: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface googleAdsIntegrationLogicActions {
loadGoogleAdsAccessibleAccounts: () => {
value: true
}
loadGoogleAdsAccessibleAccountsFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
loadGoogleAdsAccessibleAccountsSuccess: (
googleAdsAccessibleAccounts: {
id: string
level: string
name: string
parent_id: string
}[],
payload?: {
value: true
}
) => {
googleAdsAccessibleAccounts: {
id: string
level: string
name: string
parent_id: string
}[]
payload?: {
value: true
}
}
loadGoogleAdsConversionActions: (
customerId: string,
parentId: string
) => {
customerId: string
parentId: string
}
loadGoogleAdsConversionActionsFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
loadGoogleAdsConversionActionsSuccess: (
googleAdsConversionActions: GoogleAdsConversionActionType[],
payload?: {
customerId: string
parentId: string
}
) => {
googleAdsConversionActions: GoogleAdsConversionActionType[]
payload?: {
customerId: string
parentId: string
}
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface googleAdsIntegrationLogicProps {
id: number
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface googleAdsIntegrationLogicMeta {
key: number
}
export type googleAdsIntegrationLogicType = MakeLogicType<
googleAdsIntegrationLogicValues,
googleAdsIntegrationLogicActions,
googleAdsIntegrationLogicProps,
googleAdsIntegrationLogicMeta
>
export const googleAdsIntegrationLogic = kea<googleAdsIntegrationLogicType>([
props({} as { id: number }),
key((props) => props.id),
path((key) => ['lib', 'integrations', 'googleAdsIntegrationLogic', key]),
actions({
loadGoogleAdsConversionActions: (customerId: string, parentId: string) => ({ customerId, parentId }),
loadGoogleAdsAccessibleAccounts: true,
}),
loaders(({ props }) => ({
googleAdsConversionActions: [
null as GoogleAdsConversionActionType[] | null,
{
loadGoogleAdsConversionActions: async ({
customerId,
parentId,
}: {
customerId: string
parentId: string
}) => {
const res = await api.integrations.googleAdsConversionActions(props.id, {
customerId,
parentId,
})
return res.conversionActions
},
},
],
googleAdsAccessibleAccounts: [
null as { id: string; level: string; parent_id: string; name: string }[] | null,
{
loadGoogleAdsAccessibleAccounts: async () => {
const res = await api.integrations.googleAdsAccounts(props.id)
return res.accessibleAccounts
},
},
],
})),
])