: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 { useActions, useValues } from 'kea'
import { IconPlus, IconPlusSmall } from '@posthog/icons'
import { LemonButton, LemonTabs } from '@posthog/lemon-ui'
import { Button } from '@posthog/quill'
import { ActivityLog } from 'lib/components/ActivityLog/ActivityLog'
import { Shortcut } from 'lib/components/Shortcuts/Shortcut'
import { keyBinds } from 'lib/components/Shortcuts/shortcuts'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { LinkPrimitive } from 'lib/lemon-ui/Link'
import { sceneConfigurations } from 'scenes/scenes'
import { Scene, SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { ProductKey } from '~/queries/schema/schema-general'
import { ActivityScope } from '~/types'
import { webScriptsEmptyState } from 'products/cdp/frontend/emptyState/webScriptsEmptyState'
import { DataPipelinesHogFunctions } from './DataPipelinesHogFunctions'
import { webScriptsSceneLogic } from './webScriptsSceneLogic'
export const scene: SceneExport = {
component: WebScriptsScene,
logic: webScriptsSceneLogic,
productKey: ProductKey.SITE_APPS,
emptyState: webScriptsEmptyState,
}
export function WebScriptsScene(): JSX.Element {
const { activeTab } = useValues(webScriptsSceneLogic)
const { setActiveTab } = useActions(webScriptsSceneLogic)
const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')
const action = (
<Shortcut
name="NewPipelineApp"
keybind={[keyBinds.new]}
intent="New JS snippet"
interaction="click"
scope={Scene.WebScripts}
>
{todayRailNav ? (
<Button
variant="primary"
render={<LinkPrimitive to={urls.webScriptsNew()} />}
tooltip="New web script"
data-attr="new-web-script"
>
<IconPlus />
New web script
</Button>
) : (
<LemonButton
type="primary"
to={urls.webScriptsNew()}
icon={<IconPlusSmall />}
size="small"
tooltip="New web script"
data-attr="new-web-script"
>
New web script
</LemonButton>
)}
</Shortcut>
)
const tabs = [
{
key: 'all',
label: 'All web scripts',
content: <DataPipelinesHogFunctions kind="site_app" />,
},
{
key: 'history',
label: 'History',
content: <ActivityLog scope={[ActivityScope.HOG_FUNCTION, ActivityScope.BATCH_EXPORT]} />,
},
]
return (
<SceneContent>
<SceneTitleSection
name={sceneConfigurations[Scene.WebScripts].name}
description={sceneConfigurations[Scene.WebScripts].description}
resourceType={{
type: sceneConfigurations[Scene.WebScripts].iconType || 'default_icon_type',
}}
actions={action}
/>
<LemonTabs
activeKey={activeTab}
onChange={(key) => setActiveTab(key as 'all' | 'history')}
tabs={tabs}
sceneInset
/>
</SceneContent>
)
}