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(flags): link the announcement from the hidden flag called message (#114251)

Phil Haackb66a92533b60
diff --git a/frontend/src/lib/components/TaxonomicFilter/HiddenEventExplanation.tsx b/frontend/src/lib/components/TaxonomicFilter/HiddenEventExplanation.tsx
new file mode 100644
index 000000000000..8eda9763c962
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicFilter/HiddenEventExplanation.tsx
@@ -0,0 +1,27 @@
+import { FEATURE_FLAGS } from 'lib/constants'
+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
+import { Link } from 'lib/lemon-ui/Link'
+import { getFeatureFlagPayload } from 'lib/logic/featureFlagLogic'
+import { isHttpsUrl } from 'lib/utils/url'
+
+export function HiddenEventExplanation(): JSX.Element {
+ const moveNoticesEnabled = useFeatureFlag('FLAG_CALLED_MOVE_NOTICES')
+ const payloadUrl = moveNoticesEnabled ? getFeatureFlagPayload(FEATURE_FLAGS.FLAG_CALLED_MOVE_NOTICES)?.url : null
+ // isHttpsUrl ignores surrounding whitespace. Link turns a value with a leading space into an in-app path.
+ const announcementUrl = typeof payloadUrl === 'string' && isHttpsUrl(payloadUrl) ? payloadUrl.trim() : null
+
+ return (
+ <>
+ PostHog still collects this event, but you can't build a saved query on it. Its data is moving, so a saved
+ query would stop returning results. To see how a flag is used, open the flag and check its Usage tab.
+ {announcementUrl && (
+ <>
+ {' '}
+ <Link to={announcementUrl} target="_blank" data-attr="taxonomic-hidden-event-announcement">
+ Learn more
+ </Link>
+ </>
+ )}
+ </>
+ )
+}
diff --git a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
index 78afdb48f589..ee635c24283f 100644
--- a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
@@ -50,6 +50,7 @@ import { pluralize } from 'lib/utils/strings'
import { getCoreFilterDefinition } from '~/taxonomy/helpers'
import { EventDefinition, PropertyDefinition } from '~/types'
+import { HiddenEventExplanation } from './HiddenEventExplanation'
import { NO_ITEM_SELECTED, infiniteListLogic } from './infiniteListLogic'
import { TaxonomicEventMatchSuggestions } from './TaxonomicEventMatchSuggestions'
@@ -795,9 +796,7 @@ function InfiniteListEmptyState(): JSX.Element {
<strong>{hiddenEventSearched}</strong> isn't available here
</span>
<span className="max-w-80 text-center text-secondary">
- PostHog still collects this event, but you can't build a saved query on it. Its data is moving,
- so a saved query would stop returning results. To see how a flag is used, open the flag and
- check its Usage tab.
+ <HiddenEventExplanation />
</span>
</div>
) : (
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
index 2bdaaae58e65..ea2e06851d6a 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
@@ -7,6 +7,8 @@ import userEvent from '@testing-library/user-event'
import { Provider, getContext } from 'kea'
import posthog from 'posthog-js'
+import { FEATURE_FLAGS } from 'lib/constants'
+import * as featureFlagLogicModule from 'lib/logic/featureFlagLogic'
import { teamLogic } from 'scenes/teamLogic'
import { FlagEvaluationsModeEnumApi } from '~/generated/core/api.schemas'
@@ -50,6 +52,16 @@ function setFlagEvaluationsMode(mode: FlagEvaluationsModeEnumApi): void {
teamLogic.actions.loadCurrentTeamSuccess({ ...MOCK_DEFAULT_TEAM, flag_evaluations_mode: mode })
}
+const ANNOUNCEMENT_URL = 'https://example.com/announcement'
+
+function setMoveNotices(enabled: boolean, url: string | null): void {
+ featureFlagLogicModule.featureFlagLogic.mount()
+ featureFlagLogicModule.featureFlagLogic.actions.setFeatureFlags([], {
+ [FEATURE_FLAGS.FLAG_CALLED_MOVE_NOTICES]: enabled,
+ })
+ jest.spyOn(featureFlagLogicModule, 'getFeatureFlagPayload').mockReturnValue({ url })
+}
+
describe('TaxonomicFilter', () => {
let onChangeMock: jest.Mock
let onCloseMock: jest.Mock
@@ -554,19 +566,33 @@ describe('TaxonomicFilter', () => {
setFlagEvaluationsMode(FlagEvaluationsModeEnumApi.Number1)
})
- it('explains the absence instead of reporting no results', async () => {
- renderFilter({ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events] })
+ afterEach(() => {
+ jest.restoreAllMocks()
+ })
- await activateGroupWithResults('taxonomic-tab-events')
- await withoutDebounceDelay((user) =>
- user.type(screen.getByTestId('taxonomic-filter-searchfield'), '$feature_flag_called')
- )
+ it.each([
+ ['links the announcement', true, ANNOUNCEMENT_URL, ANNOUNCEMENT_URL],
+ ['has no link while the announcement has no URL', true, null, undefined],
+ ['has no link while the move notices are off', false, ANNOUNCEMENT_URL, undefined],
+ ])(
+ 'explains the absence instead of reporting no results, and %s',
+ async (_label, moveNoticesOn, url, expectedHref) => {
+ setMoveNotices(moveNoticesOn, url)
+ renderFilter({ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events] })
- await waitFor(() => {
- expect(inVisibleTab(screen.getAllByTestId('taxonomic-hidden-event'))).toBeTruthy()
- })
- expect(screen.queryByText(/No results for/)).not.toBeInTheDocument()
- })
+ await activateGroupWithResults('taxonomic-tab-events')
+ await withoutDebounceDelay((user) =>
+ user.type(screen.getByTestId('taxonomic-filter-searchfield'), '$feature_flag_called')
+ )
+
+ await waitFor(() => {
+ expect(inVisibleTab(screen.getAllByTestId('taxonomic-hidden-event'))).toBeTruthy()
+ })
+ expect(screen.queryByText(/No results for/)).not.toBeInTheDocument()
+ const link = inVisibleTab(screen.queryAllByTestId('taxonomic-hidden-event-announcement'))
+ expect(link?.getAttribute('href')).toBe(expectedHref)
+ }
+ )
// The aggregated tab's own group carries no exclusions, so reading the active list's
// group instead of the Events group leaves this arm silent.
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
index fb0f2ba0c513..78599f3a1b4d 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
@@ -7,6 +7,8 @@ import userEvent from '@testing-library/user-event'
import { Provider } from 'kea'
import { useState } from 'react'
+import { FEATURE_FLAGS } from 'lib/constants'
+import * as featureFlagLogicModule from 'lib/logic/featureFlagLogic'
import { teamLogic } from 'scenes/teamLogic'
import { FlagEvaluationsModeEnumApi } from '~/generated/core/api.schemas'
@@ -115,6 +117,16 @@ function setFlagEvaluationsMode(mode: FlagEvaluationsModeEnumApi): void {
teamLogic.actions.loadCurrentTeamSuccess({ ...MOCK_DEFAULT_TEAM, flag_evaluations_mode: mode })
}
+const ANNOUNCEMENT_URL = 'https://example.com/announcement'
+
+function setMoveNotices(enabled: boolean, url: string | null): void {
+ featureFlagLogicModule.featureFlagLogic.mount()
+ featureFlagLogicModule.featureFlagLogic.actions.setFeatureFlags([], {
+ [FEATURE_FLAGS.FLAG_CALLED_MOVE_NOTICES]: enabled,
+ })
+ jest.spyOn(featureFlagLogicModule, 'getFeatureFlagPayload').mockReturnValue({ url })
+}
+
describe('MenuFilterCombobox', () => {
beforeEach(() => {
__clearTaxonomicResourceCache()
@@ -1152,18 +1164,39 @@ describe('MenuFilterCombobox', () => {
setFlagEvaluationsMode(FlagEvaluationsModeEnumApi.Number1)
})
- it('explains the absence, and drops recovery buttons that cannot recover it', async () => {
- renderAll({
- groupTypes: [TaxonomicFilterGroupType.Events],
- searchQuery: '$feature_flag_called',
- })
-
- const empty = await waitFor(() => screen.getByTestId('menu-filter-empty'))
- expect(within(empty).getByText(/\$feature_flag_called isn't available here/)).toBeInTheDocument()
- expect(screen.queryByTestId('menu-filter-include-stale-events')).not.toBeInTheDocument()
- expect(screen.queryByTestId('menu-filter-check-other-categories')).not.toBeInTheDocument()
+ afterEach(() => {
+ jest.restoreAllMocks()
+ localStorage.clear()
})
+ it.each([
+ ['links the announcement', true, ANNOUNCEMENT_URL, ANNOUNCEMENT_URL],
+ [
+ 'links the announcement when its URL has leading whitespace',
+ true,
+ ` ${ANNOUNCEMENT_URL}`,
+ ANNOUNCEMENT_URL,
+ ],
+ ['has no link while the announcement has no URL', true, null, undefined],
+ ['has no link while the move notices are off', false, ANNOUNCEMENT_URL, undefined],
+ ])(
+ 'explains the absence, drops recovery buttons that cannot recover it, and %s',
+ async (_label, moveNoticesOn, url, expectedHref) => {
+ setMoveNotices(moveNoticesOn, url)
+ renderAll({
+ groupTypes: [TaxonomicFilterGroupType.Events],
+ searchQuery: '$feature_flag_called',
+ })
+
+ const empty = await waitFor(() => screen.getByTestId('menu-filter-empty'))
+ expect(within(empty).getByText(/\$feature_flag_called isn't available here/)).toBeInTheDocument()
+ expect(screen.queryByTestId('menu-filter-include-stale-events')).not.toBeInTheDocument()
+ expect(screen.queryByTestId('menu-filter-check-other-categories')).not.toBeInTheDocument()
+ const link = within(empty).queryByTestId('taxonomic-hidden-event-announcement')
+ expect(link?.getAttribute('href')).toBe(expectedHref)
+ }
+ )
+
it('reports no matches as usual for a team on the Events mode', async () => {
setFlagEvaluationsMode(FlagEvaluationsModeEnumApi.Number0)
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
index 0633d9c29842..15d5b6e704f3 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
@@ -13,7 +13,7 @@
import { Autocomplete } from '@base-ui/react/autocomplete'
import { useValues } from 'kea'
import posthog from 'posthog-js'
-import { MutableRefObject, ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import { MutableRefObject, ReactElement, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { IconCheck, IconChevronRight, IconClock, IconPinFilled } from '@posthog/icons'
import {
@@ -43,6 +43,7 @@ import { surveyQuestionLabelsLogic } from 'scenes/surveys/surveyQuestionLabelsLo
import { getCoreFilterDefinition } from '~/taxonomy/helpers'
import { useTaxonomicFilterContext } from '../headless/context'
+import { HiddenEventExplanation } from '../HiddenEventExplanation'
import { useGroupList } from '../hooks/useGroupList'
import {
OPEN_AS_SELF_ON_REOPEN,
@@ -720,7 +721,7 @@ export function MenuFilterCombobox({
// resolved. Names the active category for context.
// - "no items" — initial render with no search and no resolved
// entries (rare for finite groups).
- const emptyState = useMemo<{ title: string; body?: string } | null>(() => {
+ const emptyState = useMemo<{ title: string; body?: ReactNode } | null>(() => {
if (filtered.length > 0) {
return null
}
@@ -754,7 +755,7 @@ export function MenuFilterCombobox({
// is absent, and neither of them can bring back an excluded name.
return {
title: `${hiddenEventSearched} isn't available here`,
- body: "PostHog still collects this event, but you can't build a saved query on it. Its data is moving, so a saved query would stop returning results. To see how a flag is used, open the flag and check its Usage tab.",
+ body: <HiddenEventExplanation />,
}
}
const categoryLabel = singleGroup?.name ?? null