Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

feat(dashboard): draft a report from a description, and one empty state design everywhere (#600)

Carl-Gerhard Lindesvärd3a5fbd05f520
diff --git a/apps/start/e2e/data-sessions-profiles.spec.ts b/apps/start/e2e/data-sessions-profiles.spec.ts
index e90aeebde..33d8aded5 100644
--- a/apps/start/e2e/data-sessions-profiles.spec.ts
+++ b/apps/start/e2e/data-sessions-profiles.spec.ts
@@ -107,7 +107,7 @@ test.describe('sessions', () => {
}
await page.getByPlaceholder(/Search/).fill('zzz-no-such-session');
- await expect(page.getByText('No sessions found')).toBeVisible();
+ await expect(page.getByText('No sessions', { exact: true })).toBeVisible();
await page.screenshot({ path: `${SHOTS}/sessions-empty.png` });
expect(problems).toEqual([]);
});
diff --git a/apps/start/e2e/reports-builder.spec.ts b/apps/start/e2e/reports-builder.spec.ts
index 0fdebf51b..003e901fe 100644
--- a/apps/start/e2e/reports-builder.spec.ts
+++ b/apps/start/e2e/reports-builder.spec.ts
@@ -47,9 +47,9 @@ test('linear report: build, compare with the API, save, reload, edit, update', a
try {
await page.goto(`/acme/${SHOP}/reports?dashboardId=${dashboard.id}`);
await page.waitForLoadState('networkidle');
- await expect(
- page.getByText('Pick at least one event to start visualising')
- ).toBeVisible({ timeout: 30_000 });
+ await expect(page.getByRole('button', { name: 'Pick events' })).toBeVisible(
+ { timeout: 30_000 }
+ );
await addEvent(page, 'purchase');
await addEvent(page, 'add_to_cart');
const sheet = await openSidebar(page);
diff --git a/apps/start/e2e/reports-prompt.spec.ts b/apps/start/e2e/reports-prompt.spec.ts
new file mode 100644
index 000000000..20f8383f9
--- /dev/null
+++ b/apps/start/e2e/reports-prompt.spec.ts
@@ -0,0 +1,80 @@
+// The empty report editor drafts a report from a description. Needs an AI
+// provider on the API; without one the editor shows the event picker instead.
+
+import { expect, test } from './fixtures';
+import {
+ hideFeedbackPrompt,
+ shot,
+ trackProblems,
+ trpcQuery,
+ waitForChart,
+} from './reports-helpers';
+
+const SHOP = 'acme-shop';
+const DRAFT_TIMEOUT = 90_000;
+
+interface ChatModels {
+ models: Array<{ id: string }>;
+}
+
+test.use({ actionTimeout: 20_000 });
+
+test.beforeEach(async ({ page }) => {
+ await hideFeedbackPrompt(page);
+});
+
+test('an empty report is drafted from a description and can be saved', async ({
+ page,
+}) => {
+ test.setTimeout(240_000);
+ const problems = trackProblems(page);
+ await page.goto(`/acme/${SHOP}/reports`);
+ const chat = await trpcQuery<ChatModels>(page, 'chat.models', undefined);
+ test.skip(chat.models.length === 0, 'no AI provider configured on the API');
+
+ const promptBox = page.getByLabel('Describe the report');
+ await expect(promptBox).toBeVisible({ timeout: 30_000 });
+ await expect(page.getByRole('button', { name: 'Save' })).toBeDisabled();
+ await shot(page, 'prompt-empty');
+
+ await promptBox.fill(
+ 'Purchases per day for the last 7 days, split by device'
+ );
+ await page.keyboard.press('Enter');
+ await expect(promptBox).toBeHidden({ timeout: DRAFT_TIMEOUT });
+ await waitForChart(page);
+ await shot(page, 'prompt-drafted');
+
+ // The editor, not the toast that also names the draft.
+ const editor = page.locator('#report-editor').locator('..');
+ await expect(
+ editor.getByText('purchase', { exact: false }).first()
+ ).toBeVisible();
+ await expect(editor.getByText('by device', { exact: true })).toBeVisible();
+ await expect(page.getByRole('button', { name: 'Last 7 days' })).toBeVisible();
+ await expect(
+ page.getByRole('button', { name: 'Unnamed Report' })
+ ).toHaveCount(0);
+ await expect(page.getByRole('button', { name: 'Save' })).toBeEnabled();
+
+ expect(problems.pageErrors).toEqual([]);
+});
+
+test('a request with no matching events explains what is tracked instead', async ({
+ page,
+}) => {
+ test.setTimeout(240_000);
+ await page.goto(`/acme/${SHOP}/reports`);
+ const chat = await trpcQuery<ChatModels>(page, 'chat.models', undefined);
+ test.skip(chat.models.length === 0, 'no AI provider configured on the API');
+
+ const promptBox = page.getByLabel('Describe the report');
+ await expect(promptBox).toBeVisible({ timeout: 30_000 });
+ await promptBox.fill('unicorn sightings by moon phase');
+ await page.keyboard.press('Enter');
+ const notice = page.getByRole('status').filter({ hasText: /./ }).last();
+ await expect(notice).toBeVisible({ timeout: DRAFT_TIMEOUT });
+ await expect(notice).not.toHaveText(/Reading|Drafting|Almost/);
+ await expect(promptBox).toBeVisible();
+ await expect(page.getByRole('button', { name: 'Save' })).toBeDisabled();
+});
diff --git a/apps/start/e2e/settings-notifications.spec.ts b/apps/start/e2e/settings-notifications.spec.ts
index 3dad48522..d8bae1a4c 100644
--- a/apps/start/e2e/settings-notifications.spec.ts
+++ b/apps/start/e2e/settings-notifications.spec.ts
@@ -143,11 +143,13 @@ test('both notification tabs render their empty state', async ({ page }) => {
target.getByRole('tab', { name: 'Rules' })
);
await expect(page).toHaveURL(/notifications\/notifications$/);
- await expect(page.getByText('No data')).toBeVisible(SLOW_ASSERT);
+ await expect(page.getByText('No notifications yet')).toBeVisible(SLOW_ASSERT);
await page.getByRole('tab', { name: 'Rules' }).click();
await expect(page).toHaveURL(/notifications\/rules$/);
- await expect(page.getByText('No rules yet')).toBeVisible(SLOW_ASSERT);
+ await expect(page.getByText('No notification rules yet')).toBeVisible(
+ SLOW_ASSERT
+ );
await screenshot(page, 'rules-empty');
await page.goBack();
@@ -315,7 +317,9 @@ test('a rule is deleted after confirmation', async ({ page }) => {
await card.getByRole('button', { name: 'Delete' }).click();
await dialog.getByRole('button', { name: 'Yes' }).click();
await expect(page.getByText('Rule deleted')).toBeVisible(SLOW_ASSERT);
- await expect(page.getByText('No rules yet')).toBeVisible(SLOW_ASSERT);
+ await expect(page.getByText('No notification rules yet')).toBeVisible(
+ SLOW_ASSERT
+ );
expect(await fetchRules()).toEqual([]);
// The funnel card renders its events without keys; known, so it is filtered out below.
expect(
diff --git a/apps/start/src/components/chat/chat-empty.tsx b/apps/start/src/components/chat/chat-empty.tsx
index f90227f4d..91feed1a7 100644
--- a/apps/start/src/components/chat/chat-empty.tsx
+++ b/apps/start/src/components/chat/chat-empty.tsx
@@ -1,64 +1,131 @@
import type { ChatLaunchHint } from '@openpanel/core/modules/assistant/assistant.constants';
-import { ExternalLinkIcon, KeyRoundIcon, SparklesIcon } from 'lucide-react';
+import {
+ ActivityIcon,
+ ArrowLeftRightIcon,
+ ArrowUpRightIcon,
+ ChartBarIcon,
+ ChartLineIcon,
+ CodeIcon,
+ CompassIcon,
+ ExternalLinkIcon,
+ FilterIcon,
+ GitForkIcon,
+ GlobeIcon,
+ HistoryIcon,
+ KeyRoundIcon,
+ LayersIcon,
+ LayoutDashboardIcon,
+ ListIcon,
+ LogInIcon,
+ type LucideIcon,
+ PlugIcon,
+ PlusIcon,
+ RouteIcon,
+ ScrollTextIcon,
+ SearchIcon,
+ TargetIcon,
+ TrendingDownIcon,
+ TrendingUpIcon,
+ TriangleAlertIcon,
+ UndoIcon,
+ UserIcon,
+ UsersIcon,
+ ZapIcon,
+} from 'lucide-react';
import CopyInput from '@/components/forms/copy-input';
-const DEFAULT_PROMPTS = [
- 'What changed this week compared to last week?',
- 'Show me unique visitors per day for the last 30 days',
- 'Build a dashboard for signups and where they come from',
- 'How do I connect the MCP server to Claude?',
+interface Suggestion {
+ icon: LucideIcon;
+ text: string;
+}
+
+const DEFAULT_PROMPTS: Suggestion[] = [
+ {
+ icon: ArrowLeftRightIcon,
+ text: 'What changed this week compared to last week?',
+ },
+ {
+ icon: ChartLineIcon,
+ text: 'Show me unique visitors per day for the last 30 days',
+ },
+ {
+ icon: LayoutDashboardIcon,
+ text: 'Build a dashboard for signups and where they come from',
+ },
+ { icon: PlugIcon, text: 'How do I connect the MCP server to Claude?' },
];
-function promptsFor(hint?: ChatLaunchHint): string[] {
+function promptsFor(hint?: ChatLaunchHint): Suggestion[] {
switch (hint?.page) {
case 'profile':
return [
- 'Tell me about this user',
- 'What did they do in their last session?',
- 'How does this user compare to a typical one?',
- 'Which pages did they visit most?',
+ { icon: UserIcon, text: 'Tell me about this user' },
+ { icon: HistoryIcon, text: 'What did they do in their last session?' },
+ {
+ icon: UsersIcon,
+ text: 'How does this user compare to a typical one?',
+ },
+ { icon: ListIcon, text: 'Which pages did they visit most?' },
];
case 'session':
return [
- 'Walk me through this session',
- 'Where did this visitor come from?',
- 'Did they convert?',
- 'Show similar sessions from the same referrer',
+ { icon: RouteIcon, text: 'Walk me through this session' },
+ { icon: CompassIcon, text: 'Where did this visitor come from?' },
+ { icon: TargetIcon, text: 'Did they convert?' },
+ {
+ icon: LayersIcon,
+ text: 'Show similar sessions from the same referrer',
+ },
];
case 'dashboard':
return [
- 'Summarize this dashboard',
- 'Which report changed the most this week?',
- 'Add a chart of signups by referrer to this dashboard',
- 'Which of these charts should I worry about?',
+ { icon: ScrollTextIcon, text: 'Summarize this dashboard' },
+ {
+ icon: TrendingUpIcon,
+ text: 'Which report changed the most this week?',
+ },
+ {
+ icon: PlusIcon,
+ text: 'Add a chart of signups by referrer to this dashboard',
+ },
+ {
+ icon: TriangleAlertIcon,
+ text: 'Which of these charts should I worry about?',
+ },
];
case 'seo':
return [
- 'Which queries are the easiest wins?',
- 'Is my organic traffic trending up?',
- 'Any pages competing for the same query?',
- 'Top pages in Google last 30 days',
+ { icon: SearchIcon, text: 'Which queries are the easiest wins?' },
+ { icon: TrendingUpIcon, text: 'Is my organic traffic trending up?' },
+ { icon: GitForkIcon, text: 'Any pages competing for the same query?' },
+ { icon: GlobeIcon, text: 'Top pages in Google last 30 days' },
];
case 'pages':
return [
- 'Which pages have the highest bounce rate?',
- 'Top entry pages last 7 days',
- 'Which pages are losing traffic?',
- 'Chart pageviews for /pricing over time',
+ { icon: UndoIcon, text: 'Which pages have the highest bounce rate?' },
+ { icon: LogInIcon, text: 'Top entry pages last 7 days' },
+ { icon: TrendingDownIcon, text: 'Which pages are losing traffic?' },
+ { icon: ChartLineIcon, text: 'Chart pageviews for /pricing over time' },
];
case 'onboarding':
return [
- 'Why are no events arriving?',
- 'Check my install on my website',
- 'Which SDK fits my stack?',
- 'Show the last events that reached this project',
+ { icon: TriangleAlertIcon, text: 'Why are no events arriving?' },
+ { icon: GlobeIcon, text: 'Check my install on my website' },
+ { icon: CodeIcon, text: 'Which SDK fits my stack?' },
+ {
+ icon: ActivityIcon,
+ text: 'Show the last events that reached this project',
+ },
];
case 'events':
return [
- 'Which events fire most often?',
- 'Show me the last 20 purchase events',
- 'Build a funnel from signup to purchase',
- 'Chart the daily count of each conversion event',
+ { icon: ZapIcon, text: 'Which events fire most often?' },
+ { icon: ListIcon, text: 'Show me the last 20 purchase events' },
+ { icon: FilterIcon, text: 'Build a funnel from signup to purchase' },
+ {
+ icon: ChartBarIcon,
+ text: 'Chart the daily count of each conversion event',
+ },
];
default:
return DEFAULT_PROMPTS;
@@ -73,28 +140,34 @@ export function ChatEmpty({
onPick: (prompt: string) => void;
}) {
return (
- <div className="mx-auto flex w-full max-w-2xl flex-1 flex-col items-center justify-center gap-6 px-4 py-10 text-center">
- <div className="flex size-11 items-center justify-center rounded-full bg-primary/10 text-primary">
- <SparklesIcon className="size-5" />
- </div>
- <div>
- <h1 className="font-semibold text-2xl">What do you want to know?</h1>
- <p className="mt-2 text-muted-foreground">
+ <div className="mx-auto flex w-full max-w-2xl flex-1 flex-col justify-center gap-8 px-4 py-10">
+ <div className="space-y-1.5 text-center">
+ <h1 className="font-semibold text-2xl tracking-tight">
+ What do you want to know?
+ </h1>
+ <p className="mx-auto max-w-md text-muted-foreground">
Ask about your numbers, get charts inline, build dashboards, or ask
how OpenPanel works.
</p>
</div>
- <div className="grid w-full gap-2 sm:grid-cols-2">
- {promptsFor(hint).map((prompt) => (
- <button
- className="rounded-xl border bg-card px-4 py-3 text-left text-sm transition-colors hover:bg-muted/60"
- key={prompt}
- onClick={() => onPick(prompt)}
- type="button"
- >
- {prompt}
- </button>
- ))}
+ <div className="space-y-2">
+ <p className="px-1 font-medium text-muted-foreground text-xs">
+ Try asking
+ </p>
+ <div className="grid gap-2 sm:grid-cols-2">
+ {promptsFor(hint).map(({ icon: Icon, text }) => (
+ <button
+ className="group flex items-center gap-3 rounded-xl bg-def-200 px-3.5 py-3 text-left text-sm transition-colors hover:bg-def-300 dark:bg-def-300 dark:hover:bg-def-400/60"
+ key={text}
+ onClick={() => onPick(text)}
+ type="button"
+ >
+ <Icon className="size-4 shrink-0 text-muted-foreground transition-colors group-hover:text-foreground" />
+ <span className="min-w-0 flex-1">{text}</span>
+ <ArrowUpRightIcon className="size-4 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100" />
+ </button>
+ ))}
+ </div>
</div>
</div>
);
diff --git a/apps/start/src/components/cohort/cohort-events-chart.tsx b/apps/start/src/components/cohort/cohort-events-chart.tsx
index abfb4ab0f..e9bc1267e 100644
--- a/apps/start/src/components/cohort/cohort-events-chart.tsx
+++ b/apps/start/src/components/cohort/cohort-events-chart.tsx
@@ -6,6 +6,7 @@ import { Grid } from '@/components/charts/grid';
import { OPChartTooltip } from '@/components/charts/op-tooltip';
import { XAxis } from '@/components/charts/x-axis';
import { YAxis } from '@/components/charts/y-axis';
+import { EmptyState } from '@/components/empty-state';
import { Widget, WidgetBody } from '@/components/widget';
import { formatDateInterval } from '@/hooks/use-format-date-interval';
import { useNumber } from '@/hooks/use-numer-formatter';
@@ -41,9 +42,13 @@ export function CohortEventsChart({ data }: Props) {
</WidgetHead>
<WidgetBody>
{total === 0 ? (
- <p className="py-4 text-center text-muted-foreground text-sm">
- No events yet
- </p>
+ <EmptyState
+ className="h-[200px]"
+ description="Events from people in this cohort will be charted here."
+ icon={ActivityIcon}
+ title="No events in the last 30 days"
+ variant="inline"
+ />
) : (
<AreaChart
animationDuration={0}
diff --git a/apps/start/src/components/empty-state.tsx b/apps/start/src/components/empty-state.tsx
new file mode 100644
index 000000000..c0d11dd4a
--- /dev/null
+++ b/apps/start/src/components/empty-state.tsx
@@ -0,0 +1,127 @@
+import { InboxIcon } from 'lucide-react';
+import type { ComponentType, ReactNode } from 'react';
+import { cn } from '@/utils/cn';
+
+/**
+ * page: a whole route (not found, no access, maintenance); fills the viewport.
+ * section: the body of a page whose header stays (no dashboards yet).
+ * inline: inside a table, widget or card that already draws a frame.
+ */
+export type EmptyStateVariant = 'page' | 'section' | 'inline';
+
+interface EmptyStateProps {
+ icon?: ComponentType<{ className?: string }>;
+ title: string;
+ description?: ReactNode;
+ /** Actions: buttons and links shown under the description. */
+ children?: ReactNode;
+ variant?: EmptyStateVariant;
+ className?: string;
+}
+
+const CONTAINER_CLASS: Record<EmptyStateVariant, string> = {
+ page: 'min-h-[calc(100dvh-4rem)] px-6 py-16 lg:min-h-dvh',
+ section: 'rounded-xl border border-dashed px-6 py-16 sm:py-24',
+ inline: 'px-4 py-10',
+};
+
+const TILE_CLASS: Record<EmptyStateVariant, string> = {
+ page: 'size-14 rounded-2xl [&_svg]:size-6',
+ section: 'size-12 rounded-2xl [&_svg]:size-5',
+ inline: 'size-10 rounded-xl [&_svg]:size-4',
+};
+
+const TITLE_CLASS: Record<EmptyStateVariant, string> = {
+ page: 'text-2xl tracking-tight',
+ section: 'text-lg',
+ inline: 'text-sm',
+};
+
+const DESCRIPTION_CLASS: Record<EmptyStateVariant, string> = {
+ page: 'text-base',
+ section: 'text-sm',
+ inline: 'text-sm',
+};
+
+/** Diameters of the rings drawn behind the icon tile, inner to outer. */
+const RING_SIZES: Record<EmptyStateVariant, readonly number[]> = {
+ page: [112, 192, 272, 352],
+ section: [96, 160, 224, 288],
+ inline: [72, 120, 168],
+};
+
+const RING_FADE =
+ '[mask-image:radial-gradient(closest-side,black_20%,transparent_100%)]';
+
+export function EmptyState({
+ icon: Icon = InboxIcon,
+ title,
+ description,
+ children,
+ variant = 'section',
+ className,
+}: EmptyStateProps) {
+ const ringSizes = RING_SIZES[variant];
+ const ringCanvas = ringSizes.at(-1);
+ const Heading = variant === 'page' ? 'h1' : 'h2';
+
+ return (
+ <div
+ className={cn(
+ 'relative flex flex-col items-center justify-center overflow-hidden text-center',
+ CONTAINER_CLASS[variant],
+ className
+ )}
+ >
+ <div className="relative mb-5">
+ <div
+ aria-hidden
+ className={cn(
+ 'pointer-events-none absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2',
+ RING_FADE
+ )}
+ style={{ width: ringCanvas, height: ringCanvas }}
+ >
+ {ringSizes.map((size, index) => (
+ <div
+ className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border border-foreground/10 dark:border-foreground/15"
+ key={size}
+ style={{
+ width: size,
+ height: size,
+ opacity: 1 - index / ringSizes.length,
+ }}
+ />
+ ))}
+ </div>
+ <div
+ className={cn(
+ 'relative flex items-center justify-center bg-card text-muted-foreground shadow-sm ring-1 ring-border',
+ TILE_CLASS[variant]
+ )}
+ >
+ <Icon />
+ </div>
+ </div>
+
+ <Heading className={cn('relative font-semibold', TITLE_CLASS[variant])}>
+ {title}
+ </Heading>
+ {description && (
+ <p
+ className={cn(
+ 'relative mt-1.5 max-w-sm text-pretty text-muted-foreground',
+ DESCRIPTION_CLASS[variant]
+ )}
+ >
+ {description}
+ </p>
+ )}
+ {children && (
+ <div className="relative mt-6 flex flex-wrap items-center justify-center gap-2">
+ {children}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/apps/start/src/components/events/table/index.tsx b/apps/start/src/components/events/table/index.tsx
index 76e747ca4..c78b0477e 100644
--- a/apps/start/src/components/events/table/index.tsx
+++ b/apps/start/src/components/events/table/index.tsx
@@ -5,7 +5,7 @@ import { getCoreRowModel, useReactTable } from '@tanstack/react-table';
import { useWindowVirtualizer } from '@tanstack/react-virtual';
import type { TRPCInfiniteData } from '@trpc/tanstack-react-query';
import { format } from 'date-fns';
-import { CalendarIcon, Loader2Icon } from 'lucide-react';
+import { CalendarIcon, Loader2Icon, ZapIcon } from 'lucide-react';
import { parseAsIsoDateTime, useQueryState } from 'nuqs';
import { last } from 'ramda';
import { memo, useCallback, useEffect, useMemo, useRef } from 'react';
@@ -13,7 +13,7 @@ import { useInViewport } from 'react-in-viewport';
import EventListener from '../event-listener';
import { useEventDrawer } from '../use-event-drawer';
import { useColumns } from './columns';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import {
OverviewFilterButton,
OverviewFiltersButtons,
@@ -193,9 +193,12 @@ const VirtualizedEventsTable = ({
</div>
{!isLoading && data.length === 0 && (
- <FullPageEmptyState
- description={"Start sending events and you'll see them here"}
+ <EmptyState
+ className="py-16"
+ description="Nothing matches this date range and filters. Events appear within seconds of your site or app sending them."
+ icon={ZapIcon}
title="No events"
+ variant="inline"
/>
)}
diff --git a/apps/start/src/components/full-page-empty-state.tsx b/apps/start/src/components/full-page-empty-state.tsx
deleted file mode 100644
index ce2da1622..000000000
--- a/apps/start/src/components/full-page-empty-state.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import type { LucideIcon } from 'lucide-react';
-import { BoxSelectIcon } from 'lucide-react';
-import { PageHeader } from './page-header';
-import { cn } from '@/utils/cn';
-
-interface FullPageEmptyStateProps {
- icon?: LucideIcon;
- title: string;
- description?: string;
- children?: React.ReactNode;
- className?: string;
-}
-
-export function FullPageEmptyState({
- icon: Icon = BoxSelectIcon,
- title,
- description,
- children,
- className,
-}: FullPageEmptyStateProps) {
- return (
- <div
- className={cn(
- 'flex items-center justify-center p-4 text-center',
- className
- )}
- >
- <div className="flex w-full max-w-xl flex-col items-center justify-center p-8">
- <div className="mb-6 flex h-24 w-24 items-center justify-center rounded-full bg-card shadow-sm">
- <Icon size={60} strokeWidth={1} />
- </div>
-
- <PageHeader className="mb-4" description={description} title={title} />
-
- {children}
- </div>
- </div>
- );
-}
diff --git a/apps/start/src/components/full-page-error-state.tsx b/apps/start/src/components/full-page-error-state.tsx
index 19f0c1f5e..b2086dd61 100644
--- a/apps/start/src/components/full-page-error-state.tsx
+++ b/apps/start/src/components/full-page-error-state.tsx
@@ -1,23 +1,26 @@
-import { ServerCrashIcon } from 'lucide-react';
-import { FullPageEmptyState } from './full-page-empty-state';
+import { TriangleAlertIcon } from 'lucide-react';
+import { EmptyState, type EmptyStateVariant } from './empty-state';
export const FullPageErrorState = ({
- title = 'Error...',
- description = 'Something went wrong...',
+ title = 'Something went wrong',
+ description = 'Try again in a moment. If it keeps happening, let us know.',
children,
+ variant = 'page',
}: {
title?: string;
description?: string;
children?: React.ReactNode;
+ /** `inline` when the error sits inside a table or card that is still on screen. */
+ variant?: Extract<EmptyStateVariant, 'page' | 'inline'>;
}) => {
return (
- <FullPageEmptyState
- className="min-h-[calc(100vh-theme(spacing.16))]"
- icon={ServerCrashIcon}
+ <EmptyState
+ description={description}
+ icon={TriangleAlertIcon}
title={title}
+ variant={variant}
>
- {description}
- {children && <div className="mt-4">{children}</div>}
- </FullPageEmptyState>
+ {children}
+ </EmptyState>
);
};
diff --git a/apps/start/src/components/full-page-loading-state.tsx b/apps/start/src/components/full-page-loading-state.tsx
index cd9c75762..2613ae163 100644
--- a/apps/start/src/components/full-page-loading-state.tsx
+++ b/apps/start/src/components/full-page-loading-state.tsx
@@ -1,25 +1,16 @@
-import type { LucideIcon } from 'lucide-react';
-import { Loader2Icon } from 'lucide-react';
-import { FullPageEmptyState } from './full-page-empty-state';
+import { Spinner } from '@/components/ui/spinner';
-const FullPageLoadingState = ({
- title = 'Fetching...',
- description = 'Please wait while we fetch your data...',
-}: {
- title?: string;
- description?: string;
-}) => {
+const FullPageLoadingState = ({ title = 'Loading…' }: { title?: string }) => {
return (
- <FullPageEmptyState
- className="min-h-[calc(100vh-theme(spacing.16))]"
- description={description}
- icon={
- ((props) => (
- <Loader2Icon {...props} className="animate-spin" />
- )) as LucideIcon
- }
- title={title}
- />
+ <div
+ aria-busy
+ className="flex min-h-[calc(100dvh-4rem)] flex-col items-center justify-center gap-3 p-8 text-center lg:min-h-dvh"
+ >
+ <Spinner aria-hidden size="md" />
+ <p className="text-muted-foreground text-sm" role="status">
+ {title}
+ </p>
+ </div>
);
};
diff --git a/apps/start/src/components/groups/group-member-growth.tsx b/apps/start/src/components/groups/group-member-growth.tsx
index 5a9c35d90..4ed36efb4 100644
--- a/apps/start/src/components/groups/group-member-growth.tsx
+++ b/apps/start/src/components/groups/group-member-growth.tsx
@@ -6,6 +6,7 @@ import { Grid } from '@/components/charts/grid';
import { OPChartTooltip } from '@/components/charts/op-tooltip';
import { XAxis } from '@/components/charts/x-axis';
import { YAxis } from '@/components/charts/y-axis';
+import { EmptyState } from '@/components/empty-state';
import { Widget, WidgetBody } from '@/components/widget';
import { formatDateInterval } from '@/hooks/use-format-date-interval';
import { useNumber } from '@/hooks/use-numer-formatter';
@@ -47,9 +48,13 @@ export function GroupMemberGrowth({ data }: Props) {
</WidgetHead>
<WidgetBody>
{data.length === 0 ? (
- <p className="py-4 text-center text-muted-foreground text-sm">
- No data yet
- </p>
+ <EmptyState
+ className="h-[200px]"
+ description="New members in the last 30 days will be charted here."
+ icon={TrendingUpIcon}
+ title="No new members yet"
+ variant="inline"
+ />
) : (
<AreaChart
animationDuration={0}
diff --git a/apps/start/src/components/integrations/active-integrations.tsx b/apps/start/src/components/integrations/active-integrations.tsx
index a37c0032d..75551b413 100644
--- a/apps/start/src/components/integrations/active-integrations.tsx
+++ b/apps/start/src/components/integrations/active-integrations.tsx
@@ -1,22 +1,22 @@
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { AnimatePresence, motion } from 'framer-motion';
-import { BoxSelectIcon } from 'lucide-react';
+import { PlugIcon } from 'lucide-react';
import { useMemo } from 'react';
import { PingBadge } from '../ping';
-import { Button } from '../ui/button';
+import { Button, LinkButton } from '../ui/button';
import {
IntegrationCard,
IntegrationCardFooter,
- IntegrationCardLogo,
IntegrationCardSkeleton,
} from './integration-card';
import { INTEGRATIONS } from './integrations';
+import { EmptyState } from '@/components/empty-state';
import { useAppParams } from '@/hooks/use-app-params';
import { useTRPC } from '@/integrations/trpc/react';
import { pushModal, showConfirm } from '@/modals';
export function ActiveIntegrations() {
- const { projectId } = useAppParams();
+ const { organizationId, projectId } = useAppParams();
const trpc = useTRPC();
const query = useQuery(
trpc.integration.list.queryOptions({
@@ -62,15 +62,19 @@ export function ActiveIntegrations() {
</>
)}
{!isLoading && data.length === 0 && (
- <IntegrationCard
- description="Integrations allow you to connect your systems to OpenPanel. You can add them in the available integrations section."
- icon={
- <IntegrationCardLogo className="bg-def-200 text-foreground">
- <BoxSelectIcon className="size-10" strokeWidth={1} />
- </IntegrationCardLogo>
- }
- name="No integrations yet"
- />
+ <EmptyState
+ className="md:col-span-2"
+ description="Connect Slack, Discord or a webhook to send notifications and data to the tools you already use."
+ icon={PlugIcon}
+ title="No integrations yet"
+ >
+ <LinkButton
+ params={{ organizationId, projectId }}
+ to="/$organizationId/$projectId/integrations/available"
+ >
+ Browse integrations
+ </LinkButton>
+ </EmptyState>
)}
<AnimatePresence mode="popLayout">
{data.map((item) => {
diff --git a/apps/start/src/components/notifications/notification-rules.tsx b/apps/start/src/components/notifications/notification-rules.tsx
deleted file mode 100644
index 0c3849099..000000000
--- a/apps/start/src/components/notifications/notification-rules.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-import { useQuery } from '@tanstack/react-query';
-import { AnimatePresence, motion } from 'framer-motion';
-import { PencilRulerIcon, PlusIcon } from 'lucide-react';
-import { useMemo } from 'react';
-import { FullPageEmptyState } from '../full-page-empty-state';
-import { IntegrationCardSkeleton } from '../integrations/integration-card';
-import { Button } from '../ui/button';
-import { RuleCard } from './rule-card';
-import { useAppParams } from '@/hooks/use-app-params';
-import { useTRPC } from '@/integrations/trpc/react';
-import { pushModal } from '@/modals';
-
-export function NotificationRules() {
- const { projectId } = useAppParams();
- const trpc = useTRPC();
- const query = useQuery(
- trpc.notification.rules.queryOptions({
- projectId,
- })
- );
- const data = useMemo(() => {
- return query.data || [];
- }, [query.data]);
-
- const isLoading = query.isLoading;
-
- if (!isLoading && data.length === 0) {
- return (
- <FullPageEmptyState icon={PencilRulerIcon} title="No rules yet">
- <p>
- You have not created any rules yet. Create a rule to start getting
- notifications.
- </p>
- <Button
- className="mt-8"
- onClick={() =>
- pushModal('AddNotificationRule', {
- rule: undefined,
- })
- }
- variant="outline"
- >
- Add Rule
- </Button>
- </FullPageEmptyState>
- );
- }
-
- return (
- <div>
- <div className="mb-2">
- <Button
- icon={PlusIcon}
- onClick={() =>
- pushModal('AddNotificationRule', {
- rule: undefined,
- })
- }
- variant="outline"
- >
- Add Rule
- </Button>
- </div>
- <div className="col grid w-full gap-4 md:grid-cols-2">
- {isLoading && (
- <>
- <IntegrationCardSkeleton />
- <IntegrationCardSkeleton />
- <IntegrationCardSkeleton />
- </>
- )}
- <AnimatePresence mode="popLayout">
- {data.map((item) => {
- return (
- <motion.div key={item.id} layout="position">
- <RuleCard rule={item} />
- </motion.div>
- );
- })}
- </AnimatePresence>
- </div>
- </div>
- );
-}
diff --git a/apps/start/src/components/notifications/table/index.tsx b/apps/start/src/components/notifications/table/index.tsx
index a0c8a34bc..e1b840257 100644
--- a/apps/start/src/components/notifications/table/index.tsx
+++ b/apps/start/src/components/notifications/table/index.tsx
@@ -26,7 +26,16 @@ export const NotificationsTable = ({ query }: Props) => {
return (
<>
<DataTableToolbar table={table} />
- <DataTable error={isError} loading={isLoading} table={table} />
+ <DataTable
+ empty={{
+ title: 'No notifications yet',
+ description:
+ 'Alerts from your rules land here, and in the channels they send to.',
+ }}
+ error={isError}
+ loading={isLoading}
+ table={table}
+ />
</>
);
};
diff --git a/apps/start/src/components/profiles/most-events.tsx b/apps/start/src/components/profiles/most-events.tsx
index f1c894057..c574fb80b 100644
--- a/apps/start/src/components/profiles/most-events.tsx
+++ b/apps/start/src/components/profiles/most-events.tsx
@@ -1,10 +1,11 @@
import { ZapIcon } from 'lucide-react';
import { WidgetHead, WidgetTitle } from '../overview/overview-widget';
-import { Widget, WidgetEmptyState } from '@/components/widget';
+import { EmptyState } from '@/components/empty-state';
+import { Widget } from '@/components/widget';
-type Props = {
+interface Props {
data: { count: number; name: string }[];
-};
+}
export const MostEvents = ({ data }: Props) => {
const max = data.length > 0 ? Math.max(...data.map((item) => item.count)) : 0;
@@ -14,7 +15,7 @@ export const MostEvents = ({ data }: Props) => {
<WidgetTitle>Popular events</WidgetTitle>
</WidgetHead>
{data.length === 0 ? (
- <WidgetEmptyState icon={ZapIcon} text="No events yet" />
+ <EmptyState icon={ZapIcon} title="No events yet" variant="inline" />
) : (
<div className="flex flex-col gap-1 p-1">
{data.slice(0, 5).map((item) => (
diff --git a/apps/start/src/components/profiles/popular-routes.tsx b/apps/start/src/components/profiles/popular-routes.tsx
index e3418fa36..8a2e15ae5 100644
--- a/apps/start/src/components/profiles/popular-routes.tsx
+++ b/apps/start/src/components/profiles/popular-routes.tsx
@@ -1,10 +1,11 @@
import { RouteIcon } from 'lucide-react';
import { WidgetHead, WidgetTitle } from '../overview/overview-widget';
-import { Widget, WidgetEmptyState } from '@/components/widget';
+import { EmptyState } from '@/components/empty-state';
+import { Widget } from '@/components/widget';
-type Props = {
+interface Props {
data: { count: number; path: string }[];
-};
+}
export const PopularRoutes = ({ data }: Props) => {
const max = data.length > 0 ? Math.max(...data.map((item) => item.count)) : 0;
@@ -14,7 +15,11 @@ export const PopularRoutes = ({ data }: Props) => {
<WidgetTitle>Most visited pages</WidgetTitle>
</WidgetHead>
{data.length === 0 ? (
- <WidgetEmptyState icon={RouteIcon} text="No pages visited yet" />
+ <EmptyState
+ icon={RouteIcon}
+ title="No pages visited yet"
+ variant="inline"
+ />
) : (
<div className="flex flex-col gap-1 p-1">
{data.slice(0, 5).map((item) => (
diff --git a/apps/start/src/components/profiles/profile-properties.tsx b/apps/start/src/components/profiles/profile-properties.tsx
index cf54fb784..4256ebb68 100644
--- a/apps/start/src/components/profiles/profile-properties.tsx
+++ b/apps/start/src/components/profiles/profile-properties.tsx
@@ -1,6 +1,7 @@
import type { IServiceEvent, IServiceProfile } from '@openpanel/core';
+import { TagIcon } from 'lucide-react';
import { parseAsStringEnum, useQueryState } from 'nuqs';
-import { FullPageEmptyState } from '../full-page-empty-state';
+import { EmptyState } from '../empty-state';
import { WidgetButtons, WidgetHead } from '../overview/overview-widget';
import { KeyValueGrid } from '@/components/ui/key-value-grid';
import { Widget } from '@/components/widget';
@@ -113,8 +114,13 @@ export const ProfileProperties = ({ profile }: Props) => {
}))}
/>
)}
- {!(profile && profile.properties) && (
- <FullPageEmptyState title="No properties found" />
+ {!profile?.properties && (
+ <EmptyState
+ description="Properties you pass to identify show up here."
+ icon={TagIcon}
+ title="No properties yet"
+ variant="inline"
+ />
)}
</Widget>
);
diff --git a/apps/start/src/components/report-chart/common/empty.tsx b/apps/start/src/components/report-chart/common/empty.tsx
index 9983c5dc8..6b9a198ee 100644
--- a/apps/start/src/components/report-chart/common/empty.tsx
+++ b/apps/start/src/components/report-chart/common/empty.tsx
@@ -1,5 +1,6 @@
-import { BirdIcon, CornerLeftUpIcon, ForkliftIcon } from 'lucide-react';
+import { ChartLineIcon, ChartNoAxesColumnIcon } from 'lucide-react';
import { useReportChartContext } from '../context';
+import { EmptyState } from '@/components/empty-state';
import { cn } from '@/utils/cn';
export function ReportChartEmpty({
@@ -13,44 +14,27 @@ export function ReportChartEmpty({
isEditMode,
report: { series },
} = useReportChartContext();
+ const hasSeries = series && series.length > 0;
- if (!series || series.length === 0) {
+ if (!hasSeries) {
return (
- <div className="card center-center relative h-full w-full flex-col p-4">
- <div className="row absolute top-4 left-4 items-end gap-2">
- <CornerLeftUpIcon
- className="size-8 animate-pulse text-muted-foreground"
- strokeWidth={1.2}
- />
- <div className="text-muted-foreground">Start here</div>
- </div>
- <ForkliftIcon
- className="mb-4 size-1/3 max-w-40 animate-pulse text-muted-foreground"
- strokeWidth={1.2}
- />
- <div className="font-medium text-muted-foreground">
- Ready when you're
- </div>
- <div className="mt-2 text-muted-foreground">
- Pick at least one event to start visualising
- </div>
- </div>
+ <EmptyState
+ className="card h-full w-full"
+ description="Pick at least one event and the chart draws itself here."
+ icon={ChartLineIcon}
+ title="Ready when you are"
+ variant="inline"
+ />
);
}
return (
- <div
- className={cn(
- 'center-center h-full w-full flex-col',
- isEditMode && 'card p-4'
- )}
- >
- <BirdIcon
- className="mb-4 size-1/3 animate-pulse text-muted-foreground"
- strokeWidth={1.2}
- />
- <div className="font-medium text-muted-foreground">{title}</div>
- <div className="mt-2 text-muted-foreground">{children}</div>
- </div>
+ <EmptyState
+ className={cn('h-full w-full', isEditMode && 'card')}
+ description={children}
+ icon={ChartNoAxesColumnIcon}
+ title={title}
+ variant="inline"
+ />
);
}
diff --git a/apps/start/src/components/report-chart/report-editor.tsx b/apps/start/src/components/report-chart/report-editor.tsx
index de3e21deb..a2586bfa8 100644
--- a/apps/start/src/components/report-chart/report-editor.tsx
+++ b/apps/start/src/components/report-chart/report-editor.tsx
@@ -1,7 +1,9 @@
import type { IServiceReport } from '@openpanel/core';
+import { useQuery } from '@tanstack/react-query';
import { ShareIcon } from 'lucide-react';
import { useEffect } from 'react';
import EditReportName from '../report/edit-report-name';
+import { ReportPrompt } from '../report/report-prompt';
import { ReportSummaryTrigger } from '../report/report-summary-trigger';
import { ReportChartType } from '@/components/report/ReportChartType';
import { ReportInterval } from '@/components/report/ReportInterval';
@@ -23,6 +25,7 @@ import { TimeWindowPicker } from '@/components/time-window-picker';
import { Button } from '@/components/ui/button';
import { Sheet, SheetContent, SheetTrigger } from '@/components/ui/sheet';
import { useAppParams } from '@/hooks/use-app-params';
+import { useTRPC } from '@/integrations/trpc/react';
import { pushModal } from '@/modals';
import { useDispatch, useSelector } from '@/redux';
@@ -33,6 +36,20 @@ interface ReportEditorProps {
report: IServiceReport | null;
}
+/** With an AI provider the empty editor asks for a description; without one it points at the event picker. */
+function EmptyReport({ projectId }: { projectId: string }) {
+ const trpc = useTRPC();
+ const models = useQuery(trpc.chat.models.queryOptions());
+ const report = useSelector((state) => state.report);
+ if (models.isPending) {
+ return <div className="card min-h-72" />;
+ }
+ if ((models.data?.models.length ?? 0) > 0) {
+ return <ReportPrompt />;
+ }
+ return <ReportChart isEditMode report={{ ...report, projectId }} />;
+}
+
export default function ReportEditor({
report: initialReport,
}: ReportEditorProps) {
@@ -129,7 +146,10 @@ export default function ReportEditor({
</div>
</div>
<div className="flex flex-col gap-4 p-4 pt-0" id="report-editor">
- {report.ready && (
+ {report.ready && report.series.length === 0 && (
+ <EmptyReport projectId={projectId} />
+ )}
+ {report.ready && report.series.length > 0 && (
<ReportChart isEditMode report={{ ...report, projectId }} />
)}
</div>
diff --git a/apps/start/src/components/report/report-prompt.tsx b/apps/start/src/components/report/report-prompt.tsx
new file mode 100644
index 000000000..0b5219d9c
--- /dev/null
+++ b/apps/start/src/components/report/report-prompt.tsx
@@ -0,0 +1,143 @@
+import { useMutation } from '@tanstack/react-query';
+import { ArrowUpIcon } from 'lucide-react';
+import { useEffect, useRef, useState } from 'react';
+import { toast } from 'sonner';
+import { applyDraft } from './reportSlice';
+import { Button } from '@/components/ui/button';
+import { fieldSurface } from '@/components/ui/input';
+import { Spinner } from '@/components/ui/spinner';
+import { useAppParams } from '@/hooks/use-app-params';
+import { handleError, useTRPC } from '@/integrations/trpc/react';
+import { useDispatch } from '@/redux';
+import { cn } from '@/utils/cn';
+
+/** What the box says while the model reads the project and drafts; one line per few seconds. */
+const BUSY_STATUS = [
+ 'Reading your events…',
+ 'Drafting the report…',
+ 'Almost there…',
+] as const;
+const BUSY_STATUS_STEP_MS = 3500;
+
+function useBusyStatus(busy: boolean): string | null {
+ const [index, setIndex] = useState(0);
+ useEffect(() => {
+ if (!busy) {
+ setIndex(0);
+ return;
+ }
+ const timer = setInterval(() => {
+ setIndex((current) => Math.min(current + 1, BUSY_STATUS.length - 1));
+ }, BUSY_STATUS_STEP_MS);
+ return () => clearInterval(timer);
+ }, [busy]);
+ return busy ? BUSY_STATUS[index] : null;
+}
+
+/** The empty editor: say what you want and the model drafts a starting point from the project's events. */
+export function ReportPrompt() {
+ const { projectId } = useAppParams();
+ const dispatch = useDispatch();
+ const trpc = useTRPC();
+ const [text, setText] = useState('');
+ const [notice, setNotice] = useState<string | null>(null);
+ const textareaRef = useRef<HTMLTextAreaElement>(null);
+
+ const draft = useMutation(
+ trpc.chat.draftReport.mutationOptions({
+ onSuccess(result) {
+ if (!result.report) {
+ setNotice(result.summary);
+ return;
+ }
+ dispatch(applyDraft(result.report));
+ toast(result.report.name, { description: result.summary });
+ },
+ onError: handleError,
+ })
+ );
+ const busy = draft.isPending;
+ const status = useBusyStatus(busy);
+
+ useEffect(() => {
+ textareaRef.current?.focus();
+ }, []);
+
+ const submit = () => {
+ const value = text.trim();
+ if (!value || busy) {
+ return;
+ }
+ setNotice(null);
+ draft.mutate({ projectId, prompt: value });
+ };
+
+ return (
+ <div className="card flex flex-col items-center px-4 py-16 md:py-24">
+ <div className="max-w-lg space-y-1 text-center">
+ <h2 className="font-semibold text-xl">Describe your report</h2>
+ <p className="font-medium text-base text-muted-foreground">
+ Say what you want to see and we'll generate a good starting point. You
+ can adjust everything afterwards.
+ </p>
+ </div>
+
+ <form
+ className="mt-8 w-full max-w-2xl"
+ onSubmit={(event) => {
+ event.preventDefault();
+ submit();
+ }}
+ >
+ <div className={cn(fieldSurface, 'rounded-2xl', busy && 'opacity-80')}>
+ <textarea
+ aria-label="Describe the report"
+ className="block w-full resize-none bg-transparent px-4 pt-4 pb-2 text-base text-foreground outline-none placeholder:text-muted-foreground/70"
+ disabled={busy}
+ onChange={(event) => setText(event.target.value)}
+ onKeyDown={(event) => {
+ if (event.key === 'Enter' && !event.shiftKey) {
+ event.preventDefault();
+ submit();
+ }
+ }}
+ placeholder="Unique visitors per day for the last 30 days, split by device"
+ ref={textareaRef}
+ rows={3}
+ value={text}
+ />
+ <div className="flex items-center justify-between gap-2 px-3 pb-3">
+ <span
+ aria-live="polite"
+ className="min-w-0 truncate text-muted-foreground text-xs"
+ >
+ {status}
+ </span>
+ <Button
+ aria-label="Generate report"
+ className="size-8 shrink-0 rounded-full"
+ disabled={!text.trim() || busy}
+ size="icon"
+ type="submit"
+ >
+ {busy ? (
+ <Spinner size="sm" variant="white" />
+ ) : (
+ <ArrowUpIcon className="size-4" />
+ )}
+ </Button>
+ </div>
+ </div>
+ </form>
+
+ {notice && (
+ <p
+ className="mt-3 max-w-2xl rounded-lg bg-def-100 px-3 py-2 text-center text-sm dark:bg-def-200"
+ role="status"
+ >
+ {notice}
+ </p>
+ )}
+ </div>
+ );
+}
diff --git a/apps/start/src/components/report/report-slice.test.ts b/apps/start/src/components/report/report-slice.test.ts
index 41e34f393..f5d23f3a6 100644
--- a/apps/start/src/components/report/report-slice.test.ts
+++ b/apps/start/src/components/report/report-slice.test.ts
@@ -1,8 +1,10 @@
import type { IReport } from '@openpanel/core/modules/report/report.constants';
import { describe, expect, test } from 'vitest';
import reducer, {
+ applyDraft,
changeConversionYAxisScale,
changeFunnelWindow,
+ ready,
removeEvent,
setReport,
} from './reportSlice';
@@ -66,3 +68,30 @@ describe('conversion y-axis scale', () => {
).toBeUndefined();
});
});
+
+describe('applyDraft', () => {
+ test('loads the draft as unsaved work with the editor defaults filled in', () => {
+ const state = reducer(
+ reducer(undefined, ready()),
+ applyDraft({
+ projectId: 'project',
+ name: 'Purchases by device',
+ chartType: 'linear',
+ interval: 'day',
+ range: '7d',
+ previous: false,
+ metric: 'sum',
+ series: [event('A')],
+ breakdowns: [{ id: '1', name: 'device' }],
+ })
+ );
+ expect(state.dirty).toBe(true);
+ expect(state.ready).toBe(true);
+ expect(state.name).toBe('Purchases by device');
+ expect(state.range).toBe('7d');
+ expect(state.startDate).toBeNull();
+ expect(state.lineType).toBe('monotone');
+ expect(state.globalFilters).toEqual([]);
+ expect(state.series).toHaveLength(1);
+ });
+});
diff --git a/apps/start/src/components/report/reportSlice.ts b/apps/start/src/components/report/reportSlice.ts
index c640f807a..28e500b7b 100644
--- a/apps/start/src/components/report/reportSlice.ts
+++ b/apps/start/src/components/report/reportSlice.ts
@@ -9,6 +9,7 @@ import type {
IConversionYAxisScale,
IInterval,
IReport,
+ IReportInput,
IReportOptions,
zCriteria,
} from '@openpanel/core/modules/report/report.constants';
@@ -101,6 +102,19 @@ export const reportSlice = createSlice({
ready: true,
};
},
+ // A draft from the editor's prompt box; dirty, so it can be saved as is.
+ applyDraft(state, action: PayloadAction<IReportInput & { name: string }>) {
+ return {
+ ...state,
+ ...action.payload,
+ lineType: action.payload.lineType ?? state.lineType,
+ globalFilters: action.payload.globalFilters ?? [],
+ startDate: action.payload.startDate ?? null,
+ endDate: action.payload.endDate ?? null,
+ dirty: true,
+ ready: true,
+ };
+ },
setName(state, action: PayloadAction<string>) {
state.dirty = true;
state.name = action.payload;
@@ -462,6 +476,7 @@ export const {
reset,
ready,
setReport,
+ applyDraft,
setName,
addSerie,
removeEvent,
diff --git a/apps/start/src/components/sessions/table/index.tsx b/apps/start/src/components/sessions/table/index.tsx
index 94762e814..89a842504 100644
--- a/apps/start/src/components/sessions/table/index.tsx
+++ b/apps/start/src/components/sessions/table/index.tsx
@@ -5,14 +5,14 @@ import type { Table } from '@tanstack/react-table';
import { getCoreRowModel, useReactTable } from '@tanstack/react-table';
import { useWindowVirtualizer } from '@tanstack/react-virtual';
import type { TRPCInfiniteData } from '@trpc/tanstack-react-query';
-import { Loader2Icon, RotateCwIcon } from 'lucide-react';
+import { Loader2Icon, RotateCwIcon, UsersIcon } from 'lucide-react';
import { last } from 'ramda';
import { memo, useCallback, useEffect, useMemo, useRef } from 'react';
import { useInViewport } from 'react-in-viewport';
import { useLocalStorage } from 'usehooks-ts';
import { useColumns } from './columns';
+import { EmptyState } from '@/components/empty-state';
import { TableFilterPills } from '@/components/filters/TableFilterPills';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
import { FullPageErrorState } from '@/components/full-page-error-state';
import { Skeleton } from '@/components/skeleton';
import { Button } from '@/components/ui/button';
@@ -224,9 +224,12 @@ const VirtualizedSessionsTable = ({
</div>
{!isLoading && data.length === 0 && (
- <FullPageEmptyState
- description="Looks like you haven't inserted any events yet."
- title="No sessions found"
+ <EmptyState
+ className="py-16"
+ description="Nothing matches this date range and filters. Sessions appear as soon as your site or app sends events."
+ icon={UsersIcon}
+ title="No sessions"
+ variant="inline"
/>
)}
@@ -338,6 +341,7 @@ export const SessionsTable = ({ query }: Props) => {
<FullPageErrorState
description="We could not load this data. Try again in a moment."
title="Something went wrong"
+ variant="inline"
>
<Button
icon={RotateCwIcon}
diff --git a/apps/start/src/components/ui/data-table/data-table.tsx b/apps/start/src/components/ui/data-table/data-table.tsx
index fd13fe6bd..d0f115f15 100644
--- a/apps/start/src/components/ui/data-table/data-table.tsx
+++ b/apps/start/src/components/ui/data-table/data-table.tsx
@@ -9,7 +9,7 @@ import {
TableRow,
} from '../table';
import { getCommonPinningStyles } from './data-table-helpers';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import { FullPageErrorState } from '@/components/full-page-error-state';
import { FloatingPagination } from '@/components/pagination-floating';
import { Skeleton } from '@/components/skeleton';
@@ -46,8 +46,8 @@ export function DataTable<TData>({
className,
onRowClick,
empty = {
- title: 'No data',
- description: 'We could not find any data here yet',
+ title: 'Nothing here yet',
+ description: 'Rows show up here as soon as there is data to list.',
},
...props
}: DataTableProps<TData>) {
@@ -85,13 +85,11 @@ export function DataTable<TData>({
<TableBody>
{error ? (
<TableRow>
- <TableCell
- className="h-24 text-center"
- colSpan={table.getAllColumns().length}
- >
+ <TableCell colSpan={table.getAllColumns().length}>
<FullPageErrorState
description="We could not load this data. Try again in a moment."
title="Something went wrong"
+ variant="inline"
/>
</TableCell>
</TableRow>
@@ -129,13 +127,11 @@ export function DataTable<TData>({
))
) : (
<TableRow>
- <TableCell
- className="h-24 text-center"
- colSpan={table.getAllColumns().length}
- >
- <FullPageEmptyState
+ <TableCell colSpan={table.getAllColumns().length}>
+ <EmptyState
description={empty.description}
title={empty.title}
+ variant="inline"
/>
</TableCell>
</TableRow>
diff --git a/apps/start/src/components/ui/data-table/virtualized-data-table.tsx b/apps/start/src/components/ui/data-table/virtualized-data-table.tsx
index d23448097..dab0516df 100644
--- a/apps/start/src/components/ui/data-table/virtualized-data-table.tsx
+++ b/apps/start/src/components/ui/data-table/virtualized-data-table.tsx
@@ -5,6 +5,7 @@ import {
type VirtualItem,
} from '@tanstack/react-virtual';
import throttle from 'lodash.throttle';
+import { SearchIcon } from 'lucide-react';
import { useEffect, useRef, useState } from 'react';
import {
Table,
@@ -16,6 +17,7 @@ import {
} from '../table';
import { DataTableColumnHeader } from './data-table-column-header';
import { getCommonPinningStyles } from './data-table-helpers';
+import { EmptyState } from '@/components/empty-state';
import { Skeleton } from '@/components/skeleton';
import { cn } from '@/utils/cn';
@@ -162,13 +164,17 @@ export function VirtualizedDataTable<TData>({
{visibleRows.length ? (
visibleRows.map((row) => renderTableRow(rows[row.index]!, row))
) : (
- <TableRow style={{ display: 'flex', height: '96px' }}>
+ <TableRow style={{ display: 'flex' }}>
<TableCell
- className="flex h-24 items-center justify-center text-center"
colSpan={table.getAllColumns().length}
style={{ width: '100%' }}
>
- No results.
+ <EmptyState
+ description="Nothing matches the current filters."
+ icon={SearchIcon}
+ title="No results"
+ variant="inline"
+ />
</TableCell>
</TableRow>
)}
diff --git a/apps/start/src/components/ui/key-value-grid.tsx b/apps/start/src/components/ui/key-value-grid.tsx
index 7a04b0265..729221593 100644
--- a/apps/start/src/components/ui/key-value-grid.tsx
+++ b/apps/start/src/components/ui/key-value-grid.tsx
@@ -2,6 +2,7 @@ import type { IServiceEvent } from '@openpanel/core';
import { isToday } from 'date-fns';
import { CopyIcon } from 'lucide-react';
import { SerieIcon } from '../report-chart/common/serie-icon';
+import { EmptyState } from '@/components/empty-state';
import { fancyMinutes } from '@/hooks/use-numer-formatter';
import { countries } from '@/translations/countries';
import { camelCaseToWords } from '@/utils/casing';
@@ -159,9 +160,11 @@ export function KeyValueGrid({
})}
{data.length === 0 && (
- <div className="col-span-full py-8 text-center text-muted-foreground">
- No data available
- </div>
+ <EmptyState
+ className="col-span-full py-6"
+ title="Nothing to show"
+ variant="inline"
+ />
)}
</div>
);
diff --git a/apps/start/src/components/widget.tsx b/apps/start/src/components/widget.tsx
index 2e76c675d..669c7d6e2 100644
--- a/apps/start/src/components/widget.tsx
+++ b/apps/start/src/components/widget.tsx
@@ -54,19 +54,6 @@ export function WidgetBody({ children, className }: WidgetBodyProps) {
return <div className={cn('p-4', className)}>{children}</div>;
}
-export interface WidgetEmptyStateProps {
- icon: LucideIcon;
- text: string;
-}
-export function WidgetEmptyState({ icon: Icon, text }: WidgetEmptyStateProps) {
- return (
- <div className="flex flex-col items-center justify-center gap-2 py-8 text-muted-foreground">
- <Icon size={28} strokeWidth={1.5} />
- <p className="text-sm">{text}</p>
- </div>
- );
-}
-
export interface WidgetProps {
children: React.ReactNode;
className?: string;
diff --git a/apps/start/src/router.tsx b/apps/start/src/router.tsx
index 5de93be85..da064f4c7 100644
--- a/apps/start/src/router.tsx
+++ b/apps/start/src/router.tsx
@@ -1,9 +1,10 @@
import { createRouter as createTanstackRouter } from '@tanstack/react-router';
import { setupRouterSsrQueryIntegration } from '@tanstack/react-router-ssr-query';
+import { CompassIcon } from 'lucide-react';
import * as TanstackQuery from './integrations/tanstack-query/root-provider';
import { routeTree } from './routeTree.gen';
import { getServerEnvs } from './server/get-envs';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import { LinkButton } from '@/components/ui/button';
export const getRouter = async () => {
@@ -24,13 +25,14 @@ export const getRouter = async () => {
},
defaultPreload: 'intent',
defaultNotFoundComponent: () => (
- <FullPageEmptyState
- className="min-h-screen"
+ <EmptyState
description="The page you're looking for doesn't exist or has moved."
+ icon={CompassIcon}
title="Page not found"
+ variant="page"
>
<LinkButton href="/">Go to home</LinkButton>
- </FullPageEmptyState>
+ </EmptyState>
),
Wrap: (props: { children: React.ReactNode }) => {
return (
diff --git a/apps/start/src/routes/__root.tsx b/apps/start/src/routes/__root.tsx
index a492d643b..d6e3585ea 100644
--- a/apps/start/src/routes/__root.tsx
+++ b/apps/start/src/routes/__root.tsx
@@ -15,7 +15,7 @@ import type { TRPCOptionsProxy } from '@trpc/tanstack-react-query';
import { LockIcon } from 'lucide-react';
import appCss from '../styles.css?url';
import type { ConfigResonse } from './api/config';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import { FullPageErrorState } from '@/components/full-page-error-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import { Providers } from '@/components/providers';
@@ -72,13 +72,14 @@ export const Route = createRootRouteWithContext<MyRouterContext>()({
// hard-redirects them to /login.
if (error instanceof TRPCClientError && error.data?.httpStatus === 403) {
return (
- <FullPageEmptyState
+ <EmptyState
description={error.message}
icon={LockIcon}
title="No access"
+ variant="page"
>
<LinkButton href="/">Go back to home</LinkButton>
- </FullPageEmptyState>
+ </EmptyState>
);
}
return (
diff --git a/apps/start/src/routes/_app.$organizationId.$projectId.cohorts.tsx b/apps/start/src/routes/_app.$organizationId.$projectId.cohorts.tsx
index 698fe1425..b0f359955 100644
--- a/apps/start/src/routes/_app.$organizationId.$projectId.cohorts.tsx
+++ b/apps/start/src/routes/_app.$organizationId.$projectId.cohorts.tsx
@@ -11,7 +11,7 @@ import {
} from 'lucide-react';
import { toast } from 'sonner';
import { Card, CardActions, CardActionsItem } from '@/components/card';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import { ProjectLink } from '@/components/links';
import { PageContainer } from '@/components/page-container';
@@ -86,21 +86,6 @@ function Component() {
}
}
- if (cohorts.length === 0) {
- return (
- <FullPageEmptyState icon={UsersIcon} title="No cohorts">
- <p>You have not created any cohorts for this project yet</p>
- <Button
- className="mt-14"
- icon={PlusIcon}
- onClick={() => pushModal('AddCohort')}
- >
- Create cohort
- </Button>
- </FullPageEmptyState>
- );
- }
-
return (
<PageContainer>
<PageHeader
@@ -114,109 +99,122 @@ function Component() {
description="Create and manage user segments based on events and properties"
title="Cohorts"
/>
- <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3">
- {cohorts.map((cohort) => {
- const count =
- 'currentCount' in cohort
- ? cohort.currentCount
- : cohort.profileCount;
- const displayCount = count ?? 0;
- return (
- <Card hover key={cohort.id}>
- <ProjectLink
- className="flex flex-col p-4 outline-none"
- params={{ cohortId: cohort.id }}
- to="/cohorts/$cohortId"
- >
- <div className="col gap-2">
- <div className="font-medium">{cohort.name}</div>
- {cohort.description && (
- <div className="line-clamp-2 text-muted-foreground text-sm">
- {cohort.description}
- </div>
- )}
- <div className="mt-2 flex items-center gap-4 text-muted-foreground text-sm">
- <div className="flex items-center gap-1">
- <UsersIcon size={14} />
- <span>
- {displayCount.toLocaleString()}{' '}
- {displayCount === 1 ? 'member' : 'members'}
- </span>
+ {cohorts.length === 0 ? (
+ <EmptyState
+ description="Group people by what they did or who they are, then filter any report or funnel by that group."
+ icon={UsersIcon}
+ title="No cohorts yet"
+ >
+ <Button icon={PlusIcon} onClick={() => pushModal('AddCohort')}>
+ Create cohort
+ </Button>
+ </EmptyState>
+ ) : (
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3">
+ {cohorts.map((cohort) => {
+ const count =
+ 'currentCount' in cohort
+ ? cohort.currentCount
+ : cohort.profileCount;
+ const displayCount = count ?? 0;
+ return (
+ <Card hover key={cohort.id}>
+ <ProjectLink
+ className="flex flex-col p-4 outline-none"
+ params={{ cohortId: cohort.id }}
+ to="/cohorts/$cohortId"
+ >
+ <div className="col gap-2">
+ <div className="font-medium">{cohort.name}</div>
+ {cohort.description && (
+ <div className="line-clamp-2 text-muted-foreground text-sm">
+ {cohort.description}
+ </div>
+ )}
+ <div className="mt-2 flex items-center gap-4 text-muted-foreground text-sm">
+ <div className="flex items-center gap-1">
+ <UsersIcon size={14} />
+ <span>
+ {displayCount.toLocaleString()}{' '}
+ {displayCount === 1 ? 'member' : 'members'}
+ </span>
+ </div>
+ {cohort.lastComputedAt && (
+ <div className={cn('text-xs')}>
+ Updated{' '}
+ {format(cohort.lastComputedAt, 'MMM d, HH:mm')}
+ </div>
+ )}
</div>
- {cohort.lastComputedAt && (
- <div className={cn('text-xs')}>
- Updated {format(cohort.lastComputedAt, 'MMM d, HH:mm')}
+ {cohort.isStatic && (
+ <div className="mt-1 inline-flex w-fit rounded bg-blue-100 px-2 py-0.5 text-blue-700 text-xs">
+ Static
</div>
)}
</div>
- {cohort.isStatic && (
- <div className="mt-1 inline-flex w-fit rounded bg-blue-100 px-2 py-0.5 text-blue-700 text-xs">
- Static
- </div>
- )}
- </div>
- </ProjectLink>
+ </ProjectLink>
- <CardActions>
- <CardActionsItem asChild className="w-full">
- <button
- onClick={() => handleDownload(cohort.id, cohort.name)}
- type="button"
- >
- <DownloadIcon size={16} />
- Download
- </button>
- </CardActionsItem>
- {!cohort.isStatic && (
+ <CardActions>
<CardActionsItem asChild className="w-full">
+ <button
+ onClick={() => handleDownload(cohort.id, cohort.name)}
+ type="button"
+ >
+ <DownloadIcon size={16} />
+ Download
+ </button>
+ </CardActionsItem>
+ {!cohort.isStatic && (
+ <CardActionsItem asChild className="w-full">
+ <button
+ onClick={() => {
+ refresh.mutate({ cohortId: cohort.id });
+ }}
+ type="button"
+ >
+ <RefreshCwIcon size={16} />
+ Refresh
+ </button>
+ </CardActionsItem>
+ )}
+ <CardActionsItem asChild className="w-full">
+ <button
+ onClick={() => {
+ pushModal('EditCohort', {
+ id: cohort.id,
+ name: cohort.name,
+ description: cohort.description,
+ definition: cohort.definition as never,
+ isStatic: cohort.isStatic,
+ });
+ }}
+ type="button"
+ >
+ <PencilIcon size={16} />
+ Edit
+ </button>
+ </CardActionsItem>
+ <CardActionsItem asChild className="w-full text-destructive">
<button
onClick={() => {
- refresh.mutate({ cohortId: cohort.id });
+ showConfirm({
+ title: 'Delete cohort',
+ text: 'Are you sure you want to delete this cohort? This action cannot be undone.',
+ onConfirm: () => deletion.mutate({ id: cohort.id }),
+ });
}}
type="button"
>
- <RefreshCwIcon size={16} />
- Refresh
+ <TrashIcon size={16} />
+ Delete
</button>
</CardActionsItem>
- )}
- <CardActionsItem asChild className="w-full">
- <button
- onClick={() => {
- pushModal('EditCohort', {
- id: cohort.id,
- name: cohort.name,
- description: cohort.description,
- definition: cohort.definition as never,
- isStatic: cohort.isStatic,
- });
- }}
- type="button"
- >
- <PencilIcon size={16} />
- Edit
- </button>
- </CardActionsItem>
- <CardActionsItem asChild className="w-full text-destructive">
- <button
- onClick={() => {
- showConfirm({
- title: 'Delete cohort',
- text: 'Are you sure you want to delete this cohort? This action cannot be undone.',
- onConfirm: () => deletion.mutate({ id: cohort.id }),
- });
- }}
- type="button"
- >
- <TrashIcon size={16} />
- Delete
- </button>
- </CardActionsItem>
- </CardActions>
- </Card>
- );
- })}
- </div>
+ </CardActions>
+ </Card>
+ );
+ })}
+ </div>
+ )}
</PageContainer>
);
}
diff --git a/apps/start/src/routes/_app.$organizationId.$projectId.dashboards.tsx b/apps/start/src/routes/_app.$organizationId.$projectId.dashboards.tsx
index fcbfd82f1..4307ed6b9 100644
--- a/apps/start/src/routes/_app.$organizationId.$projectId.dashboards.tsx
+++ b/apps/start/src/routes/_app.$organizationId.$projectId.dashboards.tsx
@@ -5,7 +5,7 @@ import { LayoutPanelTopIcon, Pencil, PlusIcon, Trash } from 'lucide-react';
import { toast } from 'sonner';
import { Card, CardActions, CardActionsItem } from '@/components/card';
import { DashboardPreview } from '@/components/dashboard-preview';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import { PageContainer } from '@/components/page-container';
import { PageHeader } from '@/components/page-header';
@@ -72,21 +72,6 @@ function Component() {
})
);
- if (dashboards.length === 0) {
- return (
- <FullPageEmptyState icon={LayoutPanelTopIcon} title="No dashboards">
- <p>You have not created any dashboards for this project yet</p>
- <Button
- className="mt-14"
- icon={PlusIcon}
- onClick={() => pushModal('AddDashboard')}
- >
- Create dashboard
- </Button>
- </FullPageEmptyState>
- );
- }
-
return (
<PageContainer>
<PageHeader
@@ -100,56 +85,68 @@ function Component() {
description="Access all your dashboards here"
title="Dashboards"
/>
- <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3">
- {dashboards.map((item) => (
- <Card className="group" hover key={item.id}>
- <Link
- className="col gap-3 p-3"
- from={Route.fullPath}
- to={`${item.id}`}
- >
- <DashboardPreview reports={item.reports} />
- <div className="col gap-0.5 px-1">
- <div className="truncate font-medium">{item.name}</div>
- <div className="truncate text-muted-foreground text-sm">
- {item.reports.length}{' '}
- {item.reports.length === 1 ? 'report' : 'reports'} · Updated{' '}
- {format(item.updatedAt, 'MMM d, HH:mm')}
+ {dashboards.length === 0 ? (
+ <EmptyState
+ description="Put the reports you check most often on one page, then share it with your team or embed it."
+ icon={LayoutPanelTopIcon}
+ title="No dashboards yet"
+ >
+ <Button icon={PlusIcon} onClick={() => pushModal('AddDashboard')}>
+ Create dashboard
+ </Button>
+ </EmptyState>
+ ) : (
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3">
+ {dashboards.map((item) => (
+ <Card className="group" hover key={item.id}>
+ <Link
+ className="col gap-3 p-3"
+ from={Route.fullPath}
+ to={`${item.id}`}
+ >
+ <DashboardPreview reports={item.reports} />
+ <div className="col gap-0.5 px-1">
+ <div className="truncate font-medium">{item.name}</div>
+ <div className="truncate text-muted-foreground text-sm">
+ {item.reports.length}{' '}
+ {item.reports.length === 1 ? 'report' : 'reports'} · Updated{' '}
+ {format(item.updatedAt, 'MMM d, HH:mm')}
+ </div>
</div>
- </div>
- </Link>
+ </Link>
- <CardActions>
- <CardActionsItem asChild className="w-full">
- <button
- onClick={() => {
- pushModal('EditDashboard', item);
- }}
- type="button"
- >
- <Pencil size={16} />
- Edit
- </button>
- </CardActionsItem>
- <CardActionsItem asChild className="w-full text-destructive">
- <button
- onClick={() => {
- showConfirm({
- title: 'Delete dashboard',
- text: 'Are you sure you want to delete this dashboard? All your reports will be deleted!',
- onConfirm: () => deletion.mutate({ id: item.id }),
- });
- }}
- type="button"
- >
- <Trash size={16} />
- Delete
- </button>
- </CardActionsItem>
- </CardActions>
- </Card>
- ))}
- </div>
+ <CardActions>
+ <CardActionsItem asChild className="w-full">
+ <button
+ onClick={() => {
+ pushModal('EditDashboard', item);
+ }}
+ type="button"
+ >
+ <Pencil size={16} />
+ Edit
+ </button>
+ </CardActionsItem>
+ <CardActionsItem asChild className="w-full text-destructive">
+ <button
+ onClick={() => {
+ showConfirm({
+ title: 'Delete dashboard',
+ text: 'Are you sure you want to delete this dashboard? All your reports will be deleted!',
+ onConfirm: () => deletion.mutate({ id: item.id }),
+ });
+ }}
+ type="button"
+ >
+ <Trash size={16} />
+ Delete
+ </button>
+ </CardActionsItem>
+ </CardActions>
+ </Card>
+ ))}
+ </div>
+ )}
</PageContainer>
);
}
diff --git a/apps/start/src/routes/_app.$organizationId.$projectId.dashboards_.$dashboardId.tsx b/apps/start/src/routes/_app.$organizationId.$projectId.dashboards_.$dashboardId.tsx
index 8cf36cadc..753b74db5 100644
--- a/apps/start/src/routes/_app.$organizationId.$projectId.dashboards_.$dashboardId.tsx
+++ b/apps/start/src/routes/_app.$organizationId.$projectId.dashboards_.$dashboardId.tsx
@@ -1,7 +1,7 @@
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { createFileRoute, useRouter } from '@tanstack/react-router';
import {
- LayoutPanelTopIcon,
+ ChartLineIcon,
MoreHorizontal,
PlusIcon,
RotateCcw,
@@ -18,7 +18,7 @@ import {
TILE_MIN_SIZE,
useDashboardLayout,
} from '@/components/dashboard-grid';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import { OverviewInterval } from '@/components/overview/overview-interval';
import { OverviewRange } from '@/components/overview/overview-range';
@@ -356,10 +356,12 @@ function Component() {
/>
{reports.length === 0 ? (
- <FullPageEmptyState icon={LayoutPanelTopIcon} title="No reports">
- <p>You can visualize your data with a report</p>
+ <EmptyState
+ description="Reports you save to this dashboard show up here as tiles you can move and resize."
+ icon={ChartLineIcon}
+ title="No reports on this dashboard yet"
+ >
<LinkButton
- className="mt-14"
from={Route.fullPath}
icon={PlusIcon}
search={{ dashboardId }}
@@ -367,7 +369,7 @@ function Component() {
>
Create report
</LinkButton>
- </FullPageEmptyState>
+ </EmptyState>
) : reportsQuery.isLoading ? (
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
<ReportItemSkeleton />
@@ -378,9 +380,15 @@ function Component() {
<ReportItemSkeleton />
</div>
) : filteredReports.length === 0 ? (
- <FullPageEmptyState icon={SearchIcon} title="No matching reports">
- <p>No reports match "{search}". Try a different search.</p>
- </FullPageEmptyState>
+ <EmptyState
+ description={`Nothing on this dashboard matches “${search}”.`}
+ icon={SearchIcon}
+ title="No matching reports"
+ >
+ <Button onClick={() => setSearch('')} variant="outline">
+ Clear search
+ </Button>
+ </EmptyState>
) : (
<DashboardGrid
isEditable={!search}
diff --git a/apps/start/src/routes/_app.$organizationId.$projectId.insights.tsx b/apps/start/src/routes/_app.$organizationId.$projectId.insights.tsx
index a828175b7..1865a1c78 100644
--- a/apps/start/src/routes/_app.$organizationId.$projectId.insights.tsx
+++ b/apps/start/src/routes/_app.$organizationId.$projectId.insights.tsx
@@ -1,13 +1,15 @@
import { INSIGHT_LIST_ALL_MAX_LIMIT } from '@openpanel/core/modules/insight/insight.constants';
import { useQuery } from '@tanstack/react-query';
import { createFileRoute, useNavigate } from '@tanstack/react-router';
+import { SearchIcon, SparklesIcon } from 'lucide-react';
import { parseAsString, parseAsStringEnum, useQueryState } from 'nuqs';
import { useMemo } from 'react';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import { InsightCard } from '@/components/insights/insight-card';
import { PageContainer } from '@/components/page-container';
import { PageHeader } from '@/components/page-header';
import { Skeleton } from '@/components/skeleton';
+import { Button } from '@/components/ui/button';
import {
Carousel,
CarouselContent,
@@ -299,6 +301,20 @@ function Component() {
);
}
+ const isFiltered =
+ search !== '' ||
+ moduleFilter !== 'all' ||
+ windowKindFilter !== 'all' ||
+ severityFilter !== 'all' ||
+ directionFilter !== 'all';
+ const clearFilters = () => {
+ void setSearch(null);
+ void setModuleFilter(null);
+ void setWindowKindFilter(null);
+ void setSeverityFilter(null);
+ void setDirectionFilter(null);
+ };
+
return (
<PageContainer>
<PageHeader
@@ -381,13 +397,9 @@ function Component() {
</TableButtons>
{filteredAndSorted.length === 0 && !isLoading && (
- <FullPageEmptyState
- description={
- search || moduleFilter !== 'all' || windowKindFilter !== 'all'
- ? 'Try adjusting your filters to see more insights.'
- : 'Insights will appear here as trends are detected in your analytics.'
- }
- title="No insights found"
+ <InsightsEmptyState
+ isFiltered={isFiltered}
+ onClearFilters={clearFilters}
/>
)}
@@ -460,3 +472,32 @@ function Component() {
</PageContainer>
);
}
+
+function InsightsEmptyState({
+ isFiltered,
+ onClearFilters,
+}: {
+ isFiltered: boolean;
+ onClearFilters: () => void;
+}) {
+ if (isFiltered) {
+ return (
+ <EmptyState
+ description="Nothing matches the current search and filters."
+ icon={SearchIcon}
+ title="No matching insights"
+ >
+ <Button onClick={onClearFilters} variant="outline">
+ Clear filters
+ </Button>
+ </EmptyState>
+ );
+ }
+ return (
+ <EmptyState
+ description="Insights are detected automatically from your traffic. Give it a few days of data and check back."
+ icon={SparklesIcon}
+ title="No insights yet"
+ />
+ );
+}
diff --git a/apps/start/src/routes/_app.$organizationId.$projectId.notifications._tabs.rules.tsx b/apps/start/src/routes/_app.$organizationId.$projectId.notifications._tabs.rules.tsx
index 0db5d6a17..7444f83ff 100644
--- a/apps/start/src/routes/_app.$organizationId.$projectId.notifications._tabs.rules.tsx
+++ b/apps/start/src/routes/_app.$organizationId.$projectId.notifications._tabs.rules.tsx
@@ -1,9 +1,9 @@
import { useQuery } from '@tanstack/react-query';
import { createFileRoute } from '@tanstack/react-router';
import { AnimatePresence, motion } from 'framer-motion';
-import { PencilRulerIcon, PlusIcon } from 'lucide-react';
+import { BellRingIcon, PlusIcon } from 'lucide-react';
import { useMemo } from 'react';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import { IntegrationCardSkeleton } from '@/components/integrations/integration-card';
import { RuleCard } from '@/components/notifications/rule-card';
@@ -39,41 +39,27 @@ function Component() {
const isLoading = query.isLoading;
+ const addRule = () => pushModal('AddNotificationRule', { rule: undefined });
+
if (!isLoading && data.length === 0) {
return (
- <FullPageEmptyState icon={PencilRulerIcon} title="No rules yet">
- <p>
- You have not created any rules yet. Create a rule to start getting
- notifications.
- </p>
- <Button
- className="mt-8"
- onClick={() =>
- pushModal('AddNotificationRule', {
- rule: undefined,
- })
- }
- variant="outline"
- >
- Add Rule
+ <EmptyState
+ description="Get a message when an event fires or a funnel is completed, in Slack, Discord, email or a webhook."
+ icon={BellRingIcon}
+ title="No notification rules yet"
+ >
+ <Button icon={PlusIcon} onClick={addRule}>
+ Add rule
</Button>
- </FullPageEmptyState>
+ </EmptyState>
);
}
return (
<div>
<div className="mb-2">
- <Button
- icon={PlusIcon}
- onClick={() =>
- pushModal('AddNotificationRule', {
- rule: undefined,
- })
- }
- variant="outline"
- >
- Add Rule
+ <Button icon={PlusIcon} onClick={addRule} variant="outline">
+ Add rule
</Button>
</div>
<div className="col grid w-full gap-4 md:grid-cols-2">
diff --git a/apps/start/src/routes/_app.$organizationId.$projectId.seo.tsx b/apps/start/src/routes/_app.$organizationId.$projectId.seo.tsx
index 3bccb8f3d..b4db9576d 100644
--- a/apps/start/src/routes/_app.$organizationId.$projectId.seo.tsx
+++ b/apps/start/src/routes/_app.$organizationId.$projectId.seo.tsx
@@ -4,7 +4,7 @@ import { createFileRoute, useNavigate } from '@tanstack/react-router';
import { SearchIcon } from 'lucide-react';
import { useMemo, useState } from 'react';
import { OPLineChart } from '@/components/charts/op-line-chart';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import { OverviewInterval } from '@/components/overview/overview-interval';
import { OverviewMetricCard } from '@/components/overview/overview-metric-card';
import { OverviewRange } from '@/components/overview/overview-range';
@@ -155,23 +155,29 @@ function SeoPage() {
if (!isConnected) {
return (
- <FullPageEmptyState
- className="pt-[20vh]"
- description="Connect Google Search Console to track your search impressions, clicks, and keyword rankings."
- icon={SearchIcon}
- title="No SEO data yet"
- >
- <Button
- onClick={() =>
- navigate({
- to: '/$organizationId/$projectId/settings/gsc',
- params: { organizationId, projectId },
- })
- }
+ <PageContainer>
+ <PageHeader
+ className="mb-8"
+ description="Google Search Console data"
+ title="SEO"
+ />
+ <EmptyState
+ description="See which queries and pages bring you search traffic, with clicks, impressions and positions next to the rest of your analytics."
+ icon={SearchIcon}
+ title="Connect Google Search Console"
>
- Connect Google Search Console
- </Button>
- </FullPageEmptyState>
+ <Button
+ onClick={() =>
+ navigate({
+ to: '/$organizationId/$projectId/settings/gsc',
+ params: { organizationId, projectId },
+ })
+ }
+ >
+ Connect Google Search Console
+ </Button>
+ </EmptyState>
+ </PageContainer>
);
}
diff --git a/apps/start/src/routes/_app.$organizationId.$projectId.sessions_.$sessionId.tsx b/apps/start/src/routes/_app.$organizationId.$projectId.sessions_.$sessionId.tsx
index f0402a612..d70f63e02 100644
--- a/apps/start/src/routes/_app.$organizationId.$projectId.sessions_.$sessionId.tsx
+++ b/apps/start/src/routes/_app.$organizationId.$projectId.sessions_.$sessionId.tsx
@@ -1,6 +1,8 @@
import type { IServiceEvent, IServiceSession } from '@openpanel/core';
import { useQuery, useSuspenseQuery } from '@tanstack/react-query';
import { createFileRoute, Link } from '@tanstack/react-router';
+import { ZapIcon } from 'lucide-react';
+import { EmptyState } from '@/components/empty-state';
import { EventIcon } from '@/components/events/event-icon';
import { useEventDrawer } from '@/components/events/use-event-drawer';
import FullPageLoadingState from '@/components/full-page-loading-state';
@@ -405,9 +407,12 @@ function Component() {
</button>
))}
{events.length === 0 && (
- <div className="py-8 text-center text-muted-foreground text-sm">
- No events found
- </div>
+ <EmptyState
+ description="This session has no events in it."
+ icon={ZapIcon}
+ title="No events"
+ variant="inline"
+ />
)}
</div>
</Widget>
diff --git a/apps/start/src/routes/_app.$organizationId.$projectId.settings._tabs.imports.tsx b/apps/start/src/routes/_app.$organizationId.$projectId.settings._tabs.imports.tsx
index 5451060a8..f848550ae 100644
--- a/apps/start/src/routes/_app.$organizationId.$projectId.settings._tabs.imports.tsx
+++ b/apps/start/src/routes/_app.$organizationId.$projectId.settings._tabs.imports.tsx
@@ -5,12 +5,13 @@ import { formatDistanceToNow } from 'date-fns';
import {
CheckCircleIcon,
Download,
+ ImportIcon,
InfoIcon,
Loader2Icon,
XCircleIcon,
} from 'lucide-react';
import { toast } from 'sonner';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import {
IntegrationCard,
IntegrationCardFooter,
@@ -171,9 +172,11 @@ function ImportsSettings() {
{!importsQuery.isLoading && imports.length === 0 && (
<TableRow>
<TableCell colSpan={6}>
- <FullPageEmptyState
- description="Your import history will appear here."
+ <EmptyState
+ description="Imports from other analytics tools show up here with their progress."
+ icon={ImportIcon}
title="No imports yet"
+ variant="inline"
/>
</TableCell>
</TableRow>
diff --git a/apps/start/src/routes/_app.$organizationId.billing.tsx b/apps/start/src/routes/_app.$organizationId.billing.tsx
index 9325da536..43a386db5 100644
--- a/apps/start/src/routes/_app.$organizationId.billing.tsx
+++ b/apps/start/src/routes/_app.$organizationId.billing.tsx
@@ -1,8 +1,8 @@
import { isOrganizationAdminRole } from '@openpanel/core/modules/organization/organization.constants';
import { useQuery } from '@tanstack/react-query';
import { createFileRoute, redirect } from '@tanstack/react-router';
-import { BoxSelectIcon } from 'lucide-react';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { Building2Icon } from 'lucide-react';
+import { EmptyState } from '@/components/empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import Billing from '@/components/organization/billing';
import { PageHeader } from '@/components/page-header';
@@ -62,7 +62,12 @@ function OrganizationPage() {
if (!organization) {
return (
- <FullPageEmptyState icon={BoxSelectIcon} title="Organization not found" />
+ <EmptyState
+ description="This workspace doesn't exist or you don't have access to it."
+ icon={Building2Icon}
+ title="Workspace not found"
+ variant="page"
+ />
);
}
diff --git a/apps/start/src/routes/_app.$organizationId.index.tsx b/apps/start/src/routes/_app.$organizationId.index.tsx
index dd703d067..86d5fd03d 100644
--- a/apps/start/src/routes/_app.$organizationId.index.tsx
+++ b/apps/start/src/routes/_app.$organizationId.index.tsx
@@ -1,7 +1,7 @@
import { useQuery } from '@tanstack/react-query';
import { createFileRoute } from '@tanstack/react-router';
-import { BoxSelectIcon, PlusIcon } from 'lucide-react';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { FolderPlusIcon, PlusIcon } from 'lucide-react';
+import { EmptyState } from '@/components/empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import { LazyComponent } from '@/components/lazy-component';
import { PageHeader } from '@/components/page-header';
@@ -51,21 +51,28 @@ function OrganizationPage() {
if (!projects?.length) {
return (
- <FullPageEmptyState
- description={
- isAdmin
- ? 'Create your first project to get started with analytics.'
- : 'You do not have access to any projects in this organization yet. Ask an admin to grant you access.'
- }
- icon={BoxSelectIcon}
- title="No projects found"
- >
- {isAdmin && (
- <Button icon={PlusIcon} onClick={() => pushModal('AddProject')}>
- Create project
- </Button>
- )}
- </FullPageEmptyState>
+ <div className="container p-8">
+ <PageHeader
+ className="mb-8"
+ description="All your projects in this workspace"
+ title="Projects"
+ />
+ <EmptyState
+ description={
+ isAdmin
+ ? 'A project holds the data for one website or app. Create one, install the SDK, and your first events show up within minutes.'
+ : "You don't have access to any projects in this workspace yet. Ask an admin to add you to one."
+ }
+ icon={FolderPlusIcon}
+ title={isAdmin ? 'Create your first project' : 'No projects yet'}
+ >
+ {isAdmin && (
+ <Button icon={PlusIcon} onClick={() => pushModal('AddProject')}>
+ Create project
+ </Button>
+ )}
+ </EmptyState>
+ </div>
);
}
diff --git a/apps/start/src/routes/_app.$organizationId.settings.tsx b/apps/start/src/routes/_app.$organizationId.settings.tsx
index 6f15373bf..4f9dae1b4 100644
--- a/apps/start/src/routes/_app.$organizationId.settings.tsx
+++ b/apps/start/src/routes/_app.$organizationId.settings.tsx
@@ -1,11 +1,12 @@
import { zEditOrganization } from '@openpanel/core/modules/organization/organization.constants';
import { useMutation, useQuery } from '@tanstack/react-query';
import { createFileRoute } from '@tanstack/react-router';
+import { Building2Icon } from 'lucide-react';
import { Controller, useForm } from 'react-hook-form';
import { toast } from 'sonner';
import type { z } from 'zod';
+import { EmptyState } from '@/components/empty-state';
import { InputWithLabel, WithLabel } from '@/components/forms/input-with-label';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import { PageHeader } from '@/components/page-header';
import DeleteOrganization from '@/components/settings/delete-organization';
@@ -50,7 +51,14 @@ function Component() {
}
if (!organization) {
- return <FullPageEmptyState title="Organization not found" />;
+ return (
+ <EmptyState
+ description="This workspace doesn't exist or you don't have access to it."
+ icon={Building2Icon}
+ title="Workspace not found"
+ variant="page"
+ />
+ );
}
const { register, handleSubmit, formState, reset, control } = useForm<IForm>({
diff --git a/apps/start/src/routes/_app.$organizationId.tsx b/apps/start/src/routes/_app.$organizationId.tsx
index 6e7727b4f..1c83479a9 100644
--- a/apps/start/src/routes/_app.$organizationId.tsx
+++ b/apps/start/src/routes/_app.$organizationId.tsx
@@ -10,7 +10,7 @@ import {
} from '@tanstack/react-router';
import { format } from 'date-fns';
import { Building2Icon } from 'lucide-react';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import FeedbackPrompt from '@/components/organization/feedback-prompt';
import SupporterPrompt from '@/components/organization/supporter-prompt';
@@ -73,14 +73,14 @@ export const Route = createFileRoute('/_app/$organizationId')({
},
pendingComponent: FullPageLoadingState,
notFoundComponent: () => (
- <FullPageEmptyState
- className="min-h-[calc(100vh-4rem)]"
+ <EmptyState
description="This workspace doesn't exist or you don't have access to it."
icon={Building2Icon}
title="Workspace not found"
+ variant="page"
>
<LinkButton href="/">Go to home</LinkButton>
- </FullPageEmptyState>
+ </EmptyState>
),
});
diff --git a/apps/start/src/routes/_app.tsx b/apps/start/src/routes/_app.tsx
index 2bdf17eef..486ff2d54 100644
--- a/apps/start/src/routes/_app.tsx
+++ b/apps/start/src/routes/_app.tsx
@@ -7,8 +7,8 @@ import {
import { ConstructionIcon } from 'lucide-react';
import { useEffect } from 'react';
import { useChatLaunch } from '@/components/chat/chat-launch';
+import { EmptyState } from '@/components/empty-state';
import { EventDrawer } from '@/components/events/event-drawer';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
import { Sidebar } from '@/components/sidebar';
import { buttonVariants } from '@/components/ui/button';
import { useAppContext } from '@/hooks/use-app-context';
@@ -30,11 +30,11 @@ function AppLayout() {
if (isMaintenance) {
return (
- <FullPageEmptyState
- className="min-h-screen"
- description="We are currently performing maintenance on the system. Please check back later."
+ <EmptyState
+ description="We're doing maintenance right now. Check back in a little while."
icon={ConstructionIcon}
title="Maintenance mode"
+ variant="page"
>
<a
className={cn(buttonVariants())}
@@ -44,7 +44,7 @@ function AppLayout() {
>
Check out our status page
</a>
- </FullPageEmptyState>
+ </EmptyState>
);
}
diff --git a/apps/start/src/routes/_steps.onboarding.$projectId.connect.tsx b/apps/start/src/routes/_steps.onboarding.$projectId.connect.tsx
index 92aff3459..38ffa8448 100644
--- a/apps/start/src/routes/_steps.onboarding.$projectId.connect.tsx
+++ b/apps/start/src/routes/_steps.onboarding.$projectId.connect.tsx
@@ -1,8 +1,8 @@
import { useQuery } from '@tanstack/react-query';
import { createFileRoute, Link, redirect } from '@tanstack/react-router';
-import { XIcon } from 'lucide-react';
+import { SearchXIcon } from 'lucide-react';
import { useEffect, useRef } from 'react';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import { ClientCredentials } from '@/components/onboarding/client-credentials';
import {
@@ -89,10 +89,11 @@ function Component() {
if (!(project && client)) {
return (
- <FullPageEmptyState
- description="The project you are looking for does not exist. Please reload the page."
- icon={XIcon}
- title="No project found"
+ <EmptyState
+ description="This project doesn't exist or isn't ready yet. Reload the page to try again."
+ icon={SearchXIcon}
+ title="Project not found"
+ variant="page"
/>
);
}
diff --git a/apps/start/src/routes/share.dashboard.$shareId.tsx b/apps/start/src/routes/share.dashboard.$shareId.tsx
index 0dc81beb3..0e1b5ff48 100644
--- a/apps/start/src/routes/share.dashboard.$shareId.tsx
+++ b/apps/start/src/routes/share.dashboard.$shareId.tsx
@@ -1,10 +1,11 @@
import { useQuery, useSuspenseQuery } from '@tanstack/react-query';
import { createFileRoute, notFound, useSearch } from '@tanstack/react-router';
+import { LayoutPanelTopIcon, UnlinkIcon } from 'lucide-react';
import { useMemo } from 'react';
import { z } from 'zod';
import { ShareEnterPassword } from '@/components/auth/share-enter-password';
import { DashboardGrid, useDashboardLayout } from '@/components/dashboard-grid';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import { LoginNavbar } from '@/components/login-navbar';
import { OverviewInterval } from '@/components/overview/overview-interval';
@@ -66,10 +67,11 @@ export const Route = createFileRoute('/share/dashboard/$shareId')({
},
pendingComponent: FullPageLoadingState,
errorComponent: () => (
- <FullPageEmptyState
- className="min-h-[calc(100vh-theme(spacing.16))]"
- description="The dashboard you are looking for does not exist."
+ <EmptyState
+ description="This link doesn't point to a shared dashboard anymore. Ask whoever sent it for a new one."
+ icon={UnlinkIcon}
title="Share not found"
+ variant="page"
/>
),
});
@@ -140,7 +142,11 @@ function RouteComponent() {
<ReportItemSkeleton />
</div>
) : reports.length === 0 ? (
- <FullPageEmptyState title="No reports" />
+ <EmptyState
+ description="Reports added to this dashboard will show up here."
+ icon={LayoutPanelTopIcon}
+ title="This dashboard is empty"
+ />
) : (
<DashboardGrid layout={layout}>
{reports.map((report) => (
diff --git a/apps/start/src/routes/share.overview.$shareId.tsx b/apps/start/src/routes/share.overview.$shareId.tsx
index e4b378951..eaf79cdcd 100644
--- a/apps/start/src/routes/share.overview.$shareId.tsx
+++ b/apps/start/src/routes/share.overview.$shareId.tsx
@@ -1,8 +1,9 @@
import { useSuspenseQuery } from '@tanstack/react-query';
import { createFileRoute, notFound, useSearch } from '@tanstack/react-router';
+import { UnlinkIcon } from 'lucide-react';
import { z } from 'zod';
import { ShareEnterPassword } from '@/components/auth/share-enter-password';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import { LazyComponent } from '@/components/lazy-component';
import { LoginNavbar } from '@/components/login-navbar';
@@ -58,10 +59,11 @@ export const Route = createFileRoute('/share/overview/$shareId')({
},
pendingComponent: FullPageLoadingState,
errorComponent: () => (
- <FullPageEmptyState
- className="min-h-[calc(100vh-theme(spacing.16))]"
- description="The overview you are looking for does not exist."
+ <EmptyState
+ description="This link doesn't point to a shared overview anymore. Ask whoever sent it for a new one."
+ icon={UnlinkIcon}
title="Share not found"
+ variant="page"
/>
),
});
diff --git a/apps/start/src/routes/share.report.$shareId.tsx b/apps/start/src/routes/share.report.$shareId.tsx
index fe37e6d1f..ac9485782 100644
--- a/apps/start/src/routes/share.report.$shareId.tsx
+++ b/apps/start/src/routes/share.report.$shareId.tsx
@@ -1,8 +1,9 @@
import { useSuspenseQuery } from '@tanstack/react-query';
import { createFileRoute, notFound, useSearch } from '@tanstack/react-router';
+import { UnlinkIcon } from 'lucide-react';
import { z } from 'zod';
import { ShareEnterPassword } from '@/components/auth/share-enter-password';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import { LoginNavbar } from '@/components/login-navbar';
import { OverviewInterval } from '@/components/overview/overview-interval';
@@ -65,10 +66,11 @@ export const Route = createFileRoute('/share/report/$shareId')({
},
pendingComponent: FullPageLoadingState,
errorComponent: () => (
- <FullPageEmptyState
- className="min-h-[calc(100vh-theme(spacing.16))]"
- description="The report you are looking for does not exist."
+ <EmptyState
+ description="This link doesn't point to a shared report anymore. Ask whoever sent it for a new one."
+ icon={UnlinkIcon}
title="Share not found"
+ variant="page"
/>
),
});
diff --git a/apps/start/src/routes/unsubscribe.tsx b/apps/start/src/routes/unsubscribe.tsx
index a56687b84..f71807291 100644
--- a/apps/start/src/routes/unsubscribe.tsx
+++ b/apps/start/src/routes/unsubscribe.tsx
@@ -1,9 +1,10 @@
import { emailCategories } from '@openpanel/core/modules/email/email.constants';
import { useMutation } from '@tanstack/react-query';
import { createFileRoute, useSearch } from '@tanstack/react-router';
+import { MailXIcon } from 'lucide-react';
import { useState } from 'react';
import { z } from 'zod';
-import { FullPageEmptyState } from '@/components/full-page-empty-state';
+import { EmptyState } from '@/components/empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import { PublicPageCard } from '@/components/public-page-card';
import { Button, LinkButton } from '@/components/ui/button';
@@ -21,9 +22,11 @@ export const Route = createFileRoute('/unsubscribe')({
pendingComponent: FullPageLoadingState,
// A missing or malformed parameter would otherwise show the raw ZodError.
errorComponent: () => (
- <FullPageEmptyState
+ <EmptyState
description="This unsubscribe link is missing information or has expired. Open the link from your email again, or change your preferences from your account settings."
+ icon={MailXIcon}
title="Link not valid"
+ variant="page"
/>
),
});
diff --git a/packages/core/src/modules/assistant/assistant.constants.ts b/packages/core/src/modules/assistant/assistant.constants.ts
index 82a73c1f4..ea664798b 100644
--- a/packages/core/src/modules/assistant/assistant.constants.ts
+++ b/packages/core/src/modules/assistant/assistant.constants.ts
@@ -182,6 +182,16 @@ export const zChatRequest = z.object({
export type ChatRequest = z.infer<typeof zChatRequest>;
+const MAX_REPORT_PROMPT_LENGTH = 1000;
+
+/** The report editor's prompt box: a description of the chart the user wants. */
+export const zReportDraftRequest = z.object({
+ projectId: z.string().min(1),
+ prompt: z.string().trim().min(1).max(MAX_REPORT_PROMPT_LENGTH),
+});
+
+export type ReportDraftRequest = z.infer<typeof zReportDraftRequest>;
+
export const zChatMessageMetadata = z.object({
modelId: z.string().optional(),
createdAt: z.number().optional(),
@@ -267,7 +277,7 @@ export const CHAT_ROUTES = {
path: '/reports',
label: 'Report editor',
description:
- 'Build a new chart by hand: pick events, breakdowns, chart type.',
+ 'Build a new chart: describe it in words, or pick events, breakdowns and chart type by hand.',
},
report: {
path: '/reports/:reportId',
diff --git a/packages/core/src/modules/assistant/assistant.rpc.ts b/packages/core/src/modules/assistant/assistant.rpc.ts
index c533772ad..5f460943e 100644
--- a/packages/core/src/modules/assistant/assistant.rpc.ts
+++ b/packages/core/src/modules/assistant/assistant.rpc.ts
@@ -2,11 +2,19 @@
// the input parser — `models` takes no input and needs no object-id check of
// its own, so the handler is the query and nothing else.
+import { TRPCError } from '@trpc/server';
import { createTRPCRouter, protectedProcedure } from '../../rpc/base';
+import { TRPCNotFoundError } from '../../rpc/errors';
+import {
+ getOrganizationByProjectIdCached,
+ getSettingsForProject,
+} from '../organization/organization.service';
import {
getAvailableChatModels,
getDefaultChatModelId,
+ zReportDraftRequest,
} from './assistant.constants';
+import { checkChatLimits, resolveChatTier } from './src/limits';
export const chatRouter = createTRPCRouter({
models: protectedProcedure.query(({ ctx }) => {
@@ -22,4 +30,42 @@ export const chatRouter = createTRPCRouter({
canChooseModel: ctx.config.selfHosted,
};
}),
+
+ // The report editor's prompt box. Drafts a report for the caller's own
+ // editor and changes no project state, but it is a model turn, so it counts
+ // against the same spend limits as a chat message.
+ draftReport: protectedProcedure
+ .meta({ readOnlyMutation: true })
+ .input(zReportDraftRequest)
+ .mutation(async ({ ctx, input }) => {
+ const userId = ctx.session.userId;
+ await ctx.services.auth.requireProjectAccess({
+ userId,
+ projectId: input.projectId,
+ level: 'read',
+ });
+ const [organization, settings] = await Promise.all([
+ getOrganizationByProjectIdCached(ctx, input.projectId),
+ getSettingsForProject(ctx, input.projectId),
+ ]);
+ if (!organization) {
+ throw new TRPCNotFoundError('Project not found');
+ }
+ const limited = await checkChatLimits(ctx, {
+ organizationId: organization.id,
+ userId,
+ tier: resolveChatTier(organization, ctx.config.selfHosted),
+ });
+ if (limited) {
+ throw new TRPCError({
+ code: 'TOO_MANY_REQUESTS',
+ message: limited.message,
+ });
+ }
+ return ctx.services.assistant.draftReport({
+ prompt: input.prompt,
+ projectId: input.projectId,
+ timezone: settings.timezone || 'UTC',
+ });
+ }),
});
diff --git a/packages/core/src/modules/assistant/assistant.service.ts b/packages/core/src/modules/assistant/assistant.service.ts
index f9f8dc36c..10055fd5c 100644
--- a/packages/core/src/modules/assistant/assistant.service.ts
+++ b/packages/core/src/modules/assistant/assistant.service.ts
@@ -4,9 +4,15 @@ import {
type FilterCommandInput,
runFilterCommand,
} from './src/filter-command';
+import {
+ type ReportDraftInput,
+ type ReportDraftResult,
+ runReportDraft,
+} from './src/report-draft';
export type { FilterCommandResult } from './src/filter-command';
export type { AssistantUIMessage, AssistantUIMessagePart } from './src/message';
+export type { ReportDraft, ReportDraftResult } from './src/report-draft';
export function createAssistantService(
deps: ServiceDeps,
@@ -17,5 +23,7 @@ export function createAssistantService(
runFilterCommand: (
input: FilterCommandInput
): ReturnType<typeof runFilterCommand> => runFilterCommand(deps, input),
+ draftReport: (input: ReportDraftInput): Promise<ReportDraftResult> =>
+ runReportDraft(deps, input),
};
}
diff --git a/packages/core/src/modules/assistant/src/providers.ts b/packages/core/src/modules/assistant/src/providers.ts
index 1d17a2c7a..82422978e 100644
--- a/packages/core/src/modules/assistant/src/providers.ts
+++ b/packages/core/src/modules/assistant/src/providers.ts
@@ -3,10 +3,12 @@ import { createAnthropic } from '@ai-sdk/anthropic';
import { createOpenAI } from '@ai-sdk/openai';
import type { LanguageModel, streamText } from 'ai';
import type { CoreConfig } from '../../../config';
-import type {
- ChatModelEntry,
- ChatProvider,
- ConfiguredProviders,
+import {
+ CHAT_MODELS,
+ type ChatModelEntry,
+ type ChatProvider,
+ type ConfiguredProviders,
+ getDefaultChatModelId,
} from '../assistant.constants';
/** Cheap models for titles and the one-shot filter command. */
@@ -77,6 +79,19 @@ export function resolveChatModel(
return modelFor(config, entry.provider, entry.modelId);
}
+/** The model the chat runs by default; for one-shot work that needs the chat's judgement, like drafting a report. */
+export function resolveDefaultChatModel(config: CoreConfig): {
+ model: LanguageModel;
+ entry: ChatModelEntry;
+} | null {
+ const id = getDefaultChatModelId(configuredProviders(config));
+ const entry = CHAT_MODELS.find((model) => model.id === id);
+ if (!entry) {
+ return null;
+ }
+ return { model: resolveChatModel(config, entry), entry };
+}
+
/** The cheapest configured model, for titles and the filter command. */
export function resolveUtilityModel(config: CoreConfig): LanguageModel | null {
const providers = configuredProviders(config);
diff --git a/packages/core/src/modules/assistant/src/report-draft.test.ts b/packages/core/src/modules/assistant/src/report-draft.test.ts
new file mode 100644
index 000000000..475141118
--- /dev/null
+++ b/packages/core/src/modules/assistant/src/report-draft.test.ts
@@ -0,0 +1,124 @@
+// No model call: `proposalToDraft` is the pure half, the shape the editor loads.
+
+import { describe, expect, test } from 'bun:test';
+import { proposalToDraft, type ReportDraftProposal } from './report-draft';
+
+const PROJECT_ID = 'p1';
+const TIMEZONE = 'UTC';
+
+const purchases: ReportDraftProposal = {
+ title: 'Purchases by device',
+ chartType: 'linear',
+ interval: 'day',
+ series: [{ type: 'event', name: 'purchase', segment: 'event', filters: [] }],
+ breakdowns: [{ name: 'device' }],
+ summary: 'Purchases per day by device.',
+};
+
+describe('proposalToDraft', () => {
+ test('a preset range is stored as the range with no dates', () => {
+ const built = proposalToDraft(PROJECT_ID, TIMEZONE, {
+ ...purchases,
+ range: '7d',
+ });
+ expect('draft' in built).toBe(true);
+ if (!('draft' in built)) {
+ return;
+ }
+ expect(built.draft.range).toBe('7d');
+ expect(built.draft.startDate).toBeNull();
+ expect(built.draft.endDate).toBeNull();
+ expect(built.draft.name).toBe('Purchases by device');
+ expect(built.draft.projectId).toBe(PROJECT_ID);
+ expect(built.draft.series[0]?.id).toBe('A');
+ expect(built.draft.breakdowns).toEqual([{ id: '1', name: 'device' }]);
+ });
+
+ test('defaults to the last 30 days when the model picks no window', () => {
+ const built = proposalToDraft(PROJECT_ID, TIMEZONE, purchases);
+ expect('draft' in built && built.draft.range).toBe('30d');
+ });
+
+ test('explicit dates become a custom range', () => {
+ const built = proposalToDraft(PROJECT_ID, TIMEZONE, {
+ ...purchases,
+ startDate: '2026-08-01',
+ endDate: '2026-08-31',
+ });
+ expect('draft' in built).toBe(true);
+ if (!('draft' in built)) {
+ return;
+ }
+ expect(built.draft.range).toBe('custom');
+ expect(built.draft.startDate).toBe('2026-08-01');
+ expect(built.draft.endDate).toBe('2026-08-31');
+ });
+
+ test('an interval too fine for the window is snapped like the range picker does', () => {
+ const hourly = proposalToDraft(PROJECT_ID, TIMEZONE, {
+ ...purchases,
+ range: '3m',
+ interval: 'hour',
+ });
+ expect('draft' in hourly && hourly.draft.interval).toBe('day');
+ const minutely = proposalToDraft(PROJECT_ID, TIMEZONE, {
+ ...purchases,
+ range: 'today',
+ interval: 'minute',
+ });
+ expect('draft' in minutely && minutely.draft.interval).toBe('hour');
+ });
+
+ test('custom dates must be real days in order', () => {
+ const malformed = proposalToDraft(PROJECT_ID, TIMEZONE, {
+ ...purchases,
+ startDate: 'last month',
+ endDate: '2026-08-31',
+ });
+ expect('error' in malformed).toBe(true);
+ const impossible = proposalToDraft(PROJECT_ID, TIMEZONE, {
+ ...purchases,
+ startDate: '2026-02-30',
+ endDate: '2026-03-01',
+ });
+ expect('error' in impossible).toBe(true);
+ const reversed = proposalToDraft(PROJECT_ID, TIMEZONE, {
+ ...purchases,
+ startDate: '2026-08-31',
+ endDate: '2026-08-01',
+ });
+ expect('error' in reversed).toBe(true);
+ });
+
+ test('a custom span clamps the interval like a preset does', () => {
+ const hourlyYear = proposalToDraft(PROJECT_ID, TIMEZONE, {
+ ...purchases,
+ interval: 'hour',
+ startDate: '2025-01-01',
+ endDate: '2025-12-31',
+ });
+ expect('draft' in hourlyYear && hourlyYear.draft.interval).toBe('day');
+ const hourlyWeek = proposalToDraft(PROJECT_ID, TIMEZONE, {
+ ...purchases,
+ interval: 'hour',
+ startDate: '2026-08-01',
+ endDate: '2026-08-07',
+ });
+ expect('draft' in hourlyWeek && hourlyWeek.draft.interval).toBe('hour');
+ const minutely = proposalToDraft(PROJECT_ID, TIMEZONE, {
+ ...purchases,
+ interval: 'minute',
+ startDate: '2026-08-01',
+ endDate: '2026-08-01',
+ });
+ expect('draft' in minutely && minutely.draft.interval).toBe('hour');
+ });
+
+ test('an invalid proposal comes back as issues the model can fix', () => {
+ const built = proposalToDraft(PROJECT_ID, TIMEZONE, {
+ ...purchases,
+ series: [{ type: 'formula', formula: 'A ; drop' }],
+ });
+ expect('error' in built).toBe(true);
+ });
+});
diff --git a/packages/core/src/modules/assistant/src/report-draft.ts b/packages/core/src/modules/assistant/src/report-draft.ts
new file mode 100644
index 000000000..bff9b3e55
--- /dev/null
+++ b/packages/core/src/modules/assistant/src/report-draft.ts
@@ -0,0 +1,274 @@
+// The report editor's "describe it" box: one request becomes a draft report
+// the editor loads, built from the event names this project really tracks.
+import { generateText, isStepCount, tool } from 'ai';
+import { z } from 'zod';
+import type { ServiceDeps } from '../../../services';
+import {
+ type IChartRange,
+ type IReportInput,
+ isHourIntervalEnabledByRange,
+ isMinuteIntervalEnabledByRange,
+ timeWindows,
+} from '../../report/report.constants';
+import { getDatesFromRange } from '../../report/src/chart-dates';
+import { resolveDefaultChatModel } from './providers';
+import { buildReportConfig, zChartInput } from './tools/charts';
+import { discoveryTools } from './tools/discovery';
+
+/** describe_data, maybe a property lookup or two, propose_report, one retry. */
+const MAX_STEPS = 6;
+const DATE_LENGTH = 10;
+const DEFAULT_RANGE: IChartRange = '30d';
+const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
+const MS_PER_DAY = 86_400_000;
+/** The longest custom span that may be drawn per hour; the same bound the `7d` preset has. */
+const MAX_HOURLY_SPAN_DAYS = 7;
+const MAX_SUMMARY_LENGTH = 200;
+
+const PRESET_RANGES = Object.keys(timeWindows).filter(
+ (key) => key !== 'custom'
+) as [IChartRange, ...IChartRange[]];
+
+export const zReportDraftProposal = zChartInput
+ .omit({ startDate: true, endDate: true })
+ .extend({
+ range: z
+ .enum(PRESET_RANGES)
+ .optional()
+ .describe(
+ 'Preset window. Omit only when startDate and endDate carry an explicit period.'
+ ),
+ startDate: z
+ .string()
+ .optional()
+ .describe('YYYY-MM-DD. Only with endDate, and only without range.'),
+ endDate: z.string().optional().describe('YYYY-MM-DD.'),
+ summary: z
+ .string()
+ .max(MAX_SUMMARY_LENGTH)
+ .describe(
+ 'One plain sentence saying what the chart shows, e.g. "Unique users who purchased, per day, by device, last 30 days".'
+ ),
+ });
+
+export type ReportDraftProposal = z.infer<typeof zReportDraftProposal>;
+
+export type ReportDraft = IReportInput & { name: string };
+
+export interface ReportDraftInput {
+ prompt: string;
+ projectId: string;
+ timezone: string;
+}
+
+/** `report` is null when the request could not be mapped; `summary` then says why. */
+export interface ReportDraftResult {
+ report: ReportDraft | null;
+ summary: string;
+}
+
+/** A minute or hour interval on a long window would be thousands of points; snap like the editor's range picker does. */
+function clampInterval(
+ interval: ReportDraft['interval'],
+ range: IChartRange
+): ReportDraft['interval'] {
+ if (interval === 'minute' && !isMinuteIntervalEnabledByRange(range)) {
+ return 'hour';
+ }
+ if (interval === 'hour' && !isHourIntervalEnabledByRange(range)) {
+ return 'day';
+ }
+ return interval;
+}
+
+/** Custom dates are whole days, so minutes never fit and hours only on a short span. */
+function clampCustomInterval(
+ interval: ReportDraft['interval'],
+ spanDays: number
+): ReportDraft['interval'] {
+ if (interval === 'minute') {
+ return spanDays <= MAX_HOURLY_SPAN_DAYS ? 'hour' : 'day';
+ }
+ if (interval === 'hour' && spanDays > MAX_HOURLY_SPAN_DAYS) {
+ return 'day';
+ }
+ return interval;
+}
+
+function parseIsoDate(value: string): Date | null {
+ if (!ISO_DATE.test(value)) {
+ return null;
+ }
+ const date = new Date(`${value}T00:00:00Z`);
+ const roundTrips = date.toISOString().slice(0, DATE_LENGTH) === value;
+ return roundTrips ? date : null;
+}
+
+/** The model writes dates as free text; reject anything the chart engine could not turn into a window. */
+function customSpanDays(
+ startDate: string,
+ endDate: string
+): { days: number } | { error: string; issues: unknown } {
+ const start = parseIsoDate(startDate);
+ const end = parseIsoDate(endDate);
+ if (!(start && end)) {
+ return {
+ error: 'startDate and endDate must be real dates written as YYYY-MM-DD',
+ issues: { startDate, endDate },
+ };
+ }
+ if (end < start) {
+ return {
+ error: 'endDate must be the same day as startDate or later',
+ issues: { startDate, endDate },
+ };
+ }
+ return { days: (end.getTime() - start.getTime()) / MS_PER_DAY };
+}
+
+/** The editor stores a preset as `range` with no dates, or `custom` with both dates. */
+export function proposalToDraft(
+ projectId: string,
+ timezone: string,
+ proposal: ReportDraftProposal
+): { draft: ReportDraft } | { error: string; issues: unknown } {
+ const { range: _range, summary: _summary, ...chartInput } = proposal;
+ const customDates =
+ proposal.startDate && proposal.endDate
+ ? { startDate: proposal.startDate, endDate: proposal.endDate }
+ : null;
+
+ if (customDates) {
+ const span = customSpanDays(customDates.startDate, customDates.endDate);
+ if ('error' in span) {
+ return span;
+ }
+ const built = buildReportConfig(
+ { projectId },
+ { ...chartInput, ...customDates }
+ );
+ if ('error' in built) {
+ return built;
+ }
+ return {
+ draft: {
+ ...built.config,
+ range: 'custom',
+ ...customDates,
+ interval: clampCustomInterval(built.config.interval, span.days),
+ },
+ };
+ }
+
+ const range: IChartRange = proposal.range ?? DEFAULT_RANGE;
+ const built = buildReportConfig(
+ { projectId },
+ { ...chartInput, ...getDatesFromRange(range, timezone) }
+ );
+ if ('error' in built) {
+ return built;
+ }
+ return {
+ draft: {
+ ...built.config,
+ range,
+ startDate: null,
+ endDate: null,
+ interval: clampInterval(built.config.interval, range),
+ },
+ };
+}
+
+function presetCatalog(): string {
+ return PRESET_RANGES.map(
+ (key) => `\`${key}\` (${timeWindows[key].label})`
+ ).join(', ');
+}
+
+function instructions(input: ReportDraftInput): string {
+ const now = new Date();
+ const today = now.toISOString().slice(0, DATE_LENGTH);
+ const weekday = now.toLocaleDateString('en-US', {
+ weekday: 'long',
+ timeZone: 'UTC',
+ });
+ return `You draft a report in the OpenPanel report editor. The user wrote what they want to see; you answer by calling propose_report with a config built from the events this project actually tracks.
+
+# How to work
+- Call describe_data first for the event names. Call it again with an eventName, or get_property_values, only when the request needs a property or an exact filter value.
+- Then call propose_report once. Never invent event or property names; a name you did not see in a tool result does not exist.
+- If the request cannot be mapped to tracked events, do not call propose_report. Reply with one short plain-text sentence (no markdown, no backticks) saying what is missing and which tracked events come closest.
+- If propose_report returns issues, fix them and call it again.
+
+# Choosing the chart
+- \`linear\` for trends over time (the default), \`bar\` for top-N comparisons, \`pie\` for a few shares, \`metric\` for one number, \`funnel\` for ordered steps, \`retention\` for cohorts (interval week), \`conversion\` for an A-to-B rate over time, \`sankey\` for user flows, \`map\` for countries, \`histogram\` for distributions.
+- Unique visitors or users: segment \`user\`. Sessions: segment \`session\`. Revenue or any sum: segment \`property_sum\` with the property. Rates: two event series plus a formula series such as \`B / A * 100\` with the inputs hidden.
+- Page views are the \`screen_view\` event; filter on \`path\` for one page or section. Traffic sources, countries and devices are columns on every event: \`referrer_name\`, \`utm_source\`, \`country\`, \`device\`, \`browser\`, \`os\`.
+- A breakdown splits every series by a column or \`properties.<key>\`.
+
+# Time
+- Prefer a preset range: ${presetCatalog()}. Use startDate and endDate only for an explicit period no preset expresses. Default to \`30d\`.
+- Interval: \`hour\` for a day or two, \`day\` up to three months, \`week\` up to a year, \`month\` beyond. Retention uses \`week\`.
+- Today is ${weekday}, ${today} (UTC). The project reports in the ${input.timezone} timezone.
+
+# Naming
+- title: 3 to 6 words, like a dashboard tile ("Purchases by device").
+- summary: one plain sentence of what the chart shows.`;
+}
+
+const FALLBACK_SUMMARY =
+ "Couldn't turn that into a report. Name the event you want to chart.";
+
+export async function runReportDraft(
+ deps: ServiceDeps,
+ input: ReportDraftInput
+): Promise<ReportDraftResult> {
+ const resolved = resolveDefaultChatModel(deps.config);
+ if (!resolved) {
+ throw new Error(
+ 'No AI provider is configured: set OPENAI_API_KEY or ANTHROPIC_API_KEY.'
+ );
+ }
+ let accepted: ReportDraftResult | null = null;
+ const tools = {
+ ...discoveryTools({ deps, projectId: input.projectId }),
+ propose_report: tool({
+ description:
+ 'Propose the report the user asked for. Call it once, after describe_data, with verified event and property names.',
+ inputSchema: zReportDraftProposal,
+ execute: (proposal) => {
+ const built = proposalToDraft(
+ input.projectId,
+ input.timezone,
+ proposal
+ );
+ if ('error' in built) {
+ return built;
+ }
+ accepted = { report: built.draft, summary: proposal.summary };
+ return { ok: true };
+ },
+ }),
+ };
+ const result = await generateText({
+ model: resolved.model,
+ instructions: instructions(input),
+ prompt: input.prompt,
+ tools,
+ stopWhen: [isStepCount(MAX_STEPS), () => accepted !== null],
+ reasoning: resolved.entry.reasoning,
+ });
+ deps.logger.info(
+ {
+ projectId: input.projectId,
+ modelId: resolved.entry.id,
+ steps: result.steps.length,
+ accepted: accepted !== null,
+ },
+ 'report draft finished'
+ );
+ if (accepted) {
+ return accepted;
+ }
+ return { report: null, summary: result.text.trim() || FALLBACK_SUMMARY };
+}
diff --git a/packages/core/src/modules/assistant/src/tools/charts.ts b/packages/core/src/modules/assistant/src/tools/charts.ts
index 9763848a8..0ef387d45 100644
--- a/packages/core/src/modules/assistant/src/tools/charts.ts
+++ b/packages/core/src/modules/assistant/src/tools/charts.ts
@@ -137,7 +137,7 @@ export interface ChartToolOutput {
/** Builds the engine config from the model's flattened input, or a structured error the model can fix. */
export function buildReportConfig(
- ctx: ChatToolContext,
+ ctx: Pick<ChatToolContext, 'projectId'>,
input: ChartInput
):
| { config: IReportInput & { name: string } }
diff --git a/packages/core/src/modules/assistant/src/tools/discovery.ts b/packages/core/src/modules/assistant/src/tools/discovery.ts
index de03e8643..b618e7758 100644
--- a/packages/core/src/modules/assistant/src/tools/discovery.ts
+++ b/packages/core/src/modules/assistant/src/tools/discovery.ts
@@ -14,7 +14,9 @@ const SAMPLE_VALUES_PER_PROPERTY = 12;
/** Tracking internals the model never needs sample values for. */
const INTERNAL_PROPERTY_PREFIX = '__';
-export function discoveryTools(ctx: ChatToolContext) {
+export function discoveryTools(
+ ctx: Pick<ChatToolContext, 'deps' | 'projectId'>
+) {
const { deps, projectId } = ctx;
return {