: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, key, listeners, path, selectors } from 'kea'
import { router, urlToAction } from 'kea-router'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { sceneConfigurations } from 'scenes/scenes'
import { Scene } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
import { ActivityTab, Breadcrumb } from '~/types'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface liveEventsTableSceneLogicValues {
breadcrumbs: Breadcrumb[]
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface liveEventsTableSceneLogicActions {
setFeatureFlags: (
flags: string[],
variants: Record<string, boolean | string>
) => {
flags: string[]
variants: Record<string, boolean | string>
} // featureFlagLogic
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface liveEventsTableSceneLogicMeta {
key: string
}
export type liveEventsTableSceneLogicType = MakeLogicType<
liveEventsTableSceneLogicValues,
liveEventsTableSceneLogicActions,
Record<string, any>,
liveEventsTableSceneLogicMeta
>
function redirectIfLiveEventsRetired(): void {
const onLiveEvents = router.values.location.pathname.endsWith(urls.activity(ActivityTab.LiveEvents))
if (onLiveEvents && featureFlagLogic.values.featureFlags[FEATURE_FLAGS.LIVESTREAM_HOGQL]) {
router.actions.replace(urls.activity(ActivityTab.ExploreEvents))
}
}
export const liveEventsTableSceneLogic = kea<liveEventsTableSceneLogicType>([
key(() => 'scene'),
path((key) => ['scenes', 'activity', 'live-events', 'liveEventsTableSceneLogic', key]),
selectors(() => ({
breadcrumbs: [
() => [],
(): Breadcrumb[] => [
{
key: Scene.LiveEvents,
name: sceneConfigurations[Scene.LiveEvents].name,
iconType: sceneConfigurations[Scene.LiveEvents].iconType,
},
],
],
})),
connect(() => ({
actions: [featureFlagLogic, ['setFeatureFlags']],
})),
listeners(() => ({
// Flags can resolve after the URL action ran, so check again when they arrive.
setFeatureFlags: () => redirectIfLiveEventsRetired(),
})),
urlToAction(() => ({
[urls.activity(ActivityTab.LiveEvents)]: () => redirectIfLiveEventsRetired(),
})),
])