Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(dashboards): add error tracking dashboard widget (8/11) (#60524)

Matt Puaa0f9903e2b2e
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 2544431cdc2e..3bae6bce6eff 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -1480,6 +1480,34 @@ snapshots:
hash: v1.k794b7964.ec79c434bdd0a29af24dbee3162d74ac2ac927b1431b29eef0246ef0cd9b5820.BUKk_-UGOgJ-1jJ1Yw5FnL1_yp3UP0y5G7wizjZ2aaE
components-verticalnesteddnd--base--light:
hash: v1.k794b7964.253572e7c878adb761595b38b07c93ba529e1bf165d0e67fe79550ef784dcf5d.um0bjxs1ERf6_rMKphvKrO7fE5D7cV_HaikHm5fGsM8
+ dashboards-dashboard-widgets-overview--all-widget-types--dark:
+ hash: v1.k794b7964.16e7827f2f44eacd81f37bcae46809c232783c05ffa6cd3ff3965e1ceabec48e.1dqZxbw0PVEgD_mT4bej_AxQXCHQZ05XqQrDCKKqnHM
+ dashboards-dashboard-widgets-overview--all-widget-types--light:
+ hash: v1.k794b7964.a5b2813dc22662e817214a4a6632021c7f28ef817813f0a4e1322ebdec864eb6.kDG_VO59wYZ-hYOP6tbGcpB3j81SjRsqkATi3ylN_Vk
+ dashboards-dashboard-widgets-widget-types-error-tracking-top-issues--empty--dark:
+ hash: v1.k794b7964.37b0f3093591c5d717106e98dc91ca4288d2562cdb240750c1223ae2bce4f8af.K92XY4q1UjFlYZ0DhQ8G02rowmJ7Ed0FxirKIANkTog
+ dashboards-dashboard-widgets-widget-types-error-tracking-top-issues--empty--light:
+ hash: v1.k794b7964.6319573b6261dc5806ef63e9765460fa5e49b63d4116eded31491b0d9cab9810.MoYWbJ66y6yiXUNF-4St2zprnYuTj76mxD9xFptTkIk
+ dashboards-dashboard-widgets-widget-types-error-tracking-top-issues--loading--dark:
+ hash: v1.k794b7964.35039037025f9bba990032aa2d263730823887ae60825327a5e2d66db1d22d45.YqTpX_cYP6oNt5_bB2VfAjU3oAnxKLZ4Tr2lfGuJg0w
+ dashboards-dashboard-widgets-widget-types-error-tracking-top-issues--loading--light:
+ hash: v1.k794b7964.4363c87e0a425bf93e4b83e5d17445a9ef2e0cdff86d09d92eb1e191d765438c.oHuVFS2dJ4GpvncvomHWDobEpXHkT20cYwEMN_whm1Q
+ dashboards-dashboard-widgets-widget-types-error-tracking-top-issues--populated--dark:
+ hash: v1.k794b7964.7343596d9b2962f09988bcc29ae97cf6645c2f376be199079df7406c95a16beb.A4L2NY08Q_hmkwE6-t2slrfQ44-SuZbG2ft0q54J6RA
+ dashboards-dashboard-widgets-widget-types-error-tracking-top-issues--populated--light:
+ hash: v1.k794b7964.f8a0dfee4c5a61a1df65e8b434b2f907660f58ae867eb0c6387cfba2e976787f.u55hvtEOMBX3Zd6ptPjIQI5F6qG7th6rCUBLBpnfYGg
+ dashboards-dashboard-widgets-widget-types-error-tracking-top-issues--setup-unavailable--dark:
+ hash: v1.k794b7964.7d69dce6ed2191849537eb642d3c89ac2236362de6063c36b330d8539b7fffb9.N2VC2kWXD-FMFINftmH1CnhNzb6araUv6QuurqnkaI8
+ dashboards-dashboard-widgets-widget-types-error-tracking-top-issues--setup-unavailable--light:
+ hash: v1.k794b7964.cda0999d77941fe029da1ede20fa2e40c547f0d37abe30a64e2cc4a08026b856.eAPTafX6TgM9_po9UU7H_DOmOXNRP7-af5kVLhpxuBI
+ dashboards-dashboard-widgets-widget-types-error-tracking-top-issues-widget-settings--before-exception-ingestion--dark:
+ hash: v1.k794b7964.7fee57402c47dc068dd42cb5cd535b5d611b2c89303cb3fa8ae80f90b0551138.3hwCq3JyGd-h6_uCJXZLoaokoWDccig176XCclysC6w
+ dashboards-dashboard-widgets-widget-types-error-tracking-top-issues-widget-settings--before-exception-ingestion--light:
+ hash: v1.k794b7964.da76b1c9007b6158780a5e9c73961fc65f090a41dbc7763202a1a8e80fec8ee8.kOJbsAuAQNeMjEFL80QygA49LKlz4uH0OM7OaxswB2k
+ dashboards-dashboard-widgets-widget-types-error-tracking-top-issues-widget-settings--default--dark:
+ hash: v1.k794b7964.321b3a05b437647379f82a1396417ca3836e3b8324edb45bdc22681f7dc75e64.GGZFGrydw_LpK5CDXm34dVegUKo1vvp6Rjk5vqcfOvs
+ dashboards-dashboard-widgets-widget-types-error-tracking-top-issues-widget-settings--default--light:
+ hash: v1.k794b7964.589ad6d84fdd1cb75c0a4fc17062f7c8223d922f410a787935dce4ebdf5ddd0e.bxVCTsAm5NufSyxv1SecNVFONuo6SGSz2L_Q53-M29g
dashboards-dashboard-widgets-widgetcard--dashboard-tile-populated--dark:
hash: v1.k794b7964.44c19632537a43879cd2fb8196905bf21e18e784b907a6851aa9d49ec7f45ce7.WRJJJH-g5HOJnILNLSsqi-nP04K6dA4KQiUwxLxbiVk
dashboards-dashboard-widgets-widgetcard--dashboard-tile-populated--light:
diff --git a/frontend/src/lib/components/ProductIntroduction/ProductIntroduction.tsx b/frontend/src/lib/components/ProductIntroduction/ProductIntroduction.tsx
index 2ff7401742b9..4c9d6db23f58 100644
--- a/frontend/src/lib/components/ProductIntroduction/ProductIntroduction.tsx
+++ b/frontend/src/lib/components/ProductIntroduction/ProductIntroduction.tsx
@@ -43,9 +43,9 @@ export type ProductIntroductionProps = {
/**
* Default hides the hog below `md`. Use `responsive` to keep the hog visible on small screens with a vertical
* layout (hog above copy), switching to the horizontal layout from `md` up (or from `main-content` width when
- * `useMainContentContainerQueries` is set).
+ * `useMainContentContainerQueries` is set). Use `vertical` for always-stacked hog-above-copy (e.g. narrow dashboard tiles).
*/
- hogLayout?: 'default' | 'responsive'
+ hogLayout?: 'default' | 'responsive' | 'vertical'
/**
* When set with `hogLayout="responsive"`, use the `main-content` container (see Navigation) instead of the
* viewport for breakpoints so layout responds when the side panel narrows the main column.
@@ -95,6 +95,7 @@ export const ProductIntroduction = ({
}
const actionable = action || actionElementOverride
+ const isVerticalHogLayout = hogLayout === 'vertical'
const isResponsiveHogLayout = hogLayout === 'responsive'
return (
@@ -121,15 +122,18 @@ export const ProductIntroduction = ({
<div
className={cn(
'flex w-full justify-center',
- isResponsiveHogLayout
- ? useMainContentContainerQueries
- ? 'flex-col @min-[48rem]/main-content:flex-row items-center gap-6 @min-[48rem]/main-content:gap-8'
- : 'flex-col md:flex-row items-center gap-6 md:gap-8'
- : 'flex-row items-center gap-8'
+ isVerticalHogLayout
+ ? 'flex-col items-center gap-6'
+ : isResponsiveHogLayout
+ ? useMainContentContainerQueries
+ ? 'flex-col @min-[48rem]/main-content:flex-row items-center gap-6 @min-[48rem]/main-content:gap-8'
+ : 'flex-col md:flex-row items-center gap-6 md:gap-8'
+ : 'flex-row items-center gap-8'
)}
>
<div
className={cn(
+ isVerticalHogLayout && 'w-full flex justify-center',
isResponsiveHogLayout &&
(useMainContentContainerQueries
? 'w-full @min-[48rem]/main-content:w-auto flex justify-center'
@@ -139,11 +143,13 @@ export const ProductIntroduction = ({
<div
className={cn(
'mx-auto',
- isResponsiveHogLayout
- ? useMainContentContainerQueries
- ? 'block w-36 sm:w-40 lg:w-50 mb-4 @min-[48rem]/main-content:mb-0'
- : 'block w-36 sm:w-40 lg:w-50 mb-4 md:mb-0'
- : 'w-40 lg:w-50 mb-4 hidden md:block'
+ isVerticalHogLayout
+ ? 'block w-36 sm:w-40 lg:w-50 mb-4'
+ : isResponsiveHogLayout
+ ? useMainContentContainerQueries
+ ? 'block w-36 sm:w-40 lg:w-50 mb-4 @min-[48rem]/main-content:mb-0'
+ : 'block w-36 sm:w-40 lg:w-50 mb-4 md:mb-0'
+ : 'w-40 lg:w-50 mb-4 hidden md:block'
)}
>
{CustomHog ? (
@@ -158,6 +164,7 @@ export const ProductIntroduction = ({
<div
className={cn(
'flex-shrink max-w-140',
+ isVerticalHogLayout && 'w-full text-center',
isResponsiveHogLayout &&
(useMainContentContainerQueries
? 'w-full text-center @min-[48rem]/main-content:text-left'
@@ -188,6 +195,7 @@ export const ProductIntroduction = ({
<div
className={cn(
'flex items-center gap-x-4 gap-y-2 mt-6 flex-wrap',
+ isVerticalHogLayout && 'justify-center',
isResponsiveHogLayout &&
(useMainContentContainerQueries
? 'justify-center @min-[48rem]/main-content:justify-start'
diff --git a/frontend/src/scenes/dashboard/DashboardItems.test.tsx b/frontend/src/scenes/dashboard/DashboardItems.test.tsx
index f6277807f612..3b6ce911cd72 100644
--- a/frontend/src/scenes/dashboard/DashboardItems.test.tsx
+++ b/frontend/src/scenes/dashboard/DashboardItems.test.tsx
@@ -1,7 +1,7 @@
import '@testing-library/jest-dom'
import { render } from '@testing-library/react'
-import { useActions, useValues } from 'kea'
+import { useActions, useAsyncActions, useValues } from 'kea'
import { router } from 'kea-router'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
@@ -17,6 +17,7 @@ jest.mock('kea', () => ({
...jest.requireActual('kea'),
useValues: jest.fn(),
useActions: jest.fn(),
+ useAsyncActions: jest.fn(),
}))
jest.mock('scenes/dashboard/dashboardLogic', () => ({
@@ -140,6 +141,7 @@ jest.mock('@posthog/products-dashboards/frontend/components/DashboardWidgetItem/
const mockedUseValues = useValues as jest.Mock
const mockedUseActions = useActions as jest.Mock
+const mockedUseAsyncActions = useAsyncActions as jest.Mock
describe('DashboardItems', () => {
beforeEach(() => {
@@ -195,7 +197,6 @@ describe('DashboardItems', () => {
duplicateTile: jest.fn(),
refreshDashboardItem: jest.fn(),
refreshDashboardWidgets: jest.fn(),
- updateWidgetTileMetadata: jest.fn(),
moveToDashboard: jest.fn(),
copyToDashboard: jest.fn(),
setTileOverride: jest.fn(),
@@ -223,6 +224,16 @@ describe('DashboardItems', () => {
return {}
})
+
+ mockedUseAsyncActions.mockImplementation((logic) => {
+ if (logic === dashboardLogic) {
+ return {
+ updateWidgetTile: jest.fn(),
+ }
+ }
+
+ return {}
+ })
})
it('matches snapshot in edit mode with layout zoom enabled', () => {
diff --git a/frontend/src/scenes/dashboard/DashboardItems.tsx b/frontend/src/scenes/dashboard/DashboardItems.tsx
index e6f89746f612..ba727b7b5119 100644
--- a/frontend/src/scenes/dashboard/DashboardItems.tsx
+++ b/frontend/src/scenes/dashboard/DashboardItems.tsx
@@ -1,7 +1,7 @@
import './DashboardItems.scss'
import clsx from 'clsx'
-import { useActions, useValues } from 'kea'
+import { useActions, useAsyncActions, useValues } from 'kea'
import { router } from 'kea-router'
import { RefObject, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { Layout, Responsive as ReactGridLayout, useContainerWidth } from 'react-grid-layout'
@@ -65,13 +65,12 @@ export function DashboardItems(): JSX.Element {
duplicateTile,
refreshDashboardItem,
refreshDashboardWidgets,
- updateWidgetTileMetadata,
- updateWidgetTileConfig,
moveToDashboard,
copyToDashboard,
setTileOverride,
setDashboardMode,
} = useActions(dashboardLogic)
+ const { updateWidgetTile } = useAsyncActions(dashboardLogic)
const { renameInsight } = useActions(insightsModel)
const { reportDashboardTileRepositioned } = useActions(eventUsageLogic)
const { push } = useActions(router)
@@ -500,8 +499,9 @@ export function DashboardItems(): JSX.Element {
onRefresh={() =>
refreshDashboardWidgets({ tileIds: [tile.id], forceRefresh: true })
}
- onUpdateConfig={(config) => updateWidgetTileConfig({ tile, config })}
- onUpdateMetadata={(metadata) => updateWidgetTileMetadata({ tile, ...metadata })}
+ onUpdateWidgetTile={async (patch) => {
+ await updateWidgetTile({ tile, ...patch })
+ }}
toggleShowDescription={() => toggleTileDescription(tile.id)}
onDuplicate={() => duplicateTile(tile)}
onRemove={commonTileProps.removeFromDashboard}
diff --git a/frontend/src/scenes/dashboard/dashboardLogic.test.ts b/frontend/src/scenes/dashboard/dashboardLogic.test.ts
index a1c88ee56b48..21e4f0a803a0 100644
--- a/frontend/src/scenes/dashboard/dashboardLogic.test.ts
+++ b/frontend/src/scenes/dashboard/dashboardLogic.test.ts
@@ -5,6 +5,7 @@ import { router } from 'kea-router'
import { expectLogic, truth } from 'kea-test-utils'
import { lemonToast } from '@posthog/lemon-ui'
+import * as dashboardWidgetUtils from '@posthog/products-dashboards/frontend/utils'
import { DASHBOARD_WIDGET_FETCH_ERROR_MESSAGE } from '@posthog/products-dashboards/frontend/widgets/constants'
import api from 'lib/api'
@@ -1435,7 +1436,7 @@ describe('dashboardLogic', () => {
const toastContent = lemonToastInfoSpy.mock.calls.at(-1)?.[0]
const { container } = render(toastContent)
- expect(container.textContent).toBe('error_tracking_list widget removed')
+ expect(container.textContent).toBe('Top issues widget removed')
})
it('uses custom widget name in undo toast when set', async () => {
@@ -1665,6 +1666,49 @@ describe('dashboardLogic', () => {
expect(logic.values.widgetRefreshStatus[11]?.error).toBe(DASHBOARD_WIDGET_FETCH_ERROR_MESSAGE)
})
+ it('duplicateTile refreshes newly duplicated widget tiles', async () => {
+ const duplicatedTile = {
+ id: 99,
+ widget: { id: '3', widget_type: 'error_tracking_list', config: { limit: 5 } },
+ layouts: { sm: { i: '99', x: 0, y: 10, w: 6, h: 5 } },
+ color: null,
+ } as unknown as DashboardTile<QueryBasedInsightModel>
+
+ jest.spyOn(api, 'update').mockResolvedValueOnce(
+ dashboardResult(5, [...dashboards[5].tiles, WIDGET_TILE, duplicatedTile])
+ )
+
+ logic = dashboardLogic({ id: 5 })
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ fetchRunWidgetsMock.mockResolvedValueOnce([
+ {
+ tile_id: duplicatedTile.id,
+ widget_type: 'error_tracking_list',
+ result: { results: [{ id: 'issue-1' }], hasMore: false },
+ error: null,
+ },
+ ])
+
+ await expectLogic(logic, () => {
+ logic.actions.duplicateTile(WIDGET_TILE)
+ })
+ .toDispatchActions(['refreshDashboardWidgets'])
+ .toFinishAllListeners()
+
+ expect(fetchRunWidgetsMock).toHaveBeenCalledWith(
+ String(MOCK_TEAM_ID),
+ 5,
+ [duplicatedTile.id],
+ expect.anything()
+ )
+ expect(logic.values.widgetResultsByTileId[duplicatedTile.id]?.result).toEqual({
+ results: [{ id: 'issue-1' }],
+ hasMore: false,
+ })
+ })
+
it('addWidgetTiles refreshes newly created widget tiles', async () => {
const addedTile = {
id: 99,
@@ -1702,6 +1746,51 @@ describe('dashboardLogic', () => {
expect(fetchRunWidgetsMock).toHaveBeenCalledWith(String(MOCK_TEAM_ID), 5, [addedTile.id], expect.anything())
})
+ it('updateWidgetTile persists config and metadata in one patch', async () => {
+ const updateDashboardWidgetTileMock = jest
+ .spyOn(dashboardWidgetUtils, 'updateDashboardWidgetTile')
+ .mockResolvedValueOnce({
+ ...WIDGET_TILE,
+ widget: {
+ ...WIDGET_TILE.widget!,
+ name: 'Weekly errors',
+ description: 'Top issues this week',
+ config: { limit: 5 },
+ },
+ } as DashboardTile<QueryBasedInsightModel>)
+
+ logic = dashboardLogic({ id: 5 })
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ await expectLogic(logic, () => {
+ logic.actions.updateWidgetTile({
+ tile: WIDGET_TILE,
+ config: { limit: 5 },
+ name: 'Weekly errors',
+ description: 'Top issues this week',
+ })
+ })
+ .toDispatchActions(['refreshDashboardWidgets'])
+ .toFinishAllListeners()
+
+ expect(updateDashboardWidgetTileMock).toHaveBeenCalledWith({
+ teamId: MOCK_TEAM_ID,
+ dashboardId: 5,
+ tile: WIDGET_TILE,
+ config: { limit: 5 },
+ name: 'Weekly errors',
+ description: 'Top issues this week',
+ })
+ expect(logic.values.dashboard?.tiles.find((tile) => tile.id === WIDGET_TILE.id)?.widget).toMatchObject({
+ name: 'Weekly errors',
+ description: 'Top issues this week',
+ config: { limit: 5 },
+ })
+
+ updateDashboardWidgetTileMock.mockRestore()
+ })
+
it('copyToDashboard calls copy_tile for widget tiles', async () => {
jest.spyOn(api, 'create').mockResolvedValueOnce({})
diff --git a/frontend/src/scenes/dashboard/dashboardLogic.tsx b/frontend/src/scenes/dashboard/dashboardLogic.tsx
index 0b6a1f56313e..96e47974872a 100644
--- a/frontend/src/scenes/dashboard/dashboardLogic.tsx
+++ b/frontend/src/scenes/dashboard/dashboardLogic.tsx
@@ -169,6 +169,29 @@ const tileLayoutsFromDashboard = (
return tileIdToLayouts
}
+function mergeUpdatedWidgetTileIntoDashboard(
+ dashboard: DashboardType<QueryBasedInsightModel>,
+ updatedTile: DashboardTile<QueryBasedInsightModel>
+): DashboardType<QueryBasedInsightModel> | null {
+ return getQueryBasedDashboard({
+ ...dashboard,
+ tiles: dashboard.tiles.map((existingTile) => {
+ if (existingTile.id !== updatedTile.id) {
+ return existingTile
+ }
+
+ return {
+ ...existingTile,
+ ...updatedTile,
+ widget:
+ existingTile.widget && updatedTile.widget
+ ? { ...existingTile.widget, ...updatedTile.widget }
+ : (updatedTile.widget ?? existingTile.widget),
+ }
+ }),
+ } as DashboardType<InsightModel>)
+}
+
export const dashboardLogic = kea<dashboardLogicType>([
path(['scenes', 'dashboard', 'dashboardLogic']),
connect(() => ({
@@ -252,15 +275,6 @@ export const dashboardLogic = kea<dashboardLogicType>([
dashboardId: number
widgets: { widgetType: string; config: Record<string, unknown> }[]
}) => payload,
- updateWidgetTileConfig: (payload: {
- tile: DashboardTile<QueryBasedInsightModel>
- config: Record<string, unknown>
- }) => payload,
- updateWidgetTileMetadata: (payload: {
- tile: DashboardTile<QueryBasedInsightModel>
- name?: string
- description?: string
- }) => payload,
setAddWidgetModalOpen: (open: boolean) => ({ open }),
toggleAddWidgetSelectedType: (widgetType: string) => ({ widgetType }),
clearAddWidgetSelectedTypes: true,
@@ -680,6 +694,60 @@ export const dashboardLogic = kea<dashboardLogicType>([
},
},
],
+ widgetTileUpdate: [
+ null,
+ {
+ updateWidgetTile: async ({
+ tile,
+ config,
+ name,
+ description,
+ }: {
+ tile: DashboardTile<QueryBasedInsightModel>
+ config?: Record<string, unknown>
+ name?: string | null
+ description?: string
+ }) => {
+ if (!values.dashboard?.id || !tile.widget) {
+ return null
+ }
+ if (config === undefined && name === undefined && description === undefined) {
+ return null
+ }
+
+ try {
+ const shouldShowDescription =
+ description !== undefined &&
+ description.trim().length > 0 &&
+ tile.show_description === false
+
+ const updatedTile = await updateDashboardWidgetTile({
+ teamId: teamLogic.values.currentTeamId!,
+ dashboardId: values.dashboard.id,
+ tile,
+ config,
+ name,
+ description,
+ showDescription: shouldShowDescription ? true : undefined,
+ })
+ const dashboard = mergeUpdatedWidgetTileIntoDashboard(values.dashboard, updatedTile)
+ if (dashboard) {
+ dashboardsModel.actions.updateDashboardSuccess(dashboard)
+ }
+ if (config !== undefined) {
+ actions.refreshDashboardWidgets({ tileIds: [tile.id], forceRefresh: true })
+ }
+ return null
+ } catch (e) {
+ if (config !== undefined && isWidgetConfigValidationError(e)) {
+ throw e
+ }
+ lemonToast.error(e instanceof ApiError ? (e.detail ?? e.message) : 'Could not update widget')
+ throw e
+ }
+ },
+ },
+ ],
})),
reducers(({ props }) => ({
dashboardLoading: [
@@ -1970,6 +2038,28 @@ export const dashboardLogic = kea<dashboardLogicType>([
actions.loadDashboard({ action: DashboardLoadAction.Update })
}
},
+ duplicateTile: () => {
+ cache.widgetTileIdsBeforeDuplicate = new Set(values.widgetTiles.map((tile) => tile.id))
+ },
+ duplicateTileSuccess: ({ dashboard }) => {
+ if (!dashboard || !values.dashboardWidgetsEnabled) {
+ return
+ }
+
+ const previousTileIds = cache.widgetTileIdsBeforeDuplicate as Set<number> | undefined
+ cache.widgetTileIdsBeforeDuplicate = undefined
+ if (!previousTileIds) {
+ return
+ }
+
+ const createdTiles = findNewlyAddedWidgetTiles(previousTileIds, dashboard.tiles)
+ if (createdTiles.length > 0) {
+ actions.refreshDashboardWidgets({
+ tileIds: createdTiles.map((tile) => tile.id),
+ forceRefresh: true,
+ })
+ }
+ },
removeTile: ({ tile }) => {
cache.removedTileForUndo = tile
},
@@ -2517,61 +2607,6 @@ export const dashboardLogic = kea<dashboardLogicType>([
actions.addWidgetTileFinished()
}
},
- updateWidgetTileConfig: async ({ tile, config }) => {
- if (!values.dashboard?.id || !tile.widget) {
- return
- }
- try {
- const updatedTile = await updateDashboardWidgetTile({
- teamId: teamLogic.values.currentTeamId!,
- dashboardId: values.dashboard.id,
- tile,
- config,
- })
- const dashboard = getQueryBasedDashboard({
- ...values.dashboard,
- tiles: values.dashboard.tiles.map((existingTile) =>
- existingTile.id === tile.id ? { ...existingTile, ...updatedTile } : existingTile
- ),
- } as DashboardType<InsightModel>)
- if (dashboard) {
- dashboardsModel.actions.updateDashboardSuccess(dashboard)
- }
- actions.refreshDashboardWidgets({ tileIds: [tile.id], forceRefresh: true })
- } catch (e) {
- if (isWidgetConfigValidationError(e)) {
- throw e
- }
- lemonToast.error(e instanceof ApiError ? (e.detail ?? e.message) : 'Could not update widget')
- throw e
- }
- },
- updateWidgetTileMetadata: async ({ tile, name, description }) => {
- if (!values.dashboard?.id || !tile.widget) {
- return
- }
- try {
- const updatedTile = await updateDashboardWidgetTile({
- teamId: teamLogic.values.currentTeamId!,
- dashboardId: values.dashboard.id,
- tile,
- name,
- description,
- })
- const dashboard = getQueryBasedDashboard({
- ...values.dashboard,
- tiles: values.dashboard.tiles.map((existingTile) =>
- existingTile.id === tile.id ? { ...existingTile, ...updatedTile } : existingTile
- ),
- } as DashboardType<InsightModel>)
- if (dashboard) {
- dashboardsModel.actions.updateDashboardSuccess(dashboard)
- }
- } catch (e) {
- lemonToast.error(e instanceof ApiError ? (e.detail ?? e.message) : 'Could not update widget')
- throw e
- }
- },
saveEditModeChanges: () => {
if (
values.dashboard?.persisted_filters?.date_from !== values.effectiveEditBarFilters.date_from ||
diff --git a/frontend/src/scenes/dashboard/dashboardUtils.test.ts b/frontend/src/scenes/dashboard/dashboardUtils.test.ts
index 678599feb383..9b93a1e7cf51 100644
--- a/frontend/src/scenes/dashboard/dashboardUtils.test.ts
+++ b/frontend/src/scenes/dashboard/dashboardUtils.test.ts
@@ -21,7 +21,7 @@ describe('getDashboardTileDisplayName', () => {
color: null,
}
- expect(getDashboardTileDisplayName(tile)).toBe('error_tracking_list')
+ expect(getDashboardTileDisplayName(tile)).toBe('Top issues')
})
it('uses custom widget name when set', () => {
diff --git a/frontend/src/scenes/dashboard/tileLayouts.ts b/frontend/src/scenes/dashboard/tileLayouts.ts
index 00239866b62a..57b678096975 100644
--- a/frontend/src/scenes/dashboard/tileLayouts.ts
+++ b/frontend/src/scenes/dashboard/tileLayouts.ts
@@ -1,6 +1,7 @@
import { Layout } from 'react-grid-layout'
import {
+ DASHBOARD_WIDGET_CATALOG,
getDashboardWidgetCatalogEntry,
type DashboardWidgetCatalogEntry,
} from '@posthog/products-dashboards/frontend/widget_types/catalog'
@@ -31,10 +32,10 @@ type WidgetCatalogLayout = DashboardWidgetCatalogEntry['defaultLayout']
* (default size 6×5, mins `MIN_WIDGET_TILE_WIDTH_COLS` / `MIN_WIDGET_TILE_HEIGHT_ROWS`).
*/
function getWidgetCatalogLayout(widgetType: string | undefined): WidgetCatalogLayout | undefined {
- if (!widgetType) {
+ if (!widgetType || !(widgetType in DASHBOARD_WIDGET_CATALOG)) {
return undefined
}
- return getDashboardWidgetCatalogEntry(widgetType)?.defaultLayout
+ return getDashboardWidgetCatalogEntry(widgetType).defaultLayout
}
function getTileMinDimensions({
diff --git a/products/dashboards/backend/api/dashboard.py b/products/dashboards/backend/api/dashboard.py
index 2f5e4b7ebaa6..724a4b7b220b 100644
--- a/products/dashboards/backend/api/dashboard.py
+++ b/products/dashboards/backend/api/dashboard.py
@@ -937,6 +937,7 @@ def _report_dashboard_tile_added(
tile_type: str,
request: Request | None = None,
widget_type: str | None = None,
+ tile: DashboardTile | None = None,
) -> None:
properties: dict[str, Any] = {
"tile_type": tile_type,
@@ -954,6 +955,26 @@ def _report_dashboard_tile_added(
request=request,
)
+ if widget_type is None:
+ return
+
+ widget_properties: dict[str, Any] = {
+ "widget_type": widget_type,
+ "dashboard_id": dashboard.id,
+ }
+ if tile is not None:
+ widget_properties["tile_id"] = tile.id
+ if tile.widget_id is not None:
+ widget_properties["widget_id"] = str(tile.widget_id)
+
+ report_user_action(
+ user,
+ "dashboard widget added",
+ widget_properties,
+ team=dashboard.team,
+ request=request,
+ )
+
class DashboardSerializer(DashboardMetadataSerializer):
tiles = serializers.SerializerMethodField()
@@ -1288,6 +1309,7 @@ class DashboardSerializer(DashboardMetadataSerializer):
tile_type=tile_type,
widget_type=widget_type,
request=self.context["request"],
+ tile=tile,
)
duplicate_tiles = initial_data.pop("duplicate_tiles", [])
@@ -2696,6 +2718,7 @@ class DashboardsViewSet(
tile_type="widget",
widget_type=tile.widget.widget_type,
request=request,
+ tile=tile,
)
return Response(
diff --git a/products/dashboards/backend/api/test/test_dashboard_widgets.py b/products/dashboards/backend/api/test/test_dashboard_widgets.py
index f9ef578f2f82..645f7f2cf7a2 100644
--- a/products/dashboards/backend/api/test/test_dashboard_widgets.py
+++ b/products/dashboards/backend/api/test/test_dashboard_widgets.py
@@ -653,6 +653,14 @@ class TestDashboardWidgets(APIBaseTest):
team=ANY,
request=ANY,
)
+ widget_added_calls = [
+ call for call in mock_report_user_action.call_args_list if call[0][1] == "dashboard widget added"
+ ]
+ assert len(widget_added_calls) == 1
+ assert widget_added_calls[0][0][2]["widget_type"] == "error_tracking_list"
+ assert widget_added_calls[0][0][2]["dashboard_id"] == dashboard_id
+ assert "tile_id" in widget_added_calls[0][0][2]
+ assert "widget_id" in widget_added_calls[0][0][2]
@override_settings(IN_UNIT_TESTING=True)
@patch("products.dashboards.backend.api.dashboard.report_user_action")
@@ -682,6 +690,14 @@ class TestDashboardWidgets(APIBaseTest):
team=ANY,
request=ANY,
)
+ widget_added_calls = [
+ call for call in mock_report_user_action.call_args_list if call[0][1] == "dashboard widget added"
+ ]
+ assert len(widget_added_calls) == 1
+ assert widget_added_calls[0][0][2]["widget_type"] == "error_tracking_list"
+ assert widget_added_calls[0][0][2]["dashboard_id"] == dashboard_id
+ assert "tile_id" in widget_added_calls[0][0][2]
+ assert "widget_id" in widget_added_calls[0][0][2]
@override_settings(IN_UNIT_TESTING=True)
def test_can_batch_create_widget_tiles(self) -> None:
@@ -753,6 +769,7 @@ class TestDashboardWidgets(APIBaseTest):
for call in mock_report_user_action.call_args_list:
assert call[0][1] != "dashboard tile added"
+ assert call[0][1] != "dashboard widget added"
@override_settings(IN_UNIT_TESTING=True)
@patch("posthog.resource_limits.evaluator.report_user_action")
diff --git a/products/dashboards/backend/api/test/test_run_widgets.py b/products/dashboards/backend/api/test/test_run_widgets.py
index 5e970da45eeb..c2c50cd22c93 100644
--- a/products/dashboards/backend/api/test/test_run_widgets.py
+++ b/products/dashboards/backend/api/test/test_run_widgets.py
@@ -13,6 +13,7 @@ from posthog.scopes import APIScopeObject
from products.dashboards.backend.constants import DEFAULT_ERROR_TRACKING_LIST_WIDGET_LIMIT, MAX_WIDGETS_BATCH_SIZE
from products.dashboards.backend.widget_registry import EXPECTED_WIDGET_TYPES, WIDGET_REGISTRY, validate_widget_config
from products.dashboards.backend.widgets.error_tracking_list import validate_error_tracking_list_config
+from products.error_tracking.backend.api.query_utils import ERROR_TRACKING_LISTING_VOLUME_RESOLUTION
class TestWidgetRegistry(APIBaseTest):
@@ -126,6 +127,20 @@ class TestDashboardRunWidgets(APIBaseTest):
self.assertEqual(body["results"][0]["result"]["limit"], 10)
mock_calculate.assert_called_once()
+ @patch("products.dashboards.backend.widgets.error_tracking_list.ErrorTrackingQueryRunner")
+ def test_run_widgets_requests_listing_volume_resolution(self, mock_runner_cls: MagicMock) -> None:
+ mock_runner_cls.return_value.calculate.return_value = MagicMock(
+ model_dump=lambda mode="json": {"results": [], "hasMore": False, "limit": 10, "offset": 0}
+ )
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dash"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(dashboard_id, config={"limit": 10})
+ tile_id = dashboard_json["tiles"][0]["id"]
+
+ self._run(dashboard_id, [tile_id])
+
+ query = mock_runner_cls.call_args.kwargs["query"]
+ self.assertEqual(query.volumeResolution, ERROR_TRACKING_LISTING_VOLUME_RESOLUTION)
+
@patch("products.dashboards.backend.widgets.error_tracking_list.ErrorTrackingQueryRunner")
def test_run_widgets_uses_team_filter_test_accounts_default(self, mock_runner_cls: MagicMock) -> None:
mock_runner_cls.return_value.calculate.return_value = MagicMock(
diff --git a/products/dashboards/backend/test/test_widget_layouts.py b/products/dashboards/backend/test/test_widget_layouts.py
index 63687c7ca71d..78bdf884ee76 100644
--- a/products/dashboards/backend/test/test_widget_layouts.py
+++ b/products/dashboards/backend/test/test_widget_layouts.py
@@ -4,12 +4,12 @@ from products.dashboards.backend.widget_layouts import stack_widget_layout_at_bo
class TestWidgetLayouts:
"""Backend placement only reads `layouts.sm`.
- Uses the same lowest-segment greedy packing as ``tileLayouts.calculateLayouts`` /
- ``_apply_reorder_layout`` (preserve). Mobile (`xs`) placement is still derived on
- the frontend; the backend mirrors sm → xs for API/schema completeness.
+ New widgets append to the bottom row of the dashboard (below the tallest tile),
+ packing batch adds horizontally on that row. Mobile (`xs`) placement is still
+ derived on the frontend; the backend mirrors sm → xs for API/schema completeness.
"""
- def test_stack_widget_layout_at_bottom_fills_lowest_segment(self) -> None:
+ def test_stack_widget_layout_at_bottom_appends_below_tallest_tile(self) -> None:
existing = [
{"x": 0, "y": 0, "w": 6, "h": 4},
{"x": 6, "y": 0, "w": 6, "h": 11},
@@ -20,10 +20,10 @@ class TestWidgetLayouts:
existing_sm_layouts=existing,
)
- assert layouts["sm"] == {"x": 0, "y": 4, "w": 6, "h": 5}
+ assert layouts["sm"] == {"x": 0, "y": 11, "w": 6, "h": 5}
assert layouts["xs"] == layouts["sm"]
- def test_stack_widget_layout_at_bottom_uses_right_column_when_left_is_taller(self) -> None:
+ def test_stack_widget_layout_at_bottom_packs_batch_on_same_row(self) -> None:
existing = [
{"x": 0, "y": 0, "w": 6, "h": 4},
{"x": 6, "y": 0, "w": 6, "h": 9},
@@ -46,7 +46,7 @@ class TestWidgetLayouts:
assert layouts["sm"] == {"x": 6, "y": 18, "w": 6, "h": 5}
- def test_stack_widget_layout_at_bottom_prefers_shorter_right_column(self) -> None:
+ def test_stack_widget_layout_at_bottom_ignores_short_column_gaps(self) -> None:
existing = [
{"x": 0, "y": 0, "w": 6, "h": 10},
{"x": 6, "y": 0, "w": 6, "h": 4},
@@ -57,7 +57,7 @@ class TestWidgetLayouts:
existing_sm_layouts=existing,
)
- assert layouts["sm"] == {"x": 6, "y": 4, "w": 6, "h": 5}
+ assert layouts["sm"] == {"x": 0, "y": 10, "w": 6, "h": 5}
def test_stack_widget_layout_at_bottom_packs_batch_side_by_side(self) -> None:
first = stack_widget_layout_at_bottom(
@@ -72,3 +72,21 @@ class TestWidgetLayouts:
assert first["sm"] == {"x": 0, "y": 0, "w": 6, "h": 5}
assert second["sm"] == {"x": 6, "y": 0, "w": 6, "h": 5}
+
+ def test_stack_widget_layout_at_bottom_wraps_to_next_row_when_bottom_row_full(self) -> None:
+ existing = [
+ {"x": 0, "y": 0, "w": 6, "h": 5},
+ {"x": 6, "y": 0, "w": 6, "h": 5},
+ ]
+ pending = [
+ {"x": 0, "y": 0, "w": 6, "h": 5},
+ {"x": 6, "y": 0, "w": 6, "h": 5},
+ ]
+
+ layouts = stack_widget_layout_at_bottom(
+ widget_type="error_tracking_list",
+ existing_sm_layouts=existing,
+ pending_sm_layouts=pending,
+ )
+
+ assert layouts["sm"] == {"x": 0, "y": 5, "w": 6, "h": 5}
diff --git a/products/dashboards/backend/widget_layouts.py b/products/dashboards/backend/widget_layouts.py
index b7869a5d9d4f..e6acd833d9a8 100644
--- a/products/dashboards/backend/widget_layouts.py
+++ b/products/dashboards/backend/widget_layouts.py
@@ -6,38 +6,69 @@ from products.dashboards.backend.constants import DASHBOARD_GRID_COLUMN_COUNT
from products.dashboards.backend.widget_catalog import get_default_widget_layouts
-def _column_heights_from_sm_layouts(sm_layouts: list[dict[str, Any]]) -> list[int]:
- column_heights = [0] * DASHBOARD_GRID_COLUMN_COUNT
+def _rectangles_overlap(
+ x1: int,
+ y1: int,
+ w1: int,
+ h1: int,
+ x2: int,
+ y2: int,
+ w2: int,
+ h2: int,
+) -> bool:
+ return x1 < x2 + w2 and x1 + w1 > x2 and y1 < y2 + h2 and y1 + h1 > y2
+
+
+def _layout_overlaps_any(
+ sm_layouts: list[dict[str, Any]],
+ x: int,
+ y: int,
+ w: int,
+ h: int,
+) -> bool:
+ for layout in sm_layouts:
+ lx = int(layout.get("x", 0))
+ ly = int(layout.get("y", 0))
+ lw = max(1, min(int(layout.get("w", 1)), DASHBOARD_GRID_COLUMN_COUNT))
+ lh = max(1, int(layout.get("h", 1)))
+ if _rectangles_overlap(x, y, w, h, lx, ly, lw, lh):
+ return True
+ return False
+
+
+def _dashboard_bottom_y(sm_layouts: list[dict[str, Any]]) -> int:
+ bottom_y = 0
for layout in sm_layouts:
- x = int(layout.get("x", 0))
y = int(layout.get("y", 0))
- w = max(1, min(int(layout.get("w", 1)), DASHBOARD_GRID_COLUMN_COUNT))
h = max(1, int(layout.get("h", 1)))
- x = max(0, min(x, DASHBOARD_GRID_COLUMN_COUNT - 1))
- for column in range(x, min(x + w, DASHBOARD_GRID_COLUMN_COUNT)):
- column_heights[column] = max(column_heights[column], y + h)
- return column_heights
+ bottom_y = max(bottom_y, y + h)
+ return bottom_y
-def _find_lowest_segment_placement(
+def _find_bottom_row_placement(
*,
- column_heights: list[int],
+ existing_sm_layouts: list[dict[str, Any]],
+ pending_sm_layouts: list[dict[str, Any]] | None,
width: int,
height: int,
) -> dict[str, int]:
- """Greedy lowest-segment packing from ``frontend/src/scenes/dashboard/tileLayouts.ts``."""
+ """Place a widget on the bottom row of the dashboard, packing batch adds horizontally."""
w = max(1, min(width, DASHBOARD_GRID_COLUMN_COUNT))
h = max(1, height)
+ pending = pending_sm_layouts or []
+ all_layouts = [*existing_sm_layouts, *pending]
+
+ if pending:
+ placement_y = int(pending[0].get("y", 0))
+ else:
+ placement_y = _dashboard_bottom_y(existing_sm_layouts)
- best_x = 0
- best_y = max(column_heights[0:w])
- for x in range(1, DASHBOARD_GRID_COLUMN_COUNT - w + 1):
- segment_top = max(column_heights[x : x + w])
- if segment_top < best_y:
- best_x = x
- best_y = segment_top
+ for x in range(0, DASHBOARD_GRID_COLUMN_COUNT - w + 1):
+ if not _layout_overlaps_any(all_layouts, x, placement_y, w, h):
+ return {"x": x, "y": placement_y, "w": w, "h": h}
- return {"x": best_x, "y": best_y, "w": w, "h": h}
+ next_y = _dashboard_bottom_y(all_layouts)
+ return {"x": 0, "y": next_y, "w": w, "h": h}
def stack_widget_layout_at_bottom(
@@ -49,9 +80,12 @@ def stack_widget_layout_at_bottom(
defaults = get_default_widget_layouts(widget_type)
width = defaults["sm"]["w"]
height = defaults["sm"]["h"]
- sm_layouts = [*existing_sm_layouts, *(pending_sm_layouts or [])]
- column_heights = _column_heights_from_sm_layouts(sm_layouts)
- sm = _find_lowest_segment_placement(column_heights=column_heights, width=width, height=height)
+ sm = _find_bottom_row_placement(
+ existing_sm_layouts=existing_sm_layouts,
+ pending_sm_layouts=pending_sm_layouts,
+ width=width,
+ height=height,
+ )
return {"sm": sm, "xs": {**sm}}
diff --git a/products/dashboards/backend/widgets/error_tracking_list.py b/products/dashboards/backend/widgets/error_tracking_list.py
index b42cbfbe4c22..e77105448171 100644
--- a/products/dashboards/backend/widgets/error_tracking_list.py
+++ b/products/dashboards/backend/widgets/error_tracking_list.py
@@ -16,7 +16,9 @@ from products.dashboards.backend.widgets.config import (
resolve_filter_test_accounts,
validate_widget_date_range,
)
+from products.error_tracking.backend.api.query import is_error_tracking_query_v3_enabled, query_v3_volume_resolution
from products.error_tracking.backend.api.query_utils import (
+ ERROR_TRACKING_LISTING_VOLUME_RESOLUTION,
LIST_ISSUE_FIELDS,
build_date_range,
get_page_info,
@@ -64,6 +66,8 @@ def run_error_tracking_list_widget(team: Team, config: dict[str, Any], user: Use
limit = cast(int, config["limit"])
offset = 0
date_range_raw = config.get("dateRange")
+ use_query_v3 = is_error_tracking_query_v3_enabled(user, team) if user is not None else False
+ volume_resolution = ERROR_TRACKING_LISTING_VOLUME_RESOLUTION
query = ErrorTrackingQuery(
kind="ErrorTrackingQuery",
dateRange=DateRange(**build_date_range(date_range_raw)),
@@ -73,7 +77,8 @@ def run_error_tracking_list_widget(team: Team, config: dict[str, Any], user: Use
orderDirection=cast(str, config.get("orderDirection", "DESC")),
limit=limit,
offset=offset,
- volumeResolution=0,
+ volumeResolution=query_v3_volume_resolution(volume_resolution) if use_query_v3 else volume_resolution,
+ useQueryV3=use_query_v3 or None,
withAggregations=True,
withFirstEvent=False,
withLastEvent=False,
diff --git a/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.test.tsx b/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.test.tsx
index 0afd5ed34864..197e43d160c7 100644
--- a/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.test.tsx
+++ b/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.test.tsx
@@ -17,6 +17,7 @@ import {
QueryBasedInsightModel,
} from '~/types'
+import { getDashboardWidgetCatalogEntry, tryGetDashboardWidgetCatalogEntry } from '../../widget_types/catalog'
import { DashboardWidgetItem } from './DashboardWidgetItem'
jest.mock('lib/utils/accessControlUtils', () => ({
@@ -31,13 +32,11 @@ jest.mock('../../widgets/registry', () => ({
name,
defaultTitle,
description,
- onSaveMetadata: _onSaveMetadata,
}: {
isOpen: boolean
name?: string
defaultTitle?: string
description?: string
- onSaveMetadata?: (metadata: { name?: string; description?: string }) => void
}) =>
isOpen ? (
<div role="dialog" aria-label="Widget settings">
@@ -54,13 +53,29 @@ jest.mock('../../widgets/registry', () => ({
}))
jest.mock('../../widget_types/catalog', () => ({
- getDashboardWidgetCatalogEntry: () => ({
+ getDashboardWidgetCatalogEntry: jest.fn(() => ({
titleHref: '/error_tracking',
headerLayout: 'dashboard_tile',
- groupLabel: 'Error tracking',
+ groupId: 'error_tracking',
label: 'Top issues',
headerTitle: 'Top issues',
- }),
+ })),
+ tryGetDashboardWidgetCatalogEntry: jest.fn(() => ({
+ titleHref: '/error_tracking',
+ headerLayout: 'dashboard_tile',
+ groupId: 'error_tracking',
+ label: 'Top issues',
+ headerTitle: 'Top issues',
+ headerMeta: { showWidgetType: true, showDateRange: true },
+ })),
+ getUnknownDashboardWidgetCatalogFallback: jest.fn((widgetType: string) => ({
+ groupId: widgetType,
+ label: widgetType,
+ headerTitle: widgetType,
+ headerLayout: 'dashboard_tile',
+ headerMeta: { showWidgetType: true, showDateRange: true },
+ })),
+ getDashboardWidgetGroupLabel: () => 'Error tracking',
}))
const tile = {
@@ -127,8 +142,7 @@ describe('DashboardWidgetItem', () => {
loading={false}
lastFetchedAt={Date.now()}
onRefresh={onRefresh}
- onUpdateConfig={jest.fn()}
- onUpdateMetadata={jest.fn()}
+ onUpdateWidgetTile={jest.fn()}
toggleShowDescription={jest.fn()}
showEditingControls
onDuplicate={jest.fn()}
@@ -168,8 +182,7 @@ describe('DashboardWidgetItem', () => {
result={null}
loading={false}
onRefresh={jest.fn()}
- onUpdateConfig={jest.fn()}
- onUpdateMetadata={jest.fn()}
+ onUpdateWidgetTile={jest.fn()}
showEditingControls
onRemove={onRemove}
/>
@@ -193,8 +206,7 @@ describe('DashboardWidgetItem', () => {
result={null}
loading={false}
onRefresh={jest.fn()}
- onUpdateConfig={jest.fn()}
- onUpdateMetadata={jest.fn()}
+ onUpdateWidgetTile={jest.fn()}
showEditingControls
/>
)
@@ -212,8 +224,7 @@ describe('DashboardWidgetItem', () => {
result={null}
loading={false}
onRefresh={jest.fn()}
- onUpdateConfig={jest.fn()}
- onUpdateMetadata={jest.fn()}
+ onUpdateWidgetTile={jest.fn()}
toggleShowDescription={toggleShowDescription}
showEditingControls
/>
@@ -235,8 +246,7 @@ describe('DashboardWidgetItem', () => {
result={null}
loading={false}
onRefresh={jest.fn()}
- onUpdateConfig={jest.fn()}
- onUpdateMetadata={jest.fn()}
+ onUpdateWidgetTile={jest.fn()}
showEditingControls
/>
)
@@ -261,8 +271,7 @@ describe('DashboardWidgetItem', () => {
result={null}
loading={false}
onRefresh={jest.fn()}
- onUpdateConfig={jest.fn()}
- onUpdateMetadata={jest.fn()}
+ onUpdateWidgetTile={jest.fn()}
showEditingControls
/>
)
@@ -270,4 +279,47 @@ describe('DashboardWidgetItem', () => {
expect(container.querySelector('[data-attr="widget-card-title"] .EditableField')).toBeNull()
expect(container.querySelector('[data-attr="widget-card-title"]')).toHaveTextContent('My issues')
})
+
+ it('contains unknown widget errors in the card body while keeping the header', () => {
+ const catalogEntryMock = getDashboardWidgetCatalogEntry as jest.Mock
+ ;(tryGetDashboardWidgetCatalogEntry as jest.Mock).mockReturnValue(undefined)
+ catalogEntryMock.mockImplementation(() => {
+ throw new Error('Unknown dashboard widget type: session_replay_list')
+ })
+
+ const { container } = render(
+ <DashboardWidgetItem
+ tile={tile}
+ placement={DashboardPlacement.Dashboard}
+ dashboardId={99}
+ result={null}
+ loading={false}
+ error="Unknown widget type: session_replay_list"
+ onRefresh={jest.fn()}
+ onRemove={jest.fn()}
+ showEditingControls
+ />
+ )
+
+ expect(within(container).getByText('My issues')).toBeInTheDocument()
+ expect(within(container).getByText('An error has occurred')).toBeInTheDocument()
+ expect(within(container).getByText(/Unknown dashboard widget type: session_replay_list/)).toBeInTheDocument()
+ expect(within(container).queryByText('Refresh data')).not.toBeInTheDocument()
+
+ ;(tryGetDashboardWidgetCatalogEntry as jest.Mock).mockReturnValue({
+ titleHref: '/error_tracking',
+ headerLayout: 'dashboard_tile',
+ groupId: 'error_tracking',
+ label: 'Top issues',
+ headerTitle: 'Top issues',
+ headerMeta: { showWidgetType: true, showDateRange: true },
+ })
+ catalogEntryMock.mockImplementation(() => ({
+ titleHref: '/error_tracking',
+ headerLayout: 'dashboard_tile',
+ groupId: 'error_tracking',
+ label: 'Top issues',
+ headerTitle: 'Top issues',
+ }))
+ })
})
diff --git a/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.tsx b/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.tsx
index 77f03687df74..9618466e0cc3 100644
--- a/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.tsx
+++ b/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.tsx
@@ -12,9 +12,19 @@ import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
import { ErrorBoundary } from '~/layout/ErrorBoundary'
import { DashboardPlacement, DashboardTile, DashboardType, QueryBasedInsightModel } from '~/types'
-import { getDashboardWidgetCatalogEntry } from '../../widget_types/catalog'
+import {
+ getDashboardWidgetCatalogEntry,
+ getDashboardWidgetGroupLabel,
+ getUnknownDashboardWidgetCatalogFallback,
+ tryGetDashboardWidgetCatalogEntry,
+ type ResolvedDashboardWidgetCatalogEntry,
+} from '../../widget_types/catalog'
import { userHasDashboardWidgetProductAccess } from '../../widgetProductAccess'
-import { getDashboardWidgetDefinition, type DashboardWidgetComponentProps } from '../../widgets/registry'
+import {
+ getDashboardWidgetDefinition,
+ type DashboardWidgetComponentProps,
+ type DashboardWidgetDefinition,
+} from '../../widgets/registry'
import { WidgetCard } from '../WidgetCard/WidgetCard'
import { WidgetCardBody } from '../WidgetCard/WidgetCardBody'
import { WidgetCardHeader, widgetCardShouldHideMoreButton } from '../WidgetCard/WidgetCardHeader'
@@ -29,8 +39,11 @@ type DashboardWidgetItemProps = {
error?: string | null
lastFetchedAt?: number
onRefresh: () => void
- onUpdateConfig: (config: Record<string, unknown>) => void | Promise<void>
- onUpdateMetadata?: (metadata: { name?: string; description?: string }) => void
+ onUpdateWidgetTile?: (patch: {
+ config?: Record<string, unknown>
+ name?: string
+ description?: string
+ }) => void | Promise<void>
toggleShowDescription?: () => void
showResizeHandles?: boolean
canEnterEditModeFromEdge?: boolean
@@ -45,6 +58,226 @@ type DashboardWidgetItemProps = {
children?: React.ReactNode
} & Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>
+type DashboardWidgetItemContentProps = Omit<
+ DashboardWidgetItemProps,
+ 'children' | 'className' | 'style' | 'showResizeHandles' | 'canEnterEditModeFromEdge' | 'onEnterEditModeFromEdge'
+> & {
+ widget: NonNullable<DashboardTile<QueryBasedInsightModel>['widget']>
+ definition: DashboardWidgetDefinition | undefined
+ headerCatalogEntry: ResolvedDashboardWidgetCatalogEntry
+ isUnknownWidgetType: boolean
+ copyToDestinations: ReturnType<typeof useValues<typeof dashboardWidgetMenusLogic>>['copyToDestinations']
+ editOpen: boolean
+ setEditOpen: (open: boolean) => void
+}
+
+type DashboardWidgetItemBodyProps = {
+ widget: NonNullable<DashboardTile<QueryBasedInsightModel>['widget']>
+ definition: DashboardWidgetDefinition | undefined
+ componentProps: DashboardWidgetComponentProps
+}
+
+function DashboardWidgetItemBody({
+ widget,
+ definition,
+ componentProps,
+}: DashboardWidgetItemBodyProps): JSX.Element | null {
+ const catalogEntry = getDashboardWidgetCatalogEntry(widget.widget_type)
+ const WidgetComponent = definition?.Component
+ const hasProductAccess = userHasDashboardWidgetProductAccess(definition?.productAccess)
+
+ if (!hasProductAccess || !WidgetComponent) {
+ return null
+ }
+
+ return (
+ <WidgetRuntimeAvailabilityGuard
+ availability={catalogEntry.availability}
+ unavailableContentFallback={definition?.unavailableContentFallback}
+ >
+ <WidgetComponent {...componentProps} />
+ </WidgetRuntimeAvailabilityGuard>
+ )
+}
+
+function DashboardWidgetItemContent({
+ tile,
+ placement,
+ widget,
+ definition,
+ headerCatalogEntry,
+ isUnknownWidgetType,
+ result,
+ loading,
+ error,
+ lastFetchedAt,
+ onRefresh,
+ onUpdateWidgetTile,
+ toggleShowDescription,
+ onDragHandleMouseDown,
+ showEditingControls,
+ onDuplicate,
+ onRemove,
+ onMoveToDashboard,
+ onCopyToDashboard,
+ copyToDestinations,
+ editOpen,
+ setEditOpen,
+}: DashboardWidgetItemContentProps): JSX.Element {
+ const widgetTypeLabel = getDashboardWidgetGroupLabel(headerCatalogEntry.groupId)
+ const defaultTitle = headerCatalogEntry.headerTitle ?? widgetTypeLabel
+ const title = widget.name?.trim() || ''
+ const description = widget.description?.trim() || ''
+ const showDescription = tile.show_description !== false
+ const headerLayout = headerCatalogEntry.headerLayout
+
+ const hasProductAccess = userHasDashboardWidgetProductAccess(definition?.productAccess)
+
+ const titleHref =
+ hasProductAccess && placement !== DashboardPlacement.Public && headerCatalogEntry.titleHref
+ ? headerCatalogEntry.titleHref
+ : undefined
+
+ const componentProps: DashboardWidgetComponentProps = {
+ tileId: tile.id,
+ config: widget.config,
+ result,
+ loading,
+ error,
+ onRefresh,
+ onUpdateConfig: onUpdateWidgetTile
+ ? async (config) => {
+ await onUpdateWidgetTile({ config })
+ }
+ : undefined,
+ }
+
+ const EditModal = definition?.EditModal
+
+ const hasDashboardSectionActions =
+ !!(onMoveToDashboard || onCopyToDashboard || onRemove) ||
+ (showEditingControls && toggleShowDescription && !!description) ||
+ (showEditingControls && onUpdateWidgetTile && !showDescription && !description)
+
+ const refreshDisabledReason = loading ? 'Refreshing...' : undefined
+
+ return (
+ <>
+ <WidgetCardHeader
+ layout={headerLayout}
+ title={title}
+ defaultTitle={defaultTitle}
+ titleHref={titleHref}
+ widgetTypeLabel={widgetTypeLabel}
+ config={widget.config}
+ headerMeta={headerCatalogEntry.headerMeta}
+ description={description}
+ showDescription={showDescription}
+ loading={loading}
+ showEditingControls={showEditingControls}
+ shouldHideMoreButton={widgetCardShouldHideMoreButton(placement, showEditingControls)}
+ moreButtonOverlay={
+ <>
+ {titleHref && (
+ <LemonButton to={titleHref} fullWidth>
+ View
+ </LemonButton>
+ )}
+ {showEditingControls && EditModal && (
+ <LemonButton fullWidth data-attr="dashboard-widget-edit" onClick={() => setEditOpen(true)}>
+ Edit
+ </LemonButton>
+ )}
+ {onDuplicate && (
+ <LemonButton fullWidth onClick={onDuplicate}>
+ Duplicate
+ </LemonButton>
+ )}
+ {hasDashboardSectionActions && (
+ <>
+ <LemonDivider />
+ <h5 className="mx-2 my-1">Dashboard</h5>
+ {showEditingControls && onUpdateWidgetTile && !showDescription && !description && (
+ <LemonButton
+ fullWidth
+ onClick={() => {
+ toggleShowDescription?.()
+ setEditOpen(true)
+ }}
+ >
+ Add description
+ </LemonButton>
+ )}
+ {showEditingControls && toggleShowDescription && !!description && (
+ <LemonButton fullWidth onClick={toggleShowDescription}>
+ {tile.show_description === false ? 'Show description' : 'Hide description'}
+ </LemonButton>
+ )}
+ {(onMoveToDashboard || onCopyToDashboard) && (
+ <DashboardWidgetPlacementMenus
+ placementDestinations={copyToDestinations ?? []}
+ onMoveToDashboard={onMoveToDashboard}
+ onCopyToDashboard={onCopyToDashboard}
+ />
+ )}
+ {onRemove && (
+ <LemonButton status="danger" fullWidth onClick={onRemove}>
+ Remove from dashboard
+ </LemonButton>
+ )}
+ </>
+ )}
+ {onRefresh && headerLayout === 'dashboard_tile' && !isUnknownWidgetType && (
+ <>
+ <LemonDivider />
+ <DashboardTileRefreshDataButton
+ onRefresh={onRefresh}
+ disabledReason={refreshDisabledReason}
+ lastRefresh={lastFetchedAt}
+ />
+ </>
+ )}
+ </>
+ }
+ onDragHandleMouseDown={onDragHandleMouseDown}
+ />
+ <WidgetCardBody
+ locked={!hasProductAccess}
+ error={!isUnknownWidgetType && hasProductAccess ? error : undefined}
+ onRefresh={isUnknownWidgetType ? undefined : onRefresh}
+ refreshing={isUnknownWidgetType ? false : loading}
+ >
+ <ErrorBoundary
+ className="flex min-h-0 min-w-0 flex-1 w-full max-w-full flex-col"
+ exceptionProps={{
+ feature: 'dashboard_widget',
+ widget_type: widget.widget_type,
+ tile_id: tile.id,
+ }}
+ >
+ <DashboardWidgetItemBody widget={widget} definition={definition} componentProps={componentProps} />
+ </ErrorBoundary>
+ {EditModal &&
+ editOpen &&
+ createPortal(
+ <EditModal
+ isOpen={editOpen}
+ onClose={() => setEditOpen(false)}
+ config={widget.config}
+ name={title}
+ defaultTitle={defaultTitle}
+ description={description}
+ onSave={async (config, metadata) => {
+ await onUpdateWidgetTile?.({ config, ...metadata })
+ }}
+ />,
+ document.body
+ )}
+ </WidgetCardBody>
+ </>
+ )
+}
+
export const DashboardWidgetItem = React.forwardRef<HTMLDivElement, DashboardWidgetItemProps>(
function DashboardWidgetItem(
{
@@ -56,8 +289,7 @@ export const DashboardWidgetItem = React.forwardRef<HTMLDivElement, DashboardWid
error,
lastFetchedAt,
onRefresh,
- onUpdateConfig,
- onUpdateMetadata,
+ onUpdateWidgetTile,
toggleShowDescription,
showResizeHandles,
canEnterEditModeFromEdge,
@@ -95,66 +327,10 @@ export const DashboardWidgetItem = React.forwardRef<HTMLDivElement, DashboardWid
tileId: tile.id,
dashboardId: dashboardId ?? undefined,
})
- const catalogEntry = getDashboardWidgetCatalogEntry(widget.widget_type)
- const widgetTypeLabel = catalogEntry?.groupLabel ?? catalogEntry?.label ?? widget.widget_type
- const defaultTitle = catalogEntry?.headerTitle ?? widgetTypeLabel
- const title = widget.name?.trim() || ''
- const description = widget.description?.trim() || ''
- const showDescription = tile.show_description !== false
- const headerLayout = catalogEntry?.headerLayout ?? 'dashboard_tile'
- const WidgetComponent = definition?.Component
-
- const handleDescriptionSave = (nextDescription: string): void => {
- onUpdateMetadata?.({ description: nextDescription })
- if (nextDescription.trim() && tile.show_description === false && toggleShowDescription) {
- toggleShowDescription()
- }
- }
-
- const hasProductAccess = userHasDashboardWidgetProductAccess(definition?.productAccess)
-
- const titleHref =
- hasProductAccess && placement !== DashboardPlacement.Public && catalogEntry?.titleHref
- ? catalogEntry.titleHref
- : undefined
-
- const componentProps: DashboardWidgetComponentProps = {
- tileId: tile.id,
- config: widget.config,
- result,
- loading,
- error,
- onRefresh,
- onUpdateConfig,
- }
-
- const EditModal = definition?.EditModal
-
- const widgetBody =
- hasProductAccess && WidgetComponent ? (
- <ErrorBoundary
- className="flex min-h-0 min-w-0 flex-1 w-full max-w-full flex-col"
- exceptionProps={{
- feature: 'dashboard_widget',
- widget_type: widget.widget_type,
- tile_id: tile.id,
- }}
- >
- <WidgetRuntimeAvailabilityGuard
- availability={catalogEntry?.availability}
- unavailableContentFallback={definition?.unavailableContentFallback}
- >
- <WidgetComponent {...componentProps} />
- </WidgetRuntimeAvailabilityGuard>
- </ErrorBoundary>
- ) : null
-
- const hasDashboardSectionActions =
- !!(onMoveToDashboard || onCopyToDashboard || onRemove) ||
- (showEditingControls && toggleShowDescription && !!description) ||
- (showEditingControls && onUpdateMetadata && !showDescription && !description)
-
- const refreshDisabledReason = loading ? 'Refreshing...' : undefined
+ const catalogEntryOrUndefined = tryGetDashboardWidgetCatalogEntry(widget.widget_type)
+ const headerCatalogEntry =
+ catalogEntryOrUndefined ?? getUnknownDashboardWidgetCatalogFallback(widget.widget_type)
+ const isUnknownWidgetType = catalogEntryOrUndefined === undefined
// react-grid-layout injects className/style via cloneElement — WidgetCard must be the root node
// so decorative resize handles and RGL's .react-resizable-handle siblings share a parent (see InsightCard).
@@ -169,124 +345,30 @@ export const DashboardWidgetItem = React.forwardRef<HTMLDivElement, DashboardWid
onEnterEditModeFromEdge={onEnterEditModeFromEdge}
gridChildren={children}
>
- <WidgetCardHeader
- layout={headerLayout}
- title={title}
- defaultTitle={defaultTitle}
- titleHref={titleHref}
- widgetTypeLabel={widgetTypeLabel}
- config={widget.config}
- headerMeta={catalogEntry?.headerMeta}
- description={description}
- showDescription={showDescription}
+ <DashboardWidgetItemContent
+ tile={tile}
+ placement={placement}
+ widget={widget}
+ definition={definition}
+ headerCatalogEntry={headerCatalogEntry}
+ isUnknownWidgetType={isUnknownWidgetType}
+ result={result}
loading={loading}
- showEditingControls={showEditingControls}
- shouldHideMoreButton={widgetCardShouldHideMoreButton(placement, showEditingControls)}
- moreButtonOverlay={
- <>
- {titleHref && (
- <LemonButton to={titleHref} fullWidth>
- View
- </LemonButton>
- )}
- {showEditingControls && EditModal && (
- <LemonButton
- fullWidth
- data-attr="dashboard-widget-edit"
- onClick={() => setEditOpen(true)}
- >
- Edit
- </LemonButton>
- )}
- {onDuplicate && (
- <LemonButton fullWidth onClick={onDuplicate}>
- Duplicate
- </LemonButton>
- )}
- {hasDashboardSectionActions && (
- <>
- <LemonDivider />
- <h5 className="mx-2 my-1">Dashboard</h5>
- {showEditingControls && onUpdateMetadata && !showDescription && !description && (
- <LemonButton
- fullWidth
- onClick={() => {
- toggleShowDescription?.()
- setEditOpen(true)
- }}
- >
- Add description
- </LemonButton>
- )}
- {showEditingControls && toggleShowDescription && !!description && (
- <LemonButton fullWidth onClick={toggleShowDescription}>
- {tile.show_description === false ? 'Show description' : 'Hide description'}
- </LemonButton>
- )}
- {(onMoveToDashboard || onCopyToDashboard) && (
- <DashboardWidgetPlacementMenus
- placementDestinations={copyToDestinations ?? []}
- onMoveToDashboard={onMoveToDashboard}
- onCopyToDashboard={onCopyToDashboard}
- />
- )}
- {onRemove && (
- <LemonButton status="danger" fullWidth onClick={onRemove}>
- Remove from dashboard
- </LemonButton>
- )}
- </>
- )}
- {onRefresh && headerLayout === 'dashboard_tile' && (
- <>
- <LemonDivider />
- <DashboardTileRefreshDataButton
- onRefresh={onRefresh}
- disabledReason={refreshDisabledReason}
- lastRefresh={lastFetchedAt}
- />
- </>
- )}
- </>
- }
+ error={error}
+ lastFetchedAt={lastFetchedAt}
+ onRefresh={onRefresh}
+ onUpdateWidgetTile={onUpdateWidgetTile}
+ toggleShowDescription={toggleShowDescription}
onDragHandleMouseDown={onDragHandleMouseDown}
+ showEditingControls={showEditingControls}
+ onDuplicate={onDuplicate}
+ onRemove={onRemove}
+ onMoveToDashboard={onMoveToDashboard}
+ onCopyToDashboard={onCopyToDashboard}
+ copyToDestinations={copyToDestinations}
+ editOpen={editOpen}
+ setEditOpen={setEditOpen}
/>
- <WidgetCardBody
- locked={!hasProductAccess}
- error={hasProductAccess ? error : undefined}
- onRefresh={onRefresh}
- refreshing={loading}
- >
- {widgetBody}
- {EditModal &&
- editOpen &&
- createPortal(
- <EditModal
- isOpen={editOpen}
- onClose={() => setEditOpen(false)}
- config={widget.config}
- name={title}
- defaultTitle={defaultTitle}
- description={description}
- onSaveMetadata={
- onUpdateMetadata
- ? async (metadata) => {
- if (metadata.name !== undefined) {
- onUpdateMetadata({ name: metadata.name.trim() || '' })
- }
- if (metadata.description !== undefined) {
- handleDescriptionSave(metadata.description)
- }
- }
- : undefined
- }
- onSave={async (config) => {
- await onUpdateConfig(config)
- }}
- />,
- document.body
- )}
- </WidgetCardBody>
</WidgetCard>
)
}
diff --git a/products/dashboards/frontend/components/WidgetAvailabilitySetupPrompt/WidgetAvailabilitySetupPrompt.tsx b/products/dashboards/frontend/components/WidgetAvailabilitySetupPrompt/WidgetAvailabilitySetupPrompt.tsx
index ed2a39613fd1..937fe7718be1 100644
--- a/products/dashboards/frontend/components/WidgetAvailabilitySetupPrompt/WidgetAvailabilitySetupPrompt.tsx
+++ b/products/dashboards/frontend/components/WidgetAvailabilitySetupPrompt/WidgetAvailabilitySetupPrompt.tsx
@@ -19,6 +19,8 @@ export function WidgetAvailabilitySetupPrompt({
return (
<WidgetCardContent className={className}>
<WidgetCardProductIntroduction
+ stacked
+ className="border-none mb-0 mt-0 p-4"
productName={presentation.productName}
productKey={presentation.productKey}
thingName={presentation.thingName}
@@ -27,9 +29,11 @@ export function WidgetAvailabilitySetupPrompt({
isEmpty
docsURL={availability.docsHref}
actionElementOverride={
- <LemonButton type="primary" to={presentation.settingsUrl}>
- {availability.setupActionLabel}
- </LemonButton>
+ <div className="flex flex-col items-center gap-4">
+ <LemonButton type="primary" to={presentation.settingsUrl}>
+ {availability.setupActionLabel}
+ </LemonButton>
+ </div>
}
/>
</WidgetCardContent>
diff --git a/products/dashboards/frontend/components/WidgetCard/DashboardWidgetsOverview.stories.tsx b/products/dashboards/frontend/components/WidgetCard/DashboardWidgetsOverview.stories.tsx
new file mode 100644
index 000000000000..efb7e0b276b0
--- /dev/null
+++ b/products/dashboards/frontend/components/WidgetCard/DashboardWidgetsOverview.stories.tsx
@@ -0,0 +1,121 @@
+import type { Meta, StoryObj } from '@storybook/react'
+import React from 'react'
+
+import { DashboardPlacement } from '~/types'
+
+import {
+ DASHBOARD_WIDGET_CATALOG,
+ getDashboardWidgetCatalogEntry,
+ getDashboardWidgetGroupLabel,
+ type DashboardWidgetCatalogKey,
+} from '../../widget_types/catalog'
+import { getDashboardWidgetDefinition } from '../../widgets/registry'
+import { WidgetCard } from './WidgetCard'
+import { WidgetCardBody } from './WidgetCardBody'
+import { WidgetCardHeader, widgetCardShouldHideMoreButton } from './WidgetCardHeader'
+import { mockMoreOverlay, withErrorTrackingProjectState } from './widgetCardStoryFixtures'
+import { getWidgetOverviewDemoState } from './widgetOverviewStoryFixtures'
+
+// Dashboard grid row height — see DashboardItems BASE_ROW_HEIGHT.
+const DASHBOARD_ROW_HEIGHT_PX = 80
+// Overview tiles render taller than catalog defaultLayout.h so widget bodies have room at story scale.
+const OVERVIEW_TILE_HEIGHT_ROWS = 8
+const OVERVIEW_TILE_MIN_HEIGHT = OVERVIEW_TILE_HEIGHT_ROWS * DASHBOARD_ROW_HEIGHT_PX
+
+// Renders all catalog keys — add demo state per type in widgetOverviewStoryFixtures.ts (CONTRIBUTING.md).
+const dashboardWidgetCatalogKeys = Object.keys(DASHBOARD_WIDGET_CATALOG) as DashboardWidgetCatalogKey[]
+
+function DashboardWidgetOverviewTile({
+ catalogKey,
+ tileId,
+}: {
+ catalogKey: DashboardWidgetCatalogKey
+ tileId: number
+}): JSX.Element | null {
+ const catalogEntry = getDashboardWidgetCatalogEntry(catalogKey)
+ const definition = getDashboardWidgetDefinition(catalogKey)
+ const demoState = getWidgetOverviewDemoState(catalogKey)
+
+ if (!definition || !catalogEntry) {
+ return null
+ }
+
+ const WidgetComponent = definition.Component
+ const widgetTypeLabel = getDashboardWidgetGroupLabel(catalogEntry.groupId)
+ const defaultTitle = catalogEntry.headerTitle ?? catalogEntry.label
+
+ return (
+ <div
+ className="min-h-0 rounded border border-dashed border-border bg-bg-light p-4"
+ style={{ minHeight: OVERVIEW_TILE_MIN_HEIGHT }}
+ >
+ <WidgetCard className="h-full">
+ <WidgetCardHeader
+ layout={catalogEntry.headerLayout}
+ title={demoState.title ?? ''}
+ defaultTitle={defaultTitle}
+ titleHref={catalogEntry.titleHref}
+ widgetTypeLabel={widgetTypeLabel}
+ config={demoState.config}
+ headerMeta={catalogEntry.headerMeta}
+ description={demoState.description}
+ showDescription={demoState.showDescription ?? true}
+ loading={demoState.loading}
+ shouldHideMoreButton={widgetCardShouldHideMoreButton(DashboardPlacement.Dashboard, false)}
+ moreButtonOverlay={mockMoreOverlay}
+ />
+ <WidgetCardBody error={demoState.cardError}>
+ <WidgetComponent
+ tileId={tileId}
+ config={demoState.config}
+ loading={demoState.loading}
+ result={demoState.result}
+ onUpdateConfig={() => undefined}
+ onRefresh={() => undefined}
+ />
+ </WidgetCardBody>
+ </WidgetCard>
+ </div>
+ )
+}
+
+function DashboardWidgetsOverview(): JSX.Element {
+ return (
+ <div className="mx-auto w-full max-w-screen-2xl p-6">
+ <div className="grid grid-cols-1 gap-8 xl:grid-cols-2">
+ {dashboardWidgetCatalogKeys.map((catalogKey, index) => (
+ <DashboardWidgetOverviewTile key={catalogKey} catalogKey={catalogKey} tileId={index + 1} />
+ ))}
+ </div>
+ </div>
+ )
+}
+
+const dashboardOverviewFrameDecorator = [
+ (Story: React.ComponentType): JSX.Element => (
+ <div className="min-h-screen bg-bg-light">
+ <Story />
+ </div>
+ ),
+]
+
+const meta: Meta<typeof DashboardWidgetsOverview> = {
+ title: 'Dashboards/Dashboard Widgets/Overview',
+ component: DashboardWidgetsOverview,
+ parameters: {
+ layout: 'fullscreen',
+ docs: {
+ description: {
+ component:
+ 'All registered dashboard widget types at dashboard scale. New catalog entries appear here automatically.',
+ },
+ },
+ },
+ decorators: [withErrorTrackingProjectState(true), ...dashboardOverviewFrameDecorator],
+}
+
+export default meta
+
+type Story = StoryObj<typeof DashboardWidgetsOverview>
+
+export const AllWidgetTypes: Story = {}
diff --git a/products/dashboards/frontend/components/WidgetCard/WidgetCardBody.tsx b/products/dashboards/frontend/components/WidgetCard/WidgetCardBody.tsx
index e0717d68b379..2509ec8ae9fa 100644
--- a/products/dashboards/frontend/components/WidgetCard/WidgetCardBody.tsx
+++ b/products/dashboards/frontend/components/WidgetCard/WidgetCardBody.tsx
@@ -201,7 +201,7 @@ type WidgetCardContentProps = {
export function WidgetCardContent({ children, footer, className }: WidgetCardContentProps): JSX.Element {
return (
<div data-slot="widget-card-content" className={clsx('flex min-h-0 min-w-0 flex-1 flex-col gap-2', className)}>
- <div className="min-h-0 min-w-0 flex-1 overflow-auto">{children}</div>
+ <div className="min-h-0 min-w-0 flex-1 overflow-y-auto overflow-x-hidden">{children}</div>
{footer ? (
<div className="flex shrink-0 justify-center pt-0.5" data-slot="widget-card-content-footer">
{footer}
diff --git a/products/dashboards/frontend/components/WidgetCard/widgetCardStoryFixtures.tsx b/products/dashboards/frontend/components/WidgetCard/widgetCardStoryFixtures.tsx
index a74147a873ce..48f6b3eb1e98 100644
--- a/products/dashboards/frontend/components/WidgetCard/widgetCardStoryFixtures.tsx
+++ b/products/dashboards/frontend/components/WidgetCard/widgetCardStoryFixtures.tsx
@@ -1,8 +1,15 @@
+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
+
+import type { Decorator } from '@storybook/react'
import React from 'react'
import { CardTopHeadingRow } from 'lib/components/Cards/CardTopHeadingRow'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonMenuOverlay, type LemonMenuItems } from 'lib/lemon-ui/LemonMenu'
+import { filterTestAccountsDefaultsLogic } from 'scenes/settings/environment/filterTestAccountDefaultsLogic'
+import { teamLogic } from 'scenes/teamLogic'
+
+import { exceptionIngestionLogic } from 'products/error_tracking/frontend/components/SetupPrompt/exceptionIngestionLogic'
import { WidgetCardContent } from './WidgetCardBody'
@@ -71,3 +78,23 @@ export const sampleListBody = (
)
export const dashboardTileTopHeading = <CardTopHeadingRow typeLabel="Analytics" showTypeLabel dateText="Last 7 days" />
+
+export function seedErrorTrackingProjectState(configured: boolean): void {
+ teamLogic.mount()
+ filterTestAccountsDefaultsLogic.mount()
+ teamLogic.actions.loadCurrentTeamSuccess({
+ ...MOCK_DEFAULT_TEAM,
+ autocapture_exceptions_opt_in: configured,
+ })
+
+ exceptionIngestionLogic.mount()
+ exceptionIngestionLogic.actions.loadExceptionIngestionStateSuccess(configured)
+}
+
+/** Configured = issues can be queried (post setup). Unconfigured = ingestion prompt / settings hidden. */
+export function withErrorTrackingProjectState(configured: boolean): Decorator {
+ return (Story: React.ComponentType): JSX.Element => {
+ seedErrorTrackingProjectState(configured)
+ return <Story />
+ }
+}
diff --git a/products/dashboards/frontend/components/WidgetCard/widgetOverviewStoryFixtures.ts b/products/dashboards/frontend/components/WidgetCard/widgetOverviewStoryFixtures.ts
new file mode 100644
index 000000000000..d2a32ebf435d
--- /dev/null
+++ b/products/dashboards/frontend/components/WidgetCard/widgetOverviewStoryFixtures.ts
@@ -0,0 +1,94 @@
+import type { DashboardWidgetCatalogKey } from '../../widget_types/catalog'
+import { DASHBOARD_WIDGET_CATALOG } from '../../widget_types/catalog'
+
+export type WidgetOverviewDemoState = {
+ title?: string
+ description?: string
+ showDescription?: boolean
+ config: Record<string, unknown>
+ loading: boolean
+ result: unknown
+ cardError?: string | null
+}
+
+export const errorTrackingSampleIssues = [
+ {
+ id: 'issue-1',
+ name: 'TypeError: Cannot read properties of undefined',
+ description: 'User profile settings fail to load when the session cache is empty.',
+ function: 'loadProfile',
+ source: 'https://app.example.test/static/js/settings.js',
+ library: 'web',
+ status: 'active',
+ assignee: null,
+ first_seen: '2026-05-01T10:00:00.000Z',
+ last_seen: '2026-05-26T08:00:00.000Z',
+ aggregations: {
+ occurrences: 42,
+ sessions: 18,
+ users: 12,
+ volume_buckets: [
+ { label: '2026-05-20T00:00:00.000Z', value: 2 },
+ { label: '2026-05-21T00:00:00.000Z', value: 4 },
+ { label: '2026-05-22T00:00:00.000Z', value: 8 },
+ { label: '2026-05-23T00:00:00.000Z', value: 12 },
+ { label: '2026-05-24T00:00:00.000Z', value: 6 },
+ { label: '2026-05-25T00:00:00.000Z', value: 5 },
+ { label: '2026-05-26T00:00:00.000Z', value: 5 },
+ ],
+ },
+ },
+ {
+ id: 'issue-2',
+ name: 'NetworkError: Failed to fetch',
+ description: 'Checkout requests fail when the payment API is unavailable.',
+ function: 'fetch',
+ source: 'https://app.example.test/static/js/api.js',
+ library: 'web',
+ status: 'pending_release',
+ assignee: null,
+ first_seen: '2026-05-10T10:00:00.000Z',
+ last_seen: '2026-05-25T12:00:00.000Z',
+ aggregations: {
+ occurrences: 18,
+ sessions: 9,
+ users: 7,
+ volume_buckets: [
+ { label: '2026-05-20T00:00:00.000Z', value: 1 },
+ { label: '2026-05-21T00:00:00.000Z', value: 2 },
+ { label: '2026-05-22T00:00:00.000Z', value: 3 },
+ { label: '2026-05-23T00:00:00.000Z', value: 2 },
+ { label: '2026-05-24T00:00:00.000Z', value: 4 },
+ { label: '2026-05-25T00:00:00.000Z', value: 3 },
+ { label: '2026-05-26T00:00:00.000Z', value: 3 },
+ ],
+ },
+ },
+]
+
+/** New widget types: add a case here. See products/dashboards/CONTRIBUTING.md. */
+export function getWidgetOverviewDemoState(catalogKey: DashboardWidgetCatalogKey): WidgetOverviewDemoState {
+ const catalogEntry = DASHBOARD_WIDGET_CATALOG[catalogKey]
+ const defaultConfig = catalogEntry.defaultConfig as Record<string, unknown>
+ const defaultTitle = catalogEntry.headerTitle ?? catalogEntry.label
+
+ switch (catalogKey) {
+ case 'error_tracking_list':
+ return {
+ title: defaultTitle,
+ description: catalogEntry.description,
+ showDescription: true,
+ config: { ...defaultConfig, orderBy: 'occurrences' },
+ loading: false,
+ result: {
+ results: errorTrackingSampleIssues,
+ hasMore: true,
+ limit: 10,
+ },
+ }
+ default: {
+ const exhaustiveCheck: never = catalogKey
+ return exhaustiveCheck
+ }
+ }
+}
diff --git a/products/dashboards/frontend/components/WidgetCardProductIntroduction/WidgetCardProductIntroduction.scss b/products/dashboards/frontend/components/WidgetCardProductIntroduction/WidgetCardProductIntroduction.scss
index b220cb77e60d..942e24c74fb1 100644
--- a/products/dashboards/frontend/components/WidgetCardProductIntroduction/WidgetCardProductIntroduction.scss
+++ b/products/dashboards/frontend/components/WidgetCardProductIntroduction/WidgetCardProductIntroduction.scss
@@ -46,4 +46,19 @@
gap: 2rem;
}
}
+
+ // Dashboard widget setup prompts: stay stacked even in wide tiles.
+ &--stacked {
+ [data-attr^='product-introduction'] > div {
+ flex-direction: column !important;
+
+ @container widget-card (min-width: 36rem) {
+ flex-direction: column !important;
+ }
+ }
+
+ .flex.flex-wrap.gap-2 {
+ justify-content: center;
+ }
+ }
}
diff --git a/products/dashboards/frontend/components/WidgetCardProductIntroduction/WidgetCardProductIntroduction.tsx b/products/dashboards/frontend/components/WidgetCardProductIntroduction/WidgetCardProductIntroduction.tsx
index 3ea80b532270..8672f2fbd08e 100644
--- a/products/dashboards/frontend/components/WidgetCardProductIntroduction/WidgetCardProductIntroduction.tsx
+++ b/products/dashboards/frontend/components/WidgetCardProductIntroduction/WidgetCardProductIntroduction.tsx
@@ -6,7 +6,13 @@ import {
} from 'lib/components/ProductIntroduction/ProductIntroduction'
import { cn } from 'lib/utils/css-classes'
-type WidgetCardProductIntroductionProps = Omit<ProductIntroductionProps, 'hogLayout' | 'useMainContentContainerQueries'>
+type WidgetCardProductIntroductionProps = Omit<
+ ProductIntroductionProps,
+ 'hogLayout' | 'useMainContentContainerQueries'
+> & {
+ /** Hog above copy at all tile widths (disables responsive side-by-side layout). */
+ stacked?: boolean
+}
/**
* ProductIntroduction tuned for dashboard widget tiles. WidgetCardBody defines
@@ -16,14 +22,23 @@ type WidgetCardProductIntroductionProps = Omit<ProductIntroductionProps, 'hogLay
export function WidgetCardProductIntroduction({
className,
contentClassName,
+ stacked,
...props
}: WidgetCardProductIntroductionProps): JSX.Element | null {
+ const isStacked = stacked ?? className?.includes('WidgetCardProductIntroduction--stacked')
+
return (
- <div className={cn('WidgetCardProductIntroduction', className)}>
+ <div
+ className={cn(
+ 'WidgetCardProductIntroduction',
+ isStacked && 'WidgetCardProductIntroduction--stacked',
+ className
+ )}
+ >
<ProductIntroduction
{...props}
contentClassName={cn('max-w-none', contentClassName)}
- hogLayout="responsive"
+ hogLayout={isStacked ? 'vertical' : 'responsive'}
/>
</div>
)
diff --git a/products/dashboards/frontend/utils.ts b/products/dashboards/frontend/utils.ts
index f03140d9f8d4..592fbc558188 100644
--- a/products/dashboards/frontend/utils.ts
+++ b/products/dashboards/frontend/utils.ts
@@ -2,6 +2,7 @@ import type { DashboardTile, QueryBasedInsightModel } from '~/types'
import { dashboardsPartialUpdate } from './generated/api'
import type { PatchedDashboardApi } from './generated/api.schemas'
+import { parseDashboardWidgetConfigApiError } from './widgets/registry'
export type WidgetFieldErrors = Record<string, string | undefined>
@@ -26,6 +27,7 @@ export async function updateDashboardWidgetTile({
config,
name,
description,
+ showDescription,
}: {
teamId: number
dashboardId: number
@@ -33,6 +35,7 @@ export async function updateDashboardWidgetTile({
config?: Record<string, unknown>
name?: string | null
description?: string
+ showDescription?: boolean
}): Promise<DashboardTile<QueryBasedInsightModel>> {
if (!tile.widget) {
throw new Error('Tile has no widget')
@@ -49,20 +52,35 @@ export async function updateDashboardWidgetTile({
widgetPatch.description = description
}
- const dashboard = await dashboardsPartialUpdate(String(teamId), dashboardId, {
- tiles: [
- {
- id: tile.id,
- widget: {
- id: tile.widget.id,
- ...widgetPatch,
- },
- },
- ],
- } as PatchedDashboardApi)
- const updatedTile = dashboard.tiles?.find((existingTile) => existingTile.id === tile.id)
- if (!updatedTile) {
- throw new Error('Updated tile not found in dashboard response')
+ const tilePatch: Record<string, unknown> = {
+ id: tile.id,
+ }
+ if (showDescription !== undefined) {
+ tilePatch.show_description = showDescription
+ }
+ if (Object.keys(widgetPatch).length > 0) {
+ tilePatch.widget = {
+ id: tile.widget.id,
+ ...widgetPatch,
+ }
+ }
+
+ try {
+ const dashboard = await dashboardsPartialUpdate(String(teamId), dashboardId, {
+ tiles: [tilePatch],
+ } as PatchedDashboardApi)
+ const updatedTile = dashboard.tiles?.find((existingTile) => existingTile.id === tile.id)
+ if (!updatedTile) {
+ throw new Error('Updated tile not found in dashboard response')
+ }
+ return updatedTile as unknown as DashboardTile<QueryBasedInsightModel>
+ } catch (error) {
+ if (config !== undefined) {
+ const fieldErrors = parseDashboardWidgetConfigApiError(tile.widget.widget_type, error, config)
+ if (fieldErrors && Object.keys(fieldErrors).length > 0) {
+ throw new WidgetConfigValidationError(fieldErrors)
+ }
+ }
+ throw error
}
- return updatedTile as unknown as DashboardTile<QueryBasedInsightModel>
}
diff --git a/products/dashboards/frontend/widget_types/catalog.ts b/products/dashboards/frontend/widget_types/catalog.ts
index e25ea1be539c..516402df58ca 100644
--- a/products/dashboards/frontend/widget_types/catalog.ts
+++ b/products/dashboards/frontend/widget_types/catalog.ts
@@ -1,4 +1,8 @@
+import { urls } from 'scenes/urls'
+
import type { DashboardWidgetProductAccess } from '../types'
+import { ErrorTrackingWidgetPreview } from '../widgets/previews/ErrorTrackingWidgetPreview'
+import { errorTrackingWidgetConfigSchema } from './configSchemas'
import type { WidgetAvailabilityConfig } from './widgetAvailability'
export const DASHBOARD_WIDGET_HEADER_LAYOUTS = ['simple', 'dashboard_tile'] as const
@@ -6,24 +10,38 @@ export const DASHBOARD_WIDGET_HEADER_LAYOUTS = ['simple', 'dashboard_tile'] as c
export type DashboardWidgetHeaderLayout = (typeof DASHBOARD_WIDGET_HEADER_LAYOUTS)[number]
export type DashboardWidgetHeaderMeta = {
- /** Show the widget type label in the compact top heading row (e.g. "Error tracking"). */
+ /** Show the widget type label in the compact top heading row (e.g. "Error tracking"). Defaults to true. */
showWidgetType?: boolean
- /** Show the configured date range in the compact top heading row (e.g. "Last 7 days"). */
+ /** Show the configured date range in the compact top heading row (e.g. "Last 7 days"). Defaults to true. */
showDateRange?: boolean
}
+export const DEFAULT_DASHBOARD_WIDGET_HEADER_LAYOUT = 'dashboard_tile' satisfies DashboardWidgetHeaderLayout
+
+export const DEFAULT_DASHBOARD_WIDGET_HEADER_META = {
+ showWidgetType: true,
+ showDateRange: true,
+} satisfies DashboardWidgetHeaderMeta
+
+/** Product area labels keyed by catalog `groupId`. New groups: add here. */
+export const DASHBOARD_WIDGET_GROUP_LABELS = {
+ error_tracking: 'Error tracking',
+} as const satisfies Record<string, string>
+
+export function getDashboardWidgetGroupLabel(groupId: string): string {
+ return DASHBOARD_WIDGET_GROUP_LABELS[groupId as keyof typeof DASHBOARD_WIDGET_GROUP_LABELS] ?? groupId
+}
+
export type DashboardWidgetCatalogEntry = {
/** Stable key for grouping widgets from the same product area. */
- groupId: string
- /** Product area label shown as a section heading in the add-widget modal. */
- groupLabel: string
+ groupId: keyof typeof DASHBOARD_WIDGET_GROUP_LABELS | (string & {})
/** Widget variant label within the group (also used as fallback card title). */
label: string
description: string
defaultConfig: Record<string, unknown>
defaultLayout: { w: number; h: number; minW: number; minH?: number }
productAccess?: DashboardWidgetProductAccess
- headerLayout: DashboardWidgetHeaderLayout
+ headerLayout?: DashboardWidgetHeaderLayout
headerMeta?: DashboardWidgetHeaderMeta
/** Title shown in the card header (defaults to `label`). */
headerTitle?: string
@@ -34,25 +52,68 @@ export type DashboardWidgetCatalogEntry = {
}
/** New widget types: add here. See products/dashboards/CONTRIBUTING.md. */
-export const DASHBOARD_WIDGET_CATALOG: Record<string, DashboardWidgetCatalogEntry> = {}
+export const DASHBOARD_WIDGET_CATALOG = {
+ error_tracking_list: {
+ groupId: 'error_tracking',
+ label: 'Top issues',
+ description: 'Ranked list of the most impactful error tracking issues.',
+ headerTitle: 'Top issues',
+ defaultConfig: errorTrackingWidgetConfigSchema.parse({
+ dateRange: { date_from: '-7d' },
+ }),
+ defaultLayout: { w: 6, h: 5, minW: 6, minH: 3 },
+ productAccess: 'error_tracking',
+ titleHref: urls.errorTracking(),
+ },
+} as const satisfies Record<string, DashboardWidgetCatalogEntry>
+
+export type DashboardWidgetCatalogKey = keyof typeof DASHBOARD_WIDGET_CATALOG
+
+/** New widget types: add preview components here. See products/dashboards/CONTRIBUTING.md. */
+export const DASHBOARD_WIDGET_PREVIEWS: Record<DashboardWidgetCatalogKey, () => JSX.Element> = {
+ error_tracking_list: ErrorTrackingWidgetPreview,
+}
-export type DashboardWidgetCatalogKey = string
+export type ResolvedDashboardWidgetCatalogEntry = DashboardWidgetCatalogEntry & {
+ headerLayout: DashboardWidgetHeaderLayout
+ headerMeta: Required<DashboardWidgetHeaderMeta>
+}
-/** New widget_type aliases: add here. See products/dashboards/CONTRIBUTING.md. */
-export const DASHBOARD_WIDGET_TYPE_ALIASES: Partial<Record<string, DashboardWidgetCatalogKey>> = {}
+function resolveDashboardWidgetCatalogEntry(entry: DashboardWidgetCatalogEntry): ResolvedDashboardWidgetCatalogEntry {
+ return {
+ ...entry,
+ headerLayout: entry.headerLayout ?? DEFAULT_DASHBOARD_WIDGET_HEADER_LAYOUT,
+ headerMeta: { ...DEFAULT_DASHBOARD_WIDGET_HEADER_META, ...entry.headerMeta },
+ }
+}
-/** New widget types: add preview components here. See products/dashboards/CONTRIBUTING.md. */
-export const DASHBOARD_WIDGET_PREVIEWS: Partial<Record<DashboardWidgetCatalogKey, () => JSX.Element>> = {}
+export function getDashboardWidgetCatalogEntry(widgetType: string): ResolvedDashboardWidgetCatalogEntry {
+ if (!(widgetType in DASHBOARD_WIDGET_CATALOG)) {
+ throw new Error(`Unknown dashboard widget type: ${widgetType}`)
+ }
+
+ return resolveDashboardWidgetCatalogEntry(DASHBOARD_WIDGET_CATALOG[widgetType as DashboardWidgetCatalogKey])
+}
-export function resolveDashboardWidgetCatalogKey(widgetType: string): DashboardWidgetCatalogKey | undefined {
- if (widgetType in DASHBOARD_WIDGET_CATALOG) {
- return widgetType
+export function tryGetDashboardWidgetCatalogEntry(widgetType: string): ResolvedDashboardWidgetCatalogEntry | undefined {
+ if (!(widgetType in DASHBOARD_WIDGET_CATALOG)) {
+ return undefined
}
- return DASHBOARD_WIDGET_TYPE_ALIASES[widgetType]
+
+ return resolveDashboardWidgetCatalogEntry(DASHBOARD_WIDGET_CATALOG[widgetType as DashboardWidgetCatalogKey])
}
-export function getDashboardWidgetCatalogEntry(widgetType: string): DashboardWidgetCatalogEntry | undefined {
- return DASHBOARD_WIDGET_CATALOG[widgetType]
+export function getUnknownDashboardWidgetCatalogFallback(widgetType: string): ResolvedDashboardWidgetCatalogEntry {
+ return {
+ groupId: widgetType,
+ label: widgetType,
+ description: '',
+ defaultConfig: {},
+ defaultLayout: { w: 6, h: 5, minW: 6 },
+ headerTitle: widgetType,
+ headerLayout: DEFAULT_DASHBOARD_WIDGET_HEADER_LAYOUT,
+ headerMeta: DEFAULT_DASHBOARD_WIDGET_HEADER_META,
+ }
}
export type DashboardWidgetCatalogGroup = {
@@ -72,12 +133,16 @@ function getDashboardWidgetCatalogGroups(): DashboardWidgetCatalogGroup[] {
let group = groupsById.get(entry.groupId)
if (!group) {
- group = { groupId: entry.groupId, groupLabel: entry.groupLabel, widgets: [] }
+ group = {
+ groupId: entry.groupId,
+ groupLabel: getDashboardWidgetGroupLabel(entry.groupId),
+ widgets: [],
+ }
groupsById.set(entry.groupId, group)
groupOrder.push(entry.groupId)
}
- group.widgets.push({ widgetType, entry })
+ group.widgets.push({ widgetType: widgetType as DashboardWidgetCatalogKey, entry })
}
return groupOrder.map((groupId) => groupsById.get(groupId)!)
diff --git a/products/dashboards/frontend/widget_types/configSchemas.ts b/products/dashboards/frontend/widget_types/configSchemas.ts
index 927ae4d611f0..73e72bae6430 100644
--- a/products/dashboards/frontend/widget_types/configSchemas.ts
+++ b/products/dashboards/frontend/widget_types/configSchemas.ts
@@ -54,4 +54,30 @@ const widgetDateRangeObjectSchema = z
export const widgetDateRangeSchema = widgetDateRangeObjectSchema.optional()
+/** Shared limit field for list-style dashboard widgets (1–25 rows). */
+export const widgetLimitFieldSchema = z
+ .number({ error: 'Must be an integer between 1 and 25.' })
+ .int('Must be an integer between 1 and 25.')
+ .min(1, 'Must be an integer between 1 and 25.')
+ .max(25, 'Must be an integer between 1 and 25.')
+
+export const widgetOrderDirectionSchema = z.enum(['ASC', 'DESC']).default('DESC')
+
// New widget types: add per-type schemas here — CONTRIBUTING.md
+export const errorTrackingWidgetConfigSchema = baseWidgetConfigSchema.extend({
+ limit: widgetLimitFieldSchema.default(10),
+ orderBy: z.enum(['last_seen', 'first_seen', 'occurrences', 'users', 'sessions']).default('occurrences'),
+ orderDirection: widgetOrderDirectionSchema,
+ status: z.enum(['archived', 'active', 'resolved', 'pending_release', 'suppressed', 'all']).default('active'),
+ dateRange: widgetDateRangeSchema,
+})
+
+export type ErrorTrackingWidgetConfig = z.infer<typeof errorTrackingWidgetConfigSchema>
+
+/** Form fields edited in the error tracking widget settings modal. */
+export const errorTrackingWidgetFormSchema = z.object({
+ limit: widgetLimitFieldSchema,
+ orderBy: errorTrackingWidgetConfigSchema.shape.orderBy,
+ dateFrom: widgetDateFromSchema,
+ filterTestAccounts: z.boolean(),
+})
diff --git a/products/dashboards/frontend/widgets/AddWidgetModal.test.tsx b/products/dashboards/frontend/widgets/AddWidgetModal.test.tsx
new file mode 100644
index 000000000000..89e579dad9e9
--- /dev/null
+++ b/products/dashboards/frontend/widgets/AddWidgetModal.test.tsx
@@ -0,0 +1,116 @@
+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
+
+import '@testing-library/jest-dom'
+
+import { cleanup, render, screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { BindLogic } from 'kea'
+
+import { dashboardLogic } from 'scenes/dashboard/dashboardLogic'
+
+import { initKeaTests } from '~/test/init'
+import { AccessControlLevel, DashboardType, QueryBasedInsightModel } from '~/types'
+
+import { AddWidgetModal } from './AddWidgetModal'
+
+type AddWidgetModalProps = React.ComponentProps<typeof AddWidgetModal>
+
+jest.mock('../widget_types/catalog', () => ({
+ ...jest.requireActual('../widget_types/catalog'),
+ DASHBOARD_WIDGET_PREVIEWS: {
+ error_tracking_list: () => <div data-attr="error-tracking-preview">Preview</div>,
+ },
+}))
+
+const MOCK_DASHBOARD: DashboardType<QueryBasedInsightModel> = {
+ id: 5,
+ name: 'Test Dashboard',
+ description: 'A test dashboard',
+ pinned: false,
+ tiles: [],
+ tags: [],
+ created_at: '2020-01-01T00:00:00Z',
+ created_by: {
+ id: 1,
+ first_name: 'Test',
+ last_name: 'User',
+ email: '[email protected]',
+ uuid: 'abc',
+ distinct_id: 'test-distinct-id',
+ },
+ last_accessed_at: '2020-01-01T00:00:00Z',
+ is_shared: false,
+ deleted: false,
+ creation_mode: 'default',
+ user_access_level: AccessControlLevel.Editor,
+ filters: {},
+ variables: {},
+}
+
+function renderAddWidgetModal(props: Partial<AddWidgetModalProps> = {}): ReturnType<typeof dashboardLogic.build> {
+ const logic = dashboardLogic({ id: MOCK_DASHBOARD.id, dashboard: MOCK_DASHBOARD })
+ logic.mount()
+
+ render(
+ <BindLogic logic={dashboardLogic} props={{ id: MOCK_DASHBOARD.id, dashboard: MOCK_DASHBOARD }}>
+ <AddWidgetModal isOpen onClose={jest.fn()} onAdd={jest.fn()} {...props} />
+ </BindLogic>
+ )
+
+ return logic
+}
+
+describe('AddWidgetModal', () => {
+ beforeEach(() => {
+ initKeaTests(true, { ...MOCK_DEFAULT_TEAM, autocapture_exceptions_opt_in: false })
+ })
+
+ afterEach(() => {
+ cleanup()
+ })
+
+ it('renders grouped widget options with section headings', () => {
+ renderAddWidgetModal()
+
+ expect(
+ screen.getByText(/Bring context from your different PostHog products into one dashboard/i)
+ ).toBeInTheDocument()
+ expect(screen.getByRole('heading', { name: 'Error tracking' })).toBeInTheDocument()
+ expect(screen.getByRole('checkbox', { name: 'Top issues' })).toBeInTheDocument()
+ expect(screen.getByText(/Ranked list of the most impactful error tracking issues/i)).toBeInTheDocument()
+ })
+
+ it('allows multi-select checkbox behavior within grouped layout', async () => {
+ renderAddWidgetModal()
+
+ const topIssuesCard = screen.getByRole('checkbox', { name: 'Top issues' })
+
+ expect(topIssuesCard).toHaveAttribute('aria-checked', 'false')
+
+ await userEvent.click(topIssuesCard)
+ expect(topIssuesCard).toHaveAttribute('aria-checked', 'true')
+
+ await userEvent.click(topIssuesCard)
+ expect(topIssuesCard).toHaveAttribute('aria-checked', 'false')
+ })
+
+ it('submits all selected widget types', async () => {
+ const onAdd = jest.fn().mockResolvedValue(undefined)
+ const onClose = jest.fn()
+
+ renderAddWidgetModal({ onAdd, onClose })
+
+ await userEvent.click(screen.getByRole('checkbox', { name: 'Top issues' }))
+ await userEvent.click(screen.getByRole('button', { name: 'Add widget' }))
+
+ expect(onAdd).toHaveBeenCalledWith([expect.objectContaining({ widgetType: 'error_tracking_list' })])
+ expect(onClose).toHaveBeenCalled()
+ })
+
+ it('still shows previews when exception autocapture is disabled', () => {
+ renderAddWidgetModal()
+
+ expect(screen.getByTestId('error-tracking-preview')).toBeInTheDocument()
+ expect(screen.queryByText("You haven't captured any exceptions")).not.toBeInTheDocument()
+ })
+})
diff --git a/products/dashboards/frontend/widgets/EditWidgetModalFiltersSection.tsx b/products/dashboards/frontend/widgets/EditWidgetModalFiltersSection.tsx
new file mode 100644
index 000000000000..297df91e5bee
--- /dev/null
+++ b/products/dashboards/frontend/widgets/EditWidgetModalFiltersSection.tsx
@@ -0,0 +1,29 @@
+import { TestAccountFilter } from 'scenes/insights/filters/TestAccountFilter'
+
+type EditWidgetModalFiltersSectionProps = {
+ filterTestAccounts: boolean
+ saving: boolean
+ setFilterTestAccounts: (value: boolean) => void
+}
+
+export function EditWidgetModalFiltersSection({
+ filterTestAccounts,
+ saving,
+ setFilterTestAccounts,
+}: EditWidgetModalFiltersSectionProps): JSX.Element {
+ return (
+ <section className="flex flex-col gap-3">
+ <h5 className="text-sm font-semibold m-0">Filters</h5>
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
+ <div className="sm:col-span-2">
+ <TestAccountFilter
+ size="small"
+ filters={{ filter_test_accounts: filterTestAccounts }}
+ onChange={({ filter_test_accounts }) => setFilterTestAccounts(filter_test_accounts ?? false)}
+ disabledReason={saving ? 'Saving…' : undefined}
+ />
+ </div>
+ </div>
+ </section>
+ )
+}
diff --git a/products/dashboards/frontend/widgets/EditWidgetModalTileDetailsSection.tsx b/products/dashboards/frontend/widgets/EditWidgetModalTileDetailsSection.tsx
new file mode 100644
index 000000000000..fb0e6a03a42d
--- /dev/null
+++ b/products/dashboards/frontend/widgets/EditWidgetModalTileDetailsSection.tsx
@@ -0,0 +1,56 @@
+import { LemonTextArea } from '@posthog/lemon-ui'
+
+import { LemonField } from 'lib/lemon-ui/LemonField/LemonField'
+import { LemonInput } from 'lib/lemon-ui/LemonInput/LemonInput'
+
+type EditWidgetModalTileDetailsSectionProps = {
+ tileName: string
+ tileDescription: string
+ defaultTitle: string
+ saving: boolean
+ setTileName: (value: string) => void
+ setTileDescription: (value: string) => void
+}
+
+export function EditWidgetModalTileDetailsSection({
+ tileName,
+ tileDescription,
+ defaultTitle,
+ saving,
+ setTileName,
+ setTileDescription,
+}: EditWidgetModalTileDetailsSectionProps): JSX.Element {
+ return (
+ <section className="flex flex-col gap-3">
+ <h5 className="text-sm font-semibold m-0">Tile details</h5>
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
+ <LemonField.Pure
+ className="sm:col-span-2"
+ label="Title"
+ help="Shown on the tile. Leave empty to use the default title."
+ >
+ <LemonInput
+ value={tileName}
+ onChange={setTileName}
+ placeholder={defaultTitle}
+ maxLength={400}
+ disabled={saving}
+ />
+ </LemonField.Pure>
+ <LemonField.Pure
+ className="sm:col-span-2"
+ label="Description"
+ help="Shown under the tile title. Supports markdown. Leave empty to hide."
+ >
+ <LemonTextArea
+ value={tileDescription}
+ onChange={setTileDescription}
+ placeholder="Enter description (optional)"
+ minRows={2}
+ disabled={saving}
+ />
+ </LemonField.Pure>
+ </div>
+ </section>
+ )
+}
diff --git a/products/dashboards/frontend/widgets/editWidgetModalBuilders.ts b/products/dashboards/frontend/widgets/editWidgetModalBuilders.ts
new file mode 100644
index 000000000000..42a830d7718d
--- /dev/null
+++ b/products/dashboards/frontend/widgets/editWidgetModalBuilders.ts
@@ -0,0 +1,121 @@
+type ValidationResult = { success: true } | { success: false; fieldErrors: Record<string, string> }
+
+export const widgetEditModalTileActions = {
+ setTileName: (tileName: string) => ({ tileName }),
+ setTileDescription: (tileDescription: string) => ({ tileDescription }),
+}
+
+export const widgetEditModalTileReducers = {
+ tileName: [
+ '',
+ {
+ setTileName: (_: string, { tileName }: { tileName: string }) => tileName,
+ },
+ ],
+ tileDescription: [
+ '',
+ {
+ setTileDescription: (_: string, { tileDescription }: { tileDescription: string }) => tileDescription,
+ },
+ ],
+}
+
+export const widgetEditModalListFieldActions = {
+ setLimit: (limit: number) => ({ limit }),
+ setDateFrom: (dateFrom: string) => ({ dateFrom }),
+}
+
+export const widgetEditModalListFieldReducers = {
+ limit: [
+ 10,
+ {
+ setLimit: (_: number, { limit }: { limit: number }) => limit,
+ },
+ ],
+ dateFrom: [
+ '-7d',
+ {
+ setDateFrom: (_: string, { dateFrom }: { dateFrom: string }) => dateFrom,
+ },
+ ],
+}
+
+export const widgetEditModalFilterTestAccountsActions = {
+ setFilterTestAccounts: (filterTestAccounts: boolean) => ({ filterTestAccounts }),
+}
+
+export const widgetEditModalFilterTestAccountsReducers = {
+ filterTestAccounts: [
+ false,
+ {
+ setFilterTestAccounts: (_: boolean, { filterTestAccounts }: { filterTestAccounts: boolean }) =>
+ filterTestAccounts,
+ },
+ ],
+}
+
+export const widgetEditModalFieldErrorsActions = {
+ setFieldErrors: (fieldErrors: Record<string, string>) => ({ fieldErrors }),
+ clearFieldError: (field: string) => ({ field }),
+}
+
+export const widgetEditModalFieldErrorsReducers = {
+ fieldErrors: [
+ {} as Record<string, string>,
+ {
+ setFieldErrors: (_: Record<string, string>, { fieldErrors }: { fieldErrors: Record<string, string> }) =>
+ fieldErrors,
+ clearFieldError: (state: Record<string, string>, { field }: { field: string }) => {
+ if (!state[field]) {
+ return state
+ }
+ const next = { ...state }
+ delete next[field]
+ return next
+ },
+ },
+ ],
+}
+
+export const widgetEditModalSavingReducers = {
+ saving: [
+ false,
+ {
+ submit: (_state: boolean, _payload: { value: true }) => true,
+ submitSuccess: (_state: boolean, _payload: { value: true }) => false,
+ submitFailure: (_state: boolean, _payload: { value: true }) => false,
+ },
+ ],
+}
+
+export const widgetEditModalPropSelectors = {
+ onClose: [(_: unknown, p: { onClose: () => void }) => [p.onClose], (onClose: () => void) => onClose],
+ defaultTitle: [
+ (_: unknown, p: { defaultTitle?: string }) => [p.defaultTitle],
+ (defaultTitle?: string) => defaultTitle ?? 'Untitled',
+ ],
+}
+
+export const widgetEditModalValidationSelectors = {
+ activeFieldErrors: [
+ (s: { validation: ValidationResult; fieldErrors: Record<string, string> }) => [s.validation, s.fieldErrors],
+ (validation: ValidationResult, fieldErrors: Record<string, string>): Record<string, string> => {
+ if (!validation.success) {
+ return { ...validation.fieldErrors, ...fieldErrors }
+ }
+ return fieldErrors
+ },
+ ],
+ saveDisabledReason: [
+ (s: { saving: boolean; validation: ValidationResult }) => [s.saving, s.validation],
+ (saving: boolean, validation: ValidationResult): string | undefined => {
+ if (saving) {
+ return 'Saving…'
+ }
+ if (!validation.success) {
+ return 'Fix validation errors to save'
+ }
+ return undefined
+ },
+ ],
+}
diff --git a/products/dashboards/frontend/widgets/editWidgetModalTileUtils.test.ts b/products/dashboards/frontend/widgets/editWidgetModalTileUtils.test.ts
new file mode 100644
index 000000000000..e2204453956c
--- /dev/null
+++ b/products/dashboards/frontend/widgets/editWidgetModalTileUtils.test.ts
@@ -0,0 +1,37 @@
+import { buildWidgetTileMetadataPatch, getWidgetEditModalTileDefaults } from './editWidgetModalTileUtils'
+
+describe('editWidgetModalTileUtils', () => {
+ it('getWidgetEditModalTileDefaults returns empty strings when metadata is missing', () => {
+ expect(getWidgetEditModalTileDefaults({})).toEqual({
+ tileName: '',
+ tileDescription: '',
+ })
+ })
+
+ it('buildWidgetTileMetadataPatch batches name and description changes', () => {
+ expect(
+ buildWidgetTileMetadataPatch(
+ { name: 'Old', description: 'Old desc', defaultTitle: 'Top issues' },
+ 'New title',
+ 'New desc'
+ )
+ ).toEqual({ name: 'New title', description: 'New desc' })
+ })
+
+ it('buildWidgetTileMetadataPatch returns empty object when nothing changed', () => {
+ expect(
+ buildWidgetTileMetadataPatch(
+ { name: 'Same', description: 'Same desc', defaultTitle: 'Untitled' },
+ 'Same',
+ 'Same desc'
+ )
+ ).toEqual({})
+ })
+
+ it('buildWidgetTileMetadataPatch clears name when it matches default title', () => {
+ expect(buildWidgetTileMetadataPatch({ name: 'Custom', defaultTitle: 'Untitled' }, 'Untitled', 'Desc')).toEqual({
+ name: '',
+ description: 'Desc',
+ })
+ })
+})
diff --git a/products/dashboards/frontend/widgets/editWidgetModalTileUtils.ts b/products/dashboards/frontend/widgets/editWidgetModalTileUtils.ts
new file mode 100644
index 000000000000..21d91b835461
--- /dev/null
+++ b/products/dashboards/frontend/widgets/editWidgetModalTileUtils.ts
@@ -0,0 +1,41 @@
+import type { DashboardWidgetEditModalProps } from './registry'
+
+export type WidgetEditModalTileMetadataProps = Pick<
+ DashboardWidgetEditModalProps,
+ 'name' | 'description' | 'defaultTitle'
+>
+
+export function getWidgetEditModalTileDefaults(props: Pick<DashboardWidgetEditModalProps, 'name' | 'description'>): {
+ tileName: string
+ tileDescription: string
+} {
+ return {
+ tileName: props.name ?? '',
+ tileDescription: props.description ?? '',
+ }
+}
+
+export type WidgetTileMetadataPatch = {
+ name?: string
+ description?: string
+}
+
+export function buildWidgetTileMetadataPatch(
+ props: WidgetEditModalTileMetadataProps,
+ tileName: string,
+ tileDescription: string
+): WidgetTileMetadataPatch {
+ const trimmedName = tileName.trim()
+ const trimmedDescription = tileDescription.trim()
+ const nameChanged = trimmedName !== (props.name ?? '').trim()
+ const descriptionChanged = trimmedDescription !== (props.description ?? '').trim()
+
+ const metadata: WidgetTileMetadataPatch = {}
+ if (nameChanged) {
+ metadata.name = trimmedName === (props.defaultTitle ?? 'Untitled').trim() ? '' : trimmedName
+ }
+ if (descriptionChanged) {
+ metadata.description = trimmedDescription
+ }
+ return metadata
+}
diff --git a/products/dashboards/frontend/widgets/error_tracking/EditErrorTrackingWidgetModal.stories.tsx b/products/dashboards/frontend/widgets/error_tracking/EditErrorTrackingWidgetModal.stories.tsx
new file mode 100644
index 000000000000..2fa32c7b5406
--- /dev/null
+++ b/products/dashboards/frontend/widgets/error_tracking/EditErrorTrackingWidgetModal.stories.tsx
@@ -0,0 +1,60 @@
+import type { Meta, StoryObj } from '@storybook/react'
+
+import { withErrorTrackingProjectState } from '../../components/WidgetCard/widgetCardStoryFixtures'
+import { getDashboardWidgetCatalogEntry } from '../../widget_types/catalog'
+import type { DashboardWidgetEditModalProps } from '../registry'
+import { EditErrorTrackingWidgetModal } from './EditErrorTrackingWidgetModal'
+
+const ERROR_TRACKING_CATALOG = getDashboardWidgetCatalogEntry('error_tracking_list')!
+const DEFAULT_CONFIG = ERROR_TRACKING_CATALOG.defaultConfig as Record<string, unknown>
+
+type EditErrorTrackingWidgetModalStoryProps = Partial<DashboardWidgetEditModalProps>
+
+function EditErrorTrackingWidgetModalStory({
+ isOpen = true,
+ onClose = () => undefined,
+ onSave = () => Promise.resolve(),
+ config = DEFAULT_CONFIG,
+ name = 'Top issues',
+ defaultTitle = ERROR_TRACKING_CATALOG.headerTitle ?? ERROR_TRACKING_CATALOG.label,
+ description = 'Track the most common errors affecting your users.',
+ ...props
+}: EditErrorTrackingWidgetModalStoryProps): JSX.Element {
+ return (
+ <EditErrorTrackingWidgetModal
+ isOpen={isOpen}
+ onClose={onClose}
+ config={config}
+ onSave={onSave}
+ name={name}
+ defaultTitle={defaultTitle}
+ description={description}
+ {...props}
+ />
+ )
+}
+
+// Storybook CSF requires a string literal `title` derived from catalog groupLabel/label.
+const meta: Meta<typeof EditErrorTrackingWidgetModalStory> = {
+ title: 'Dashboards/Dashboard Widgets/Widget types/Error tracking/Top issues/Widget settings',
+ component: EditErrorTrackingWidgetModalStory,
+ parameters: {
+ layout: 'fullscreen',
+ },
+ decorators: [],
+ args: {
+ config: { ...DEFAULT_CONFIG, orderBy: 'occurrences', filterTestAccounts: true },
+ },
+}
+
+export default meta
+
+type Story = StoryObj<typeof EditErrorTrackingWidgetModalStory>
+
+export const Default: Story = {
+ decorators: [withErrorTrackingProjectState(true)],
+}
+
+export const BeforeExceptionIngestion: Story = {
+ decorators: [withErrorTrackingProjectState(false)],
+}
diff --git a/products/dashboards/frontend/widgets/error_tracking/EditErrorTrackingWidgetModal.test.tsx b/products/dashboards/frontend/widgets/error_tracking/EditErrorTrackingWidgetModal.test.tsx
new file mode 100644
index 000000000000..ef48d36c1fdb
--- /dev/null
+++ b/products/dashboards/frontend/widgets/error_tracking/EditErrorTrackingWidgetModal.test.tsx
@@ -0,0 +1,201 @@
+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
+
+import '@testing-library/jest-dom'
+
+import { cleanup, render, screen, within } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { filterTestAccountsDefaultsLogic } from 'scenes/settings/environment/filterTestAccountDefaultsLogic'
+
+import { initKeaTests } from '~/test/init'
+import { PropertyFilterType, PropertyOperator } from '~/types'
+
+import { exceptionIngestionLogic } from 'products/error_tracking/frontend/components/SetupPrompt/exceptionIngestionLogic'
+
+import { EditErrorTrackingWidgetModal } from './EditErrorTrackingWidgetModal'
+import * as errorTrackingWidgetUtils from './utils'
+
+describe('EditErrorTrackingWidgetModal', () => {
+ beforeEach(() => {
+ initKeaTests(true, {
+ ...MOCK_DEFAULT_TEAM,
+ test_account_filters: [
+ {
+ key: 'email',
+ value: '@posthog.com',
+ operator: PropertyOperator.NotIContains,
+ type: PropertyFilterType.Person,
+ },
+ ],
+ })
+ featureFlagLogic.mount()
+ filterTestAccountsDefaultsLogic.mount()
+ exceptionIngestionLogic.mount()
+ exceptionIngestionLogic.actions.loadExceptionIngestionStateSuccess(true)
+ jest.spyOn(errorTrackingWidgetUtils, 'canConfigureErrorTrackingWidgetIssues').mockReturnValue(true)
+ })
+
+ afterEach(() => {
+ jest.restoreAllMocks()
+ cleanup()
+ })
+
+ it('shows inline error for limit above 25 instead of saving', async () => {
+ const onSave = jest.fn()
+
+ render(
+ <EditErrorTrackingWidgetModal
+ isOpen
+ onClose={jest.fn()}
+ config={{ limit: 10, orderBy: 'occurrences', dateRange: { date_from: '-7d' } }}
+ onSave={onSave}
+ />
+ )
+
+ const limitInput = screen.getByRole('spinbutton')
+ await userEvent.clear(limitInput)
+ await userEvent.type(limitInput, '30')
+
+ expect(screen.getByText('Must be an integer between 1 and 25.')).toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'Save' })).toHaveAttribute('aria-disabled', 'true')
+ expect(onSave).not.toHaveBeenCalled()
+ })
+
+ it('saves title and description from widget settings modal', async () => {
+ const onSave = jest.fn().mockResolvedValue(undefined)
+
+ render(
+ <EditErrorTrackingWidgetModal
+ isOpen
+ onClose={jest.fn()}
+ config={{ limit: 10, orderBy: 'occurrences', dateRange: { date_from: '-7d' } }}
+ name=""
+ defaultTitle="Top issues"
+ description=""
+ onSave={onSave}
+ />
+ )
+
+ await userEvent.type(screen.getByPlaceholderText('Top issues'), 'Critical crashes')
+ await userEvent.type(screen.getByPlaceholderText('Enter description (optional)'), 'Top crashes this week')
+ const dialog = screen.getByRole('dialog')
+ await userEvent.click(within(dialog).getByRole('button', { name: 'Save' }))
+
+ expect(onSave).toHaveBeenCalledTimes(1)
+ expect(onSave).toHaveBeenCalledWith(
+ expect.objectContaining({
+ limit: 10,
+ orderBy: 'occurrences',
+ }),
+ {
+ name: 'Critical crashes',
+ description: 'Top crashes this week',
+ }
+ )
+ })
+
+ it('saves filterTestAccounts from widget settings modal', async () => {
+ const onSave = jest.fn().mockResolvedValue(undefined)
+
+ render(
+ <EditErrorTrackingWidgetModal
+ isOpen
+ onClose={jest.fn()}
+ config={{
+ limit: 10,
+ orderBy: 'occurrences',
+ dateRange: { date_from: '-7d' },
+ filterTestAccounts: true,
+ }}
+ onSave={onSave}
+ />
+ )
+
+ await userEvent.click(screen.getByRole('switch', { name: /Filter out internal and test users/i }))
+ const dialog = screen.getByRole('dialog')
+ await userEvent.click(within(dialog).getByRole('button', { name: 'Save' }))
+
+ expect(onSave).toHaveBeenCalledWith(
+ expect.objectContaining({
+ filterTestAccounts: false,
+ }),
+ {}
+ )
+ })
+
+ it('saves description from widget settings modal', async () => {
+ const onSave = jest.fn().mockResolvedValue(undefined)
+
+ render(
+ <EditErrorTrackingWidgetModal
+ isOpen
+ onClose={jest.fn()}
+ config={{ limit: 10, orderBy: 'occurrences', dateRange: { date_from: '-7d' } }}
+ description=""
+ onSave={onSave}
+ />
+ )
+
+ await userEvent.type(screen.getByPlaceholderText('Enter description (optional)'), 'Top crashes this week')
+ const dialog = screen.getByRole('dialog')
+ await userEvent.click(within(dialog).getByRole('button', { name: 'Save' }))
+
+ expect(onSave).toHaveBeenCalledTimes(1)
+ expect(onSave).toHaveBeenCalledWith(
+ expect.objectContaining({
+ limit: 10,
+ }),
+ { description: 'Top crashes this week' }
+ )
+ })
+
+ it('disables save while request is in flight', async () => {
+ let resolveSave: (() => void) | undefined
+ const onSave = jest.fn(
+ () =>
+ new Promise<void>((resolve) => {
+ resolveSave = resolve
+ })
+ )
+
+ render(
+ <EditErrorTrackingWidgetModal
+ isOpen
+ onClose={jest.fn()}
+ config={{ limit: 10, orderBy: 'occurrences', dateRange: { date_from: '-7d' } }}
+ onSave={onSave}
+ />
+ )
+
+ const dialog = screen.getByRole('dialog')
+ await userEvent.click(within(dialog).getByRole('button', { name: 'Save' }))
+
+ expect(within(dialog).getByRole('button', { name: 'Save' })).toHaveAttribute('aria-disabled', 'true')
+ expect(within(dialog).getByRole('button', { name: 'Cancel' })).toHaveAttribute('aria-disabled', 'true')
+
+ resolveSave?.()
+ await within(dialog).findByRole('button', { name: 'Save' })
+ })
+
+ it('hides issue settings when exception ingestion is not configured', () => {
+ jest.spyOn(errorTrackingWidgetUtils, 'canConfigureErrorTrackingWidgetIssues').mockReturnValue(false)
+
+ render(
+ <EditErrorTrackingWidgetModal
+ isOpen
+ onClose={jest.fn()}
+ config={{ limit: 10, orderBy: 'occurrences', dateRange: { date_from: '-7d' } }}
+ name=""
+ defaultTitle="Top issues"
+ description=""
+ onSave={jest.fn()}
+ />
+ )
+
+ expect(screen.getByPlaceholderText('Top issues')).toBeInTheDocument()
+ expect(screen.queryByRole('spinbutton')).not.toBeInTheDocument()
+ expect(screen.queryByText('Sort by')).not.toBeInTheDocument()
+ expect(screen.queryByText(/Filter out internal and test users/i)).not.toBeInTheDocument()
+ })
+})
diff --git a/products/dashboards/frontend/widgets/error_tracking/EditErrorTrackingWidgetModal.tsx b/products/dashboards/frontend/widgets/error_tracking/EditErrorTrackingWidgetModal.tsx
new file mode 100644
index 000000000000..76639856bd58
--- /dev/null
+++ b/products/dashboards/frontend/widgets/error_tracking/EditErrorTrackingWidgetModal.tsx
@@ -0,0 +1,177 @@
+import { BindLogic, useActions, useValues } from 'kea'
+
+import { LemonButton } from 'lib/lemon-ui/LemonButton'
+import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
+import { LemonField } from 'lib/lemon-ui/LemonField/LemonField'
+import { LemonInput } from 'lib/lemon-ui/LemonInput/LemonInput'
+import { LemonModal } from 'lib/lemon-ui/LemonModal'
+import { LemonSelect } from 'lib/lemon-ui/LemonSelect'
+
+import { getDashboardWidgetGroupLabel } from '../../widget_types/catalog'
+import { WIDGET_DATE_RANGE_SELECT_OPTIONS } from '../../widget_types/configSchemas'
+import { EditWidgetModalFiltersSection } from '../EditWidgetModalFiltersSection'
+import { EditWidgetModalTileDetailsSection } from '../EditWidgetModalTileDetailsSection'
+import type { DashboardWidgetEditModalProps } from '../registry'
+import { editErrorTrackingWidgetModalLogic } from './editErrorTrackingWidgetModalLogic'
+import { ERROR_TRACKING_WIDGET_ORDER_BY_OPTIONS } from './utils'
+
+function EditErrorTrackingWidgetModalContents(): JSX.Element {
+ const {
+ showIssueSettings,
+ limit,
+ orderBy,
+ dateFrom,
+ tileName,
+ tileDescription,
+ filterTestAccounts,
+ activeFieldErrors,
+ saving,
+ saveDisabledReason,
+ onClose,
+ defaultTitle,
+ } = useValues(editErrorTrackingWidgetModalLogic)
+ const {
+ setLimit,
+ setOrderBy,
+ setDateFrom,
+ setTileName,
+ setTileDescription,
+ setFilterTestAccounts,
+ clearFieldError,
+ submit,
+ } = useActions(editErrorTrackingWidgetModalLogic)
+
+ const showTileDetails = true
+
+ return (
+ <LemonModal
+ isOpen
+ onClose={onClose}
+ title="Widget settings"
+ description={
+ showIssueSettings
+ ? 'Configure tile details and which error tracking issues appear on this dashboard.'
+ : 'Configure tile details for this dashboard widget.'
+ }
+ width={680}
+ footer={
+ <>
+ <div className="flex-1" />
+ <LemonButton type="secondary" onClick={onClose} disabled={saving}>
+ Cancel
+ </LemonButton>
+ <LemonButton
+ type="primary"
+ loading={saving}
+ disabledReason={saveDisabledReason}
+ onClick={() => submit()}
+ >
+ Save
+ </LemonButton>
+ </>
+ }
+ >
+ <div className="flex flex-col gap-4">
+ {showTileDetails ? (
+ <EditWidgetModalTileDetailsSection
+ tileName={tileName}
+ tileDescription={tileDescription}
+ defaultTitle={defaultTitle}
+ saving={saving}
+ setTileName={setTileName}
+ setTileDescription={setTileDescription}
+ />
+ ) : null}
+ {showIssueSettings ? (
+ <>
+ {showTileDetails ? <LemonDivider className="my-0" /> : null}
+ <EditWidgetModalFiltersSection
+ filterTestAccounts={filterTestAccounts}
+ saving={saving}
+ setFilterTestAccounts={setFilterTestAccounts}
+ />
+ <LemonDivider className="my-0" />
+ <section className="flex flex-col gap-3">
+ <h5 className="text-sm font-semibold m-0">
+ {getDashboardWidgetGroupLabel('error_tracking')}
+ </h5>
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
+ <LemonField.Pure
+ label="Date range"
+ help="Only include issues seen in this period."
+ error={activeFieldErrors.dateFrom}
+ >
+ <LemonSelect
+ fullWidth
+ value={dateFrom}
+ onChange={(value) => {
+ setDateFrom(value)
+ clearFieldError('dateFrom')
+ }}
+ options={WIDGET_DATE_RANGE_SELECT_OPTIONS}
+ />
+ </LemonField.Pure>
+ <LemonField.Pure
+ label="Number of issues"
+ help="Show up to 25 issues on the tile."
+ error={activeFieldErrors.limit}
+ >
+ <LemonInput
+ type="number"
+ min={1}
+ max={25}
+ fullWidth
+ value={limit}
+ onChange={(value) => {
+ setLimit(Number(value))
+ clearFieldError('limit')
+ }}
+ />
+ </LemonField.Pure>
+ <LemonField.Pure
+ className="sm:col-span-2"
+ label="Sort by"
+ help="Order issues by this metric within the date range."
+ error={activeFieldErrors.orderBy}
+ >
+ <LemonSelect
+ fullWidth
+ value={orderBy}
+ onChange={(value) => {
+ setOrderBy(value)
+ clearFieldError('orderBy')
+ }}
+ options={[...ERROR_TRACKING_WIDGET_ORDER_BY_OPTIONS]}
+ />
+ </LemonField.Pure>
+ </div>
+ </section>
+ </>
+ ) : null}
+ </div>
+ </LemonModal>
+ )
+}
+
+export function EditErrorTrackingWidgetModal({
+ isOpen,
+ onClose,
+ config,
+ onSave,
+ name,
+ defaultTitle,
+ description,
+}: DashboardWidgetEditModalProps): JSX.Element | null {
+ if (!isOpen) {
+ return null
+ }
+
+ return (
+ <BindLogic
+ logic={editErrorTrackingWidgetModalLogic}
+ props={{ onClose, config, onSave, name, defaultTitle, description }}
+ >
+ <EditErrorTrackingWidgetModalContents />
+ </BindLogic>
+ )
+}
diff --git a/products/dashboards/frontend/widgets/error_tracking/ErrorTrackingWidget.stories.tsx b/products/dashboards/frontend/widgets/error_tracking/ErrorTrackingWidget.stories.tsx
new file mode 100644
index 000000000000..0c10ecffab65
--- /dev/null
+++ b/products/dashboards/frontend/widgets/error_tracking/ErrorTrackingWidget.stories.tsx
@@ -0,0 +1,195 @@
+import type { Meta, StoryObj } from '@storybook/react'
+import type { ReactNode } from 'react'
+
+import { DashboardPlacement } from '~/types'
+
+import { WidgetCard } from '../../components/WidgetCard/WidgetCard'
+import { WidgetCardBody } from '../../components/WidgetCard/WidgetCardBody'
+import { WidgetCardHeader, widgetCardShouldHideMoreButton } from '../../components/WidgetCard/WidgetCardHeader'
+import {
+ mockMoreOverlay,
+ widgetTileFrameDecorator,
+ withErrorTrackingProjectState,
+} from '../../components/WidgetCard/widgetCardStoryFixtures'
+import { getDashboardWidgetCatalogEntry, getDashboardWidgetGroupLabel } from '../../widget_types/catalog'
+import type { DashboardWidgetComponentProps } from '../registry'
+import { ErrorTrackingWidget } from './ErrorTrackingWidget'
+
+const ERROR_TRACKING_CATALOG = getDashboardWidgetCatalogEntry('error_tracking_list')!
+const DEFAULT_CONFIG = ERROR_TRACKING_CATALOG.defaultConfig as Record<string, unknown>
+
+type ErrorTrackingWidgetTileStoryProps = DashboardWidgetComponentProps & {
+ title?: string
+ description?: string
+ showDescription?: boolean
+ body?: ReactNode
+}
+
+function ErrorTrackingWidgetTileStory({
+ title = '',
+ description = 'Track the most common errors affecting your users.',
+ showDescription = true,
+ body,
+ ...widgetProps
+}: ErrorTrackingWidgetTileStoryProps): JSX.Element {
+ const widgetTypeLabel = getDashboardWidgetGroupLabel(ERROR_TRACKING_CATALOG.groupId)
+ const defaultTitle = ERROR_TRACKING_CATALOG.headerTitle ?? ERROR_TRACKING_CATALOG.label
+
+ return (
+ <WidgetCard className="h-full">
+ <WidgetCardHeader
+ layout={ERROR_TRACKING_CATALOG.headerLayout}
+ title={title}
+ defaultTitle={defaultTitle}
+ titleHref={ERROR_TRACKING_CATALOG.titleHref}
+ widgetTypeLabel={widgetTypeLabel}
+ config={widgetProps.config}
+ headerMeta={ERROR_TRACKING_CATALOG.headerMeta}
+ description={description}
+ showDescription={showDescription}
+ loading={widgetProps.loading}
+ shouldHideMoreButton={widgetCardShouldHideMoreButton(DashboardPlacement.Dashboard, false)}
+ moreButtonOverlay={mockMoreOverlay}
+ />
+ <WidgetCardBody>{body ?? <ErrorTrackingWidget {...widgetProps} />}</WidgetCardBody>
+ </WidgetCard>
+ )
+}
+
+const sampleIssues = [
+ {
+ id: 'issue-1',
+ name: 'TypeError: Cannot read properties of undefined',
+ description: 'User profile settings fail to load when the session cache is empty.',
+ function: 'loadProfile',
+ source: 'https://app.example.test/static/js/settings.js',
+ library: 'web',
+ status: 'active',
+ assignee: null,
+ first_seen: '2026-05-01T10:00:00.000Z',
+ last_seen: '2026-05-26T08:00:00.000Z',
+ aggregations: {
+ occurrences: 42,
+ sessions: 18,
+ users: 12,
+ volume_buckets: [
+ { label: '2026-05-20T00:00:00.000Z', value: 2 },
+ { label: '2026-05-21T00:00:00.000Z', value: 4 },
+ { label: '2026-05-22T00:00:00.000Z', value: 8 },
+ { label: '2026-05-23T00:00:00.000Z', value: 12 },
+ { label: '2026-05-24T00:00:00.000Z', value: 6 },
+ { label: '2026-05-25T00:00:00.000Z', value: 5 },
+ { label: '2026-05-26T00:00:00.000Z', value: 5 },
+ ],
+ },
+ },
+ {
+ id: 'issue-2',
+ name: 'NetworkError: Failed to fetch',
+ description: 'Checkout requests fail when the payment API is unavailable.',
+ function: 'fetch',
+ source: 'https://app.example.test/static/js/api.js',
+ library: 'web',
+ status: 'pending_release',
+ assignee: null,
+ first_seen: '2026-05-10T10:00:00.000Z',
+ last_seen: '2026-05-25T12:00:00.000Z',
+ aggregations: {
+ occurrences: 18,
+ sessions: 9,
+ users: 7,
+ volume_buckets: [
+ { label: '2026-05-20T00:00:00.000Z', value: 1 },
+ { label: '2026-05-21T00:00:00.000Z', value: 2 },
+ { label: '2026-05-22T00:00:00.000Z', value: 3 },
+ { label: '2026-05-23T00:00:00.000Z', value: 2 },
+ { label: '2026-05-24T00:00:00.000Z', value: 4 },
+ { label: '2026-05-25T00:00:00.000Z', value: 3 },
+ { label: '2026-05-26T00:00:00.000Z', value: 3 },
+ ],
+ },
+ },
+]
+
+// Storybook CSF requires a string literal `title` derived from catalog groupLabel/label.
+const meta: Meta<typeof ErrorTrackingWidgetTileStory> = {
+ title: 'Dashboards/Dashboard Widgets/Widget types/Error tracking/Top issues',
+ component: ErrorTrackingWidgetTileStory,
+ parameters: {
+ layout: 'padded',
+ },
+ decorators: [...widgetTileFrameDecorator],
+ args: {
+ tileId: 1,
+ config: DEFAULT_CONFIG,
+ loading: false,
+ result: null,
+ onUpdateConfig: () => undefined,
+ onRefresh: () => undefined,
+ },
+}
+
+export default meta
+
+type Story = StoryObj<typeof ErrorTrackingWidgetTileStory>
+
+export const Populated: Story = {
+ decorators: [withErrorTrackingProjectState(true)],
+ args: {
+ title: 'Top issues',
+ config: { ...DEFAULT_CONFIG, orderBy: 'occurrences' },
+ loading: false,
+ result: {
+ results: sampleIssues,
+ hasMore: true,
+ limit: 10,
+ },
+ },
+}
+
+export const Loading: Story = {
+ decorators: [withErrorTrackingProjectState(true)],
+ args: {
+ title: 'Top issues',
+ config: DEFAULT_CONFIG,
+ loading: true,
+ result: null,
+ },
+ parameters: {
+ testOptions: { waitForLoadersToDisappear: false },
+ },
+}
+
+export const Empty: Story = {
+ decorators: [withErrorTrackingProjectState(true)],
+ args: {
+ title: 'Top issues',
+ config: DEFAULT_CONFIG,
+ loading: false,
+ result: { results: [] },
+ },
+ parameters: {
+ docs: {
+ description: {
+ story: 'Celebratory empty state when no issues match the widget filters.',
+ },
+ },
+ },
+}
+
+export const SetupUnavailable: Story = {
+ args: {
+ title: 'Top issues',
+ config: DEFAULT_CONFIG,
+ loading: false,
+ result: null,
+ },
+ decorators: [withErrorTrackingProjectState(false)],
+ parameters: {
+ docs: {
+ description: {
+ story: 'Uses the shared `ErrorTrackingIngestionPrompt` from error tracking (via `ErrorTrackingWidget`) when exception autocapture is disabled and no exceptions have been captured.',
+ },
+ },
+ },
+}
diff --git a/products/dashboards/frontend/widgets/error_tracking/ErrorTrackingWidget.test.tsx b/products/dashboards/frontend/widgets/error_tracking/ErrorTrackingWidget.test.tsx
new file mode 100644
index 000000000000..05ea91941ee2
--- /dev/null
+++ b/products/dashboards/frontend/widgets/error_tracking/ErrorTrackingWidget.test.tsx
@@ -0,0 +1,88 @@
+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
+
+import '@testing-library/jest-dom'
+
+import { render, screen, cleanup } from '@testing-library/react'
+
+import { teamLogic } from 'scenes/teamLogic'
+
+import { initKeaTests } from '~/test/init'
+
+import { exceptionIngestionLogic } from 'products/error_tracking/frontend/components/SetupPrompt/exceptionIngestionLogic'
+
+import { ErrorTrackingWidget } from './ErrorTrackingWidget'
+
+jest.mock('products/error_tracking/frontend/components/ErrorTrackingIssueList/ErrorTrackingIssueList', () => ({
+ ErrorTrackingIssueList: (): JSX.Element => <div>Issue list</div>,
+}))
+
+describe('ErrorTrackingWidget', () => {
+ afterEach(() => {
+ cleanup()
+ })
+
+ beforeEach(() => {
+ initKeaTests(true, { ...MOCK_DEFAULT_TEAM, autocapture_exceptions_opt_in: true })
+ exceptionIngestionLogic.mount()
+ exceptionIngestionLogic.actions.loadExceptionIngestionStateSuccess(true)
+ })
+
+ const issue = {
+ id: 'issue-1',
+ name: 'TypeError',
+ description: 'Something broke',
+ function: 'load',
+ source: 'app.js',
+ library: 'web',
+ status: 'active',
+ assignee: null,
+ first_seen: '2026-05-01T10:00:00.000Z',
+ last_seen: '2026-05-26T08:00:00.000Z',
+ aggregations: {
+ occurrences: 1,
+ sessions: 1,
+ users: 1,
+ volume_buckets: [],
+ },
+ }
+
+ it('renders issue list when results exist', () => {
+ render(
+ <ErrorTrackingWidget
+ tileId={1}
+ config={{ limit: 10 }}
+ loading={false}
+ result={{ results: [issue], hasMore: true, limit: 10 }}
+ />
+ )
+
+ expect(screen.getByText('Issue list')).toBeInTheDocument()
+ })
+
+ it('renders a celebratory empty state when there are no issues', () => {
+ const { container } = render(
+ <ErrorTrackingWidget tileId={1} config={{ limit: 10 }} loading={false} result={{ results: [] }} />
+ )
+
+ expect(container.querySelector('[data-attr="error-tracking-widget-empty-state"]')).toBeInTheDocument()
+ expect(screen.getByText('All clear!')).toBeInTheDocument()
+ expect(
+ screen.getByText("No issues matched your filters. That's a good thing. Enjoy the quiet.")
+ ).toBeInTheDocument()
+ expect(screen.getByAltText('PostHog hedgehog')).toBeInTheDocument()
+ })
+
+ it('shows setup prompt when exception autocapture is disabled', async () => {
+ teamLogic.actions.loadCurrentTeamSuccess({
+ ...MOCK_DEFAULT_TEAM,
+ autocapture_exceptions_opt_in: false,
+ })
+ exceptionIngestionLogic.actions.loadExceptionIngestionStateSuccess(false)
+
+ render(<ErrorTrackingWidget tileId={1} config={{ limit: 10 }} loading={false} result={{ results: [issue] }} />)
+
+ expect(await screen.findByText("You haven't captured any exceptions")).toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'Enable exception autocapture' })).toBeInTheDocument()
+ expect(screen.queryByText('Issue list')).not.toBeInTheDocument()
+ })
+})
diff --git a/products/dashboards/frontend/widgets/error_tracking/ErrorTrackingWidget.tsx b/products/dashboards/frontend/widgets/error_tracking/ErrorTrackingWidget.tsx
new file mode 100644
index 000000000000..b51ad5444a7c
--- /dev/null
+++ b/products/dashboards/frontend/widgets/error_tracking/ErrorTrackingWidget.tsx
@@ -0,0 +1,101 @@
+import { useValues } from 'kea'
+import type { ReactNode } from 'react'
+
+import { Spinner } from '@posthog/lemon-ui'
+
+import { SupermanHog } from 'lib/components/hedgehogs'
+import { teamLogic } from 'scenes/teamLogic'
+
+import { ErrorTrackingIssue } from '~/queries/schema/schema-general'
+
+import { ErrorTrackingIssueList } from 'products/error_tracking/frontend/components/ErrorTrackingIssueList/ErrorTrackingIssueList'
+import { ErrorTrackingIssueListSkeleton } from 'products/error_tracking/frontend/components/ErrorTrackingIssueList/ErrorTrackingIssueListSkeleton'
+import { exceptionIngestionLogic } from 'products/error_tracking/frontend/components/SetupPrompt/exceptionIngestionLogic'
+import { ErrorTrackingIngestionPrompt } from 'products/error_tracking/frontend/components/SetupPrompt/SetupPrompt'
+
+import { WidgetCardBodyMessage, WidgetCardContent } from '../../components/WidgetCard'
+import { WidgetCardProductIntroduction } from '../../components/WidgetCardProductIntroduction/WidgetCardProductIntroduction'
+import type { DashboardWidgetComponentProps } from '../registry'
+import { canConfigureErrorTrackingWidgetIssues } from './utils'
+
+type ErrorTrackingWidgetResult = {
+ results?: ErrorTrackingIssue[]
+ hasMore?: boolean
+ limit?: number
+}
+
+export function ErrorTrackingWidget({ result, loading }: DashboardWidgetComponentProps): JSX.Element {
+ if (loading) {
+ return (
+ <WidgetCardContent>
+ <ErrorTrackingIssueListSkeleton rowCount={4} className="w-full" />
+ </WidgetCardContent>
+ )
+ }
+
+ return (
+ <ErrorTrackingWidgetSetupGate>
+ <ErrorTrackingWidgetBody result={result} />
+ </ErrorTrackingWidgetSetupGate>
+ )
+}
+
+function ErrorTrackingWidgetSetupGate({ children }: { children: ReactNode }): JSX.Element {
+ const { hasSentExceptionEvent, hasSentExceptionEventLoading } = useValues(exceptionIngestionLogic)
+ const { currentTeam } = useValues(teamLogic)
+
+ if (hasSentExceptionEventLoading || !currentTeam) {
+ return (
+ <WidgetCardContent>
+ <div className="flex justify-center">
+ <Spinner />
+ </div>
+ </WidgetCardContent>
+ )
+ }
+
+ if (!canConfigureErrorTrackingWidgetIssues(currentTeam, hasSentExceptionEvent)) {
+ return (
+ <WidgetCardContent>
+ <ErrorTrackingIngestionPrompt
+ className="border-none mb-0 mt-0 p-4"
+ introductionStacked
+ IntroductionComponent={WidgetCardProductIntroduction}
+ actionElementClassName="flex flex-col items-center gap-4"
+ />
+ </WidgetCardContent>
+ )
+ }
+
+ return <>{children}</>
+}
+
+function ErrorTrackingWidgetBody({ result }: { result: DashboardWidgetComponentProps['result'] }): JSX.Element {
+ const payload = result as ErrorTrackingWidgetResult | null | undefined
+ const rows = payload?.results ?? []
+
+ if (rows.length === 0) {
+ return (
+ <WidgetCardContent>
+ <WidgetCardBodyMessage>
+ <div
+ className="flex max-w-xs flex-col items-center gap-2 px-2 text-balance"
+ data-attr="error-tracking-widget-empty-state"
+ >
+ <SupermanHog className="size-20 shrink-0" />
+ <p className="m-0 text-base font-semibold text-primary">All clear!</p>
+ <p className="m-0 text-sm text-muted">
+ No issues matched your filters. That's a good thing. Enjoy the quiet.
+ </p>
+ </div>
+ </WidgetCardBodyMessage>
+ </WidgetCardContent>
+ )
+ }
+
+ return (
+ <WidgetCardContent>
+ <ErrorTrackingIssueList issues={rows} />
+ </WidgetCardContent>
+ )
+}
diff --git a/products/dashboards/frontend/widgets/error_tracking/editErrorTrackingWidgetModalLogic.ts b/products/dashboards/frontend/widgets/error_tracking/editErrorTrackingWidgetModalLogic.ts
new file mode 100644
index 000000000000..11ea648afa06
--- /dev/null
+++ b/products/dashboards/frontend/widgets/error_tracking/editErrorTrackingWidgetModalLogic.ts
@@ -0,0 +1,236 @@
+import { actions, connect, defaults, kea, listeners, path, props, reducers, selectors } from 'kea'
+
+import { filterTestAccountsDefaultsLogic } from 'scenes/settings/environment/filterTestAccountDefaultsLogic'
+import { teamLogic } from 'scenes/teamLogic'
+
+import { exceptionIngestionLogic } from 'products/error_tracking/frontend/components/SetupPrompt/exceptionIngestionLogic'
+
+import { isWidgetConfigValidationError } from '../../utils'
+import {
+ resolveWidgetFilterTestAccounts,
+ type ErrorTrackingWidgetConfig,
+ type WidgetDateFromValue,
+} from '../../widget_types/configSchemas'
+import {
+ widgetEditModalFilterTestAccountsActions,
+ widgetEditModalListFieldActions,
+ widgetEditModalPropSelectors,
+ widgetEditModalTileActions,
+} from '../editWidgetModalBuilders'
+import { buildWidgetTileMetadataPatch, getWidgetEditModalTileDefaults } from '../editWidgetModalTileUtils'
+import type { DashboardWidgetEditModalProps } from '../registry'
+import type { editErrorTrackingWidgetModalLogicType } from './editErrorTrackingWidgetModalLogicType'
+import {
+ parseErrorTrackingWidgetConfig,
+ validateErrorTrackingWidgetConfigInput,
+ type ErrorTrackingWidgetFieldErrors,
+} from './errorTrackingWidgetConfigValidation'
+import { canConfigureErrorTrackingWidgetIssues } from './utils'
+
+export type EditErrorTrackingWidgetModalLogicProps = Omit<DashboardWidgetEditModalProps, 'isOpen'>
+
+export const editErrorTrackingWidgetModalLogic = kea<editErrorTrackingWidgetModalLogicType>([
+ path(['products', 'dashboards', 'widgets', 'error_tracking', 'editErrorTrackingWidgetModalLogic']),
+
+ props({
+ config: {},
+ onSave: async () => {},
+ onClose: () => {},
+ name: '',
+ defaultTitle: 'Untitled',
+ description: '',
+ } as EditErrorTrackingWidgetModalLogicProps),
+
+ connect({
+ values: [
+ teamLogic,
+ ['currentTeam'],
+ filterTestAccountsDefaultsLogic,
+ ['filterTestAccountsDefault'],
+ exceptionIngestionLogic,
+ ['hasSentExceptionEvent', 'hasSentExceptionEventLoading'],
+ ],
+ }),
+
+ actions({
+ setOrderBy: (orderBy: string) => ({ orderBy }),
+ ...widgetEditModalListFieldActions,
+ ...widgetEditModalTileActions,
+ ...widgetEditModalFilterTestAccountsActions,
+ setFieldErrors: (fieldErrors: ErrorTrackingWidgetFieldErrors) => ({ fieldErrors }),
+ clearFieldError: (field: keyof ErrorTrackingWidgetFieldErrors) => ({ field }),
+ submit: true,
+ submitSuccess: true,
+ submitFailure: true,
+ }),
+
+ reducers({
+ orderBy: [
+ 'occurrences' as ErrorTrackingWidgetConfig['orderBy'],
+ {
+ setOrderBy: (
+ _: ErrorTrackingWidgetConfig['orderBy'],
+ { orderBy }: { orderBy: string }
+ ): ErrorTrackingWidgetConfig['orderBy'] => orderBy as ErrorTrackingWidgetConfig['orderBy'],
+ },
+ ],
+ limit: [
+ 10,
+ {
+ setLimit: (_: number, { limit }: { limit: number }) => limit,
+ },
+ ],
+ dateFrom: [
+ '-7d',
+ {
+ setDateFrom: (_: WidgetDateFromValue, { dateFrom }: { dateFrom: string }): WidgetDateFromValue =>
+ dateFrom as WidgetDateFromValue,
+ },
+ ],
+ tileName: [
+ '',
+ {
+ setTileName: (_: string, { tileName }: { tileName: string }) => tileName,
+ },
+ ],
+ tileDescription: [
+ '',
+ {
+ setTileDescription: (_: string, { tileDescription }: { tileDescription: string }) => tileDescription,
+ },
+ ],
+ filterTestAccounts: [
+ false,
+ {
+ setFilterTestAccounts: (_: boolean, { filterTestAccounts }: { filterTestAccounts: boolean }) =>
+ filterTestAccounts,
+ },
+ ],
+ fieldErrors: [
+ {} as ErrorTrackingWidgetFieldErrors,
+ {
+ setFieldErrors: (
+ _: ErrorTrackingWidgetFieldErrors,
+ { fieldErrors }: { fieldErrors: ErrorTrackingWidgetFieldErrors }
+ ) => fieldErrors,
+ clearFieldError: (
+ state: ErrorTrackingWidgetFieldErrors,
+ { field }: { field: keyof ErrorTrackingWidgetFieldErrors }
+ ) => {
+ if (!state[field]) {
+ return state
+ }
+ const next = { ...state }
+ delete next[field]
+ return next
+ },
+ },
+ ],
+ saving: [
+ false,
+ {
+ submit: (_state: boolean, _payload: { value: true }) => true,
+ submitSuccess: (_state: boolean, _payload: { value: true }) => false,
+ submitFailure: (_state: boolean, _payload: { value: true }) => false,
+ },
+ ],
+ }),
+
+ selectors({
+ showIssueSettings: [
+ (s) => [s.currentTeam, s.hasSentExceptionEvent, s.hasSentExceptionEventLoading],
+ (currentTeam, hasSentExceptionEvent, hasSentExceptionEventLoading): boolean =>
+ canConfigureErrorTrackingWidgetIssues(currentTeam, hasSentExceptionEvent) &&
+ !hasSentExceptionEventLoading &&
+ !!currentTeam,
+ ],
+ widgetConfig: [
+ (_, p) => [p.config],
+ (config): ErrorTrackingWidgetConfig => parseErrorTrackingWidgetConfig(config),
+ ],
+ ...widgetEditModalPropSelectors,
+ validation: [
+ (s) => [s.limit, s.orderBy, s.dateFrom, s.filterTestAccounts, s.widgetConfig],
+ (limit, orderBy, dateFrom, filterTestAccounts, widgetConfig) =>
+ validateErrorTrackingWidgetConfigInput({
+ limit,
+ orderBy,
+ dateFrom,
+ filterTestAccounts,
+ baseConfig: widgetConfig,
+ }),
+ ],
+ activeFieldErrors: [
+ (s) => [s.validation, s.fieldErrors],
+ (validation, fieldErrors): ErrorTrackingWidgetFieldErrors => {
+ if (!validation.success) {
+ return { ...validation.fieldErrors, ...fieldErrors }
+ }
+ return fieldErrors
+ },
+ ],
+ saveDisabledReason: [
+ (s) => [s.saving, s.validation],
+ (saving, validation): string | undefined => {
+ if (saving) {
+ return 'Saving…'
+ }
+ if (!validation.success) {
+ return 'Fix validation errors to save'
+ }
+ return undefined
+ },
+ ],
+ }),
+
+ defaults(({ props, values }) => {
+ const baseConfig = parseErrorTrackingWidgetConfig(props.config)
+
+ return {
+ limit: baseConfig.limit,
+ orderBy: baseConfig.orderBy,
+ dateFrom: baseConfig.dateRange?.date_from ?? '-7d',
+ ...getWidgetEditModalTileDefaults(props),
+ filterTestAccounts: resolveWidgetFilterTestAccounts(
+ baseConfig.filterTestAccounts,
+ values.filterTestAccountsDefault
+ ),
+ fieldErrors: {},
+ saving: false,
+ }
+ }),
+
+ listeners(({ actions, props, values }) => ({
+ submit: async () => {
+ const result = validateErrorTrackingWidgetConfigInput({
+ limit: values.limit,
+ orderBy: values.orderBy,
+ dateFrom: values.dateFrom,
+ filterTestAccounts: values.filterTestAccounts,
+ baseConfig: values.widgetConfig,
+ })
+
+ if (!result.success) {
+ actions.setFieldErrors(result.fieldErrors)
+ return
+ }
+
+ try {
+ await props.onSave(
+ result.config,
+ buildWidgetTileMetadataPatch(props, values.tileName, values.tileDescription)
+ )
+ actions.setFieldErrors({})
+ props.onClose()
+ actions.submitSuccess()
+ } catch (error) {
+ actions.submitFailure()
+ if (isWidgetConfigValidationError(error)) {
+ actions.setFieldErrors(error.fieldErrors as ErrorTrackingWidgetFieldErrors)
+ return
+ }
+ throw error
+ }
+ },
+ })),
+])
diff --git a/products/dashboards/frontend/widgets/error_tracking/errorTrackingWidgetConfigValidation.test.ts b/products/dashboards/frontend/widgets/error_tracking/errorTrackingWidgetConfigValidation.test.ts
new file mode 100644
index 000000000000..b9734eabee43
--- /dev/null
+++ b/products/dashboards/frontend/widgets/error_tracking/errorTrackingWidgetConfigValidation.test.ts
@@ -0,0 +1,87 @@
+import { ApiError } from 'lib/api-error'
+
+import { errorTrackingWidgetConfigSchema } from '../../widget_types/configSchemas'
+import {
+ parseErrorTrackingWidgetConfigApiError,
+ validateErrorTrackingWidgetConfigInput,
+} from './errorTrackingWidgetConfigValidation'
+
+describe('validateErrorTrackingWidgetConfigInput', () => {
+ it('rejects limit above 25 with inline-friendly message', () => {
+ const result = validateErrorTrackingWidgetConfigInput({
+ limit: 30,
+ orderBy: 'occurrences',
+ dateFrom: '-7d',
+ filterTestAccounts: true,
+ baseConfig: errorTrackingWidgetConfigSchema.parse({}),
+ })
+
+ expect(result.success).toBe(false)
+ if (!result.success) {
+ expect(result.fieldErrors.limit).toBe('Must be an integer between 1 and 25.')
+ }
+ })
+
+ it('accepts valid config', () => {
+ const result = validateErrorTrackingWidgetConfigInput({
+ limit: 10,
+ orderBy: 'occurrences',
+ dateFrom: '-7d',
+ filterTestAccounts: true,
+ baseConfig: errorTrackingWidgetConfigSchema.parse({}),
+ })
+
+ expect(result.success).toBe(true)
+ if (result.success) {
+ expect(result.config.limit).toBe(10)
+ expect(result.config.dateRange).toEqual({ date_from: '-7d' })
+ expect(result.config.filterTestAccounts).toBe(true)
+ }
+ })
+
+ it('omits filterTestAccounts when not provided in config', () => {
+ const result = errorTrackingWidgetConfigSchema.safeParse({
+ limit: 10,
+ orderBy: 'occurrences',
+ dateRange: { date_from: '-7d' },
+ })
+
+ expect(result.success).toBe(true)
+ if (result.success) {
+ expect(result.data.filterTestAccounts).toBeUndefined()
+ }
+ })
+
+ it('accepts short date range', () => {
+ const result = validateErrorTrackingWidgetConfigInput({
+ limit: 10,
+ orderBy: 'occurrences',
+ dateFrom: '-1h',
+ filterTestAccounts: true,
+ baseConfig: errorTrackingWidgetConfigSchema.parse({}),
+ })
+
+ expect(result.success).toBe(true)
+ if (result.success) {
+ expect(result.config.dateRange).toEqual({ date_from: '-1h' })
+ }
+ })
+})
+
+describe('parseErrorTrackingWidgetConfigApiError', () => {
+ it('maps invalid config to zod field errors', () => {
+ const error = new ApiError('limit must be an integer between 1 and 25.', 400, undefined, {
+ config: 'limit must be an integer between 1 and 25.',
+ })
+
+ expect(
+ parseErrorTrackingWidgetConfigApiError(error, {
+ limit: 30,
+ orderBy: 'occurrences',
+ dateRange: { date_from: '-7d' },
+ })
+ ).toEqual({
+ limit: 'Must be an integer between 1 and 25.',
+ })
+ })
+})
diff --git a/products/dashboards/frontend/widgets/error_tracking/errorTrackingWidgetConfigValidation.ts b/products/dashboards/frontend/widgets/error_tracking/errorTrackingWidgetConfigValidation.ts
new file mode 100644
index 000000000000..1e945d18c64d
--- /dev/null
+++ b/products/dashboards/frontend/widgets/error_tracking/errorTrackingWidgetConfigValidation.ts
@@ -0,0 +1,94 @@
+import { z, type ZodError } from 'zod'
+
+import { ApiError } from 'lib/api-error'
+
+import {
+ errorTrackingWidgetConfigSchema,
+ errorTrackingWidgetFormSchema,
+ type ErrorTrackingWidgetConfig,
+} from '../../widget_types/configSchemas'
+
+type ErrorTrackingWidgetFormField = keyof z.infer<typeof errorTrackingWidgetFormSchema>
+
+export type ErrorTrackingWidgetFieldErrors = Partial<Record<ErrorTrackingWidgetFormField, string>>
+
+function fieldErrorsFromZodError(error: ZodError): ErrorTrackingWidgetFieldErrors {
+ const { fieldErrors } = z.flattenError(error)
+
+ return Object.fromEntries(
+ (Object.entries(fieldErrors) as [string, string[]][]).flatMap(([field, messages]) =>
+ messages.length > 0 ? [[field, messages[0]]] : []
+ )
+ )
+}
+
+export function parseErrorTrackingWidgetConfig(config: Record<string, unknown>): ErrorTrackingWidgetConfig {
+ const parsed = errorTrackingWidgetConfigSchema.safeParse(config)
+ return parsed.success ? parsed.data : errorTrackingWidgetConfigSchema.parse({})
+}
+
+export function buildErrorTrackingWidgetConfig(
+ formInput: z.infer<typeof errorTrackingWidgetFormSchema>,
+ baseConfig: ErrorTrackingWidgetConfig
+): ErrorTrackingWidgetConfig {
+ return errorTrackingWidgetConfigSchema.parse({
+ ...baseConfig,
+ limit: formInput.limit,
+ orderBy: formInput.orderBy,
+ filterTestAccounts: formInput.filterTestAccounts,
+ dateRange: { date_from: formInput.dateFrom },
+ })
+}
+
+export function validateErrorTrackingWidgetConfigInput(input: {
+ limit: number
+ orderBy: string
+ dateFrom: string
+ filterTestAccounts: boolean
+ baseConfig: ErrorTrackingWidgetConfig
+}):
+ | { success: true; config: ErrorTrackingWidgetConfig }
+ | { success: false; fieldErrors: ErrorTrackingWidgetFieldErrors } {
+ const parsed = errorTrackingWidgetFormSchema.safeParse({
+ limit: input.limit,
+ orderBy: input.orderBy,
+ dateFrom: input.dateFrom,
+ filterTestAccounts: input.filterTestAccounts,
+ })
+
+ if (!parsed.success) {
+ return { success: false, fieldErrors: fieldErrorsFromZodError(parsed.error) }
+ }
+
+ return {
+ success: true,
+ config: buildErrorTrackingWidgetConfig(parsed.data, input.baseConfig),
+ }
+}
+
+export function parseErrorTrackingWidgetConfigApiError(
+ error: unknown,
+ config: Record<string, unknown>
+): ErrorTrackingWidgetFieldErrors | null {
+ if (!(error instanceof ApiError)) {
+ return null
+ }
+
+ const parsedConfig = errorTrackingWidgetConfigSchema.safeParse(config)
+ if (parsedConfig.success) {
+ return null
+ }
+
+ const formInput = {
+ limit: (config.limit as number) ?? 0,
+ orderBy: (config.orderBy as ErrorTrackingWidgetConfig['orderBy']) ?? 'occurrences',
+ dateFrom: (config.dateRange as { date_from?: string } | undefined)?.date_from ?? '-7d',
+ filterTestAccounts: (config.filterTestAccounts as boolean) ?? false,
+ }
+ const parsedForm = errorTrackingWidgetFormSchema.safeParse(formInput)
+ if (!parsedForm.success) {
+ return fieldErrorsFromZodError(parsedForm.error)
+ }
+
+ return fieldErrorsFromZodError(parsedConfig.error)
+}
diff --git a/products/dashboards/frontend/widgets/error_tracking/utils.ts b/products/dashboards/frontend/widgets/error_tracking/utils.ts
new file mode 100644
index 000000000000..e07aec5f7544
--- /dev/null
+++ b/products/dashboards/frontend/widgets/error_tracking/utils.ts
@@ -0,0 +1,19 @@
+export const ERROR_TRACKING_WIDGET_ORDER_BY_OPTIONS = [
+ { value: 'occurrences', label: 'Occurrences' },
+ { value: 'last_seen', label: 'Last seen' },
+ { value: 'first_seen', label: 'First seen' },
+ { value: 'users', label: 'Users' },
+ { value: 'sessions', label: 'Sessions' },
+] as const
+
+/** True when the project can query error tracking issues (matches tile setup prompt gating). */
+export function canConfigureErrorTrackingWidgetIssues(
+ team: { autocapture_exceptions_opt_in?: boolean | null } | null | undefined,
+ hasSentExceptionEvent: boolean | undefined
+): boolean {
+ if (!team) {
+ return false
+ }
+
+ return hasSentExceptionEvent === true || !!team.autocapture_exceptions_opt_in
+}
diff --git a/products/dashboards/frontend/widgets/previews/ErrorTrackingWidgetPreview.tsx b/products/dashboards/frontend/widgets/previews/ErrorTrackingWidgetPreview.tsx
new file mode 100644
index 000000000000..066b7786f28f
--- /dev/null
+++ b/products/dashboards/frontend/widgets/previews/ErrorTrackingWidgetPreview.tsx
@@ -0,0 +1,94 @@
+import { ErrorTrackingIssue } from '~/queries/schema/schema-general'
+
+import { ErrorTrackingIssueList } from 'products/error_tracking/frontend/components/ErrorTrackingIssueList/ErrorTrackingIssueList'
+
+const PREVIEW_ISSUES: ErrorTrackingIssue[] = [
+ {
+ id: 'preview-1',
+ name: 'Checkout API timeout',
+ description:
+ 'Checkout requests occasionally time out while creating a payment session, preventing upgrades from completing.',
+ function: 'fetch',
+ source: 'https://app.hedgebox.test/static/js/api.js',
+ library: 'web',
+ status: 'active',
+ assignee: null,
+ first_seen: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString(),
+ last_seen: new Date(Date.now() - 2 * 60 * 60 * 1000).toISOString(),
+ aggregations: {
+ occurrences: 42,
+ sessions: 18,
+ users: 12,
+ volume_buckets: [
+ { label: new Date(Date.now() - 6 * 24 * 60 * 60 * 1000).toISOString(), value: 2 },
+ { label: new Date(Date.now() - 5 * 24 * 60 * 60 * 1000).toISOString(), value: 4 },
+ { label: new Date(Date.now() - 4 * 24 * 60 * 60 * 1000).toISOString(), value: 3 },
+ { label: new Date(Date.now() - 3 * 24 * 60 * 60 * 1000).toISOString(), value: 8 },
+ { label: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000).toISOString(), value: 12 },
+ { label: new Date(Date.now() - 1 * 24 * 60 * 60 * 1000).toISOString(), value: 6 },
+ { label: new Date().toISOString(), value: 4 },
+ ],
+ },
+ },
+ {
+ id: 'preview-2',
+ name: 'File preview render failure',
+ description:
+ 'Preview rendering fails for some uploaded PDFs, leaving customers unable to inspect files before sharing them.',
+ function: 'renderPreview',
+ source: 'https://app.hedgebox.test/static/js/workers/pdf.js',
+ library: 'web',
+ status: 'active',
+ assignee: null,
+ first_seen: new Date(Date.now() - 14 * 24 * 60 * 60 * 1000).toISOString(),
+ last_seen: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(),
+ aggregations: {
+ occurrences: 18,
+ sessions: 9,
+ users: 7,
+ volume_buckets: [
+ { label: new Date(Date.now() - 6 * 24 * 60 * 60 * 1000).toISOString(), value: 1 },
+ { label: new Date(Date.now() - 5 * 24 * 60 * 60 * 1000).toISOString(), value: 1 },
+ { label: new Date(Date.now() - 4 * 24 * 60 * 60 * 1000).toISOString(), value: 2 },
+ { label: new Date(Date.now() - 3 * 24 * 60 * 60 * 1000).toISOString(), value: 3 },
+ { label: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000).toISOString(), value: 2 },
+ { label: new Date(Date.now() - 1 * 24 * 60 * 60 * 1000).toISOString(), value: 1 },
+ { label: new Date().toISOString(), value: 1 },
+ ],
+ },
+ },
+ {
+ id: 'preview-3',
+ name: 'TypeError: Cannot read properties of undefined',
+ description: 'User profile settings fail to load when the session cache is empty.',
+ function: 'loadProfile',
+ source: 'https://app.hedgebox.test/static/js/settings.js',
+ library: 'web',
+ status: 'pending_release',
+ assignee: null,
+ first_seen: new Date(Date.now() - 21 * 24 * 60 * 60 * 1000).toISOString(),
+ last_seen: new Date(Date.now() - 3 * 24 * 60 * 60 * 1000).toISOString(),
+ aggregations: {
+ occurrences: 9,
+ sessions: 4,
+ users: 3,
+ volume_buckets: [
+ { label: new Date(Date.now() - 6 * 24 * 60 * 60 * 1000).toISOString(), value: 0 },
+ { label: new Date(Date.now() - 5 * 24 * 60 * 60 * 1000).toISOString(), value: 1 },
+ { label: new Date(Date.now() - 4 * 24 * 60 * 60 * 1000).toISOString(), value: 0 },
+ { label: new Date(Date.now() - 3 * 24 * 60 * 60 * 1000).toISOString(), value: 2 },
+ { label: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000).toISOString(), value: 1 },
+ { label: new Date(Date.now() - 1 * 24 * 60 * 60 * 1000).toISOString(), value: 0 },
+ { label: new Date().toISOString(), value: 0 },
+ ],
+ },
+ },
+]
+
+export function ErrorTrackingWidgetPreview(): JSX.Element {
+ return (
+ <div className="pointer-events-none shadow-sm">
+ <ErrorTrackingIssueList issues={PREVIEW_ISSUES} />
+ </div>
+ )
+}
diff --git a/products/dashboards/frontend/widgets/registry.test.tsx b/products/dashboards/frontend/widgets/registry.test.tsx
index b1a060d9f1e8..a3824df802ac 100644
--- a/products/dashboards/frontend/widgets/registry.test.tsx
+++ b/products/dashboards/frontend/widgets/registry.test.tsx
@@ -1,7 +1,7 @@
import posthog from 'posthog-js'
import { DASHBOARD_WIDGET_CATALOG } from '../widget_types/catalog'
-import { getDashboardWidgetDefinition } from './registry'
+import { getDashboardWidgetDefinition, parseDashboardWidgetConfigApiError } from './registry'
import { resetDashboardWidgetRegistryReportingForTests } from './registry'
jest.mock('posthog-js', () => ({
@@ -17,6 +17,20 @@ describe('dashboard widget registry', () => {
resetDashboardWidgetRegistryReportingForTests()
})
+ it('registers error_tracking_list widget', () => {
+ const definition = getDashboardWidgetDefinition('error_tracking_list')
+ expect(definition?.Component).toBeTruthy()
+ expect(definition?.EditModal).toBeTruthy()
+ expect(definition?.productAccess).toBe('error_tracking')
+ expect(definition?.parseConfigApiError).toBeTruthy()
+ expect(posthog.captureException).not.toHaveBeenCalled()
+ })
+
+ it('delegates config api error parsing to the widget registry entry', () => {
+ expect(parseDashboardWidgetConfigApiError('unknown_widget_type', new Error('nope'), {})).toBeNull()
+ expect(parseDashboardWidgetConfigApiError('error_tracking_list', new Error('nope'), {})).toBeNull()
+ })
+
it('registers every catalog key', () => {
for (const key of Object.keys(DASHBOARD_WIDGET_CATALOG)) {
expect(getDashboardWidgetDefinition(key)).not.toBeUndefined()
diff --git a/products/dashboards/frontend/widgets/registry.tsx b/products/dashboards/frontend/widgets/registry.tsx
index 6b3883f45b80..d1e276c4321d 100644
--- a/products/dashboards/frontend/widgets/registry.tsx
+++ b/products/dashboards/frontend/widgets/registry.tsx
@@ -2,12 +2,16 @@ import posthog from 'posthog-js'
import type { ComponentType } from 'react'
import type { DashboardWidgetProductAccess } from '../types'
-import {
- type DashboardWidgetCatalogKey,
- DASHBOARD_WIDGET_TYPE_ALIASES,
- getDashboardWidgetCatalogEntry,
-} from '../widget_types/catalog'
+import { DASHBOARD_WIDGET_CATALOG, type DashboardWidgetCatalogKey } from '../widget_types/catalog'
import type { WidgetAvailabilityConfig } from '../widget_types/widgetAvailability'
+import { EditErrorTrackingWidgetModal } from './error_tracking/EditErrorTrackingWidgetModal'
+import { ErrorTrackingWidget } from './error_tracking/ErrorTrackingWidget'
+import { parseErrorTrackingWidgetConfigApiError } from './error_tracking/errorTrackingWidgetConfigValidation'
+
+export type DashboardWidgetConfigApiErrorParser = (
+ error: unknown,
+ config: Record<string, unknown>
+) => Record<string, string | undefined> | null
export type DashboardWidgetRegistryLookupContext = {
tileId?: number
@@ -30,7 +34,7 @@ function reportMissingDashboardWidgetRegistryEntry(
return
}
- const hasCatalogEntry = getDashboardWidgetCatalogEntry(widgetType) !== undefined
+ const hasCatalogEntry = widgetType in DASHBOARD_WIDGET_CATALOG
const dedupeKey = `${canonicalType}:${hasCatalogEntry ? 'catalog' : 'none'}`
if (reportedMissingRegistryEntries.has(dedupeKey)) {
return
@@ -55,6 +59,8 @@ export type DashboardWidgetDefinition = {
Component: ComponentType<DashboardWidgetComponentProps>
EditModal?: ComponentType<DashboardWidgetEditModalProps>
productAccess?: DashboardWidgetProductAccess
+ /** Maps dashboard PATCH API errors to edit-modal field errors for this widget type. */
+ parseConfigApiError: DashboardWidgetConfigApiErrorParser
/** Fallback when catalog `availability` is unmet; defaults to `WidgetAvailabilitySetupPrompt`. */
unavailableContentFallback?: ComponentType<{ availability: WidgetAvailabilityConfig }>
}
@@ -69,15 +75,19 @@ export type DashboardWidgetComponentProps = {
onUpdateConfig?: (config: Record<string, unknown>) => void | Promise<void>
}
+export type DashboardWidgetMetadataPatch = {
+ name?: string
+ description?: string
+}
+
export type DashboardWidgetEditModalProps = {
isOpen: boolean
onClose: () => void
config: Record<string, unknown>
- onSave: (config: Record<string, unknown>) => void | Promise<void>
+ onSave: (config: Record<string, unknown>, metadata?: DashboardWidgetMetadataPatch) => void | Promise<void>
name?: string
defaultTitle?: string
description?: string
- onSaveMetadata?: (metadata: { name?: string; description?: string }) => void | Promise<void>
}
/**
@@ -85,7 +95,14 @@ export type DashboardWidgetEditModalProps = {
*
* `satisfies Record<DashboardWidgetCatalogKey, …>` fails typecheck if catalog grows without a matching key.
*/
-export const DASHBOARD_WIDGET_REGISTRY: Record<string, DashboardWidgetDefinition> = {}
+export const DASHBOARD_WIDGET_REGISTRY = {
+ error_tracking_list: {
+ Component: ErrorTrackingWidget,
+ EditModal: EditErrorTrackingWidgetModal,
+ productAccess: 'error_tracking',
+ parseConfigApiError: parseErrorTrackingWidgetConfigApiError,
+ },
+} satisfies Record<DashboardWidgetCatalogKey, DashboardWidgetDefinition>
function isDashboardWidgetRegistryKey(widgetType: string): widgetType is DashboardWidgetCatalogKey {
return widgetType in DASHBOARD_WIDGET_REGISTRY
@@ -95,10 +112,17 @@ export function getDashboardWidgetDefinition(
widgetType: string,
context?: DashboardWidgetRegistryLookupContext
): DashboardWidgetDefinition | undefined {
- const canonicalType = DASHBOARD_WIDGET_TYPE_ALIASES[widgetType] ?? widgetType
- if (!isDashboardWidgetRegistryKey(canonicalType)) {
- reportMissingDashboardWidgetRegistryEntry(widgetType, canonicalType, context)
+ if (!isDashboardWidgetRegistryKey(widgetType)) {
+ reportMissingDashboardWidgetRegistryEntry(widgetType, widgetType, context)
return undefined
}
- return DASHBOARD_WIDGET_REGISTRY[canonicalType]
+ return DASHBOARD_WIDGET_REGISTRY[widgetType]
+}
+
+export function parseDashboardWidgetConfigApiError(
+ widgetType: string,
+ error: unknown,
+ config: Record<string, unknown>
+): Record<string, string | undefined> | null {
+ return getDashboardWidgetDefinition(widgetType)?.parseConfigApiError(error, config) ?? null
}
diff --git a/products/error_tracking/backend/api/query_utils.py b/products/error_tracking/backend/api/query_utils.py
index d6766182c702..aa23676ac9b4 100644
--- a/products/error_tracking/backend/api/query_utils.py
+++ b/products/error_tracking/backend/api/query_utils.py
@@ -33,6 +33,9 @@ LIST_ISSUE_FIELDS = [
"aggregations",
]
+# Keep in sync with ERROR_TRACKING_LISTING_RESOLUTION in products/error_tracking/frontend/utils.ts
+ERROR_TRACKING_LISTING_VOLUME_RESOLUTION = 20
+
CONTEXT_EVENT_SELECTS = ["properties.$exception_list", "properties.$exception_releases"]
EVENT_PROPERTY_SELECTS = [
"properties.$exception_types",
diff --git a/products/error_tracking/frontend/components/ErrorTrackingIssueList/ErrorTrackingIssueList.test.tsx b/products/error_tracking/frontend/components/ErrorTrackingIssueList/ErrorTrackingIssueList.test.tsx
new file mode 100644
index 000000000000..09046dae5930
--- /dev/null
+++ b/products/error_tracking/frontend/components/ErrorTrackingIssueList/ErrorTrackingIssueList.test.tsx
@@ -0,0 +1,83 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render, screen } from '@testing-library/react'
+import { Provider } from 'kea'
+
+import { ErrorTrackingIssue } from '~/queries/schema/schema-general'
+import { initKeaTests } from '~/test/init'
+
+import { ErrorTrackingIssueList, ErrorTrackingIssueListRow } from './ErrorTrackingIssueList'
+import { ErrorTrackingIssueListSkeleton } from './ErrorTrackingIssueListSkeleton'
+
+jest.mock('../VolumeSparkline/VolumeSparkline', () => ({
+ VolumeSparkline: (): JSX.Element => <div data-attr="mock-sparkline" />,
+}))
+
+const ISSUE: ErrorTrackingIssue = {
+ id: 'issue-abc',
+ name: 'TypeError: undefined is not a function',
+ description: 'Something broke',
+ library: 'web',
+ status: 'active',
+ assignee: null,
+ first_seen: '2026-05-01T10:00:00.000Z',
+ last_seen: '2026-05-26T08:00:00.000Z',
+ aggregations: {
+ occurrences: 12,
+ sessions: 4,
+ users: 3,
+ volume_buckets: [],
+ },
+}
+
+describe('ErrorTrackingIssueListRow', () => {
+ beforeEach(() => {
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ cleanup()
+ })
+
+ it('links to the error tracking issue page with last_seen timestamp', () => {
+ render(
+ <Provider>
+ <ErrorTrackingIssueListRow issue={ISSUE} />
+ </Provider>
+ )
+
+ const link = screen.getByRole('link', { name: /TypeError: undefined is not a function/i })
+ expect(link.getAttribute('href')).toMatch(
+ /\/error_tracking\/issue-abc\?timestamp=2026-05-26T08%3A00%3A00\.000Z$/
+ )
+ })
+})
+
+describe('ErrorTrackingIssueListSkeleton', () => {
+ it('renders accessible loading state with skeleton rows', () => {
+ const { container } = render(<ErrorTrackingIssueListSkeleton rowCount={3} />)
+
+ expect(screen.getByLabelText('Loading issues')).toHaveAttribute('aria-busy', 'true')
+ expect(container.querySelectorAll('[aria-hidden]').length).toBeGreaterThanOrEqual(3)
+ })
+})
+
+describe('ErrorTrackingIssueList', () => {
+ beforeEach(() => {
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ cleanup()
+ })
+
+ it('renders linked issue rows', () => {
+ render(
+ <Provider>
+ <ErrorTrackingIssueList issues={[ISSUE]} />
+ </Provider>
+ )
+
+ expect(screen.getByRole('link', { name: /TypeError: undefined is not a function/i })).toBeInTheDocument()
+ })
+})
diff --git a/products/error_tracking/frontend/components/ErrorTrackingIssueList/ErrorTrackingIssueList.tsx b/products/error_tracking/frontend/components/ErrorTrackingIssueList/ErrorTrackingIssueList.tsx
new file mode 100644
index 000000000000..6ab34b1a03be
--- /dev/null
+++ b/products/error_tracking/frontend/components/ErrorTrackingIssueList/ErrorTrackingIssueList.tsx
@@ -0,0 +1,147 @@
+import { useMemo } from 'react'
+
+import { Link } from '@posthog/lemon-ui'
+
+import { getRuntimeFromLib } from 'lib/components/Errors/utils'
+import { TZLabel } from 'lib/components/TZLabel'
+import { humanFriendlyLargeNumber } from 'lib/utils'
+import { cn } from 'lib/utils/css-classes'
+import { urls } from 'scenes/urls'
+
+import { ErrorTrackingIssue } from '~/queries/schema/schema-general'
+
+import { useSparklineData } from '../../hooks/use-sparkline-data'
+import { errorTrackingIssueSceneLogic } from '../../scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic'
+import { ERROR_TRACKING_LISTING_RESOLUTION, sourceDisplay } from '../../utils'
+import { AssigneeIconDisplay, AssigneeLabelDisplay, AssigneeResolver } from '../Assignee/AssigneeDisplay'
+import { StatusIndicator } from '../Indicators'
+import { RuntimeIcon } from '../RuntimeIcon'
+import { CustomSeparator } from '../TableColumns'
+import { VolumeSparkline } from '../VolumeSparkline/VolumeSparkline'
+
+/** Issue (flex) + volume sparkline + occurrences count. Fixed side columns so headers fit in dashboard tiles. */
+export const ERROR_TRACKING_ISSUE_LIST_GRID_COLS = 'grid-cols-[minmax(0,1fr)_5.5rem_7rem]' as const
+
+export function ErrorTrackingIssueListHeader(): JSX.Element {
+ return (
+ <div
+ className={cn(
+ 'grid gap-3 border-b border-primary bg-bg-light px-3 py-1.5 text-xs font-semibold uppercase tracking-wide text-muted',
+ ERROR_TRACKING_ISSUE_LIST_GRID_COLS
+ )}
+ >
+ <span>Issue</span>
+ <span className="text-center">Volume</span>
+ <span className="text-center">Occurrences</span>
+ </div>
+ )
+}
+
+function prefetchIssueScene(issue: ErrorTrackingIssue): void {
+ const issueLogic = errorTrackingIssueSceneLogic({
+ id: issue.id,
+ timestamp: issue.last_seen,
+ })
+ issueLogic.mount()
+ issueLogic.actions.setIssue(issue)
+}
+
+export function ErrorTrackingIssueListRow({ issue }: { issue: ErrorTrackingIssue }): JSX.Element {
+ const runtime = getRuntimeFromLib(issue.library)
+ const sparklineKey = issue.id ?? 'issue-unknown'
+ const sparklineData = useSparklineData(issue.aggregations, ERROR_TRACKING_LISTING_RESOLUTION)
+ const occurrences = issue.aggregations?.occurrences ?? 0
+
+ const issueUrl = useMemo(
+ () =>
+ urls.errorTrackingIssue(issue.id, {
+ timestamp: issue.last_seen,
+ }),
+ [issue.id, issue.last_seen]
+ )
+
+ return (
+ <Link
+ to={issueUrl}
+ className={cn(
+ 'grid items-start gap-3 border-b border-primary px-3 py-2 last:border-b-0 text-primary transition-colors hover:bg-fill-button-tertiary-hover',
+ ERROR_TRACKING_ISSUE_LIST_GRID_COLS
+ )}
+ onClick={() => prefetchIssueScene(issue)}
+ >
+ <div className="flex min-w-0 flex-col gap-0.5">
+ <div className="flex items-center gap-2 text-sm">
+ <RuntimeIcon className="shrink-0" runtime={runtime} fontSize="0.75rem" />
+ <span className="line-clamp-1 font-semibold">{issue.name || 'Unknown Type'}</span>
+ </div>
+ {issue.description ? (
+ <div title={issue.description} className="line-clamp-1 text-xs font-medium text-muted">
+ {issue.description}
+ </div>
+ ) : null}
+ {issue.function || issue.source ? (
+ <div className="line-clamp-1 text-xs font-light italic text-secondary">
+ {issue.function}
+ {issue.source ? <> in {sourceDisplay(issue.source)}</> : null}
+ </div>
+ ) : null}
+ <div className="flex items-center gap-1 text-secondary">
+ <StatusIndicator status={issue.status} size="xsmall" className="ml-0 text-xs text-secondary" />
+ <CustomSeparator />
+ <AssigneeResolver assignee={issue.assignee}>
+ {({ assignee }) => (
+ <div className="ml-1 flex items-center text-xs text-secondary">
+ <AssigneeIconDisplay assignee={assignee} size="xsmall" />
+ <AssigneeLabelDisplay
+ assignee={assignee}
+ className="ml-1 text-xs text-secondary"
+ size="xsmall"
+ placeholder="Unassigned"
+ />
+ </div>
+ )}
+ </AssigneeResolver>
+ <CustomSeparator />
+ {issue.last_seen ? (
+ <TZLabel time={issue.last_seen} className="ml-1 border-b border-dotted text-xs" delayMs={750} />
+ ) : null}
+ </div>
+ </div>
+ <div className="flex min-w-0 flex-col justify-center pt-1">
+ <div className="h-8 min-h-8 w-full">
+ <VolumeSparkline
+ className="h-full"
+ data={sparklineData}
+ layout="compact"
+ xAxis="minimal"
+ sparklineKey={sparklineKey}
+ />
+ </div>
+ </div>
+ <div className="pt-1 text-center text-base font-medium tabular-nums">
+ {humanFriendlyLargeNumber(occurrences)}
+ </div>
+ </Link>
+ )
+}
+
+type ErrorTrackingIssueListProps = {
+ issues: ErrorTrackingIssue[]
+ className?: string
+ listClassName?: string
+}
+
+export function ErrorTrackingIssueList({ issues, className, listClassName }: ErrorTrackingIssueListProps): JSX.Element {
+ return (
+ <div className={cn('min-w-0 w-full max-w-full overflow-x-auto rounded border bg-surface-primary', className)}>
+ <div className="w-full min-w-0">
+ <ErrorTrackingIssueListHeader />
+ <div className={listClassName} data-attr="error-tracking-issue-row">
+ {issues.map((issue) => (
+ <ErrorTrackingIssueListRow key={issue.id} issue={issue} />
+ ))}
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/products/error_tracking/frontend/components/ErrorTrackingIssueList/ErrorTrackingIssueListSkeleton.tsx b/products/error_tracking/frontend/components/ErrorTrackingIssueList/ErrorTrackingIssueListSkeleton.tsx
new file mode 100644
index 000000000000..071694528c6d
--- /dev/null
+++ b/products/error_tracking/frontend/components/ErrorTrackingIssueList/ErrorTrackingIssueListSkeleton.tsx
@@ -0,0 +1,64 @@
+import { LemonSkeleton } from '@posthog/lemon-ui'
+
+import { cn } from 'lib/utils/css-classes'
+
+import { ErrorTrackingIssueListHeader, ERROR_TRACKING_ISSUE_LIST_GRID_COLS } from './ErrorTrackingIssueList'
+
+function ErrorTrackingIssueListSkeletonRow(): JSX.Element {
+ return (
+ <div
+ className={cn(
+ 'grid items-start gap-3 border-b border-primary px-3 py-2 last:border-b-0',
+ ERROR_TRACKING_ISSUE_LIST_GRID_COLS
+ )}
+ aria-hidden
+ >
+ <div className="flex min-w-0 flex-col gap-1.5">
+ <div className="flex items-center gap-2">
+ <LemonSkeleton className="h-3.5 w-3.5 shrink-0 rounded-sm" />
+ <LemonSkeleton className="h-3.5 w-[72%] max-w-md" />
+ </div>
+ <LemonSkeleton className="h-3 w-[88%] max-w-lg" />
+ <LemonSkeleton className="h-2.5 w-[55%] max-w-xs" />
+ <div className="flex items-center gap-2 pt-0.5">
+ <LemonSkeleton className="h-3 w-14" />
+ <LemonSkeleton className="h-3 w-20" />
+ <LemonSkeleton className="h-3 w-16" />
+ </div>
+ </div>
+ <div className="flex min-w-0 flex-col justify-center pt-1">
+ <LemonSkeleton className="h-8 w-full" />
+ </div>
+ <div className="flex justify-center pt-1">
+ <LemonSkeleton className="h-5 w-10" />
+ </div>
+ </div>
+ )
+}
+
+type ErrorTrackingIssueListSkeletonProps = {
+ rowCount?: number
+ className?: string
+}
+
+export function ErrorTrackingIssueListSkeleton({
+ rowCount = 5,
+ className,
+}: ErrorTrackingIssueListSkeletonProps): JSX.Element {
+ return (
+ <div
+ className={cn('min-w-0 w-full max-w-full overflow-x-auto rounded border bg-surface-primary', className)}
+ aria-busy
+ aria-label="Loading issues"
+ >
+ <div className="w-full min-w-0">
+ <ErrorTrackingIssueListHeader />
+ <div>
+ {Array.from({ length: rowCount }, (_, index) => (
+ <ErrorTrackingIssueListSkeletonRow key={index} />
+ ))}
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/products/error_tracking/frontend/components/SetupPrompt/SetupPrompt.tsx b/products/error_tracking/frontend/components/SetupPrompt/SetupPrompt.tsx
index d4c649c54d49..de42b1065b18 100644
--- a/products/error_tracking/frontend/components/SetupPrompt/SetupPrompt.tsx
+++ b/products/error_tracking/frontend/components/SetupPrompt/SetupPrompt.tsx
@@ -1,11 +1,16 @@
import { useActions, useValues } from 'kea'
+import type { ComponentType } from 'react'
import { LemonButton, Link, Spinner } from '@posthog/lemon-ui'
import { WarningHog } from 'lib/components/hedgehogs'
-import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'
+import {
+ ProductIntroduction,
+ type ProductIntroductionProps,
+} from 'lib/components/ProductIntroduction/ProductIntroduction'
import { RestrictionScope, useRestrictedArea } from 'lib/components/RestrictedArea'
import { TeamMembershipLevel } from 'lib/constants'
+import { cn } from 'lib/utils/css-classes'
import androidImage from 'scenes/onboarding/sdks/logos/android.svg'
import flutterImage from 'scenes/onboarding/sdks/logos/flutter.svg'
import javascriptImage from 'scenes/onboarding/sdks/logos/javascript_web.svg'
@@ -19,7 +24,7 @@ import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-genera
import { exceptionIngestionLogic } from './exceptionIngestionLogic'
-const FRAMEWORK_LINKS: { name: string; image?: string; docsLink: string }[] = [
+export const ERROR_TRACKING_FRAMEWORK_LINKS: { name: string; image?: string; docsLink: string }[] = [
{
name: 'JavaScript',
image: javascriptImage,
@@ -56,13 +61,29 @@ export const ErrorTrackingSetupPrompt = ({
<Spinner />
</div>
) : !hasSentExceptionEvent && !exceptionAutocaptureEnabled ? (
- <IngestionStatusCheck className={className} />
+ <ErrorTrackingIngestionPrompt className={className} />
) : (
<>{children}</>
)
}
-const IngestionStatusCheck = ({ className }: { className?: string }): JSX.Element | null => {
+export type ErrorTrackingIngestionPromptProps = {
+ className?: string
+ /** Passed to `IntroductionComponent` (e.g. `WidgetCardProductIntroduction--stacked`). */
+ introductionClassName?: string
+ /** When true, passed through to `WidgetCardProductIntroduction` for always-vertical layout. */
+ introductionStacked?: boolean
+ IntroductionComponent?: ComponentType<ProductIntroductionProps>
+ actionElementClassName?: string
+}
+
+export function ErrorTrackingIngestionPrompt({
+ className,
+ introductionClassName,
+ introductionStacked,
+ IntroductionComponent = ProductIntroduction,
+ actionElementClassName = 'flex flex-col items-start gap-4',
+}: ErrorTrackingIngestionPromptProps): JSX.Element {
const { addProductIntent, updateCurrentTeam } = useActions(teamLogic)
const restrictionReason = useRestrictedArea({
minimumAccessLevel: TeamMembershipLevel.Admin,
@@ -77,18 +98,19 @@ const IngestionStatusCheck = ({ className }: { className?: string }): JSX.Elemen
}
return (
- <ProductIntroduction
+ <IntroductionComponent
productName="Error tracking"
thingName="issue"
titleOverride="You haven't captured any exceptions"
description="PostHog captures exceptions from any of our SDKs. JavaScript apps can flip on exception autocapture; other platforms wire it up in code – the docs have per-SDK instructions."
isEmpty={true}
productKey={ProductKey.ERROR_TRACKING}
- className={className}
+ className={cn(introductionClassName, className)}
+ {...(introductionStacked !== undefined ? { stacked: introductionStacked } : {})}
mcpSurfaceKey="error_tracking.assign"
customHog={WarningHog}
actionElementOverride={
- <div className="flex flex-col items-start gap-4">
+ <div className={actionElementClassName}>
<p className="text-sm text-secondary m-0">
Read our{' '}
<Link to="https://posthog.com/docs/error-tracking" onClick={onDocsLinkClick}>
@@ -97,7 +119,7 @@ const IngestionStatusCheck = ({ className }: { className?: string }): JSX.Elemen
, or pick a framework to get started:
</p>
<div className="flex flex-wrap gap-2">
- {FRAMEWORK_LINKS.map(({ name, image, docsLink }) => (
+ {ERROR_TRACKING_FRAMEWORK_LINKS.map(({ name, image, docsLink }) => (
<LemonButton
key={name}
type="secondary"