: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, connect, kea, path, selectors } from 'kea'
import { lazyLoaders } from 'kea-loaders'
import api from 'lib/api'
import { teamLogic } from 'scenes/teamLogic'
import type { EventIngestionRestrictionApi } from '~/generated/core/api.schemas'
export enum RestrictionType {
DROP_EVENT_FROM_INGESTION = 'drop_event_from_ingestion',
SKIP_PERSON_PROCESSING = 'skip_person_processing',
FORCE_OVERFLOW_FROM_INGESTION = 'force_overflow_from_ingestion',
REDIRECT_TO_DLQ = 'redirect_to_dlq',
REDIRECT_TO_TOPIC = 'redirect_to_topic',
}
export type EventIngestionRestriction = EventIngestionRestrictionApi
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface eventIngestionRestrictionLogicValues {
currentTeamIdStrict: number | string // teamLogic
eventIngestionRestrictions: EventIngestionRestriction[]
eventIngestionRestrictionsLoading: boolean
hasProjectNoticeRestriction: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface eventIngestionRestrictionLogicActions {
loadEventIngestionRestrictions: () => any
loadEventIngestionRestrictionsFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
loadEventIngestionRestrictionsSuccess: (
eventIngestionRestrictions: any[],
payload?: any
) => {
eventIngestionRestrictions: any[]
payload?: any
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface eventIngestionRestrictionLogicMeta {
__keaTypeGenInternalSelectorTypes: {
hasProjectNoticeRestriction: (eventIngestionRestrictions: EventIngestionRestrictionApi[]) => boolean
}
}
export type eventIngestionRestrictionLogicType = MakeLogicType<
eventIngestionRestrictionLogicValues,
eventIngestionRestrictionLogicActions,
Record<string, any>,
eventIngestionRestrictionLogicMeta
>
export const eventIngestionRestrictionLogic = kea<eventIngestionRestrictionLogicType>([
path(['lib', 'logic', 'eventIngestionRestrictionLogic']),
connect(() => ({ values: [teamLogic, ['currentTeamIdStrict']] })),
lazyLoaders(({ values }) => ({
eventIngestionRestrictions: {
__default: [] as EventIngestionRestriction[],
loadEventIngestionRestrictions: async () => {
try {
// nosemgrep: prefer-codegen-api -- Legacy raw API call with a hand-written URL and an unchecked response type. Use organizationsProjectsEventIngestionRestrictionsList() from '~/generated/core/api' instead.
const response = await api.get(
`api/projects/${values.currentTeamIdStrict}/event_ingestion_restrictions/`
)
// api.get resolves to null on non-JSON responses (204, CDN error pages, etc.) — coerce to []
return Array.isArray(response) ? response : []
} catch (error) {
console.error('Failed to load event ingestion restrictions:', error)
return []
}
},
},
})),
selectors({
hasProjectNoticeRestriction: [
(s) => [s.eventIngestionRestrictions],
(eventIngestionRestrictions: EventIngestionRestriction[]): boolean => {
return eventIngestionRestrictions.some(
(r: EventIngestionRestriction) =>
r.restriction_type === RestrictionType.DROP_EVENT_FROM_INGESTION ||
r.restriction_type === RestrictionType.SKIP_PERSON_PROCESSING
)
},
],
}),
])