Skip to content

: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.

chore(notebooks): centralize node icons (#58987)

Alex Lider360243455234
diff --git a/frontend/src/scenes/notebooks/Notebook/NotebookPreview.tsx b/frontend/src/scenes/notebooks/Notebook/NotebookPreview.tsx
index 62a370554d27..c9634bf4e989 100644
--- a/frontend/src/scenes/notebooks/Notebook/NotebookPreview.tsx
+++ b/frontend/src/scenes/notebooks/Notebook/NotebookPreview.tsx
@@ -1,37 +1,14 @@
import { Fragment } from 'react'
-import {
- IconChat,
- IconFlask,
- IconGraph,
- IconHogQL,
- IconImage,
- IconNotebook,
- IconPython,
- IconRewindPlay,
- IconSquareRoot,
-} from '@posthog/icons'
+import { IconNotebook } from '@posthog/icons'
import { Link } from '@posthog/lemon-ui'
import { JSONContent, RichContentNodeType } from 'lib/components/RichContentEditor/types'
+import { NODE_ICONS } from '../nodeIcons'
import { NotebookNodeType } from '../types'
import { KNOWN_NODES } from '../utils'
-// Icons for the most common embed types.
-// Anything not listed here gets the generic IconNotebook fallback.
-const NODE_ICONS: Partial<Record<NotebookNodeType, JSX.Element>> = {
- [NotebookNodeType.Query]: <IconGraph />,
- [NotebookNodeType.HogQLSQL]: <IconHogQL />,
- [NotebookNodeType.DuckSQL]: <IconHogQL />,
- [NotebookNodeType.Python]: <IconPython />,
- [NotebookNodeType.Latex]: <IconSquareRoot />,
- [NotebookNodeType.Recording]: <IconRewindPlay />,
- [NotebookNodeType.Image]: <IconImage />,
- [NotebookNodeType.Experiment]: <IconFlask />,
- [NotebookNodeType.Survey]: <IconChat />,
-}
-
const MARK_WRAPPERS: Record<string, (children: JSX.Element, attrs?: Record<string, any>) => JSX.Element> = {
bold: (c) => <strong>{c}</strong>,
italic: (c) => <em>{c}</em>,
diff --git a/frontend/src/scenes/notebooks/Notebook/SlashCommands.tsx b/frontend/src/scenes/notebooks/Notebook/SlashCommands.tsx
index 07671a181dbf..fe327b50a3eb 100644
--- a/frontend/src/scenes/notebooks/Notebook/SlashCommands.tsx
+++ b/frontend/src/scenes/notebooks/Notebook/SlashCommands.tsx
@@ -14,10 +14,8 @@ import {
IconHogQL,
IconLifecycle,
IconPeople,
- IconPython,
IconRetention,
IconRewindPlay,
- IconSquareRoot,
IconStickiness,
IconTrends,
IconUpload,
@@ -43,6 +41,7 @@ import { BaseMathType, ChartDisplayType, FunnelVizType, PathType, RetentionPerio
import { addExperimentsToNotebookModalLogic } from '../AddExperimentsToNotebookModal/addExperimentsToNotebookModalLogic'
import { addInsightsToNotebookModalLogic } from '../AddInsightsToNotebookModal/addInsightsToNotebookModalLogic'
+import { NODE_ICONS } from '../nodeIcons'
import { buildInsightVizQueryContent, buildNodeEmbed, buildNodeQueryContent } from '../Nodes/nodeBuilders'
import { NotebookNodeType } from '../types'
import NotebookIconHeading from './NotebookIconHeading'
@@ -307,7 +306,7 @@ order by count() desc
{
title: 'SQL (DuckDB)',
search: 'duck sql',
- icon: <IconHogQL color="currentColor" />,
+ icon: NODE_ICONS[NotebookNodeType.DuckSQL],
command: (chain, pos) =>
chain.insertContentAt(pos, {
type: NotebookNodeType.DuckSQL,
@@ -324,7 +323,7 @@ order by count() desc
{
title: 'SQL (HogQL)',
search: 'hogql sql',
- icon: <IconHogQL color="currentColor" />,
+ icon: NODE_ICONS[NotebookNodeType.HogQLSQL],
command: (chain, pos) =>
chain.insertContentAt(pos, {
type: NotebookNodeType.HogQLSQL,
@@ -341,7 +340,7 @@ order by count() desc
{
title: 'Python',
search: 'python',
- icon: <IconPython color="currentColor" />,
+ icon: NODE_ICONS[NotebookNodeType.Python],
command: (chain, pos) =>
chain.insertContentAt(pos, {
type: NotebookNodeType.Python,
@@ -493,7 +492,7 @@ order by count() desc
{
title: 'LaTeX',
search: 'latex math formula equation',
- icon: <IconSquareRoot color="currentColor" />,
+ icon: NODE_ICONS[NotebookNodeType.Latex],
command: (chain, pos) =>
chain.insertContentAt(pos, {
type: NotebookNodeType.Latex,
diff --git a/frontend/src/scenes/notebooks/nodeIcons.tsx b/frontend/src/scenes/notebooks/nodeIcons.tsx
new file mode 100644
index 000000000000..72992a2b819e
--- /dev/null
+++ b/frontend/src/scenes/notebooks/nodeIcons.tsx
@@ -0,0 +1,60 @@
+import {
+ IconAI,
+ IconChat,
+ IconCheckCircle,
+ IconCode,
+ IconFlag,
+ IconFlask,
+ IconGraph,
+ IconGroups,
+ IconHogQL,
+ IconImage,
+ IconList,
+ IconMapPin,
+ IconPeople,
+ IconPerson,
+ IconPieChart,
+ IconPython,
+ IconRewindPlay,
+ IconRocket,
+ IconSquareRoot,
+ IconUserPaths,
+ IconWarning,
+} from '@posthog/icons'
+
+import { NotebookNodeType } from './types'
+
+// Single source of truth for icons that represent a notebook node type.
+// Consumers (preview, slash menu, etc.) read from here; missing entries fall
+// back to the generic notebook icon at the consumer site.
+export const NODE_ICONS: Partial<Record<NotebookNodeType, JSX.Element>> = {
+ [NotebookNodeType.Query]: <IconGraph />,
+ [NotebookNodeType.HogQLSQL]: <IconHogQL />,
+ [NotebookNodeType.DuckSQL]: <IconHogQL />,
+ [NotebookNodeType.Python]: <IconPython />,
+ [NotebookNodeType.Latex]: <IconSquareRoot />,
+ [NotebookNodeType.Recording]: <IconRewindPlay />,
+ [NotebookNodeType.RecordingPlaylist]: <IconRewindPlay />,
+ [NotebookNodeType.Image]: <IconImage />,
+ [NotebookNodeType.Experiment]: <IconFlask />,
+ [NotebookNodeType.Survey]: <IconChat />,
+ [NotebookNodeType.Cohort]: <IconPeople />,
+ [NotebookNodeType.Embed]: <IconCode />,
+ [NotebookNodeType.EarlyAccessFeature]: <IconRocket />,
+ [NotebookNodeType.FeatureFlag]: <IconFlag />,
+ [NotebookNodeType.FeatureFlagCodeExample]: <IconCode />,
+ [NotebookNodeType.Group]: <IconGroups />,
+ [NotebookNodeType.GroupProperties]: <IconList />,
+ [NotebookNodeType.Issues]: <IconWarning />,
+ [NotebookNodeType.LLMTrace]: <IconAI />,
+ [NotebookNodeType.Map]: <IconMapPin />,
+ [NotebookNodeType.RelatedGroups]: <IconGroups />,
+ [NotebookNodeType.Person]: <IconPerson />,
+ [NotebookNodeType.PersonProperties]: <IconPerson />,
+ [NotebookNodeType.PersonFeed]: <IconPerson />,
+ [NotebookNodeType.SupportTickets]: <IconChat />,
+ [NotebookNodeType.UsageMetrics]: <IconPieChart />,
+ [NotebookNodeType.ZendeskTickets]: <IconChat />,
+ [NotebookNodeType.TaskCreate]: <IconCheckCircle />,
+ [NotebookNodeType.CustomerJourney]: <IconUserPaths />,
+}