: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, afterMount, connect, kea, key, listeners, path, props, reducers } from 'kea'
import { loaders } from 'kea-loaders'
import { ApiConfig } from 'lib/api'
import { engineeringAnalyticsDeliverySummary } from '../generated/api'
import type { DeliverySummaryApi } from '../generated/api.schemas'
import { DeliveryScope, deliveryScopeKey, deliveryScopeParams } from '../lib/deliveryScope'
import { engineeringAnalyticsFiltersLogic } from './engineeringAnalyticsFiltersLogic'
export interface DeliverySummaryLogicProps {
// An author or a GitHub team; the summary endpoint rejects a single pull request.
scope: DeliveryScope
sourceId: string | null
/** The 'owner/name' in the page's path. */
repo?: string | null
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface deliverySummaryLogicValues {
dateFrom: string | null // engineeringAnalyticsFiltersLogic
dateTo: string | null // engineeringAnalyticsFiltersLogic
summary: DeliverySummaryApi | null
summaryFailed: boolean
summaryLoading: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface deliverySummaryLogicActions {
loadSummary: () => any
loadSummaryFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
loadSummarySuccess: (
summary: DeliverySummaryApi,
payload?: any
) => {
summary: DeliverySummaryApi
payload?: any
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface deliverySummaryLogicMeta {
key: string
}
export type deliverySummaryLogicType = MakeLogicType<
deliverySummaryLogicValues,
deliverySummaryLogicActions,
DeliverySummaryLogicProps,
deliverySummaryLogicMeta
>
export const deliverySummaryLogic = kea<deliverySummaryLogicType>([
path(['products', 'engineering_analytics', 'frontend', 'scenes', 'deliverySummaryLogic']),
props({} as DeliverySummaryLogicProps),
key((props) => `${deliveryScopeKey(props.scope)}@${props.repo ?? ''}@${props.sourceId ?? ''}`),
connect(() => ({
values: [engineeringAnalyticsFiltersLogic, ['dateFrom', 'dateTo']],
})),
loaders(({ props, values }) => ({
summary: [
null as DeliverySummaryApi | null,
{
loadSummary: async () =>
await engineeringAnalyticsDeliverySummary(String(ApiConfig.getCurrentProjectId()), {
...deliveryScopeParams(props.scope),
date_from: values.dateFrom ?? undefined,
date_to: values.dateTo ?? undefined,
source_id: props.sourceId ?? undefined,
repo: props.repo ?? undefined,
}),
},
],
})),
reducers({
summaryFailed: [false, { loadSummary: () => false, loadSummaryFailure: () => true }],
}),
listeners(({ actions }) => ({
[engineeringAnalyticsFiltersLogic.actionTypes.setDateRange]: () => {
actions.loadSummary()
},
})),
afterMount(({ actions }) => {
actions.loadSummary()
}),
])