πͺ’ 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(analytics): instrument filter/search-bar usage with PostHog (LFE-10781) (#14929)
Nikita Kabardin207f0e6b538f
diff --git a/web/src/components/session/index.tsx b/web/src/components/session/index.tsxindex 3ca6ad129c..a4d5a1ea01 100644--- a/web/src/components/session/index.tsx+++ b/web/src/components/session/index.tsx@@ -1183,6 +1183,10 @@ const LoadedSessionEventsPage: React.FC<{onChange={queryFilter.setFilterState}columnsWithCustomSelect={filterColumnsWithCustomSelect}label="Filter observations"+ // Analytics (LFE-10781): session-detail observation refinement is a+ // v3/legacy surface (the v4 events table filters via the grammar bar).+ tableName="session-detail"+ isV4={false}/>{/* Separator */}diff --git a/web/src/components/table/data-table-toolbar.tsx b/web/src/components/table/data-table-toolbar.tsxindex c9f2e48e35..8cd609761c 100644--- a/web/src/components/table/data-table-toolbar.tsx+++ b/web/src/components/table/data-table-toolbar.tsx@@ -9,7 +9,7 @@ import {type ColumnDefinition,type OrderByState,type TableViewPresetState,- type TableViewPresetTableName,+ TableViewPresetTableName,type TracingSearchType,} from "@langfuse/shared";import {@@ -147,6 +147,11 @@ interface DataTableToolbarProps<TData, TValue> {};orderByState?: OrderByState;viewConfig?: TableViewConfig;+ /** Analytics table identity (LFE-10781) for the popover filter builder's+ * `filters:applied`/`filters:cleared` events. Tables with a `viewConfig`+ * already supply it via `viewConfig.tableName`; tables WITHOUT one (users,+ * dataset runs/items) must pass this so the event isn't labeled "unknown". */+ tableName?: string;filterWithAI?: boolean;className?: string;rowClassName?: string;@@ -219,6 +224,7 @@ export function DataTableToolbar<TData, TValue>({rowClassName,orderByState,viewConfig,+ tableName,filterWithAI = false,viewModeToggle,leadingControls,@@ -469,6 +475,18 @@ export function DataTableToolbar<TData, TValue>({onChange={setFilterState}columnsWithCustomSelect={columnsWithCustomSelect}filterWithAI={filterWithAI}+ // Analytics (LFE-10781): the table's own identity, so popover+ // filters:applied/cleared events aren't mislabeled "unknown". Prefer+ // an explicit `tableName` (tables without a viewConfig β users,+ // dataset runs/items), else the view's table. The v4 events table+ // filters via the grammar bar (it omits filterColumnDefinition here,+ // so this popover is a v3/legacy surface); derive isV4 from the+ // ObservationsEvents view for consistency + future-proofing.+ tableName={tableName ?? viewConfig?.tableName ?? "unknown"}+ isV4={+ viewConfig?.tableName ===+ TableViewPresetTableName.ObservationsEvents+ }/>)}diff --git a/web/src/components/table/table-view-presets/components/data-table-view-presets-drawer.tsx b/web/src/components/table/table-view-presets/components/data-table-view-presets-drawer.tsxindex 5154408bb7..5830a0ddfa 100644--- a/web/src/components/table/table-view-presets/components/data-table-view-presets-drawer.tsx+++ b/web/src/components/table/table-view-presets/components/data-table-view-presets-drawer.tsx@@ -144,7 +144,13 @@ interface TableViewPresetsDrawerProps {* shared-link visit where the view is intentionally not applied). */appliedViewId: string | null;handleSetViewId: (viewId: string | null) => void;- applyViewState: (viewData: TableViewPresetState) => void;+ applyViewState: (+ viewData: TableViewPresetState,+ meta?: {+ trigger: "select" | "permalink" | "default" | "system_preset";+ viewId?: string | null;+ },+ ) => void;};};currentState: {@@ -267,7 +273,7 @@ export function TableViewPresetsDrawer({});handleSetViewId(view.id);- applyViewState(view);+ applyViewState(view, { trigger: "select", viewId: view.id });};const handleSelectSystemFilterPreset = useCallback(@@ -277,7 +283,10 @@ export function TableViewPresetsDrawer({presetId: preset.id,});handleSetViewId(preset.id);- applyViewState(buildSystemFilterPresetState(preset));+ applyViewState(buildSystemFilterPresetState(preset), {+ trigger: "system_preset",+ viewId: preset.id,+ });},[capture, tableName, handleSetViewId, applyViewState],);diff --git a/web/src/components/table/table-view-presets/hooks/useTableViewManager.ts b/web/src/components/table/table-view-presets/hooks/useTableViewManager.tsindex ec7347b600..f49ec75466 100644--- a/web/src/components/table/table-view-presets/hooks/useTableViewManager.ts+++ b/web/src/components/table/table-view-presets/hooks/useTableViewManager.ts@@ -20,6 +20,26 @@ import { validateOrderBy, validateFilters } from "../validation";import { isSystemPresetId } from "../components/data-table-view-presets-drawer";import type { FilterStateMigration } from "@/src/features/filters/lib/filter-config";+/** How a saved view / preset apply was initiated β the `trigger` analytics+ * dimension on `saved_views:applied` (LFE-10781). `system_preset_cleared` is a+ * v4 category-chip toggle-off (applies the cleared/default state). */+export type SavedViewApplyTrigger =+ | "select"+ | "permalink"+ | "default"+ | "system_preset"+ | "system_preset_cleared";++export type SavedViewApplyMeta = {+ trigger: SavedViewApplyTrigger;+ viewId?: string | null;+};++export type ApplyViewStateFn = (+ viewData: TableViewPresetState,+ meta?: SavedViewApplyMeta,+) => void;+interface TableStateUpdaters {setColumnOrder: (columnOrder: string[]) => void;setColumnVisibility: (columnVisibility: VisibilityState) => void;@@ -254,9 +274,13 @@ export function useTableViewManager({setSelectedViewId,]);+ // v4 fast-mode surface iff this manager drives the events table. Drives the+ // `isV4` dimension on `saved_views:applied` (LFE-10781).+ const isV4 = tableName === TableViewPresetTableName.ObservationsEvents;+// Method to apply state from a viewconst applyViewState = useCallback(- (viewData: TableViewPresetState) => {+ (viewData: TableViewPresetState, meta?: SavedViewApplyMeta) => {// lock tablesetIsLoading(true);@@ -364,8 +388,25 @@ export function useTableViewManager({// synchronous and the URL becomes the source of truth for the applied// filters on the same render. Unlock deterministically here instead.setIsLoading(false);++ // Analytics (LFE-10781): a saved view / preset was applied. METADATA ONLY+ // β we send the view id + filter COUNT, never the filter values. Fires for+ // every apply path, including the programmatic default/session restore the+ // drawer's own captures miss. `trigger` classifies the entry point.+ if (meta) {+ capture("saved_views:applied", {+ tableName,+ viewId: meta.viewId ?? null,+ trigger: meta.trigger,+ filterCount: validFilters.length,+ isV4,+ });+ }},[+ capture,+ tableName,+ isV4,setColumnOrder,setColumnVisibility,validationContext,@@ -424,6 +465,14 @@ export function useTableViewManager({return;}+ // Wait for the default-view query to resolve before applying, so the+ // trigger is classified correctly. `getDefault` and `getById` race with no+ // ordering; if `getById` wins (cold cache, a bookmark of the default view,+ // session-restore), `defaultViewId` is still undefined here and a+ // default-view restore would be mislabeled `permalink` β permanently, since+ // the `isInitializedRef` guard makes this a one-shot (LFE-10781 review).+ if (isDefaultLoading) return;+// Track permalink visitcapture("saved_views:permalink_visit", {tableName,@@ -431,7 +480,14 @@ export function useTableViewManager({name: selectedViewData.name,});- applyViewState(selectedViewData);+ // This single programmatic-restore effect covers URL permalinks, session+ // restore, and the resolved default view. Classify as "default" when the+ // applied view is the resolved default, else treat as a "permalink"+ // (deep-link / session-restore) entry (LFE-10781).+ applyViewState(selectedViewData, {+ trigger: requestedViewId === defaultViewId ? "default" : "permalink",+ viewId: requestedViewId,+ });if (storedViewId !== requestedViewId) {setStoredViewId(requestedViewId);}@@ -449,6 +505,8 @@ export function useTableViewManager({applyViewState,storedViewId,setStoredViewId,+ defaultViewId,+ isDefaultLoading,]);useEffect(() => {diff --git a/web/src/features/datasets/components/DatasetItemsTable.tsx b/web/src/features/datasets/components/DatasetItemsTable.tsxindex d54902e2b9..8ed67d1e14 100644--- a/web/src/features/datasets/components/DatasetItemsTable.tsx+++ b/web/src/features/datasets/components/DatasetItemsTable.tsx@@ -392,6 +392,7 @@ export function DatasetItemsTable({<><DataTableToolbarcolumns={columns}+ tableName="dataset-items"filterColumnDefinition={datasetItemFilterColumns}filterState={filterState}setFilterState={setFilterStateWithDebounce}diff --git a/web/src/features/datasets/components/DatasetRunAggregateColumnHelpers.tsx b/web/src/features/datasets/components/DatasetRunAggregateColumnHelpers.tsxindex 9c5f459220..f396cf9f3c 100644--- a/web/src/features/datasets/components/DatasetRunAggregateColumnHelpers.tsx+++ b/web/src/features/datasets/components/DatasetRunAggregateColumnHelpers.tsx@@ -144,6 +144,10 @@ function RunAggregateHeader({onChange={(filters: FilterState) =>debouncedUpdateRunFilters(runId, filters)}+ // Analytics (LFE-10781): per-run filtering in the dataset-run compare+ // view β a v3/legacy surface (not the v4 events table).+ tableName="dataset-runs-compare"+ isV4={false}/><BaselineToggle runId={runId} /></div>diff --git a/web/src/features/datasets/components/DatasetRunItemsByRunTable.tsx b/web/src/features/datasets/components/DatasetRunItemsByRunTable.tsxindex 3f9ec16446..22f1cd8f12 100644--- a/web/src/features/datasets/components/DatasetRunItemsByRunTable.tsx+++ b/web/src/features/datasets/components/DatasetRunItemsByRunTable.tsx@@ -279,6 +279,7 @@ export function DatasetRunItemsByRunTable(props: {<><DataTableToolbarcolumns={columns}+ tableName="dataset-run-items"filterColumnDefinition={transformedFilterOptions}filterState={userFilterState}setFilterState={setFilterState}diff --git a/web/src/features/datasets/components/DatasetRunsTable.tsx b/web/src/features/datasets/components/DatasetRunsTable.tsxindex c4783521c9..76db5ed64d 100644--- a/web/src/features/datasets/components/DatasetRunsTable.tsx+++ b/web/src/features/datasets/components/DatasetRunsTable.tsx@@ -708,6 +708,7 @@ export function DatasetRunsTable(props: {><DataTableToolbarcolumns={columns}+ tableName="dataset-runs"filterColumnDefinition={transformedFilterOptions}filterState={userFilterState}setFilterState={setFilterState}@@ -773,6 +774,7 @@ export function DatasetRunsTable(props: {<><DataTableToolbarcolumns={columns}+ tableName="dataset-runs"filterColumnDefinition={transformedFilterOptions}filterState={userFilterState}setFilterState={setFilterState}diff --git a/web/src/features/events/components/CategoryPresetChips.tsx b/web/src/features/events/components/CategoryPresetChips.tsxindex 5f6f4237d9..ab5ca47334 100644--- a/web/src/features/events/components/CategoryPresetChips.tsx+++ b/web/src/features/events/components/CategoryPresetChips.tsx@@ -63,8 +63,21 @@ type CategoryPresetChipsProps = {activeViewId: string | null;/** Sets `?viewId` (deep-link/provenance); pass null to deselect. */onApplyView: (viewId: string | null) => void;- /** Applies the preset's filters/orderBy to the live table. */- applyViewState: (viewData: TableViewPresetState) => void;+ /** Applies the preset's filters/orderBy to the live table. Accepts the+ * analytics `meta` (LFE-10781) so chip applies/toggle-offs emit+ * `saved_views:applied` β the capture is gated on `meta` being passed. */+ applyViewState: (+ viewData: TableViewPresetState,+ meta?: {+ trigger:+ | "select"+ | "permalink"+ | "default"+ | "system_preset"+ | "system_preset_cleared";+ viewId?: string | null;+ },+ ) => void;/*** Non-destructive preview of a preset's filters in the search bar while* hovering/focusing its row; pass null to restore. No-op when the search bar@@ -285,8 +298,18 @@ export function CategoryPresetChips({const next = isPresetActive ? null : preset.id;outcomeRef.current = next ? "applied" : "cleared";onApplyView(next);+ // Pass analytics meta so the chip apply / toggle-off+ // emits `saved_views:applied` (LFE-10781): applying a+ // preset is a "system_preset" trigger; toggling it off+ // applies the cleared/default state.applyViewState(next ? preset.state : CLEARED_VIEW_STATE,+ {+ trigger: next+ ? "system_preset"+ : "system_preset_cleared",+ viewId: next,+ },);capture("saved_views:category_chip_apply", {category,diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsxindex 6cbfc41037..ddde37ea5c 100644--- a/web/src/features/events/components/EventsTable.tsx+++ b/web/src/features/events/components/EventsTable.tsx@@ -444,6 +444,8 @@ export default function ObservationsEventsTable({loading: isFilterOptionsPending,loadingColumns,implicitDefaultConfig: DEFAULT_SIDEBAR_IMPLICIT_ENVIRONMENT_CONFIG,+ // v4 fast-mode surface β drives `isV4` on filters:* analytics (LFE-10781).+ isV4: true,};if (peekContext) {@@ -541,6 +543,7 @@ export default function ObservationsEventsTable({applyFilters: searchBarApplyFilters,} = useEventsSearchBar({projectId,+ tableName: eventsFilterConfig.tableName,enabled: searchBarMode,filterState: queryFilter.explicitFilterState,searchQuery,@@ -1700,6 +1703,7 @@ export default function ObservationsEventsTable({{searchBarMode && (<EventsSearchBarRowprojectId={projectId}+ tableName={eventsFilterConfig.tableName}store={searchBarStore}commit={searchBarCommit}observed={observedOptions}diff --git a/web/src/features/filters/components/filter-builder.tsx b/web/src/features/filters/components/filter-builder.tsxindex a5a1acb447..c7069c156e 100644--- a/web/src/features/filters/components/filter-builder.tsx+++ b/web/src/features/filters/components/filter-builder.tsx@@ -88,6 +88,8 @@ export function PopoverFilterBuilder({filterWithAI = false,buttonType = "default",label = "Filters",+ tableName = "unknown",+ isV4 = false,}: {/** Which column field to persist in filter.column: 'id' for stable refs, 'name' for legacy compatibility */columns: ColumnDefinitionWithAlert[];@@ -101,10 +103,18 @@ export function PopoverFilterBuilder({buttonType?: "default" | "icon";/** Trigger button label. Defaults to "Filters"; override to clarify scope. */label?: string;+ /** Table this builder filters β the `tableName` analytics dimension. */+ tableName?: string;+ /** Whether this builder sits on a v4 (fast-mode) surface β `isV4` dimension. */+ isV4?: boolean;}) {const capture = usePostHogClientCapture();const [wipFilterState, _setWipFilterState] =useState<WipFilterState>(filterState);+ // Count of already-applied (valid) filters, so `setWipFilterState` can emit+ // `filters:applied` only when a filter is newly completed β not on every+ // keystroke of an in-progress edit. Seeded from the incoming applied state.+ const prevValidCountRef = useRef(filterState.length);// Sync wipFilterState when filterState prop changes externally// (e.g., when a saved view preset is applied)@@ -121,7 +131,15 @@ export function PopoverFilterBuilder({(f) => !singleFilter.safeParse(f).success,);// Don't sync if user is actively editing (has invalid WIP filters)- return hasWipFilters ? currentWip : filterState;+ if (hasWipFilters) return currentWip;+ // Synced from external state (saved view applied, URL nav, clear-all): the+ // commit bypasses the wrapped `setWipFilterState`, so re-baseline the+ // applied-count ref here too (LFE-10781). Otherwise a stale count makes the+ // next wrapper edit β including popover close β mis-fire `filters:applied`.+ // `filterState` is already-valid (typed FilterState), so its length is the+ // valid count.+ prevValidCountRef.current = filterState.length;+ return filterState;});}, [filterState]);@@ -152,6 +170,49 @@ export function PopoverFilterBuilder({const newState = state instanceof Function ? state(prev) : state;const validFilters = getValidFilters(newState);onChange(validFilters);+ const prevCount = prevValidCountRef.current;+ // A row was actually removed (clear-all X β []; or a single row X). This+ // is the ONLY thing that counts as a clear: a valid count that drops+ // because a row went transiently invalid mid-edit (changing a row's column+ // sets value:undefined β fails safeParse) keeps the SAME row count and+ // must NOT emit `filters:cleared` β the user is refining, not clearing+ // (LFE-10781 review).+ const rowsRemoved = newState.length < prev.length;+ // Analytics (LFE-10781). METADATA ONLY β we report the changed filter's+ // shape + counts, never a raw value. Count semantics match the sidebar:+ // `conditionCount` = TOTAL applied conditions across ALL columns;+ // `columnConditionCount` = rows for the changed column.+ if (validFilters.length > prevCount) {+ // A filter was newly completed (valid count grew) β an in-progress edit+ // does not fire per keystroke.+ const applied = validFilters[validFilters.length - 1];+ if (applied) {+ capture("filters:applied", {+ surface: "filter_builder",+ tableName,+ column: applied.column,+ filterType: applied.type,+ operator: applied.operator,+ ...("key" in applied && applied.key ? { key: applied.key } : {}),+ valueCount: Array.isArray(applied.value) ? applied.value.length : 1,+ conditionCount: validFilters.length,+ columnConditionCount: validFilters.filter(+ (f) => f.column === applied.column,+ ).length,+ isV4,+ });+ }+ } else if (validFilters.length < prevCount && rowsRemoved) {+ // A real clear β the clear-all X buttons (setWipFilterState([])) or+ // removing a row. NOT a transient mid-column-change invalid shrink.+ capture("filters:cleared", {+ surface: "filter_builder",+ tableName,+ clearedCount: prevCount - validFilters.length,+ isV4,+ });+ }+ prevValidCountRef.current = validFilters.length;return newState;});};@@ -167,8 +228,11 @@ export function PopoverFilterBuilder({if (open && filterState.length === 0) addNewFilter();// Discard all wip filters when closing popoverif (!open) {+ // METADATA ONLY (LFE-10781): previously sent the full `filterState`,+ // which leaked raw filter VALUES (user ids, metadata content, free+ // text = PII) into PostHog. Send only the applied-filter count.capture("table:filter_builder_close", {- filter: filterState,+ filterCount: filterState.length,});setWipFilterState(filterState);}diff --git a/web/src/features/filters/hooks/useSidebarFilterState.tsx b/web/src/features/filters/hooks/useSidebarFilterState.tsxindex 03c0ccfc49..6e4855dbb0 100644--- a/web/src/features/filters/hooks/useSidebarFilterState.tsx+++ b/web/src/features/filters/hooks/useSidebarFilterState.tsx@@ -1,5 +1,5 @@import type React from "react";-import { useCallback, useMemo, useEffect, useState } from "react";+import { useCallback, useMemo, useEffect, useRef, useState } from "react";import {StringParam,useQueryParam,@@ -34,6 +34,7 @@ import { useKeyedSessionStorageState } from "./useKeyedSessionStorageState";import useSessionStorage from "@/src/components/useSessionStorage";import type { FilterConfig, FilterStateMigration } from "../lib/filter-config";import type { PeekTableStateContextValue } from "@/src/components/table/peek/contexts/PeekTableStateContext";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";/*** Decodes filters from URL query string and normalizes display names to column IDs.@@ -373,6 +374,14 @@ type BaseUseSidebarFilterStateOptions = {* columns that are not server-enumerated (e.g. metadata).*/loadingColumns?: ReadonlySet<string>;+ /**+ * Whether this sidebar is rendered on a v4 (fast-mode / events-table) surface.+ * Drives the `isV4` dimension on the `filters:*` analytics events so we can+ * split filtering behaviour by v3-legacy vs v4-fast-mode. Defaults to false;+ * the v4 events table passes `true`. (The `v4BetaEnabled` super property set+ * in `_app.tsx` still segments every event globally as a backstop.)+ */+ isV4?: boolean;};export type UseSidebarFilterStateOptions =@@ -505,6 +514,8 @@ export function useSidebarFilterState(hookOptions: UseSidebarFilterStateOptions = DEFAULT_HOOK_OPTIONS,) {const { loading, loadingColumns, implicitDefaultConfig } = hookOptions;+ const isV4Surface = hookOptions.isV4 ?? false;+ const capture = usePostHogClientCapture();const stateLocationType = hookOptions.stateLocation;const peekContext =stateLocationType === "peekContext" ? hookOptions.context : undefined;@@ -887,8 +898,74 @@ export function useSidebarFilterState(setStoredFiltersQuery,]);+ // When true, the applied-filter capture inside `updateFilter` is suppressed β+ // set by `updateOperator`, which funnels through `updateFilter` but must emit+ // `filters:facet_operator_toggled` instead of a duplicate `filters:applied`.+ const suppressAppliedCaptureRef = useRef(false);++ // Emit `filters:applied` for a single facet interaction. METADATA ONLY: we+ // derive shape (type/operator/key/counts) from the RESULTING filters for the+ // column and never send the raw filter value (PII). Skips emission when the+ // column ends up with no filter (a deselect-to-empty is a clear, not an+ // apply). Count semantics are aligned with the popover builder (LFE-10781+ // review): `conditionCount` = TOTAL applied conditions across ALL columns+ // (whole-filter complexity); `columnConditionCount` = rows this column+ // produced (a numeric range is 2: >= and <=); `valueCount` = selected options+ // in the attributed condition.+ //+ // `prev` (the pre-change state) lets us attribute the event to the row the+ // user JUST added/changed rather than the oldest one on the column β critical+ // for keyed facets (metadata / scores) that hold several rows per column+ // (adding `metadata.env` on top of `metadata.user_id` must report `env`, not+ // `user_id`). We pick the entry absent from `prev` (added or value-changed);+ // failing that, the last (appended) entry. The identity used to match rows+ // includes the raw value but is only ever compared locally β it is NEVER put+ // on the event payload.+ const emitFilterApplied = useCallback(+ (+ surface: "sidebar" | "filter_builder",+ column: string,+ next: FilterState,+ prev?: FilterState,+ ) => {+ const colFilters = next.filter((f) => f.column === column);+ if (colFilters.length === 0) return;+ const identity = (f: FilterState[number]): string =>+ `${"key" in f ? f.key : ""} ${f.operator} ${JSON.stringify(+ "value" in f ? f.value : null,+ )}`;+ const prevIdentities = new Set(+ (prev ?? []).filter((f) => f.column === column).map((f) => identity(f)),+ );+ const changed = colFilters.find((f) => !prevIdentities.has(identity(f)));+ const primary = changed ?? colFilters[colFilters.length - 1];+ capture("filters:applied", {+ surface,+ tableName: config.tableName,+ column,+ filterType: primary.type,+ operator: primary.operator,+ ...("key" in primary && primary.key ? { key: primary.key } : {}),+ valueCount: Array.isArray(primary.value) ? primary.value.length : 1,+ conditionCount: next.length,+ columnConditionCount: colFilters.length,+ isV4: isV4Surface,+ });+ },+ [capture, config.tableName, isV4Surface],+ );+const clearAll = () => {+ const clearedCount = explicitFilterState.length;setFilterState([]);+ if (clearedCount > 0) {+ capture("filters:cleared", {+ surface: "sidebar",+ tableName: config.tableName,+ clearedCount,+ isV4: isV4Surface,+ });+ }};// Generic apply selection logic@@ -1086,8 +1163,11 @@ export function useSidebarFilterState(const next = applySelection(withoutTextFilters, column, values, operator);setFilterState(next);+ if (!suppressAppliedCaptureRef.current) {+ emitFilterApplied("sidebar", column, next);+ }},- [filterState, applySelection, setFilterState],+ [filterState, applySelection, setFilterState, emitFilterApplied],);const updateFilterOnly = useCallback(@@ -1131,13 +1211,57 @@ export function useSidebarFilterState(],);+ const emitOperatorToggled = useCallback(+ (+ column: string,+ fromOperator: string | undefined,+ toOperator: "any of" | "all of" | "none of",+ valueCount: number,+ ) => {+ capture("filters:facet_operator_toggled", {+ surface: "sidebar",+ tableName: config.tableName,+ column,+ fromOperator,+ toOperator,+ valueCount,+ isV4: isV4Surface,+ });+ },+ [capture, config.tableName, isV4Surface],+ );++ // Runs `updateFilter` without the `filters:applied` capture, so the operator+ // toggle emits exactly one `filters:facet_operator_toggled` (not both events).+ const applyOperatorChange = useCallback(+ (+ column: string,+ values: string[],+ operator: "any of" | "all of" | "none of",+ ) => {+ suppressAppliedCaptureRef.current = true;+ try {+ updateFilter(column, values, operator);+ } finally {+ suppressAppliedCaptureRef.current = false;+ }+ },+ [updateFilter],+ );+const updateOperator = useCallback((column: string, newOperator: "any of" | "all of" | "none of") => {// Find the existing filter for this columnconst existingFilter = filterState.find((f) => f.column === column);+ const fromOperator =+ existingFilter?.type === "arrayOptions" ||+ existingFilter?.type === "stringOptions"+ ? existingFilter.operator+ : undefined;if (!existingFilter) {// Without selected values there is no valid persisted filter yet.- updateFilter(column, [], newOperator);+ applyOperatorChange(column, [], newOperator);+ emitOperatorToggled(column, fromOperator, newOperator, 0);return;}@@ -1171,9 +1295,15 @@ export function useSidebarFilterState(}// Update the filter with the new operator- updateFilter(column, currentValues, newOperator);+ applyOperatorChange(column, currentValues, newOperator);+ emitOperatorToggled(+ column,+ fromOperator,+ newOperator,+ currentValues.length,+ );},- [filterState, updateFilter, options],+ [filterState, applyOperatorChange, emitOperatorToggled, options],);const updateNumericFilter = useCallback(@@ -1211,8 +1341,9 @@ export function useSidebarFilterState(const next: FilterState = [...withoutNumeric, ...filters];setFilterState(next);+ emitFilterApplied("sidebar", column, next);},- [filterState, setFilterState],+ [filterState, setFilterState, emitFilterApplied],);const updateStringFilter = useCallback(@@ -1234,9 +1365,10 @@ export function useSidebarFilterState(},];setFilterState(next);+ emitFilterApplied("sidebar", column, next);}},- [filterState, setFilterState],+ [filterState, setFilterState, emitFilterApplied],);// Text filter management for categorical filters@@ -1270,8 +1402,9 @@ export function useSidebarFilterState(const next: FilterState = [...withoutCheckboxFilters, newFilter];setFilterState(next);+ emitFilterApplied("sidebar", column, next);},- [filterState, setFilterState],+ [filterState, setFilterState, emitFilterApplied],);const removeTextFilter = useCallback(@@ -1480,6 +1613,13 @@ export function useSidebarFilterState(];setFilterState(newFilters);+ // Analytics (LFE-10781): keyed metadata/category-score facet apply.+ emitFilterApplied(+ "sidebar",+ facet.column,+ newFilters,+ filterState,+ );},onReset: () => {// Remove all categoryOptions filters for this column@@ -1587,6 +1727,13 @@ export function useSidebarFilterState(];setFilterState(newFilters);+ // Analytics (LFE-10781): keyed numeric-score facet apply.+ emitFilterApplied(+ "sidebar",+ facet.column,+ newFilters,+ filterState,+ );},onReset: () => {// Remove all numberObject filters for this column@@ -1745,6 +1892,13 @@ export function useSidebarFilterState(];setFilterState(newFilters);+ // Analytics (LFE-10781): keyed metadata/string-score facet apply.+ emitFilterApplied(+ "sidebar",+ facet.column,+ newFilters,+ filterState,+ );},onReset: () => {// Remove all stringObject filters for this column@@ -2055,6 +2209,7 @@ export function useSidebarFilterState(removeTextFilter,expandedState,setFilterState,+ emitFilterApplied,managedEnvironmentColumn,managedEnvironmentPolicyConfig.hiddenEnvironments,]);diff --git a/web/src/features/posthog-analytics/usePostHogClientCapture.ts b/web/src/features/posthog-analytics/usePostHogClientCapture.tsindex f27797d192..b8c6163eee 100644--- a/web/src/features/posthog-analytics/usePostHogClientCapture.ts+++ b/web/src/features/posthog-analytics/usePostHogClientCapture.ts@@ -63,6 +63,7 @@ export const events = {// A bookmarked/stored system-preset id that the catalog retired β the// user was shown the one-time notice and landed on the default view."retired_view_redirect",+ "applied",],score: ["create",@@ -249,6 +250,20 @@ export const events = {cmd_k_menu: ["opened", "search_entered", "navigated"],spend_alert: ["created", "updated", "deleted"],sidebar: ["book_a_call_clicked", "v4_beta_toggled"],+ // Filter/search-bar usage analytics (LFE-10781). METADATA ONLY β payloads+ // never carry a raw filter value, search text, or AI prompt (PII). Only+ // type/column/operator/key(field-name)/counts/lengths/booleans/enums.+ // `isV4` on every event reflects fast-mode (v4 events table) at action time.+ filters: [+ "applied",+ "cleared",+ "facet_operator_toggled",+ "search_submitted",+ "search_error",+ "ai_generate_requested",+ "ai_generate_applied",+ "ai_generate_failed",+ ],} as const;// type that represents all possible event names, e.g. "traces:bookmark"diff --git a/web/src/features/search-bar/components/EventsSearchBarRow.tsx b/web/src/features/search-bar/components/EventsSearchBarRow.tsxindex 855051e461..8d5416a5d2 100644--- a/web/src/features/search-bar/components/EventsSearchBarRow.tsx+++ b/web/src/features/search-bar/components/EventsSearchBarRow.tsx@@ -27,9 +27,11 @@ import { ComposerWithPreview } from "@/src/features/search-bar/components/Composimport { SearchBarAiPrompt } from "@/src/features/search-bar/components/SearchBarAiPrompt";import { SearchBarStoreProvider } from "@/src/features/search-bar/store/SearchBarStoreProvider";import type { SearchBarStore } from "@/src/features/search-bar/store/searchBarStore";+import type { SearchCommitTrigger } from "@/src/features/search-bar/hooks/useEventsSearchBar";export function EventsSearchBarRow({projectId,+ tableName,store,commit,observed,@@ -40,8 +42,10 @@ export function EventsSearchBarRow({aiScoreNames,}: {projectId: string;+ /** Table this bar filters β threaded to AI-prompt analytics (LFE-10781). */+ tableName: string;store: SearchBarStore;- commit: () => string | null;+ commit: (trigger?: SearchCommitTrigger) => string | null;observed: ObservedOptions | undefined;/** Columns whose lazy fetch terminally errored β value-stage loading settles to* empty (per column) instead of pinning, matching the sidebar's settled-error@@ -86,6 +90,7 @@ export function EventsSearchBarRow({{aiOpen && aiAvailable ? (<SearchBarAiPromptprojectId={projectId}+ tableName={tableName}store={store}dataContext={aiDataContext}scoreNames={aiScoreNames}diff --git a/web/src/features/search-bar/components/SearchBarAiPrompt.tsx b/web/src/features/search-bar/components/SearchBarAiPrompt.tsxindex 8896b2a1c6..db674d398b 100644--- a/web/src/features/search-bar/components/SearchBarAiPrompt.tsx+++ b/web/src/features/search-bar/components/SearchBarAiPrompt.tsx@@ -25,6 +25,7 @@ import type { ObservedScoreNames } from "@/src/features/search-bar/lib/observed-import type { SearchBarStore } from "@/src/features/search-bar/store/searchBarStore";import { api } from "@/src/utils/api";import { cn } from "@/src/utils/tailwind";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";// "No such score X" note for score filters the server dropped because their// name matches no observed score (exactly or normalized).@@ -37,6 +38,7 @@ function unknownScoresMessage(names: string[]): string {export function SearchBarAiPrompt({projectId,+ tableName,store,dataContext,scoreNames,@@ -44,6 +46,8 @@ export function SearchBarAiPrompt({onExit,}: {projectId: string;+ /** Table this bar filters β the `tableName` analytics dimension. */+ tableName: string;/** The bar store; its `draft` is read as the live refine context. */store: SearchBarStore;/** Observed values + metadata keys + result count, so the model maps to the@@ -58,6 +62,7 @@ export function SearchBarAiPrompt({/** Leave AI mode and restore the grammar composer. */onExit: () => void;}) {+ const capture = usePostHogClientCapture();const [value, setValue] = React.useState("");const [error, setError] = React.useState<string | null>(null);const inputRef = React.useRef<HTMLInputElement>(null);@@ -107,11 +112,20 @@ export function SearchBarAiPrompt({// The sidebar/saved-view selector stay mounted and can change the filters// mid-request; the model returns the COMPLETE set based on this snapshot.const refine = store.getState().draft.trim();+ const refineMode = refine.length > 0;+ // Analytics (LFE-10781): METADATA ONLY β `promptLength` is a CHAR COUNT, the+ // prompt text itself is never sent. Ask-AI is a v4-only surface (isV4 true).+ capture("filters:ai_generate_requested", {+ tableName,+ refineMode,+ promptLength: prompt.length,+ isV4: true,+ });try {const result = await generateFilter.mutateAsync({projectId,prompt,- currentQuery: refine.length > 0 ? refine : undefined,+ currentQuery: refineMode ? refine : undefined,dataContext,scoreNames,});@@ -123,10 +137,22 @@ export function SearchBarAiPrompt({// so mergeWithSkipped won't preserve it). Bail and let the user retry// against the updated filters instead.if (store.getState().draft.trim() !== refine) {+ capture("filters:ai_generate_failed", {+ tableName,+ refineMode,+ reason: "stale",+ isV4: true,+ });setError("Filters changed while generating β try again.");return;}if (result.filters.length === 0) {+ capture("filters:ai_generate_failed", {+ tableName,+ refineMode,+ reason: "empty",+ isV4: true,+ });// A dropped unknown score name explains the empty result better than// the generic rephrase hint ("no such score X" beats a dead filter).setError(@@ -136,6 +162,12 @@ export function SearchBarAiPrompt({);return;}+ capture("filters:ai_generate_applied", {+ tableName,+ refineMode,+ generatedFilterCount: result.filters.length,+ isV4: true,+ });onApply(result.filters as FilterState);if (result.unknownScoreNames.length > 0) {// Partial apply: the rest of the filters went through, so exit as@@ -154,6 +186,12 @@ export function SearchBarAiPrompt({// an unhelpful "we have been notified" string anyway. The auth/precondition// cases are unreachable behind the cloud + aiFeaturesEnabled gate. Show one// generic, actionable message instead.+ capture("filters:ai_generate_failed", {+ tableName,+ refineMode,+ reason: "error",+ isV4: true,+ });setError("Couldn't reach the AI service. Please try again.");}};diff --git a/web/src/features/search-bar/components/SearchComposer.tsx b/web/src/features/search-bar/components/SearchComposer.tsxindex ee274fa40c..6215ef3fbe 100644--- a/web/src/features/search-bar/components/SearchComposer.tsx+++ b/web/src/features/search-bar/components/SearchComposer.tsx@@ -707,7 +707,9 @@ export function SearchComposer({// it reveals the invalid draft and returns null. On success it returns the// CANONICAL committed text in its RESTING form (trailing space when// non-empty) β the same text the resetTo effect re-derives.- const committedText = commitToFilterState();+ const committedText = commitToFilterState(+ advanceToTrailingSpace ? "enter" : "blur",+ );if (committedText === null) return;setHighlightedOptionId(null);// Close the undo-coalesce window at the commit boundary, mirroring undo()/@@ -756,7 +758,7 @@ export function SearchComposer({// (the `commit` path above) or blur. writeDraft ran synchronously, so the// freshly-set draftValid is current here.const commitStructuredEdit = React.useCallback(() => {- if (storeApi.getState().draftValid) commitToFilterState();+ if (storeApi.getState().draftValid) commitToFilterState("pick");}, [storeApi, commitToFilterState]);const pickOption = React.useCallback(@@ -776,7 +778,7 @@ export function SearchComposer({// reveal the red invalid state instead of silently no-op'ing (e.g. a// recent stored before a grammar tightening, or a since-retyped score).const state = storeApi.getState();- if (state.draftValid) commitToFilterState();+ if (state.draftValid) commitToFilterState("pick");else state.actions.revealInvalid();setAutocompleteOpen(false);return;diff --git a/web/src/features/search-bar/hooks/useEventsSearchBar.clienttest.tsx b/web/src/features/search-bar/hooks/useEventsSearchBar.clienttest.tsxindex 94f68c7f61..208e6aac26 100644--- a/web/src/features/search-bar/hooks/useEventsSearchBar.clienttest.tsx+++ b/web/src/features/search-bar/hooks/useEventsSearchBar.clienttest.tsx@@ -19,6 +19,7 @@ function setup(const { result } = renderHook(() =>useEventsSearchBar({projectId: "p",+ tableName: "observations",enabled: true,filterState: [],searchQuery: "refund",diff --git a/web/src/features/search-bar/hooks/useEventsSearchBar.ts b/web/src/features/search-bar/hooks/useEventsSearchBar.tsindex de506c4095..ead46c5e72 100644--- a/web/src/features/search-bar/hooks/useEventsSearchBar.ts+++ b/web/src/features/search-bar/hooks/useEventsSearchBar.ts@@ -18,6 +18,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";import type { FilterState, TracingSearchType } from "@langfuse/shared";import {+ classifySearchError,DEFAULT_SEARCH_TYPE,planCommit,} from "@/src/features/search-bar/lib/commit";@@ -31,6 +32,10 @@ import {createSearchBarStore,type SearchBarStore,} from "@/src/features/search-bar/store/searchBarStore";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";++/** How a search-bar commit was triggered β the `trigger` analytics dimension. */+export type SearchCommitTrigger = "enter" | "blur" | "pick";/** Order-independent scope-set equality (scopes are unique). */function sameScopes(a: TracingSearchType[], b: TracingSearchType[]): boolean {@@ -61,6 +66,7 @@ function filterIdentity(f: FilterState[number]): string {export function useEventsSearchBar({projectId,+ tableName,enabled,filterState,searchQuery,@@ -71,6 +77,8 @@ export function useEventsSearchBar({setSearchType,}: {projectId: string;+ /** Table this bar filters β the `tableName` analytics dimension. */+ tableName: string;enabled: boolean;/** The user's explicit facet filters (sidebar `explicitFilterState`). */filterState: FilterState;@@ -83,9 +91,11 @@ export function useEventsSearchBar({setSearchType: (type: TracingSearchType[]) => void;}): {store: SearchBarStore;- commit: () => string | null;+ commit: (trigger?: SearchCommitTrigger) => string | null;applyFilters: (filters: FilterState) => void;} {+ const capture = usePostHogClientCapture();+// Latest observed options, read inside commit and by the store's draft// validation so both route `scores.<name>` by the same observed score type.const observedRef = useRef(observed);@@ -171,44 +181,106 @@ export function useEventsSearchBar({[mergeWithSkipped],);- const commit = useCallback((): string | null => {- const result = planCommit(- store.getState().draft,- scoreTypeContextFromObserved(observedRef.current),- );- if (result.status === "invalid") {- store.getState().actions.revealInvalid();- return null;- }- const { setFilterState, setSearchQuery, setSearchType } = applyRef.current;- // Re-attach the filters the grammar can't represent so the commit never- // drops them (no-silent-drop contract; shared with the AI apply path).- const committedFilters = mergeWithSkipped(result.filters);- setFilterState(committedFilters);- setSearchQuery(result.searchQuery);- // Only write searchType when it actually changed. planCommit coerces a- // draft with no scope token to the default (`["id","content"]` β ids+names- // +input+output); the bar's default deliberately differs from the legacy- // toolbar's `["id"]`, so it IS written to the URL (that's how the content- // lane persists). The guard just avoids a redundant rewrite when unchanged.- if (!sameScopes(result.searchType, searchTypeRef.current)) {- setSearchType(result.searchType);- }- if (result.canonical.length > 0) {- recordRecentSearch(projectId, result.canonical);- }- // Return the CANONICAL committed text in its RESTING form (trailing space) β- // exactly what the resetTo effect re-derives on the next render (same- // filters + searchQuery/searchType). The composer drops the caret after it,- // so the echo string-compares equal and the space survives even when the- // commit reorders the query (e.g. `refund level:ERROR` β `level:ERROR refund`).- return restingDraft(- filterStateToQueryText(committedFilters, {- searchQuery: result.searchQuery,- searchType: result.searchType,- }).text,- );- }, [store, projectId, mergeWithSkipped]);+ // The committed text at the last render β the dedup baseline so a blur that+ // changed nothing does not emit a phantom `filters:search_submitted`.+ const committedTextRef = useRef(committedText);+ committedTextRef.current = committedText;++ // The draft that last emitted a `filters:search_error`, so a blur that+ // re-fails the SAME input does not double-emit (an explicit enter/pick retry+ // still counts β a repeated attempt is signal).+ const lastErrorTextRef = useRef<string | null>(null);++ const commit = useCallback(+ (trigger: SearchCommitTrigger = "enter"): string | null => {+ const draftText = store.getState().draft;+ const result = planCommit(+ draftText,+ scoreTypeContextFromObserved(observedRef.current),+ );+ if (result.status === "invalid") {+ store.getState().actions.revealInvalid();+ // Analytics (LFE-10781): a non-empty typed query was rejected (a UI+ // error). METADATA ONLY β `orAttempted`/`reason` come from the AST shape+ // + static diagnostic messages, `queryLength` is a char count; the query+ // TEXT is never sent. The grammar bar is v4-only, so isV4 is always true.+ // `orAttempted:true` (an OR between conditions β the parked cross-field+ // OR, LFE-10421) is the headline demand signal. Fires once per failed+ // commit: a blur that re-fails the same input is deduped.+ const trimmed = draftText.trim();+ const isBlurRefail =+ trigger === "blur" && draftText === lastErrorTextRef.current;+ if (trimmed.length > 0 && !isBlurRefail) {+ const { orAttempted, reason } = classifySearchError(+ result.ast,+ result.diagnostics,+ );+ capture("filters:search_error", {+ tableName,+ orAttempted,+ reason,+ queryLength: trimmed.length,+ trigger,+ isV4: true,+ });+ }+ lastErrorTextRef.current = draftText;+ return null;+ }+ // A valid commit clears the error-dedup baseline so a later re-failure of+ // the same text still emits.+ lastErrorTextRef.current = null;+ const { setFilterState, setSearchQuery, setSearchType } =+ applyRef.current;+ // Re-attach the filters the grammar can't represent so the commit never+ // drops them (no-silent-drop contract; shared with the AI apply path).+ const committedFilters = mergeWithSkipped(result.filters);+ setFilterState(committedFilters);+ setSearchQuery(result.searchQuery);+ // Only write searchType when it actually changed. planCommit coerces a+ // draft with no scope token to the default (`["id","content"]` β ids+names+ // +input+output); the bar's default deliberately differs from the legacy+ // toolbar's `["id"]`, so it IS written to the URL (that's how the content+ // lane persists). The guard just avoids a redundant rewrite when unchanged.+ if (!sameScopes(result.searchType, searchTypeRef.current)) {+ setSearchType(result.searchType);+ }+ if (result.canonical.length > 0) {+ recordRecentSearch(projectId, result.canonical);+ }+ // Return the CANONICAL committed text in its RESTING form (trailing space) β+ // exactly what the resetTo effect re-derives on the next render (same+ // filters + searchQuery/searchType). The composer drops the caret after it,+ // so the echo string-compares equal and the space survives even when the+ // commit reorders the query (e.g. `refund level:ERROR` β `level:ERROR refund`).+ const committed = restingDraft(+ filterStateToQueryText(committedFilters, {+ searchQuery: result.searchQuery,+ searchType: result.searchType,+ }).text,+ );++ // Analytics (LFE-10781). METADATA ONLY β `queryLength` is a CHAR COUNT, we+ // never send the query text itself. A blur that produced no change is a+ // no-op (the resting draft re-settling), so it does not emit; an explicit+ // enter/pick always counts even when re-submitting the same query. The+ // grammar bar is a v4-only surface, so isV4 is always true.+ if (trigger !== "blur" || committed !== committedTextRef.current) {+ capture("filters:search_submitted", {+ tableName,+ filterCount: committedFilters.length,+ hasFreeText: (result.searchQuery ?? "").trim().length > 0,+ searchType: result.searchType,+ queryLength: committed.trim().length,+ trigger,+ isV4: true,+ });+ }++ return committed;+ },+ [store, projectId, tableName, mergeWithSkipped, capture],+ );return { store, commit, applyFilters };}diff --git a/web/src/features/search-bar/lib/adapter.ts b/web/src/features/search-bar/lib/adapter.tsindex 8c1ce4a183..37c479cbc8 100644--- a/web/src/features/search-bar/lib/adapter.ts+++ b/web/src/features/search-bar/lib/adapter.ts@@ -33,6 +33,15 @@ import {} from "./fields";import { quoteIfNeeded } from "./quoting";+/**+ * Emitted when a top-level OR between conditions can't collapse to a same-field+ * any-of (the PARKED cross-field-OR feature, LFE-10421). Exported so the+ * analytics error classifier can match this exact cause without brittle string+ * fragments (LFE-10781 `filters:search_error` β reason `unsupported_or`).+ */+export const OR_NOT_SUPPORTED_MESSAGE =+ "OR is not supported yet, filters combine with AND. Use field:(a OR b) for any-of values";+export type SingleEventsFilter = FilterState[number];export type AstToFilterStateResult = {@@ -207,9 +216,7 @@ function lowerTopLevel(lowerFilterNode(collapsed, negated, ctx);return;}- ctx.errors.push(- "OR is not supported yet, filters combine with AND. Use field:(a OR b) for any-of values",- );+ ctx.errors.push(OR_NOT_SUPPORTED_MESSAGE);return;}case "filter":diff --git a/web/src/features/search-bar/lib/commit.ts b/web/src/features/search-bar/lib/commit.tsindex 466c6539ab..db49d76365 100644--- a/web/src/features/search-bar/lib/commit.ts+++ b/web/src/features/search-bar/lib/commit.ts@@ -9,7 +9,12 @@import type { FilterState, TracingSearchType } from "@langfuse/shared";-import { astToFilterState, type ScoreTypeContext } from "./adapter";+import type { ASTNode } from "./ast";+import {+ astToFilterState,+ OR_NOT_SUPPORTED_MESSAGE,+ type ScoreTypeContext,+} from "./adapter";import { serialize, type Diagnostic } from "./langQ";import { validateQuery } from "./validate";@@ -29,7 +34,7 @@ export type CommitResult =/** Canonical serialization of the committed query (for recent searches). */canonical: string;}- | { status: "invalid"; diagnostics: Diagnostic[] };+ | { status: "invalid"; diagnostics: Diagnostic[]; ast: ASTNode | null };/*** Validate and lower `draftText`. `committed` carries everything the table@@ -44,7 +49,7 @@ export function planCommit(): CommitResult {const res = validateQuery(draftText.trim(), scoreTypes);if (!res.valid) {- return { status: "invalid", diagnostics: res.diagnostics };+ return { status: "invalid", diagnostics: res.diagnostics, ast: res.ast };}const { filters, searchQuery, searchType, errors } = astToFilterState(res.ast,@@ -63,6 +68,7 @@ export function planCommit(severity: "error" as const,message,})),+ ast: res.ast,};}return {@@ -73,3 +79,77 @@ export function planCommit(canonical: serialize(res.ast),};}++// ---- Analytics: classify a rejected commit (LFE-10781 `filters:search_error`) ----++/** Why a non-empty typed query failed to become a valid applied filter. */+export type SearchErrorReason =+ | "unsupported_or"+ | "parse_error"+ | "unknown_field"+ | "bad_operator"+ | "unknown";++/**+ * True when the query uses an OR token BETWEEN conditions/sections β a top-level+ * `or` node (the unsupported, PARKED cross-field OR, LFE-10421). This is the+ * headline demand signal ("did the user try to OR two different conditions?").+ *+ * The supported within-a-single-field `field:(a OR b)` parses as ONE `filter`+ * node with `valueOp: "or"` β never an `or` node β so it is correctly NOT+ * flagged. An `or` node nested inside an AND/paren group or a NOT is still a+ * between-conditions OR, so we recurse through those; a `filter`'s within-field+ * OR lives in `valueOp`, so we never descend into it.+ */+export function queryUsesTopLevelOr(ast: ASTNode | null): boolean {+ if (ast === null) return false;+ switch (ast.kind) {+ case "or":+ return true;+ case "and":+ return ast.children.some(queryUsesTopLevelOr);+ case "not":+ return queryUsesTopLevelOr(ast.child);+ case "filter":+ case "text":+ return false;+ }+}++/**+ * Metadata-only classification of a rejected commit for `filters:search_error`.+ * `orAttempted` is structural (an `or` node in the AST); `reason` buckets by the+ * error cause the grammar/adapter distinguishes. NEVER reads raw values β only+ * the AST shape and diagnostic MESSAGES (which are static, value-free strings).+ */+export function classifySearchError(+ ast: ASTNode | null,+ diagnostics: Diagnostic[],+): { orAttempted: boolean; reason: SearchErrorReason } {+ const orAttempted = queryUsesTopLevelOr(ast);+ const errors = diagnostics.filter((d) => d.severity === "error");+ const has = (re: RegExp) => errors.some((d) => re.test(d.message));++ let reason: SearchErrorReason;+ if (errors.some((d) => d.message === OR_NOT_SUPPORTED_MESSAGE)) {+ reason = "unsupported_or";+ } else if (has(/^Unknown field\b/)) {+ reason = "unknown_field";+ } else if (+ has(+ /\bdoes not support\b|\bis not supported\b|\bare not supported\b|\bnot representable\b|\bonly applies\b|\bonly works\b|\bsupports a single\b|\bis an? (number|datetime|boolean|text|array) field\b|\bAND grouping\b|\ball-of groups\b/,+ )+ ) {+ reason = "bad_operator";+ } else if (+ ast === null ||+ has(+ /\bUnclosed\b|\bMissing (value|grouped)\b|\bMissing value\b|\bEmpty value\b|\bNested groups\b|\bIncomplete field\b/,+ )+ ) {+ reason = "parse_error";+ } else {+ reason = "unknown";+ }+ return { orAttempted, reason };+}diff --git a/web/src/features/search-bar/store/SearchBarStoreProvider.tsx b/web/src/features/search-bar/store/SearchBarStoreProvider.tsxindex 22666db3bd..f719f71354 100644--- a/web/src/features/search-bar/store/SearchBarStoreProvider.tsx+++ b/web/src/features/search-bar/store/SearchBarStoreProvider.tsx@@ -5,13 +5,15 @@ import {type SearchBarStore,type SearchBarStoreState,} from "@/src/features/search-bar/store/searchBarStore";+import { type SearchCommitTrigger } from "@/src/features/search-bar/hooks/useEventsSearchBar";type SearchBarContextValue = {store: SearchBarStore;/** Apply the current draft to the table's filter state (single source of* truth). Returns the canonical committed text on success, or null (and- * reveals diagnostics) when the draft is invalid. */- commit: () => string | null;+ * reveals diagnostics) when the draft is invalid. `trigger` records how the+ * commit was initiated for analytics. */+ commit: (trigger?: SearchCommitTrigger) => string | null;};const SearchBarContext = createContext<SearchBarContextValue | null>(null);@@ -23,7 +25,7 @@ export function SearchBarStoreProvider({}: {children: ReactNode;store: SearchBarStore;- commit: () => string | null;+ commit: (trigger?: SearchCommitTrigger) => string | null;}) {const value = useMemo(() => ({ store, commit }), [store, commit]);return (@@ -51,6 +53,8 @@ export function useSearchBarStore<TValue>(return useStore(useSearchBarContext().store, selector);}-export function useSearchBarCommit(): () => string | null {+export function useSearchBarCommit(): (+ trigger?: SearchCommitTrigger,+) => string | null {return useSearchBarContext().commit;}diff --git a/web/src/pages/project/[projectId]/dashboards/[dashboardId]/index.tsx b/web/src/pages/project/[projectId]/dashboards/[dashboardId]/index.tsxindex 6bf969b914..d3f7622266 100644--- a/web/src/pages/project/[projectId]/dashboards/[dashboardId]/index.tsx+++ b/web/src/pages/project/[projectId]/dashboards/[dashboardId]/index.tsx@@ -610,6 +610,10 @@ export default function DashboardDetail() {columns={filterColumns}filterState={currentFilters}onChange={setCurrentFilters}+ // Analytics (LFE-10781): custom dashboard filter β a v3/legacy+ // surface (not the v4 events table).+ tableName="dashboard"+ isV4={false}/></>),diff --git a/web/src/pages/project/[projectId]/index.tsx b/web/src/pages/project/[projectId]/index.tsxindex b1d9c3ce2d..2a18480e95 100644--- a/web/src/pages/project/[projectId]/index.tsx+++ b/web/src/pages/project/[projectId]/index.tsx@@ -283,6 +283,10 @@ export default function Dashboard() {columns={filterColumns}filterState={userFilterState}onChange={useDebounce(setUserFilterState)}+ // Analytics (LFE-10781): project-home dashboard filter β a+ // v3/legacy surface (not the v4 events table).+ tableName="home-dashboard"+ isV4={false}/></>),diff --git a/web/src/pages/project/[projectId]/users/index.tsx b/web/src/pages/project/[projectId]/users/index.tsxindex d14bb1c669..535d339c70 100644--- a/web/src/pages/project/[projectId]/users/index.tsx+++ b/web/src/pages/project/[projectId]/users/index.tsx@@ -431,6 +431,7 @@ const UsersTable = ({/>)}<DataTableToolbar+ tableName="users"filterColumnDefinition={usersTableCols}filterState={userFilterState}setFilterState={useDebounce(setUserFilterState)}