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.

chore(taxonomic-filter): remove the event match experiment from the frontend (#124133)

Paul D'Ambra3e2d2c26c51e
diff --git a/.agents/skills/modifying-taxonomic-filter/references/contested-decisions.md b/.agents/skills/modifying-taxonomic-filter/references/contested-decisions.md
index f71becb185b6..b05257568440 100644
--- a/.agents/skills/modifying-taxonomic-filter/references/contested-decisions.md
+++ b/.agents/skills/modifying-taxonomic-filter/references/contested-decisions.md
@@ -46,7 +46,6 @@ Bring evidence, not seniority.
No data isolates power users.
- **Implication:** removing a cheap feature saves little.
Removing an expensive one with almost no use saves a lot.
- Event match calls a model only for uncached empty searches, so measure its real call volume first.
## Should there be a natural-language or chat input?
diff --git a/.agents/skills/modifying-taxonomic-filter/references/feature-inventory.md b/.agents/skills/modifying-taxonomic-filter/references/feature-inventory.md
index 476141a4d4c8..893fd3922f05 100644
--- a/.agents/skills/modifying-taxonomic-filter/references/feature-inventory.md
+++ b/.agents/skills/modifying-taxonomic-filter/references/feature-inventory.md
@@ -14,26 +14,25 @@ Status meanings:
- **Candidate for removal:** low use relative to cost.
Removal still needs the checks in "Before removing anything".
-| Feature | Use | Status | Notes |
-| ----------------------------------------------------------------------------------------- | -------------------------------------------------------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------- |
-| Suggested view (default) | ~70% of selections | Protect | It is the product. |
-| Recents inside Suggested | ~40% of selections | Protect, improve | Stored per browser. Syncing per user would help people on several machines. |
-| Search | ~55% of selections involve it | Protect | See [failure-modes](failure-modes.md) 1 and 2. |
-| Email and URL promotion | Row 0 for the top terms | Protect | `PROMOTED_PROPERTIES_BY_SEARCH_TERM`. Human sign-off to change. |
-| Event properties tab | Large | Improve | Ranking: selected items sit far down the list. |
-| Person properties tab | Large, ~64% of closes on it pick (query 13, final tab) | Improve | Weakest big tab. |
-| Empty-result state | ~5 per 100 search queries (query 13) | Fix | Should show matches in other groups. This snapshot excludes Suggested; new clients record All-tab empties. |
-| Fetch error handling | ~0.2 failure events per 100 search queries (query 10) | Keep | Shows an error with retry. |
-| Persons search latency | p90 ~4s | Fix | Slowest group. |
-| Custom key for unseen properties | Ticket theme | Fix | Flags and cohorts especially. |
-| Pin toggle | ~4% of selections come from pins | Keep | Cheap. |
-| Recents tab (standalone) | ~0.3% of closes (query 13) | Candidate for removal | Same items already in Suggested. ~36% of closes on it pick, vs ~86% overall (final-tab association, query 13). |
-| Pinned tab (standalone) | ~0.06% of closes (query 13) | Candidate for removal | Keep the pin toggle. |
-| Pseudo-category tabs (autocapture, pageview, screen, email addresses, elements, metadata) | Each under 3% of category clicks (query 14, click mix) | Candidate for removal as tabs | Their **items** are picked through Suggested and search (`sourceGroupType`). Keep them as sources. |
-| Event match suggestion (model call) | ~5-8% of answers shown (rough); ~7% of sessions pick one | Candidate for removal or redesign | Calls a model only for an uncached empty search. Measure uncached calls before judging cost. |
-| Search intent switch banner | ~1 in 6 shown banners lead to a switch | Decide from its experiment | Promotion of the predicted group happens without the banner. |
-| Category rail docking | ~1% of closes have docking on (query 13, preference) | Keep | Pick rate ~79% docked vs ~86% undocked. |
-| Include stale toggle | Small, steady | Keep | Cheap. |
+| Feature | Use | Status | Notes |
+| ----------------------------------------------------------------------------------------- | ------------------------------------------------------ | ----------------------------- | -------------------------------------------------------------------------------------------------------------- |
+| Suggested view (default) | ~70% of selections | Protect | It is the product. |
+| Recents inside Suggested | ~40% of selections | Protect, improve | Stored per browser. Syncing per user would help people on several machines. |
+| Search | ~55% of selections involve it | Protect | See [failure-modes](failure-modes.md) 1 and 2. |
+| Email and URL promotion | Row 0 for the top terms | Protect | `PROMOTED_PROPERTIES_BY_SEARCH_TERM`. Human sign-off to change. |
+| Event properties tab | Large | Improve | Ranking: selected items sit far down the list. |
+| Person properties tab | Large, ~64% of closes on it pick (query 13, final tab) | Improve | Weakest big tab. |
+| Empty-result state | ~5 per 100 search queries (query 13) | Fix | Should show matches in other groups. This snapshot excludes Suggested; new clients record All-tab empties. |
+| Fetch error handling | ~0.2 failure events per 100 search queries (query 10) | Keep | Shows an error with retry. |
+| Persons search latency | p90 ~4s | Fix | Slowest group. |
+| Custom key for unseen properties | Ticket theme | Fix | Flags and cohorts especially. |
+| Pin toggle | ~4% of selections come from pins | Keep | Cheap. |
+| Recents tab (standalone) | ~0.3% of closes (query 13) | Candidate for removal | Same items already in Suggested. ~36% of closes on it pick, vs ~86% overall (final-tab association, query 13). |
+| Pinned tab (standalone) | ~0.06% of closes (query 13) | Candidate for removal | Keep the pin toggle. |
+| Pseudo-category tabs (autocapture, pageview, screen, email addresses, elements, metadata) | Each under 3% of category clicks (query 14, click mix) | Candidate for removal as tabs | Their **items** are picked through Suggested and search (`sourceGroupType`). Keep them as sources. |
+| Search intent switch banner | ~1 in 6 shown banners lead to a switch | Decide from its experiment | Promotion of the predicted group happens without the banner. |
+| Category rail docking | ~1% of closes have docking on (query 13, preference) | Keep | Pick rate ~79% docked vs ~86% undocked. |
+| Include stale toggle | Small, steady | Keep | Cheap. |
## Before removing anything
diff --git a/.agents/skills/modifying-taxonomic-filter/references/refreshing-product-reality.md b/.agents/skills/modifying-taxonomic-filter/references/refreshing-product-reality.md
index 44170fc7f8bd..29db03b9555f 100644
--- a/.agents/skills/modifying-taxonomic-filter/references/refreshing-product-reality.md
+++ b/.agents/skills/modifying-taxonomic-filter/references/refreshing-product-reality.md
@@ -329,38 +329,19 @@ LIMIT 15
### 11. Assistive feature funnels
-Event match: answered, then suggested, then selected.
Intent banner: banner shown, then switched.
Write back the step ratios.
-- `event match suggested` carries no query or request ID, so no key counts suggestions exactly.
- The raw count runs high: a tab switch that reuses a cached answer sends it again.
- The distinct count per person, session and suggestion list can run high or low: two queries with the same list count once, but pickers with different exclusions turn one answer into several lists.
- Neither is a bound.
- Report both as rough estimates, and trust the order of magnitude, not the exact value.
-- The backend sends `event match answered` for every call, even when the model never answered.
- The query leaves out `outcome` values `unavailable`, `wrong_length` and `only_values`, so the base is real model answers.
-- Selections have no exposure ID to pair with a suggestion, so the selection step compares person-sessions on both sides.
- Every experiment arm sends `search intent predicted`, but only the `banner` arm can switch.
On the banner arm, `shown` can be true when `suggestsSwitch` is false (it seems to lag one prediction), so the query needs both.
```sql
SELECT
- round(100 * uniqIf((person_id, $session_id, toString(properties.suggestedEvents)), event = 'taxonomic filter event match suggested')
- / countIf(event = 'taxonomic filter event match answered'
- AND toString(properties.outcome) NOT IN ('unavailable', 'wrong_length', 'only_values')), 1) AS match_suggested_per_answer_distinct_pct,
- round(100 * countIf(event = 'taxonomic filter event match suggested')
- / countIf(event = 'taxonomic filter event match answered'
- AND toString(properties.outcome) NOT IN ('unavailable', 'wrong_length', 'only_values')), 1) AS match_suggested_per_answer_raw_pct,
- round(100 * uniqIf((person_id, $session_id), event = 'taxonomic filter event match selected')
- / uniqIf((person_id, $session_id), event = 'taxonomic filter event match suggested'), 1) AS sessions_selecting_per_session_suggested_pct,
round(100 * countIf(event = 'taxonomic filter search intent switched')
/ countIf(event = 'taxonomic filter search intent predicted' AND properties.variant = 'banner'
AND toString(properties.suggestsSwitch) = 'true' AND toString(properties.shown) = 'true'), 1) AS switched_per_shown_banner_pct
FROM events
-WHERE event IN ('taxonomic filter event match answered', 'taxonomic filter event match suggested',
- 'taxonomic filter event match selected', 'taxonomic filter search intent predicted',
- 'taxonomic filter search intent switched')
+WHERE event IN ('taxonomic filter search intent predicted', 'taxonomic filter search intent switched')
AND timestamp >= now() - INTERVAL 7 DAY
```
diff --git a/.agents/skills/modifying-taxonomic-filter/references/telemetry-contract.md b/.agents/skills/modifying-taxonomic-filter/references/telemetry-contract.md
index 22a9abce4596..ec7e5f0eee59 100644
--- a/.agents/skills/modifying-taxonomic-filter/references/telemetry-contract.md
+++ b/.agents/skills/modifying-taxonomic-filter/references/telemetry-contract.md
@@ -55,13 +55,6 @@ Mixing them up makes reachable groups look unused.
- `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`.
- `taxonomic filter search intent switched`: `fromGroupType`, `toGroupType`.
-- `taxonomic filter event match eligible`: `tab`, `variant`.
- Sent once per project and query when the search qualifies for event match. The experiment's exposure reads it.
-- `taxonomic filter event match hint shown`: `tab`, `hint`, and `unsentEvents` when `hint` is `unsent`.
-- `taxonomic filter event match suggested`: `suggestedEvents`, `tab`.
-- `taxonomic filter event match selected`: `eventName`, `position`, `tab`.
-
-Read the event match events as a funnel: answered, then suggested, then selected.
## Events, without `surface`
@@ -72,8 +65,6 @@ Read the event match events as a funnel: answered, then suggested, then selected
- `taxonomic filter category selected`: `groupType`, `eventName`.
- `taxonomic filter category dropdown opened`: `variant`.
- `taxonomic filter category rail toggled`: `docked`.
-- `taxonomic filter event match answered`: `outcome`.
- Emitted server side.
- `taxonomic filter pin toggled`: `groupType`, `value`, `pinned`.
Sent from the shared `taxonomicFilterPinnedPropertiesLogic.ts`.
- `taxonomic filter default pins seeded`: `values`.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index dbaab2700391..1c96e7d57f5d 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -3708,30 +3708,10 @@ snapshots:
hash: v1.k794b7964.75780bca10fdc8c61cb0d0383ac6495ddaafdd30baf6f566cf6b38e8fa0f2d90.A257X7pt9K40kv8qTFkP0u04LCWEnzEh2Sy7qv11t2w
filters-taxonomic-filter--email-search-query-hint--light:
hash: v1.k794b7964.26263d464e79d354fa4a88430db602672c6ec400d23b25e635f39c78f8021c50.oKLH9VgDruDZli-BetTKm3qWMDc2f96jp30LFwHEG9Y
- filters-taxonomic-filter--empty-all-tab-with-event-match--dark:
- hash: v1.k794b7964.58e7c99b2c92f0300216c4047c2d5ea1745dfa1a606a00270b0ebc779bed3cd5.1h_7F-InpV4zcCU2i8sGo8D9GpR-M9SK0ykFwUh1DDc
- filters-taxonomic-filter--empty-all-tab-with-event-match--light:
- hash: v1.k794b7964.d6233206def8eefa24c433869ed21a94e9aecb397191a29c9e61295e161c594e.Ov1Fg1yGqOdhCRLXbyljE-x8teQSz_x7DBTcCiPAfXw
- filters-taxonomic-filter--empty-events-with-event-match--dark:
- hash: v1.k794b7964.30d20341622aff37c27fca8216269d839cc72aafd5a9cfb3a195cdde5ba414ed.ioGVHMVBgkAMr11FVdKj-pgx05LSlkwl-vuXRF-t6sw
- filters-taxonomic-filter--empty-events-with-event-match--light:
- hash: v1.k794b7964.d07e5394b85d6064eb2e0e92a43e138b71b4248a015af59d6a901874a6c0acca.ViBqvpCMYJ44bOijsqT7TfxMKsAFBtBUnHmRT17SQG4
- filters-taxonomic-filter--empty-events-with-event-match-loading--dark:
- hash: v1.k794b7964.24731467b4e99a1205df0640091c2f333b1d276df97c510a3929bf9cf342c0ee.Nd_kUIeGDDTduX8hJoZx_QCHBEqzBTKHvWdTCVQvv3g
- filters-taxonomic-filter--empty-events-with-event-match-loading--light:
- hash: v1.k794b7964.b3739c41d624c8631591ea6d5c9b0e1035031597bc57c0cf0cc3d90271a9afa7.TAZSeJKZZHZ8UxY3u9yNqOWKF0uYgjX74V6AnP6zqTE
filters-taxonomic-filter--empty-events-with-stale-toggle--dark:
hash: v1.k794b7964.c9c8b86f1f196faf8bb7ff2fa3a8b662b5da749e9d740979253eefd3caef6d83.Vi2aZn3Sv-3nBjiCPo9tkuX4Dj5bZSq-4KMFkSMAKps
filters-taxonomic-filter--empty-events-with-stale-toggle--light:
hash: v1.k794b7964.06c743209b67d84e2d6403f78e9a8dbb412f4d552936335f6380b841ab20ea05.RJKRGsdtc3psVWSHimWW-MDLaXIyUbQj2dU33xEIYC0
- filters-taxonomic-filter--empty-events-with-unsent-event-hint--dark:
- hash: v1.k794b7964.36dcc5f7829de403957bb284997042af8755fb33347ec245644328201b96a6be.WR_e3wcaujsOyjKVUAzJKopna3G4E9WWFjGLZzRXbgY
- filters-taxonomic-filter--empty-events-with-unsent-event-hint--light:
- hash: v1.k794b7964.3726716eae08f672c2d989ad565e947f5a2c2a9b3339cac58672cf2ff506579a.rzmd0zlST6aJiPXxMNXFZe4lwLeS07kxpVspx9so32A
- filters-taxonomic-filter--empty-events-with-value-hint--dark:
- hash: v1.k794b7964.56b8792ce05a2bd6639b561f1330df09e67cf01fa9307301aa91560ff69442dd.mnfSSv24JeDgvtTRf6YX_-olqjQUQIzvd7GVi6CFMNU
- filters-taxonomic-filter--empty-events-with-value-hint--light:
- hash: v1.k794b7964.97ddd61650806011675ac41c4ca31e0409b894993096eaa1e645e5748502be1a.NtvmxNSJzpPc-osNFNOzk85H2kVtbmQKDUClTvwYPfA
filters-taxonomic-filter--empty-tab-searching-a-category-name--dark:
hash: v1.k794b7964.fd4d6a0fa9ff79e0b7835a577e9fca1b5ebaea73cbce2e8fbe22b7f81d74a430.ygr-MRffkSBDiRqiPa3uZLZ3mKodH39bbm5jzD0dOSE
filters-taxonomic-filter--empty-tab-searching-a-category-name--light:
diff --git a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
index d066d00de889..408a185c8292 100644
--- a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
@@ -62,7 +62,6 @@ import { EventDefinition, PropertyDefinition } from '~/types'
import { HiddenEventExplanation } from './HiddenEventExplanation'
import { NO_ITEM_SELECTED, infiniteListLogic } from './infiniteListLogic'
-import { TaxonomicEventMatchSuggestions } from './TaxonomicEventMatchSuggestions'
export interface InfiniteListProps {
popupAnchorElement: HTMLDivElement | null
@@ -719,7 +718,6 @@ const MAX_OTHER_GROUP_SWITCHES = 3
function InfiniteListEmptyState(): JSX.Element {
const {
searchQuery,
- activeTab,
taxonomicGroups,
taxonomicGroupTypes,
metaGroupTypes,
@@ -741,11 +739,6 @@ function InfiniteListEmptyState(): JSX.Element {
!emptySearchQuery &&
!includeStaleEvents &&
(listGroupType === TaxonomicFilterGroupType.Events || listGroupType === TaxonomicFilterGroupType.CustomEvents)
- // Inactive tabs stay mounted but hidden, so only the open tab's empty state may ask for suggestions.
- const canOfferEventMatch =
- !emptySearchQuery &&
- listGroupType === activeTab &&
- (listGroupType === TaxonomicFilterGroupType.Events || isSuggestedFilters)
// When this tab has no results but the aggregated "all" (suggested filters) section does, offer a
// jump there so the user doesn't have to guess which tab their match lives in.
@@ -831,7 +824,6 @@ function InfiniteListEmptyState(): JSX.Element {
</>
)}
</span>
- {canOfferEventMatch && <TaxonomicEventMatchSuggestions />}
{canOfferStaleToggle && (
<LemonButton
type="secondary"
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicEventMatchSuggestions.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicEventMatchSuggestions.tsx
deleted file mode 100644
index dde9347d611b..000000000000
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicEventMatchSuggestions.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-import { useActions, useMountedLogic, useValues } from 'kea'
-
-import { LemonButton } from '@posthog/lemon-ui'
-
-import { Spinner } from 'lib/lemon-ui/Spinner'
-
-import { infiniteListLogic } from './infiniteListLogic'
-import { EventMatchHint, taxonomicEventMatchLogic } from './taxonomicEventMatchLogic'
-
-function listOfNames(names: string[]): string {
- if (names.length <= 1) {
- return names.join('')
- }
- return `${names.slice(0, -1).join(', ')} or ${names[names.length - 1]}`
-}
-
-function EventMatchHintMessage({ hint }: { hint: EventMatchHint }): JSX.Element {
- if (hint.kind === 'unsent') {
- return (
- <div className="flex flex-col items-center gap-y-1" data-attr="taxonomic-event-match-unsent">
- <span className="text-secondary text-center max-w-80">
- This looks like <strong>{listOfNames(hint.events.map((event) => event.display_name))}</strong>,
- which this project hasn't sent yet.
- </span>
- </div>
- )
- }
-
- return (
- <div className="flex flex-col items-center gap-y-1" data-attr="taxonomic-event-match-value">
- <span className="text-secondary text-center max-w-80">
- This looks like a value, not an event name. Pick the property that holds it, then filter on the value.
- </span>
- </div>
- )
-}
-
-export function TaxonomicEventMatchSuggestions(): JSX.Element | null {
- const { props } = useMountedLogic(infiniteListLogic)
- const logic = taxonomicEventMatchLogic(props)
- const { suggestedEvents, isMatching, hint } = useValues(logic)
- const { selectEventMatch } = useActions(logic)
-
- if (isMatching) {
- return (
- <div className="flex items-center gap-1 text-secondary" data-attr="taxonomic-event-match-loading">
- <Spinner className="text-sm" />
- <span>Looking for events you might mean</span>
- </div>
- )
- }
-
- if (suggestedEvents.length === 0) {
- return hint ? <EventMatchHintMessage hint={hint} /> : null
- }
-
- return (
- <div className="flex flex-col items-center gap-y-1" data-attr="taxonomic-event-match">
- <span className="text-secondary">Did you mean one of these events?</span>
- <div className="flex flex-wrap justify-center gap-1">
- {suggestedEvents.map((match) => (
- <LemonButton
- key={match.name}
- type="secondary"
- size="xsmall"
- // pinned: data-attr, autocapture and the flag's success metric read it
- data-attr="taxonomic-event-match-suggestion"
- onClick={() => selectEventMatch(match)}
- >
- {match.display_name}
- </LemonButton>
- ))}
- </div>
- </div>
- )
-}
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx
index 98b3fc1ad1b0..66dc8353fdc4 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx
@@ -18,7 +18,6 @@ import { type AnyPropertyFilter, AvailableFeature, EntityTypes, PropertyFilterTy
import { infiniteListLogic } from './infiniteListLogic'
import { recentTaxonomicFiltersLogic } from './recentTaxonomicFiltersLogic'
-import { resetEventMatchMemoryForTests } from './taxonomicEventMatchLogic'
import { TaxonomicFilter } from './TaxonomicFilter'
import { taxonomicFilterCategoryLayoutLogic } from './taxonomicFilterCategoryLayoutLogic'
import { taxonomicFilterLogic } from './taxonomicFilterLogic'
@@ -966,152 +965,6 @@ export const EmptyTabSearchingACategoryName: Story = {
},
}
-function EventMatchStoryRender({
- resetMatches = false,
- ...args
-}: TaxonomicFilterProps & { resetMatches?: boolean }): JSX.Element {
- useMountedLogic(actionsModel)
- const { setSearchQuery } = useActions(
- taxonomicFilterLogic({ ...args, taxonomicFilterLogicKey: args.taxonomicFilterLogicKey as string })
- )
-
- useOnMountEffect(() => {
- if (resetMatches) {
- resetEventMatchMemoryForTests()
- }
- setSearchQuery('browser capture')
- })
-
- return (
- <div className="w-fit border rounded p-2 bg-surface-primary">
- <TaxonomicFilter {...args} />
- </div>
- )
-}
-
-// No event name matches "browser capture", and the decision model answers with two core events.
-const eventMatchAutocaptureMock = mswDecorator({
- get: {
- '/api/projects/:team_id/event_definitions': [],
- },
- post: {
- '/api/projects/:team_id/taxonomic_search_intent/match_events/': () => [
- 200,
- {
- matches: [
- { name: '$autocapture', display_name: 'Autocapture', probability: 0.95 },
- { name: '$rageclick', display_name: 'Rageclick', probability: 0.74 },
- ],
- outcome: 'matched',
- unsent: [],
- },
- ],
- },
-})
-
-const eventMatchAnswerMock = (answer: Record<string, unknown>): ReturnType<typeof mswDecorator> =>
- mswDecorator({
- get: {
- '/api/projects/:team_id/event_definitions': [],
- '/api/projects/:team_id/property_definitions': { results: [], count: 0 },
- },
- post: {
- '/api/projects/:team_id/taxonomic_search_intent/match_events/': () => [200, answer],
- },
- })
-
-/** A search that matches no event name gets core events the decision model thinks it describes. */
-export const EmptyEventsWithEventMatch: Story = {
- render: EventMatchStoryRender,
- args: {
- taxonomicFilterLogicKey: 'events-event-match',
- taxonomicGroupTypes: [TaxonomicFilterGroupType.Events],
- },
- decorators: [eventMatchAutocaptureMock],
- parameters: {
- featureFlags: { [FEATURE_FLAGS.TAXONOMIC_FILTER_EVENT_MATCH]: 'test' },
- testOptions: { waitForSelector: '[data-attr="taxonomic-event-match-suggestion"]' },
- },
-}
-
-/** The "All" tab gets the same suggestions when no group has a result. */
-export const EmptyAllTabWithEventMatch: Story = {
- render: EventMatchStoryRender,
- args: {
- taxonomicFilterLogicKey: 'all-event-match',
- taxonomicGroupTypes: [TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions],
- },
- decorators: [eventMatchAutocaptureMock],
- parameters: {
- featureFlags: { [FEATURE_FLAGS.TAXONOMIC_FILTER_EVENT_MATCH]: 'test' },
- testOptions: { waitForSelector: '[data-attr="taxonomic-event-match-suggestion"]' },
- },
-}
-
-/** The model's likely event was never sent by this project, so the empty state names it instead of suggesting it. */
-export const EmptyEventsWithUnsentEventHint: Story = {
- render: (args) => <EventMatchStoryRender {...args} resetMatches />,
- args: {
- taxonomicFilterLogicKey: 'events-event-match-unsent',
- taxonomicGroupTypes: [TaxonomicFilterGroupType.Events],
- },
- decorators: [
- eventMatchAnswerMock({
- matches: [],
- outcome: 'not_ingested',
- unsent: [{ name: '$screen', display_name: 'Screen', probability: 0.85 }],
- }),
- ],
- parameters: {
- featureFlags: { [FEATURE_FLAGS.TAXONOMIC_FILTER_EVENT_MATCH]: 'test' },
- testOptions: { waitForSelector: '[data-attr="taxonomic-event-match-unsent"]' },
- },
-}
-
-/** A search made only of values gets a pointer to properties instead of an event suggestion. */
-export const EmptyEventsWithValueHint: Story = {
- render: (args) => <EventMatchStoryRender {...args} resetMatches />,
- args: {
- taxonomicFilterLogicKey: 'events-event-match-value',
- taxonomicGroupTypes: [TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.EventProperties],
- },
- decorators: [eventMatchAnswerMock({ matches: [], outcome: 'only_values', unsent: [] })],
- parameters: {
- featureFlags: { [FEATURE_FLAGS.TAXONOMIC_FILTER_EVENT_MATCH]: 'test' },
- testOptions: { waitForSelector: '[data-attr="taxonomic-event-match-value"]' },
- },
-}
-
-/** While the decision model is still answering, the empty state says so. */
-export const EmptyEventsWithEventMatchLoading: Story = {
- render: (args) => <EventMatchStoryRender {...args} resetMatches />,
- args: {
- taxonomicFilterLogicKey: 'events-event-match-loading',
- taxonomicGroupTypes: [TaxonomicFilterGroupType.Events],
- },
- decorators: [
- mswDecorator({
- get: {
- '/api/projects/:team_id/event_definitions': [],
- },
- post: {
- '/api/projects/:team_id/taxonomic_search_intent/match_events/': async () => {
- await delay('infinite')
- return [200, { matches: [], outcome: 'nothing_likely', unsent: [] }]
- },
- },
- }),
- ],
- parameters: {
- featureFlags: { [FEATURE_FLAGS.TAXONOMIC_FILTER_EVENT_MATCH]: 'test' },
- // The spinner is the point of this story, so the runner must not wait for it to disappear.
- testOptions: {
- waitForSelector: '[data-attr="taxonomic-event-match-loading"]',
- waitForLoadersToDisappear: false,
- },
- },
-}
-
// The decision model answers "person properties" for a search of "email" in every search intent story.
const searchIntentPersonPropertiesMock = mswDecorator({
post: {
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicEventMatchLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/taxonomicEventMatchLogic.test.ts
deleted file mode 100644
index daeeb780624c..000000000000
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicEventMatchLogic.test.ts
+++ /dev/null
@@ -1,434 +0,0 @@
-import { MOCK_TEAM_ID } from 'lib/api.mock'
-
-import { waitFor } from '@testing-library/react'
-import { expectLogic } from 'kea-test-utils'
-import posthog from 'posthog-js'
-
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-
-import { useMocks } from '~/mocks/jest'
-import { initKeaTests } from '~/test/init'
-import { AppContext } from '~/types'
-
-import { resetEventMatchMemoryForTests, taxonomicEventMatchLogic } from './taxonomicEventMatchLogic'
-import { taxonomicFilterLogic } from './taxonomicFilterLogic'
-import { TaxonomicFilterGroupType, TaxonomicFilterLogicProps } from './types'
-
-window.POSTHOG_APP_CONTEXT = {
- current_team: { id: MOCK_TEAM_ID },
- current_project: { id: MOCK_TEAM_ID },
-} as unknown as AppContext
-
-const PROPS: TaxonomicFilterLogicProps = {
- taxonomicFilterLogicKey: 'event-match-test',
- taxonomicGroupTypes: [TaxonomicFilterGroupType.Events],
-}
-
-// Two groups, so the picker also offers the "All" tab and opens on it.
-const ALL_TAB_PROPS: TaxonomicFilterLogicProps = {
- taxonomicFilterLogicKey: 'event-match-all-tab-test',
- taxonomicGroupTypes: [TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions],
-}
-
-const ELIGIBLE_EVENT = 'taxonomic filter event match eligible'
-
-const AUTOCAPTURE = { name: '$autocapture', display_name: 'Autocapture', probability: 0.95 }
-
-describe('taxonomicEventMatchLogic', () => {
- let filterLogic: ReturnType<typeof taxonomicFilterLogic.build>
- let logic: ReturnType<typeof taxonomicEventMatchLogic.build>
- let matchRequests: Record<string, any>[]
- let status: number
- let matches: Record<string, any>[]
- let outcome: string
- let unsent: Record<string, any>[]
- let answerGate: Promise<void> | null
-
- beforeEach(() => {
- matchRequests = []
- status = 200
- matches = [AUTOCAPTURE]
- outcome = 'matched'
- unsent = []
- answerGate = null
- resetEventMatchMemoryForTests()
- useMocks({
- get: {
- '/api/projects/:team/event_definitions': () => [200, { results: [], count: 0 }],
- },
- post: {
- '/api/projects/:team/taxonomic_search_intent/match_events/': async ({ request }) => {
- matchRequests.push((await request.json()) as Record<string, any>)
- if (answerGate) {
- await answerGate
- }
- return status === 200 ? [200, { matches, outcome, unsent }] : [status, {}]
- },
- },
- })
- initKeaTests()
- filterLogic = taxonomicFilterLogic(PROPS)
- filterLogic.mount()
- logic = taxonomicEventMatchLogic(PROPS)
- logic.mount()
- })
-
- afterEach(() => {
- jest.restoreAllMocks()
- })
-
- const search = async (query: string): Promise<void> => {
- filterLogic.actions.setSearchQuery(query)
- await expectLogic(logic).toFinishAllListeners()
- }
-
- const enroll = (variant: 'test' | 'control' | false): void => {
- featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.TAXONOMIC_FILTER_EVENT_MATCH], {
- [FEATURE_FLAGS.TAXONOMIC_FILTER_EVENT_MATCH]: variant,
- })
- }
-
- const mountAllTabPicker = (): {
- allTabFilterLogic: ReturnType<typeof taxonomicFilterLogic.build>
- allTabLogic: ReturnType<typeof taxonomicEventMatchLogic.build>
- } => {
- const allTabFilterLogic = taxonomicFilterLogic(ALL_TAB_PROPS)
- allTabFilterLogic.mount()
- const allTabLogic = taxonomicEventMatchLogic(ALL_TAB_PROPS)
- allTabLogic.mount()
- return { allTabFilterLogic, allTabLogic }
- }
-
- const holdAnswer = (): (() => void) => {
- let answer: () => void = () => {}
- answerGate = new Promise<void>((resolve) => {
- answer = resolve
- })
- return answer
- }
-
- it.each([
- ['for a person outside the flag', (): typeof logic => (enroll(false), logic)],
- ['for a person in the control arm', (): typeof logic => (enroll('control'), logic)],
- [
- 'from a tab that never shows suggestions',
- (): typeof logic => {
- enroll('test')
- const { allTabFilterLogic, allTabLogic } = mountAllTabPicker()
- allTabFilterLogic.actions.setActiveTab(TaxonomicFilterGroupType.Actions)
- allTabFilterLogic.actions.setSearchQuery('browser capture')
- return allTabLogic
- },
- ],
- ])('does not ask the model %s', async (_, arrange) => {
- const askedLogic = arrange()
- if (askedLogic === logic) {
- filterLogic.actions.setSearchQuery('browser capture')
- }
- expect(askedLogic.values.isMatching).toBe(false)
-
- await expectLogic(askedLogic).toFinishAllListeners()
-
- expect(matchRequests).toHaveLength(0)
- expect(askedLogic.values.isMatching).toBe(false)
- expect(askedLogic.values.suggestedEvents).toEqual([])
- })
-
- it.each([
- ['during the pause', async (): Promise<void> => {}, 0],
- [
- 'while the model answers',
- async (): Promise<void> => {
- await waitFor(() => expect(matchRequests).toHaveLength(1))
- },
- 1,
- ],
- ])('drops the ask when another tab opens %s', async (_, waitBeforeSwitch, expectedRequests) => {
- enroll('test')
- const captureSpy = jest.spyOn(posthog, 'capture')
- const answer = holdAnswer()
- const { allTabFilterLogic, allTabLogic } = mountAllTabPicker()
-
- allTabFilterLogic.actions.setSearchQuery('browser capture')
- await waitBeforeSwitch()
- allTabFilterLogic.actions.setActiveTab(TaxonomicFilterGroupType.Actions)
- answer()
- await expectLogic(allTabLogic).toFinishAllListeners()
-
- expect(matchRequests).toHaveLength(expectedRequests)
- expect(allTabLogic.values.isMatching).toBe(false)
- expect(allTabLogic.values.suggestedEvents).toEqual([])
- expect(captureSpy).not.toHaveBeenCalledWith('taxonomic filter event match suggested', expect.anything())
- // Exposure counts only once the pause ended on a visible list.
- expect(captureSpy.mock.calls.filter(([event]) => event === ELIGIBLE_EVENT)).toHaveLength(expectedRequests)
- })
-
- it('shows a loading state from the All tab until the answer arrives, and records the tab', async () => {
- enroll('test')
- const captureSpy = jest.spyOn(posthog, 'capture')
- const answer = holdAnswer()
- const { allTabFilterLogic, allTabLogic } = mountAllTabPicker()
- expect(allTabFilterLogic.values.activeTab).toEqual(TaxonomicFilterGroupType.SuggestedFilters)
-
- allTabFilterLogic.actions.setSearchQuery('browser capture')
- await expectLogic(allTabLogic).toDispatchActions(['startEventMatch'])
-
- expect(allTabLogic.values.isMatching).toBe(true)
- expect(allTabLogic.values.suggestedEvents).toEqual([])
-
- answer()
- await expectLogic(allTabLogic).toFinishAllListeners()
-
- expect(allTabLogic.values.isMatching).toBe(false)
- expect(allTabLogic.values.suggestedEvents).toEqual([AUTOCAPTURE])
- expect(captureSpy).toHaveBeenCalledWith('taxonomic filter event match suggested', {
- surface: 'legacy-pill',
- tab: 'suggested_filters',
- suggestedEvents: ['$autocapture'],
- })
- })
-
- it('suggests the matched events for the current search only, and selects one on click', async () => {
- enroll('test')
- const captureSpy = jest.spyOn(posthog, 'capture')
-
- await search('browser capture')
-
- expect(matchRequests).toEqual([{ query: 'browser capture' }])
- expect(logic.values.suggestedEvents).toEqual([AUTOCAPTURE])
-
- await expectLogic(filterLogic, () => logic.actions.selectEventMatch(AUTOCAPTURE)).toDispatchActions([
- (action) =>
- action.type === filterLogic.actionTypes.selectItem &&
- action.payload.group.type === TaxonomicFilterGroupType.Events &&
- action.payload.value === '$autocapture' &&
- action.payload.meta.position === 0,
- ])
- expect(captureSpy).toHaveBeenCalledWith('taxonomic filter event match selected', {
- surface: 'legacy-pill',
- tab: 'events',
- eventName: '$autocapture',
- position: 0,
- })
-
- filterLogic.actions.setSearchQuery('browser capture events')
- expect(logic.values.suggestedEvents).toEqual([])
- })
-
- it('shows the remembered answer again when the empty state remounts for the same search', async () => {
- enroll('test')
- const captureSpy = jest.spyOn(posthog, 'capture')
- await search('browser capture')
- expect(matchRequests).toHaveLength(1)
-
- logic.unmount()
- logic.mount()
- await expectLogic(logic).toFinishAllListeners()
-
- expect(matchRequests).toHaveLength(1)
- expect(logic.values.isMatching).toBe(false)
- expect(logic.values.suggestedEvents).toEqual([AUTOCAPTURE])
- const suggestedCaptures = captureSpy.mock.calls.filter(
- ([event]) => event === 'taxonomic filter event match suggested'
- )
- expect(suggestedCaptures).toHaveLength(2)
- })
-
- it('does not suggest an event the picker excludes', async () => {
- const excludingProps: TaxonomicFilterLogicProps = {
- ...PROPS,
- taxonomicFilterLogicKey: 'event-match-excluding-test',
- excludedProperties: { [TaxonomicFilterGroupType.Events]: ['$autocapture'] },
- }
- const excludingFilterLogic = taxonomicFilterLogic(excludingProps)
- excludingFilterLogic.mount()
- const excludingLogic = taxonomicEventMatchLogic(excludingProps)
- excludingLogic.mount()
- enroll('test')
- const captureSpy = jest.spyOn(posthog, 'capture')
-
- excludingFilterLogic.actions.setSearchQuery('browser capture')
- await expectLogic(excludingLogic).toFinishAllListeners()
-
- expect(matchRequests).toHaveLength(1)
- expect(excludingLogic.values.suggestedEvents).toEqual([])
- expect(captureSpy).not.toHaveBeenCalledWith('taxonomic filter event match suggested', expect.anything())
- })
-
- it('fills the suggestions from the events the picker does not exclude', async () => {
- const excludingProps: TaxonomicFilterLogicProps = {
- ...PROPS,
- taxonomicFilterLogicKey: 'event-match-limit-test',
- excludedProperties: { [TaxonomicFilterGroupType.Events]: ['$autocapture'] },
- }
- const excludingFilterLogic = taxonomicFilterLogic(excludingProps)
- excludingFilterLogic.mount()
- const excludingLogic = taxonomicEventMatchLogic(excludingProps)
- excludingLogic.mount()
- enroll('test')
- matches = [
- AUTOCAPTURE,
- { name: '$rageclick', display_name: 'Rageclick', probability: 0.9 },
- { name: '$dead_click', display_name: 'Dead click', probability: 0.85 },
- { name: '$pageview', display_name: 'Pageview', probability: 0.8 },
- { name: '$exception', display_name: 'Exception', probability: 0.75 },
- ]
-
- excludingFilterLogic.actions.setSearchQuery('browser capture')
- await expectLogic(excludingLogic).toFinishAllListeners()
-
- expect(excludingLogic.values.suggestedEvents.map((match) => match.name)).toEqual([
- '$rageclick',
- '$dead_click',
- '$pageview',
- ])
- })
-
- it('stops asking for the project after a 404', async () => {
- enroll('test')
- status = 404
-
- const captureSpy = jest.spyOn(posthog, 'capture')
-
- await search('browser capture')
- await search('page view')
-
- expect(matchRequests).toHaveLength(1)
- expect(logic.values.suggestedEvents).toEqual([])
- expect(logic.values.isMatching).toBe(false)
- // A 404 must not make the test arm look less exposed than control.
- expect(captureSpy.mock.calls.filter(([event]) => event === ELIGIBLE_EVENT)).toHaveLength(2)
- })
-
- it.each([
- [404, false],
- [429, false],
- [503, false],
- [500, true],
- ])('reports a %s failure to error tracking: %s', async (failureStatus, reported) => {
- enroll('test')
- status = failureStatus
- const captureExceptionSpy = jest.spyOn(posthog, 'captureException').mockImplementation(() => undefined as any)
-
- await search('browser capture')
-
- expect(logic.values.suggestedEvents).toEqual([])
- expect(captureExceptionSpy.mock.calls).toEqual(
- reported
- ? [[expect.anything(), { feature: 'taxonomic-event-match', projectId: MOCK_TEAM_ID, status: 500 }]]
- : []
- )
- })
-
- it.each([['control'], ['test']] as const)(
- 'reports the %s arm as eligible once per search, after the pause',
- async (variant) => {
- enroll(variant)
- const captureSpy = jest.spyOn(posthog, 'capture')
-
- // A prefix typed before the pause ends must not count as a search.
- filterLogic.actions.setSearchQuery('browser')
- await search('browser capture')
- logic.unmount()
- logic.mount()
- await expectLogic(logic).toFinishAllListeners()
-
- const eligible = captureSpy.mock.calls.filter(([event]) => event === ELIGIBLE_EVENT)
- expect(eligible).toEqual([
- ['taxonomic filter event match eligible', { surface: 'legacy-pill', tab: 'events', variant }],
- ])
- expect(matchRequests).toHaveLength(variant === 'test' ? 1 : 0)
- }
- )
-
- it('names the likely events the project never sent instead of suggesting them', async () => {
- enroll('test')
- matches = []
- outcome = 'not_ingested'
- unsent = [{ name: '$screen', display_name: 'Screen', probability: 0.85 }]
- const captureSpy = jest.spyOn(posthog, 'capture')
-
- await search('mobile screen')
-
- expect(logic.values.suggestedEvents).toEqual([])
- expect(logic.values.hint).toEqual({ kind: 'unsent', events: unsent })
- expect(captureSpy).toHaveBeenCalledWith('taxonomic filter event match hint shown', {
- surface: 'legacy-pill',
- tab: 'events',
- hint: 'unsent',
- unsentEvents: ['$screen'],
- })
- })
-
- it('does not name an unsent event the picker excludes', async () => {
- const excludingProps: TaxonomicFilterLogicProps = {
- ...PROPS,
- taxonomicFilterLogicKey: 'event-match-excluding-unsent-test',
- excludedProperties: { [TaxonomicFilterGroupType.Events]: ['$screen'] },
- }
- const excludingFilterLogic = taxonomicFilterLogic(excludingProps)
- excludingFilterLogic.mount()
- const excludingLogic = taxonomicEventMatchLogic(excludingProps)
- excludingLogic.mount()
- enroll('test')
- matches = []
- outcome = 'not_ingested'
- unsent = [{ name: '$screen', display_name: 'Screen', probability: 0.85 }]
-
- excludingFilterLogic.actions.setSearchQuery('mobile screen')
- await expectLogic(excludingLogic).toFinishAllListeners()
-
- expect(excludingLogic.values.hint).toBeNull()
- })
-
- it.each([
- { picker: 'events only', taxonomicGroupTypes: [TaxonomicFilterGroupType.Events], hint: null },
- {
- picker: 'events and event properties',
- taxonomicGroupTypes: [TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.EventProperties],
- hint: { kind: 'value' },
- },
- {
- picker: 'events and person properties',
- taxonomicGroupTypes: [TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.PersonProperties],
- hint: { kind: 'value' },
- },
- {
- picker: 'events and session properties',
- taxonomicGroupTypes: [TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.SessionProperties],
- hint: { kind: 'value' },
- },
- ])(
- 'points a value search at properties only where one can be picked: $picker',
- async ({ taxonomicGroupTypes, hint }) => {
- enroll('test')
- matches = []
- outcome = 'only_values'
- const pickerProps: TaxonomicFilterLogicProps = {
- taxonomicFilterLogicKey: `event-match-value-hint-${taxonomicGroupTypes.join('-')}`,
- taxonomicGroupTypes,
- }
- const pickerFilterLogic = taxonomicFilterLogic(pickerProps)
- pickerFilterLogic.mount()
- const pickerLogic = taxonomicEventMatchLogic(pickerProps)
- pickerLogic.mount()
- pickerFilterLogic.actions.setActiveTab(TaxonomicFilterGroupType.Events)
-
- pickerFilterLogic.actions.setSearchQuery('[email protected]')
- await expectLogic(pickerLogic).toFinishAllListeners()
-
- expect(pickerLogic.values.hint).toEqual(hint)
- }
- )
-
- it('shows no hint when the model simply found nothing likely', async () => {
- enroll('test')
- matches = []
- outcome = 'nothing_likely'
-
- await search('browser capture')
-
- expect(logic.values.hint).toBeNull()
- })
-})
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicEventMatchLogic.ts b/frontend/src/lib/components/TaxonomicFilter/taxonomicEventMatchLogic.ts
deleted file mode 100644
index cfa67e6a7458..000000000000
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicEventMatchLogic.ts
+++ /dev/null
@@ -1,388 +0,0 @@
-import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
-import posthog from 'posthog-js'
-
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-import { projectLogic } from 'scenes/projectLogic'
-
-import { taxonomicSearchIntentMatchEventsCreate } from '~/generated/core/api'
-import type { EventMatchApi, EventMatchOutcomeEnumApi } from '~/generated/core/api.schemas'
-
-import type { FeatureFlagsSet } from '../../logic/featureFlagLogic'
-import { SelectItemMeta, taxonomicFilterLogic } from './taxonomicFilterLogic'
-import { legacyTaxonomicSurface } from './taxonomicFilterSurface'
-import {
- TaxonomicFilterGroup,
- TaxonomicFilterGroupType,
- TaxonomicFilterLogicProps,
- TaxonomicFilterValue,
-} from './types'
-
-// Mirrors MIN_QUERY_CHARS and MAX_QUERY_CHARS in posthog/taxonomic_search_intent/classify.py.
-const MIN_QUERY_LENGTH = 2
-const MAX_QUERY_LENGTH = 64
-// Mirrors MAX_MATCHES in posthog/taxonomic_search_intent/event_match.py. Applied after exclusions, so they never empty the list.
-const MAX_SUGGESTIONS = 3
-// Longer than a keystroke gap, so a person who types a phrase asks once and not once per letter.
-const EVENT_MATCH_DEBOUNCE_MS = 350
-// A throttle returns 429 by design, and the backend reports its own model failures as 503.
-// Other failures are visible only in the browser, so the logic reports them without the search text.
-const UNREPORTED_FAILURE_STATUSES = [429, 503]
-// The picker keeps every tab's list mounted and hides the inactive ones, so only the open tab may ask the model.
-const TABS_WITH_SUGGESTIONS = [TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.SuggestedFilters]
-// The flag is an experiment. Only the test arm asks the model; both arms report that they reached the dead end.
-const EXPERIMENT_VARIANTS = ['control', 'test']
-const TEST_VARIANT = 'test'
-
-export interface EventMatchAnswer {
- matches: EventMatchApi[]
- outcome: EventMatchOutcomeEnumApi
- unsent: EventMatchApi[]
-}
-
-export interface EventMatches extends EventMatchAnswer {
- projectId: number
- query: string
-}
-
-/** What the empty state can say when the model has no event to suggest. */
-export type EventMatchHint = { kind: 'unsent'; events: EventMatchApi[] } | { kind: 'value' }
-
-// A 404 means the person is not in the flag for this project, so the rest of the page load does not ask again.
-const unavailableProjectIds = new Set<number>()
-// Switching between the All and Events tabs remounts the empty state and this logic with it, so each answer is
-// kept for the page load and shown again without another model call. The backend caches the same key.
-const answeredMatches = new Map<string, EventMatchAnswer>()
-// Exposure for the experiment: one report per search per page load, so retyping or remounting does not count twice.
-const reportedEligible = new Set<string>()
-
-const matchKey = (projectId: number, query: string): string => `${projectId}:${query}`
-
-// A value belongs to a property, so the value hint only helps in a picker where the person can pick one.
-const PROPERTY_GROUP_TYPES = [
- TaxonomicFilterGroupType.EventProperties,
- TaxonomicFilterGroupType.PersonProperties,
- TaxonomicFilterGroupType.SessionProperties,
-]
-
-function offersProperties(taxonomicGroupTypes: TaxonomicFilterGroupType[]): boolean {
- return PROPERTY_GROUP_TYPES.some((groupType) => taxonomicGroupTypes.includes(groupType))
-}
-
-export function resetEventMatchMemoryForTests(): void {
- unavailableProjectIds.clear()
- answeredMatches.clear()
- reportedEligible.clear()
-}
-
-function reportEligible(projectId: number, query: string, tab: TaxonomicFilterGroupType, variant: string): void {
- const key = matchKey(projectId, query)
- if (reportedEligible.has(key)) {
- return
- }
- reportedEligible.add(key)
- // pinned: analytics event name and properties, the experiment's exposure reads them
- posthog.capture('taxonomic filter event match eligible', {
- surface: legacyTaxonomicSurface(),
- tab,
- variant,
- })
-}
-
-function reportHint(hint: EventMatchHint | null, tab: TaxonomicFilterGroupType): void {
- if (!hint) {
- return
- }
- posthog.capture('taxonomic filter event match hint shown', {
- surface: legacyTaxonomicSurface(),
- tab,
- hint: hint.kind,
- unsentEvents: hint.kind === 'unsent' ? hint.events.map((event) => event.name) : undefined,
- })
-}
-
-function reportSuggested(shown: EventMatchApi[], tab: TaxonomicFilterGroupType): void {
- // Only the suggestions the picker shows, after its exclusions, count for the flag's metric.
- if (shown.length === 0) {
- return
- }
- // pinned: analytics event name and properties, the flag's success metric reads them
- posthog.capture('taxonomic filter event match suggested', {
- surface: legacyTaxonomicSurface(),
- tab,
- suggestedEvents: shown.map((match) => match.name),
- })
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface taxonomicEventMatchLogicValues {
- featureFlags: FeatureFlagsSet // featureFlagLogic
- currentProjectId: number | null // projectLogic
- activeTab: TaxonomicFilterGroupType // taxonomicFilterLogic
- searchQuery: string // taxonomicFilterLogic
- taxonomicGroupTypes: TaxonomicFilterGroupType[] // taxonomicFilterLogic
- taxonomicGroups: TaxonomicFilterGroup[] // taxonomicFilterLogic
- currentAnswer: EventMatches | null
- eventMatches: EventMatches | null
- hint: EventMatchHint | null
- isMatching: boolean
- pendingQuery: string | null
- suggestedEvents: EventMatchApi[]
- tabShowsSuggestions: boolean
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface taxonomicEventMatchLogicActions {
- selectItem: (
- group: TaxonomicFilterGroup,
- value: TaxonomicFilterValue,
- item: any,
- meta?: SelectItemMeta | undefined
- ) => {
- group: TaxonomicFilterGroup
- item: any
- meta: SelectItemMeta | undefined
- value: TaxonomicFilterValue
- } // taxonomicFilterLogic
- setSearchQuery: (searchQuery: string) => {
- searchQuery: string
- } // taxonomicFilterLogic
- findEventMatches: (searchQuery: string) => {
- searchQuery: string
- }
- selectEventMatch: (match: EventMatchApi) => {
- match: EventMatchApi
- }
- setEventMatches: (eventMatches: EventMatches | null) => {
- eventMatches: EventMatches | null
- }
- startEventMatch: (query: string) => {
- query: string
- }
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface taxonomicEventMatchLogicMeta {
- key: string
- __keaTypeGenInternalSelectorTypes: {
- currentAnswer: (
- eventMatches: EventMatches | null,
- searchQuery: string,
- currentProjectId: number | null
- ) => EventMatches | null
- hint: (
- currentAnswer: EventMatches | null,
- suggestedEvents: EventMatchApi[],
- taxonomicGroups: TaxonomicFilterGroup[],
- taxonomicGroupTypes: TaxonomicFilterGroupType[]
- ) => EventMatchHint | null
- suggestedEvents: (
- currentAnswer: EventMatches | null,
- taxonomicGroups: TaxonomicFilterGroup[]
- ) => EventMatchApi[]
- isMatching: (pendingQuery: string | null, searchQuery: string) => boolean
- tabShowsSuggestions: (activeTab: TaxonomicFilterGroupType) => boolean
- }
-}
-
-export type taxonomicEventMatchLogicType = MakeLogicType<
- taxonomicEventMatchLogicValues,
- taxonomicEventMatchLogicActions,
- TaxonomicFilterLogicProps,
- taxonomicEventMatchLogicMeta
->
-
-// A picker that excludes an event from its list must not offer or name it either.
-function withoutExcluded(events: EventMatchApi[], taxonomicGroups: TaxonomicFilterGroup[]): EventMatchApi[] {
- const excluded =
- taxonomicGroups.find((group) => group.type === TaxonomicFilterGroupType.Events)?.excludedProperties ?? []
- return events.filter((event) => !excluded.includes(event.name)).slice(0, MAX_SUGGESTIONS)
-}
-
-/**
- * Asks the decision model which PostHog core events a search that matched no event name describes, for the
- * `taxonomic-filter-event-match` experiment. Mounted by the empty state of the events list and of the "All" list.
- * The test arm suggests the matched events, or says why there are none: the likely event was never sent, or the
- * search is only values. The control arm asks nothing and only reports that it reached the dead end.
- * Legacy surface only.
- */
-export const taxonomicEventMatchLogic = kea<taxonomicEventMatchLogicType>([
- props({} as TaxonomicFilterLogicProps),
- key((props) => `${props.taxonomicFilterLogicKey}`),
- path((key) => ['lib', 'components', 'TaxonomicFilter', 'taxonomicEventMatchLogic', key]),
- connect((props: TaxonomicFilterLogicProps) => ({
- values: [
- featureFlagLogic,
- ['featureFlags'],
- projectLogic,
- ['currentProjectId'],
- taxonomicFilterLogic(props),
- ['activeTab', 'searchQuery', 'taxonomicGroupTypes', 'taxonomicGroups'],
- ],
- actions: [taxonomicFilterLogic(props), ['selectItem', 'setSearchQuery']],
- })),
- actions({
- findEventMatches: (searchQuery: string) => ({ searchQuery }),
- startEventMatch: (query: string) => ({ query }),
- setEventMatches: (eventMatches: EventMatches | null) => ({ eventMatches }),
- selectEventMatch: (match: EventMatchApi) => ({ match }),
- }),
- reducers({
- eventMatches: [
- null as EventMatches | null,
- {
- setEventMatches: (_, { eventMatches }) => eventMatches,
- },
- ],
- pendingQuery: [
- null as string | null,
- {
- startEventMatch: (_, { query }) => query,
- setEventMatches: () => null,
- },
- ],
- }),
- selectors({
- currentAnswer: [
- (s) => [s.eventMatches, s.searchQuery, s.currentProjectId],
- (
- eventMatches: EventMatches | null,
- searchQuery: string,
- currentProjectId: number | null
- ): EventMatches | null =>
- // An answer for an older search or another project stays hidden, so a suggestion never names the wrong one.
- eventMatches?.query === searchQuery.trim() && eventMatches.projectId === currentProjectId
- ? eventMatches
- : null,
- ],
- hint: [
- (s) => [s.currentAnswer, s.suggestedEvents, s.taxonomicGroups, s.taxonomicGroupTypes],
- (
- currentAnswer: EventMatches | null,
- suggestedEvents: EventMatchApi[],
- taxonomicGroups: TaxonomicFilterGroup[],
- taxonomicGroupTypes: TaxonomicFilterGroupType[]
- ): EventMatchHint | null => {
- if (!currentAnswer || suggestedEvents.length > 0) {
- return null
- }
- if (currentAnswer.outcome === 'only_values') {
- return offersProperties(taxonomicGroupTypes) ? { kind: 'value' } : null
- }
- if (currentAnswer.outcome === 'not_ingested') {
- const events = withoutExcluded(currentAnswer.unsent, taxonomicGroups)
- return events.length > 0 ? { kind: 'unsent', events } : null
- }
- return null
- },
- ],
- suggestedEvents: [
- (s) => [s.currentAnswer, s.taxonomicGroups],
- (currentAnswer: EventMatches | null, taxonomicGroups: TaxonomicFilterGroup[]): EventMatchApi[] =>
- currentAnswer ? withoutExcluded(currentAnswer.matches, taxonomicGroups) : [],
- ],
- isMatching: [
- (s) => [s.pendingQuery, s.searchQuery],
- (pendingQuery: string | null, searchQuery: string): boolean =>
- pendingQuery !== null && pendingQuery === searchQuery.trim(),
- ],
- tabShowsSuggestions: [
- (s) => [s.activeTab],
- (activeTab: TaxonomicFilterGroupType): boolean => TABS_WITH_SUGGESTIONS.includes(activeTab),
- ],
- }),
- listeners(({ actions, values }) => ({
- setSearchQuery: ({ searchQuery }) => {
- actions.findEventMatches(searchQuery)
- },
- findEventMatches: async ({ searchQuery }, breakpoint) => {
- const query = searchQuery.trim()
- const projectId = values.currentProjectId
- const variant = values.featureFlags[FEATURE_FLAGS.TAXONOMIC_FILTER_EVENT_MATCH]
- if (
- query.length < MIN_QUERY_LENGTH ||
- query.length > MAX_QUERY_LENGTH ||
- projectId === null ||
- !EXPERIMENT_VARIANTS.includes(String(variant)) ||
- !values.tabShowsSuggestions ||
- !values.taxonomicGroupTypes.includes(TaxonomicFilterGroupType.Events)
- ) {
- return
- }
- // A 404 blocks only the model call. Both arms still count as exposed, so the arms stay comparable.
- const asksTheModel = variant === TEST_VARIANT && !unavailableProjectIds.has(projectId)
- const remembered = asksTheModel ? answeredMatches.get(matchKey(projectId, query)) : undefined
- if (remembered) {
- reportEligible(projectId, query, values.activeTab, String(variant))
- actions.setEventMatches({ projectId, query, ...remembered })
- reportSuggested(values.suggestedEvents, values.activeTab)
- reportHint(values.hint, values.activeTab)
- return
- }
- if (asksTheModel) {
- actions.startEventMatch(query)
- }
- await breakpoint(EVENT_MATCH_DEBOUNCE_MS)
- // A tab opened during the pause hides this list, so the ask is dropped before it costs a model call.
- if (!values.tabShowsSuggestions) {
- actions.setEventMatches(null)
- return
- }
- // Both arms count as exposed once a settled search reaches the dead end the model would answer.
- reportEligible(projectId, query, values.activeTab, String(variant))
- if (!asksTheModel) {
- return
- }
-
- let answer: EventMatchAnswer
- try {
- const response = await taxonomicSearchIntentMatchEventsCreate(String(projectId), { query })
- answer = { matches: response.matches, outcome: response.outcome, unsent: response.unsent ?? [] }
- } catch (error: any) {
- if (error?.status === 404) {
- unavailableProjectIds.add(projectId)
- } else if (!UNREPORTED_FAILURE_STATUSES.includes(error?.status)) {
- posthog.captureException(error, {
- feature: 'taxonomic-event-match',
- projectId,
- status: error?.status,
- })
- }
- breakpoint()
- actions.setEventMatches(null)
- return
- }
- breakpoint()
- // A tab opened while the model answered hides this list, so the answer is dropped and never counted as shown.
- if (!values.tabShowsSuggestions) {
- actions.setEventMatches(null)
- return
- }
- answeredMatches.set(matchKey(projectId, query), answer)
- actions.setEventMatches({ projectId, query, ...answer })
- reportSuggested(values.suggestedEvents, values.activeTab)
- reportHint(values.hint, values.activeTab)
- },
- selectEventMatch: ({ match }) => {
- const eventsGroup = values.taxonomicGroups.find((group) => group.type === TaxonomicFilterGroupType.Events)
- if (!eventsGroup) {
- return
- }
- const position = values.suggestedEvents.findIndex((suggested) => suggested.name === match.name)
- if (position === -1) {
- return
- }
- // pinned: analytics event name and properties, the flag's success metric reads them
- posthog.capture('taxonomic filter event match selected', {
- surface: legacyTaxonomicSurface(),
- tab: values.activeTab,
- eventName: match.name,
- position,
- })
- actions.selectItem(eventsGroup, match.name, { name: match.name }, { position })
- },
- })),
- afterMount(({ actions, values }) => {
- actions.findEventMatches(values.searchQuery)
- }),
-])
diff --git a/frontend/src/lib/components/TaxonomicFilter/telemetryContract.test.ts b/frontend/src/lib/components/TaxonomicFilter/telemetryContract.test.ts
index 814207bf3be3..23e3eae36158 100644
--- a/frontend/src/lib/components/TaxonomicFilter/telemetryContract.test.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/telemetryContract.test.ts
@@ -14,8 +14,6 @@ const CONTRACT_PATH = path.resolve(
)
// Each section of the contract states whether its events carry `surface`, so it is not listed per event.
const IMPLIED_PROPERTIES = new Set(['surface'])
-// Sent from the backend, so no frontend capture call exists for it.
-const SERVER_SIDE_EVENTS = new Set(['taxonomic filter event match answered'])
function sourceFiles(root: string): string[] {
if (fs.statSync(root).isFile()) {
@@ -122,7 +120,7 @@ describe('taxonomic filter telemetry contract', () => {
)
it('lists no event that the frontend no longer sends', () => {
- const stale = [...documented.keys()].filter((event) => !captured.has(event) && !SERVER_SIDE_EVENTS.has(event))
+ const stale = [...documented.keys()].filter((event) => !captured.has(event))
expect(stale).toEqual([])
})
})
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 5f7918e27a43..ac954fdea98f 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -538,7 +538,6 @@ export const FEATURE_FLAGS = {
TASK_SUMMARIES: 'task-summaries', // owner: #team-ai-observability
TASK_TOOL: 'phai-task-tool', // owner: @kappa90 #team-posthog-ai
TASKS: 'tasks', // owner: #team-ai-observability
- TAXONOMIC_FILTER_EVENT_MATCH: 'taxonomic-filter-event-match', // owner: @pauldambra multivariate=control,test, experiment: test asks the decision model which core events an events search with no results describes, then suggests them or says why there are none; control asks nothing
TAXONOMIC_FILTER_FUZZY_EVENT_SEARCH: 'taxonomic-filter-fuzzy-event-search', // owner: @pauldambra multivariate=control,test, experiment: test makes Events and Custom events searches with no match ask the API for similar event names
TAXONOMIC_FILTER_SEARCH_INTENT: 'taxonomic-filter-search-intent', // owner: @pauldambra multivariate=control,banner,promote, classifies a picker search with the decision model. control changes nothing, banner suggests the right tab, promote moves the predicted group to the top of the All tab
TAXONOMIC_FILTER_VALUE_SEARCH_GATING: 'taxonomic-filter-value-search-gating', // owner: @pauldambra