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.

fix(taxonomic-filter): rank pageview URL values below property names (#95326)

Paul D'Ambra77eaefd8d558
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 2a7b88e77768..d6722860a13d 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -2777,9 +2777,9 @@ snapshots:
filters-taxonomic-filter--numerical-properties--light:
hash: v1.k794b7964.eeb595aa423f9104a03146d58f306ebd252f3bdda868b8655a5761018ab7427c.j2JfKgLjpJ7o0RyENwpHLY4OngOa0-6sLl1L0PsLM1Y
filters-taxonomic-filter--promoted-groups-are-reordered--dark:
- hash: v1.k794b7964.39744906c8145c68fe6ad70dfa8ced56e7f6d045229ff4d3fbd4c894171bc257.Vaqlw4UTz8B-BwS403uV5Np0khWqWlYnl1No8x-uFlA
+ hash: v1.k794b7964.5e98351034d834994dd973f36bbffb6fa45fbf1be6e8903ff023705344359f2b.9BlE8GF53LlCv-5gpABv88NPbpFzZAscLQNXZF9hlBs
filters-taxonomic-filter--promoted-groups-are-reordered--light:
- hash: v1.k794b7964.0c8b187fcf7c964ff6aa5e75ee8b031e1a9dd0c082d24b1f18cec53027bae49b.jXdNveI8wV9kdPURWyCTHuBo78KfszKmauXXOIo17Ck
+ hash: v1.k794b7964.ff3ab8df5c8c537290d3ac06c44fd393ac3a611e33020e8084f32fe0882921e8.gFcwvyfCUg9DAMqy3z4geuiLLGsvJn4FtX7lXBddQkI
filters-taxonomic-filter--properties--dark:
hash: v1.k794b7964.aa34b04cf14ce8e95422fcf1c2dd76ac83b04eac3e6c6d5326dbce7eee4d0f11.XXsKHQ9DntH3SiWm0zeEz4W6r0Uj9VxqAtxK1LRC4Uo
filters-taxonomic-filter--properties--light:
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
index d114be6714ee..62a76b50a188 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
@@ -5,6 +5,7 @@ import { expectLogic } from 'kea-test-utils'
import posthog from 'posthog-js'
import {
+ demoteValueShortcutGroups,
isSkeletonItem,
propertyTaxonomicGroupProps,
redistributeTopMatches,
@@ -531,6 +532,41 @@ describe('taxonomicFilterLogic', () => {
expect(quickLogic.values.revealBarrierOpen).toBe(true)
})
+ it('renders pageview URL rows below property name rows once the reveal barrier opens', async () => {
+ const logicProps: TaxonomicFilterLogicProps = {
+ taxonomicFilterLogicKey: 'testDemotedShortcuts',
+ taxonomicGroupTypes: [
+ TaxonomicFilterGroupType.SuggestedFilters,
+ TaxonomicFilterGroupType.PageviewUrls,
+ TaxonomicFilterGroupType.EventProperties,
+ ],
+ }
+ const demotedLogic = taxonomicFilterLogic(logicProps)
+ demotedLogic.mount()
+
+ await expectLogic(demotedLogic, () => {
+ demotedLogic.actions.setSearchQuery('host')
+ demotedLogic.actions.appendTopMatches([
+ {
+ name: 'https://posthog.com/a/very/long/url',
+ group: TaxonomicFilterGroupType.PageviewUrls,
+ } as any,
+ { name: '$host', group: TaxonomicFilterGroupType.EventProperties } as any,
+ ])
+ demotedLogic.actions.openRevealBarrier()
+ }).toMatchValues({
+ topMatchItemsWithSkeletons: [
+ expect.objectContaining({ name: '$host', group: TaxonomicFilterGroupType.EventProperties }),
+ expect.objectContaining({
+ name: 'https://posthog.com/a/very/long/url',
+ group: TaxonomicFilterGroupType.PageviewUrls,
+ }),
+ ],
+ })
+
+ demotedLogic.unmount()
+ })
+
it('does not insert skeletons when search query is empty', async () => {
const eventsListLogic = infiniteListLogic({
...quickLogic.props,
@@ -1677,6 +1713,45 @@ describe('redistributeTopMatches', () => {
})
})
+describe('demoteValueShortcutGroups', () => {
+ it.each([
+ {
+ description: 'moves value shortcut groups below the name matching groups',
+ groupTypes: [
+ TaxonomicFilterGroupType.PageviewUrls,
+ TaxonomicFilterGroupType.EmailAddresses,
+ TaxonomicFilterGroupType.Events,
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.PersonProperties,
+ ],
+ expected: [
+ TaxonomicFilterGroupType.Events,
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.PersonProperties,
+ TaxonomicFilterGroupType.PageviewUrls,
+ TaxonomicFilterGroupType.EmailAddresses,
+ ],
+ },
+ {
+ description: 'keeps the relative order inside each set',
+ groupTypes: [
+ TaxonomicFilterGroupType.EmailAddresses,
+ TaxonomicFilterGroupType.PageviewUrls,
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.Events,
+ ],
+ expected: [
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.Events,
+ TaxonomicFilterGroupType.EmailAddresses,
+ TaxonomicFilterGroupType.PageviewUrls,
+ ],
+ },
+ ])('$description', ({ groupTypes, expected }) => {
+ expect(demoteValueShortcutGroups(groupTypes)).toEqual(expected)
+ })
+})
+
describe('isSkeletonItem', () => {
it.each([
{
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
index 2e054b789244..b61b9d9db58b 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
@@ -247,6 +247,17 @@ export function redistributeTopMatches(
return result
}
+// The shortcut groups match on the *value* someone typed, so their rows are whole URLs,
+// screen names or email addresses. In the cross-category list that put long URLs above the
+// property names people usually search for, so they rank last there. The tab order keeps them
+// up front.
+export function demoteValueShortcutGroups(groupTypes: TaxonomicFilterGroupType[]): TaxonomicFilterGroupType[] {
+ return [
+ ...groupTypes.filter((groupType) => !SHORTCUT_TO_PROPERTY_FILTER_GROUP_TYPES.has(groupType)),
+ ...groupTypes.filter((groupType) => SHORTCUT_TO_PROPERTY_FILTER_GROUP_TYPES.has(groupType)),
+ ]
+}
+
export const eventTaxonomicGroupProps: Pick<TaxonomicFilterGroup, 'getPopoverHeader' | 'getIcon'> = {
getPopoverHeader: (eventDefinition: EventDefinition): string => {
if (CORE_FILTER_DEFINITIONS_BY_GROUP.events[eventDefinition.name]) {
@@ -408,6 +419,7 @@ export interface taxonomicFilterLogicValues {
selectedItemMeta: any
selectedProperties: TaxonomicFilterGroupValueMap
showNumericalPropsOnly: any
+ suggestedFilterGroupOrder: TaxonomicFilterGroupType[]
suggestedFiltersLabel: any
taxonomicFilterLogicKey: string
taxonomicGroupTypes: TaxonomicFilterGroupType[]
@@ -583,12 +595,12 @@ export interface taxonomicFilterLogicMeta {
groupAnalyticsTaxonomicGroupNames: (
groupTypes: Map<GroupTypeIndex, GroupType>,
currentTeamId: number | null,
- aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun
+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun // groupsModel
) => TaxonomicFilterGroup[]
groupAnalyticsTaxonomicGroups: (
groupTypes: Map<GroupTypeIndex, GroupType>,
currentProjectId: number | null,
- aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun
+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun // groupsModel
) => TaxonomicFilterGroup[]
infiniteListLogics: (
taxonomicGroupTypes: TaxonomicFilterGroupType[],
@@ -619,20 +631,22 @@ export interface taxonomicFilterLogicMeta {
taxonomicGroups: TaxonomicFilterGroup[],
taxonomicGroupTypes: TaxonomicFilterGroupType[]
) => string
+ suggestedFilterGroupOrder: (
+ taxonomicGroupTypes: TaxonomicFilterGroupType[],
+ metaGroupTypes: Set<string>
+ ) => TaxonomicFilterGroupType[]
redistributedTopMatchItems: (
topMatchItems: (TaxonomicDefinitionTypes & {
group: TaxonomicFilterGroupType
})[],
- taxonomicGroupTypes: TaxonomicFilterGroupType[],
- metaGroupTypes: Set<string>
+ suggestedFilterGroupOrder: TaxonomicFilterGroupType[]
) => TopMatchItem[]
topMatchItemsWithSkeletons: (
redistributedTopMatchItems: TopMatchItem[],
- taxonomicGroupTypes: TaxonomicFilterGroupType[],
+ suggestedFilterGroupOrder: TaxonomicFilterGroupType[],
loadingGroupTypes: TaxonomicFilterGroupType[],
taxonomicGroups: TaxonomicFilterGroup[],
searchQuery: string,
- metaGroupTypes: Set<string>,
revealBarrierOpen: boolean
) => (SkeletonItem | TopMatchItem)[]
}
@@ -2324,42 +2338,42 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
.join('')
},
],
- redistributedTopMatchItems: [
- (s) => [s.topMatchItems, s.taxonomicGroupTypes, s.metaGroupTypes],
+ suggestedFilterGroupOrder: [
+ // The order the cross-category "All" list renders its groups in. Every consumer of that
+ // list must read this, so the skeleton rows and the revealed rows land in the same place.
+ (s) => [s.taxonomicGroupTypes, s.metaGroupTypes],
(
- topMatchItems: TopMatchItem[],
taxonomicGroupTypes: TaxonomicFilterGroupType[],
metaGroupTypes: Set<string>
- ): TopMatchItem[] => {
- const nonMetaGroups = taxonomicGroupTypes.filter((t) => !metaGroupTypes.has(t))
- return redistributeTopMatches(topMatchItems, nonMetaGroups.length, nonMetaGroups)
- },
+ ): TaxonomicFilterGroupType[] =>
+ demoteValueShortcutGroups(taxonomicGroupTypes.filter((t) => !metaGroupTypes.has(t))),
+ ],
+ redistributedTopMatchItems: [
+ (s) => [s.topMatchItems, s.suggestedFilterGroupOrder],
+ (topMatchItems: TopMatchItem[], groupOrder: TaxonomicFilterGroupType[]): TopMatchItem[] =>
+ redistributeTopMatches(topMatchItems, groupOrder.length, groupOrder),
],
topMatchItemsWithSkeletons: [
(s) => [
s.redistributedTopMatchItems,
- s.taxonomicGroupTypes,
+ s.suggestedFilterGroupOrder,
s.loadingGroupTypes,
s.taxonomicGroups,
s.searchQuery,
- s.metaGroupTypes,
s.revealBarrierOpen,
],
(
redistributed: TopMatchItem[],
- taxonomicGroupTypes: TaxonomicFilterGroupType[],
+ groupOrder: TaxonomicFilterGroupType[],
loadingGroupTypes: TaxonomicFilterGroupType[],
taxonomicGroups: TaxonomicFilterGroup[],
searchQuery: string,
- metaGroupTypes: Set<string>,
revealBarrierOpen: boolean
): (TopMatchItem | SkeletonItem)[] => {
if (!searchQuery) {
return redistributed
}
- const nonMetaGroups = taxonomicGroupTypes.filter((t) => !metaGroupTypes.has(t))
-
const buildSkeletons = (groupType: TaxonomicFilterGroupType): SkeletonItem[] => {
const groupDef = taxonomicGroups.find((g) => g.type === groupType)
const groupName = groupDef?.name ?? groupType
@@ -2375,14 +2389,14 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
// when a slower group finishes.
if (!revealBarrierOpen) {
const result: SkeletonItem[] = []
- for (const groupType of nonMetaGroups) {
+ for (const groupType of groupOrder) {
result.push(...buildSkeletons(groupType))
}
return result
}
const result: (TopMatchItem | SkeletonItem)[] = []
- for (const groupType of nonMetaGroups) {
+ for (const groupType of groupOrder) {
const groupItems = redistributed.filter((item) => item.group === groupType)
if (groupItems.length > 0) {
result.push(...groupItems)