🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(web): instrument filter sidebar expand usage (#16769)
Trang Nguyen65d6230edcae
diff --git a/web/src/components/table/data-table-controls.clienttest.tsx b/web/src/components/table/data-table-controls.clienttest.tsxindex 87b2f8dfc3..186ef8b0dd 100644--- a/web/src/components/table/data-table-controls.clienttest.tsx+++ b/web/src/components/table/data-table-controls.clienttest.tsx@@ -629,6 +629,8 @@ describe("DataTableControls facet ordering", () => {categoricalFilter("beta", "Beta", true),]);qf.onExpandedChange = (value) => expandedChanges.push(value);+ qf.isV4 = true;+ captureSpy.mockClear();render(<TooltipProvider><DataTableControls queryFilter={qf} />@@ -638,6 +640,94 @@ describe("DataTableControls facet ordering", () => {// Nothing expanded -> the toggle offers Expand all with every column.fireEvent.click(screen.getByRole("button", { name: "Expand all filters" }));expect(expandedChanges.at(-1)).toEqual(["beta", "alpha"]);++ const expandAll = captureSpy.mock.calls.filter(+ ([event]) => event === "filters:expand_all_toggled",+ );+ expect(expandAll).toHaveLength(1);+ expect(expandAll[0][1]).toMatchObject({+ expanded: true,+ facetCount: 2,+ layout: "panel",+ isV4: true,+ });+ // Expand-all is its own intent; it must not also emit per-facet toggles.+ expect(+ captureSpy.mock.calls.filter(+ ([event]) => event === "filters:facet_toggled",+ ),+ ).toHaveLength(0);+ for (const [, payload] of captureSpy.mock.calls) {+ expect(JSON.stringify(payload ?? {})).not.toContain('"x"');+ }+ });++ it("captures expand_all_toggled collapsed when every visible facet is open", () => {+ const qf = queryFilter([+ categoricalFilter("alpha", "Alpha", false),+ categoricalFilter("beta", "Beta", true),+ ]);+ qf.expanded = ["alpha", "beta"];+ qf.isV4 = false;+ captureSpy.mockClear();+ render(+ <TooltipProvider>+ <DataTableControls queryFilter={qf} />+ </TooltipProvider>,+ );++ fireEvent.click(+ screen.getByRole("button", { name: "Collapse all filters" }),+ );+ const expandAll = captureSpy.mock.calls.filter(+ ([event]) => event === "filters:expand_all_toggled",+ );+ expect(expandAll).toHaveLength(1);+ expect(expandAll[0][1]).toMatchObject({+ expanded: false,+ facetCount: 2,+ layout: "panel",+ isV4: false,+ });+ expect(+ captureSpy.mock.calls.filter(+ ([event]) => event === "filters:facet_toggled",+ ),+ ).toHaveLength(0);+ });++ it("captures facet_toggled once when a single header is opened", () => {+ const qf = queryFilter([+ categoricalFilter("alpha", "Alpha", false),+ categoricalFilter("beta", "Beta", true),+ ]);+ qf.isV4 = true;+ captureSpy.mockClear();+ render(+ <TooltipProvider>+ <DataTableControls queryFilter={qf} />+ </TooltipProvider>,+ );++ fireEvent.click(screen.getByRole("button", { name: "Alpha All" }));+ const toggled = captureSpy.mock.calls.filter(+ ([event]) => event === "filters:facet_toggled",+ );+ expect(toggled).toHaveLength(1);+ expect(toggled[0][1]).toMatchObject({+ column: "alpha",+ expanded: true,+ layout: "panel",+ isV4: true,+ });+ expect(+ captureSpy.mock.calls.filter(+ ([event]) => event === "filters:expand_all_toggled",+ ),+ ).toHaveLength(0);+ for (const [, payload] of captureSpy.mock.calls) {+ expect(JSON.stringify(payload ?? {})).not.toContain('"x"');+ }});it("shows only active facets plus an Add filter picker when active-only mode is on", () => {diff --git a/web/src/components/table/data-table-controls.tsx b/web/src/components/table/data-table-controls.tsxindex 7b8ea198d0..adf7a2b597 100644--- a/web/src/components/table/data-table-controls.tsx+++ b/web/src/components/table/data-table-controls.tsx@@ -728,7 +728,23 @@ export function DataTableControls({type="multiple"className="w-full"value={queryFilter.expanded}- onValueChange={queryFilter.onExpandedChange}+ onValueChange={(next) => {+ const prev = queryFilter.expanded;+ queryFilter.onExpandedChange(next);+ // One header click changes exactly one column. Expand-all, add+ // filter, and AI apply call onExpandedChange directly and skip+ // this handler, so they do not double-count as facet toggles.+ const added = next.filter((column) => !prev.includes(column));+ const removed = prev.filter((column) => !next.includes(column));+ if (added.length + removed.length !== 1) return;+ capture("filters:facet_toggled", {+ tableName,+ column: added[0] ?? removed[0],+ expanded: added.length === 1,+ layout,+ isV4: queryFilter.isV4 ?? false,+ });+ }}>{/* ONE keyed child array — not two .map() slices: React canonly match keys within the same array, so a facet crossing@@ -1026,9 +1042,10 @@ export function DataTableControls({variant="ghost"size="icon"className="h-6 w-6"- onClick={() =>+ onClick={() => {+ const expanded = expandedVisibleCount === 0;queryFilter.onExpandedChange(- expandedVisibleCount === 0+ expanded? [...new Set([...queryFilter.expanded,@@ -1038,8 +1055,15 @@ export function DataTableControls({: queryFilter.expanded.filter((column) => !visibleColumns.has(column),),- )- }+ );+ capture("filters:expand_all_toggled", {+ tableName,+ expanded,+ facetCount: visibleFilters.length,+ layout,+ isV4: queryFilter.isV4 ?? false,+ });+ }}aria-label={expandedVisibleCount === 0? "Expand all filters"diff --git a/web/src/features/posthog-analytics/usePostHogClientCapture.ts b/web/src/features/posthog-analytics/usePostHogClientCapture.tsindex 11ea82c25b..ca1e7f6b81 100644--- a/web/src/features/posthog-analytics/usePostHogClientCapture.ts+++ b/web/src/features/posthog-analytics/usePostHogClientCapture.ts@@ -414,6 +414,8 @@ const events = {"facet_added","facet_search","facet_mode_switched",+ "expand_all_toggled",+ "facet_toggled","sidebar_toggled","search_submitted","search_error",