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(web-analytics): decouple the restricted UI from the legacy preagg modifier (#102037)

Lucas Ricoyf3bf8d288fd6
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 16ad9e76223a..b3ba795141ef 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -561,6 +561,7 @@ export const FEATURE_FLAGS = {
WEB_ANALYTICS_RECAP: 'web-analytics-recap', // owner: @jordanm-posthog #team-web-analytics
WEB_ANALYTICS_REGIONS_MAP: 'web-analytics-regions-map', // owner: @jordanm-posthog #team-web-analytics
WEB_ANALYTICS_REMOVE_REPLAY_TILE: 'web-analytics-remove-replay-tile', // owner: @lricoy #team-web-analytics multivariate=control,test
+ WEB_ANALYTICS_RESTRICTED_UI: 'web-analytics-restricted-ui', // owner: @lricoy #team-web-analytics
WEB_ANALYTICS_SESSION_PROPERTY_CHARTS: 'web-analytics-session-property-charts', // owner: @lricoy #team-web-analytics
WEB_ANALYTICS_SHARE_NUDGE_V2: 'web-analytics-share-nudge-v2', // owner: @jordanm-posthog #team-web-analytics multivariate=control,control_b,banner,export
WEB_ANALYTICS_STREAK_CADENCE: 'web-analytics-streak-cadence', // owner: @jordanm-posthog #team-web-analytics multivariate=control,hybrid,daily-only,weekly-only
diff --git a/frontend/src/scenes/web-analytics/WebAnalyticsFilters.tsx b/frontend/src/scenes/web-analytics/WebAnalyticsFilters.tsx
index 58aeda175d19..eae702d0c8fd 100644
--- a/frontend/src/scenes/web-analytics/WebAnalyticsFilters.tsx
+++ b/frontend/src/scenes/web-analytics/WebAnalyticsFilters.tsx
@@ -581,7 +581,7 @@ const ShareButton = (): JSX.Element => {
function FiltersPopover(): JSX.Element {
const [displayFilters, setDisplayFilters] = useState(false)
- const { rawWebAnalyticsFilters, conversionGoal, preAggregatedEnabled, productTab } = useValues(webAnalyticsLogic)
+ const { rawWebAnalyticsFilters, conversionGoal, restrictedUiEnabled, productTab } = useValues(webAnalyticsLogic)
const { setWebAnalyticsFilters, setConversionGoal } = useActions(webAnalyticsLogic)
const { featureFlags } = useValues(featureFlagLogic)
@@ -598,11 +598,11 @@ function FiltersPopover(): JSX.Element {
const showConversionGoal =
productTab === ProductTab.ANALYTICS &&
- (!preAggregatedEnabled || featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_CONVERSION_GOAL_PREAGG])
+ (!restrictedUiEnabled || featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_CONVERSION_GOAL_PREAGG])
const cohortFilterEnabled = !!featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_FILTERS_V2]
- const taxonomicGroupTypes = getWebAnalyticsTaxonomicGroupTypes(preAggregatedEnabled ?? false, cohortFilterEnabled)
- const propertyAllowList = preAggregatedEnabled ? WEB_ANALYTICS_PROPERTY_ALLOW_LIST : undefined
+ const taxonomicGroupTypes = getWebAnalyticsTaxonomicGroupTypes(restrictedUiEnabled ?? false, cohortFilterEnabled)
+ const propertyAllowList = restrictedUiEnabled ? WEB_ANALYTICS_PROPERTY_ALLOW_LIST : undefined
const activeFilterCount = rawWebAnalyticsFilters.length + (conversionGoal ? 1 : 0)
@@ -733,10 +733,10 @@ const AddSuggestedAuthorizedUrlList = (): JSX.Element => {
}
const IncompatibleFiltersWarning = (): JSX.Element | null => {
- const { hasIncompatibleFilters, incompatibleFilters, preAggregatedEnabled } = useValues(webAnalyticsLogic)
+ const { hasIncompatibleFilters, incompatibleFilters, restrictedUiEnabled } = useValues(webAnalyticsLogic)
const { removeIncompatibleFilters } = useActions(webAnalyticsLogic)
- if (!preAggregatedEnabled || !hasIncompatibleFilters) {
+ if (!restrictedUiEnabled || !hasIncompatibleFilters) {
return null
}
diff --git a/frontend/src/scenes/web-analytics/WebPropertyFilters.tsx b/frontend/src/scenes/web-analytics/WebPropertyFilters.tsx
index 82ee0f6aa1b6..dd5b91ebeebf 100644
--- a/frontend/src/scenes/web-analytics/WebPropertyFilters.tsx
+++ b/frontend/src/scenes/web-analytics/WebPropertyFilters.tsx
@@ -29,12 +29,12 @@ import { webAnalyticsLogic } from './webAnalyticsLogic'
export const WEB_ANALYTICS_PROPERTY_ALLOW_LIST = WEB_ANALYTICS_PRE_AGGREGATED_PROPERTY_ALLOW_LIST
export const getWebAnalyticsTaxonomicGroupTypes = (
- preAggregatedEnabled: boolean,
+ restrictedUiEnabled: boolean,
cohortFilterEnabled: boolean = false
): TaxonomicFilterGroupType[] => [
TaxonomicFilterGroupType.EventProperties,
TaxonomicFilterGroupType.SessionProperties,
- ...(!preAggregatedEnabled ? [TaxonomicFilterGroupType.PersonProperties] : []),
+ ...(!restrictedUiEnabled ? [TaxonomicFilterGroupType.PersonProperties] : []),
...(cohortFilterEnabled ? [TaxonomicFilterGroupType.Cohorts] : []),
]
@@ -50,7 +50,7 @@ export const WebPropertyFilters = ({
// Always call hooks unconditionally (React Rules of Hooks)
const {
rawWebAnalyticsFilters = [],
- preAggregatedEnabled = false,
+ restrictedUiEnabled = false,
hasIncompatibleFilters = false,
} = useValues(webAnalyticsLogic)
const { setWebAnalyticsFilters: logicSetFilters } = useActions(webAnalyticsLogic)
@@ -65,11 +65,11 @@ export const WebPropertyFilters = ({
const taxonomicGroupTypes = [
TaxonomicFilterGroupType.EventProperties,
TaxonomicFilterGroupType.SessionProperties,
- ...(!preAggregatedEnabled ? [TaxonomicFilterGroupType.PersonProperties] : []),
+ ...(!restrictedUiEnabled ? [TaxonomicFilterGroupType.PersonProperties] : []),
...(cohortFilterEnabled ? [TaxonomicFilterGroupType.Cohorts] : []),
]
- const webAnalyticsPropertyAllowList = preAggregatedEnabled
+ const webAnalyticsPropertyAllowList = restrictedUiEnabled
? (WEB_ANALYTICS_PRE_AGGREGATED_PROPERTY_ALLOW_LIST as unknown as {
[key: string]: string[]
})
diff --git a/frontend/src/scenes/web-analytics/webAnalyticsLogic.test.ts b/frontend/src/scenes/web-analytics/webAnalyticsLogic.test.ts
index 016bd1cf59f7..c5346c8c6c41 100644
--- a/frontend/src/scenes/web-analytics/webAnalyticsLogic.test.ts
+++ b/frontend/src/scenes/web-analytics/webAnalyticsLogic.test.ts
@@ -1,4 +1,4 @@
-import { MOCK_DEFAULT_USER, MOCK_TEAM_ID } from 'lib/api.mock'
+import { MOCK_DEFAULT_TEAM, MOCK_DEFAULT_USER, MOCK_TEAM_ID } from 'lib/api.mock'
import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
@@ -326,6 +326,54 @@ describe('webAnalyticsLogic precompute payload', () => {
})
})
+describe('webAnalyticsLogic restricted UI gating', () => {
+ let logic: ReturnType<typeof webAnalyticsLogic.build>
+
+ const mountWithTeamModifier = (legacyEngineModifier: boolean): void => {
+ localStorage.clear()
+ initKeaTests(true, {
+ ...MOCK_DEFAULT_TEAM,
+ modifiers: { useWebAnalyticsPreAggregatedTables: legacyEngineModifier },
+ })
+ jest.spyOn(api.propertyDefinitions, 'list').mockResolvedValue({ results: [] } as any)
+ jest.spyOn(api.hogFunctions, 'list').mockResolvedValue({ results: [] } as any)
+ jest.spyOn(api, 'update').mockResolvedValue({} as any)
+ featureFlagLogic.mount()
+ logic = webAnalyticsLogic()
+ logic.mount()
+ }
+
+ afterEach(() => {
+ logic.unmount()
+ jest.restoreAllMocks()
+ })
+
+ // Regression guard for the legacy-tables retirement: the restricted-ui flag
+ // must restrict on its own with no team modifier involved — a collapse of
+ // the OR re-exposes tiles that run unservable live queries on billion-event
+ // teams — while the legacy pair must keep working until it is removed, and
+ // neither half of the pair may restrict alone.
+ it.each([
+ ['restricted-ui flag alone', [FEATURE_FLAGS.WEB_ANALYTICS_RESTRICTED_UI], false, true],
+ ['no flags, no modifier', [], false, false],
+ [
+ 'legacy flag without the modifier',
+ [FEATURE_FLAGS.SETTINGS_WEB_ANALYTICS_PRE_AGGREGATED_TABLES],
+ false,
+ false,
+ ],
+ ['modifier without the legacy flag', [], true, false],
+ ['legacy flag and modifier', [FEATURE_FLAGS.SETTINGS_WEB_ANALYTICS_PRE_AGGREGATED_TABLES], true, true],
+ ])('%s → restricted %s', async (_name, flags, legacyEngineModifier, expected) => {
+ mountWithTeamModifier(legacyEngineModifier as boolean)
+ featureFlagLogic.actions.setFeatureFlags(
+ flags as string[],
+ Object.fromEntries((flags as string[]).map((flag) => [flag, true]))
+ )
+ await expectLogic(logic).toMatchValues({ restrictedUiEnabled: expected })
+ })
+})
+
describe('webAnalyticsLogic compare filter', () => {
let logic: ReturnType<typeof webAnalyticsLogic.build>
diff --git a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
index 28ecf1055aa0..7fa3abebce1e 100644
--- a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
+++ b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
@@ -227,7 +227,6 @@ export interface webAnalyticsLogicValues {
isGreaterThanMd: boolean
isPathCleaningEnabled: boolean
pathTab: string
- preAggregatedEnabled: boolean | undefined
preZoomDateFilter: {
dateFrom: string | null
dateTo: string | null
@@ -235,6 +234,7 @@ export interface webAnalyticsLogicValues {
} | null
productTab: ProductTab
replayFilters: RecordingUniversalFilters
+ restrictedUiEnabled: boolean
shouldAutoOpenFocusModeOnboarding: boolean
shouldFilterTestAccounts: boolean
shouldShowGeoIPQueries: any
@@ -535,13 +535,10 @@ export interface webAnalyticsLogicMeta {
key: 'page-visibility' | 'web-analytics'
__keaTypeGenInternalSelectorTypes: {
compareFilter: (rawCompareFilter: CompareFilter, dateFilter: DateFilterState) => CompareFilter
- preAggregatedEnabled: (
- featureFlags: FeatureFlagsSet,
- currentTeam: TeamPublicType | TeamType | null
- ) => boolean | undefined
+ restrictedUiEnabled: (featureFlags: FeatureFlagsSet, currentTeam: TeamPublicType | TeamType | null) => boolean
incompatibleFilters: (
rawWebAnalyticsFilters: WebAnalyticsPropertyFilters,
- preAggregatedEnabled: boolean | undefined
+ restrictedUiEnabled: boolean
) => WebAnalyticsPropertyFilters
hasIncompatibleFilters: (incompatibleFilters: WebAnalyticsPropertyFilters) => boolean
graphsTab: (_graphsTab: string | null) => string
@@ -567,16 +564,16 @@ export interface webAnalyticsLogicMeta {
shouldFilterTestAccounts: boolean
) => WebAnalyticsFiltersConfig
warmablePresetShortId: (
- appliedPresetShortId: string | null, // webAnalyticsFilterLogic
- appliedPresetFilters: WebAnalyticsFiltersConfig | null, // webAnalyticsFilterLogic
+ appliedPresetShortId: string | null,
+ appliedPresetFilters: WebAnalyticsFiltersConfig | null,
currentFiltersConfig: WebAnalyticsFiltersConfig
) => string | null
hasNonDefaultFilters: (
- rawWebAnalyticsFilters: WebAnalyticsPropertyFilters, // webAnalyticsFilterLogic
- domainFilter: string | null, // webAnalyticsFilterLogic
- deviceTypeFilter: DeviceType | null, // webAnalyticsFilterLogic
- countryFilter: string | null, // webAnalyticsFilterLogic
- referrerFilter: string | null, // webAnalyticsFilterLogic
+ rawWebAnalyticsFilters: WebAnalyticsPropertyFilters,
+ domainFilter: string | null,
+ deviceTypeFilter: DeviceType | null,
+ countryFilter: string | null,
+ referrerFilter: string | null,
conversionGoal: WebAnalyticsConversionGoal | null
) => boolean
webAnalyticsFilters: (
@@ -697,7 +694,7 @@ export interface webAnalyticsLogicMeta {
featureFlags: FeatureFlagsSet,
isGreaterThanMd: boolean,
tileVisualizations: Record<TileId, TileVisualizationOption>,
- preAggregatedEnabled: boolean | undefined,
+ restrictedUiEnabled: boolean,
hiddenTiles: TileId[],
warmablePresetShortId: string | null
) => WebAnalyticsTile[]
@@ -1185,22 +1182,31 @@ export const webAnalyticsLogic: LogicWrapper<webAnalyticsLogicType> = kea<webAna
// again as soon as the range becomes a bounded one.
dateFilter.dateFrom === 'all' ? { compare: false } : rawCompareFilter,
],
- preAggregatedEnabled: [
+ restrictedUiEnabled: [
(s) => [s.featureFlags, s.currentTeam],
(featureFlags: Record<string, boolean>, currentTeam: TeamPublicType | TeamType | null) => {
+ // Two independent levers restrict the UI to the precompute-servable
+ // vocabulary (tile allowlist, filter pruning, property allowlist):
+ // the standalone restricted-UI flag, which implies nothing about the
+ // query engine and exists so heavy teams stay restricted while the
+ // legacy pre-aggregated tables retire, and the legacy pair (settings
+ // flag + team modifier) that also switches the engine.
return (
- featureFlags[FEATURE_FLAGS.SETTINGS_WEB_ANALYTICS_PRE_AGGREGATED_TABLES] &&
- currentTeam?.modifiers?.useWebAnalyticsPreAggregatedTables
+ !!featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_RESTRICTED_UI] ||
+ !!(
+ featureFlags[FEATURE_FLAGS.SETTINGS_WEB_ANALYTICS_PRE_AGGREGATED_TABLES] &&
+ currentTeam?.modifiers?.useWebAnalyticsPreAggregatedTables
+ )
)
},
],
incompatibleFilters: [
- (s) => [s.rawWebAnalyticsFilters, s.preAggregatedEnabled],
+ (s) => [s.rawWebAnalyticsFilters, s.restrictedUiEnabled],
(
rawWebAnalyticsFilters: WebAnalyticsPropertyFilters,
- preAggregatedEnabled: boolean
+ restrictedUiEnabled: boolean
): WebAnalyticsPropertyFilters => {
- if (!preAggregatedEnabled) {
+ if (!restrictedUiEnabled) {
return []
}
@@ -1693,7 +1699,7 @@ export const webAnalyticsLogic: LogicWrapper<webAnalyticsLogicType> = kea<webAna
s.featureFlags,
s.isGreaterThanMd,
s.tileVisualizations,
- s.preAggregatedEnabled,
+ s.restrictedUiEnabled,
s.hiddenTiles,
s.warmablePresetShortId,
],
@@ -1720,7 +1726,7 @@ export const webAnalyticsLogic: LogicWrapper<webAnalyticsLogicType> = kea<webAna
featureFlags: import('lib/logic/featureFlagLogic').FeatureFlagsSet,
isGreaterThanMd: boolean,
tileVisualizations: Record<TileId, TileVisualizationOption>,
- preAggregatedEnabled: boolean | undefined,
+ restrictedUiEnabled: boolean | undefined,
hiddenTiles: TileId[],
warmablePresetShortId: string | null
): WebAnalyticsTile[] => {
@@ -3153,7 +3159,7 @@ export const webAnalyticsLogic: LogicWrapper<webAnalyticsLogicType> = kea<webAna
allTiles
.filter(isNotNil)
.filter((tile) =>
- preAggregatedEnabled ? TILES_ALLOWED_ON_PRE_AGGREGATED.includes(tile.tileId) : true
+ restrictedUiEnabled ? TILES_ALLOWED_ON_PRE_AGGREGATED.includes(tile.tileId) : true
)
.filter((tile) => !hiddenTiles.includes(tile.tileId)),
warmablePresetShortId
diff --git a/products/web_analytics/frontend/searchAndAi/SearchAndAiFiltersPopover.tsx b/products/web_analytics/frontend/searchAndAi/SearchAndAiFiltersPopover.tsx
index 8ae2820fd85b..59be254032fe 100644
--- a/products/web_analytics/frontend/searchAndAi/SearchAndAiFiltersPopover.tsx
+++ b/products/web_analytics/frontend/searchAndAi/SearchAndAiFiltersPopover.tsx
@@ -18,7 +18,7 @@ import {
export function SearchAndAiFiltersPopover(): JSX.Element {
const [visible, setVisible] = useState(false)
- const { rawWebAnalyticsFilters, deviceTypeFilter, preAggregatedEnabled, hasIncompatibleFilters } =
+ const { rawWebAnalyticsFilters, deviceTypeFilter, restrictedUiEnabled, hasIncompatibleFilters } =
useValues(webAnalyticsLogic)
const { setWebAnalyticsFilters } = useActions(webAnalyticsLogic)
const { featureFlags } = useValues(featureFlagLogic)
@@ -35,9 +35,9 @@ export function SearchAndAiFiltersPopover(): JSX.Element {
disablePopover
propertyFilters={rawWebAnalyticsFilters}
onChange={(filters) => setWebAnalyticsFilters(filters.filter(isWebAnalyticsPropertyFilter))}
- propertyAllowList={preAggregatedEnabled ? WEB_ANALYTICS_PROPERTY_ALLOW_LIST : undefined}
+ propertyAllowList={restrictedUiEnabled ? WEB_ANALYTICS_PROPERTY_ALLOW_LIST : undefined}
taxonomicGroupTypes={getWebAnalyticsTaxonomicGroupTypes(
- preAggregatedEnabled ?? false,
+ restrictedUiEnabled ?? false,
!!featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_FILTERS_V2]
)}
pageKey="web-analytics"