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(taxonomic-filter): measure search latency on the all tab (#117280)

posthog[bot]93737617069d
diff --git a/.agents/skills/modifying-taxonomic-filter/references/telemetry-contract.md b/.agents/skills/modifying-taxonomic-filter/references/telemetry-contract.md
index 9a27e64a379e..1489ec8faac3 100644
--- a/.agents/skills/modifying-taxonomic-filter/references/telemetry-contract.md
+++ b/.agents/skills/modifying-taxonomic-filter/references/telemetry-contract.md
@@ -69,7 +69,10 @@ All carry `surface` on both surfaces, except `include stale toggled`, which carr
## Legacy only, with `surface`
-- `taxonomic filter search latency`: `groupType`, `searchQuery`, `resultCount`, `time_to_see_data_ms`.
+- `taxonomic filter search latency`: `groupType`, `searchQuery`, `resultCount`, `time_to_see_data_ms`, `revealedBy`, `pendingGroupTypes`.
+ A category tab sends it when its own fetch lands, and `time_to_see_data_ms` is the fetch time.
+ The All tab sends it when its rows reveal, with `groupType: suggested_filters`, `revealedBy` and `pendingGroupTypes`.
+ There `time_to_see_data_ms` runs from the last keystroke, so it includes the input debounce. Compare the two only by `groupType`.
The rebuild does not send it yet (see `hooks/useGroupList.ts`).
- `taxonomic filter search intent predicted`: `query`, `activeTab`, `predictedGroupType`, `confidence`, `isConfident`, `suggestsSwitch`, `wouldPromote`, `promptVersion`, `source`, `variant`, `inTime`, `shown`.
The banner funnel in [refreshing-product-reality](refreshing-product-reality.md) reads `variant` and `shown`.
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
index d806403d208b..f1004f0e480d 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
@@ -693,9 +693,21 @@ describe('taxonomicFilterLogic', () => {
barrierLogic.actions.setSearchQuery('whatever')
}).toMatchValues({ revealBarrierOpen: false })
+ const captureSpy = jest.spyOn(posthog, 'capture')
await expectLogic(eventsListLogic).toDispatchActions(['loadRemoteItemsSuccess'])
await expectLogic(barrierLogic).toDispatchActions(['openRevealBarrier']).delay(1)
expect(barrierLogic.values.revealBarrierOpen).toBe(true)
+
+ const latencyCalls = captureSpy.mock.calls.filter(([event]) => event === 'taxonomic filter search latency')
+ expect(latencyCalls).toHaveLength(1)
+ expect(latencyCalls[0][1]).toMatchObject({
+ groupType: TaxonomicFilterGroupType.SuggestedFilters,
+ searchQuery: 'whatever',
+ time_to_see_data_ms: expect.any(Number),
+ revealedBy: 'all_groups_settled',
+ pendingGroupTypes: [],
+ })
+ captureSpy.mockRestore()
})
})
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
index 456d537a0944..da8efc10c1fc 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
@@ -2644,6 +2644,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
// 5s reveal-barrier timer as a normal keystroke would — the `setSearchQuery`
// listener doesn't run on mount because no action was dispatched.
if ((props.initialSearchQuery ?? '').trim()) {
+ cache.searchStartedAt = performance.now()
cache.disposables.add(() => {
const timerId = window.setTimeout(() => actions.openRevealBarrier(), REVEAL_BARRIER_TIMEOUT_MS)
return () => window.clearTimeout(timerId)
@@ -2832,11 +2833,13 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
// key auto-disposes the previous timer; we only need to explicitly dispose when
// the query clears (no fresh timer to schedule).
if ((searchQuery ?? '').trim()) {
+ cache.searchStartedAt = performance.now()
cache.disposables.add(() => {
const timerId = window.setTimeout(() => actions.openRevealBarrier(), REVEAL_BARRIER_TIMEOUT_MS)
return () => window.clearTimeout(timerId)
}, 'revealBarrierTimer')
} else {
+ cache.searchStartedAt = null
cache.disposables.dispose('revealBarrierTimer')
}
@@ -2858,6 +2861,30 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
}
},
+ openRevealBarrier: () => {
+ // The All tab runs no fetch of its own, so `infiniteListResultsReceived` never reports its
+ // latency. Its rows appear when this barrier opens, so the wait the user sees ends here.
+ // A group that still loads at this point means the timeout opened the barrier.
+ const startedAt = cache.searchStartedAt
+ cache.searchStartedAt = null
+ if (
+ typeof startedAt !== 'number' ||
+ values.activeTab !== TaxonomicFilterGroupType.SuggestedFilters ||
+ !values.searchQuery
+ ) {
+ return
+ }
+ posthog.capture('taxonomic filter search latency', {
+ surface: legacyTaxonomicSurface(),
+ groupType: TaxonomicFilterGroupType.SuggestedFilters,
+ searchQuery: values.searchQuery,
+ time_to_see_data_ms: Math.floor(performance.now() - startedAt),
+ resultCount: values.infiniteListCounts[TaxonomicFilterGroupType.SuggestedFilters],
+ revealedBy: values.anyGroupLoading ? 'timeout' : 'all_groups_settled',
+ pendingGroupTypes: values.loadingGroupTypes,
+ })
+ },
+
setIncludeStaleEvents: ({ includeStaleEvents }) => {
posthog.capture('taxonomic filter include stale toggled', {
includeStaleEvents,