From 61c73cf0ac606fec08fe28bafe39c61283be7c23 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Wed, 27 Mar 2024 14:23:30 +0100 Subject: [PATCH] feat(hogql): feature preview flag --- frontend/src/lib/constants.tsx | 1 + .../queries/nodes/DataNode/dataNodeLogic.ts | 3 +- .../queries/nodes/InsightViz/TrendsSeries.tsx | 3 +- frontend/src/queries/query.ts | 38 ++++++++----------- .../src/scenes/funnels/funnelDataLogic.ts | 4 +- .../src/scenes/insights/insightDataLogic.ts | 1 + .../insights/views/BoldNumber/BoldNumber.tsx | 4 +- frontend/src/scenes/paths/pathsDataLogic.ts | 3 +- .../scenes/retention/retentionModalLogic.ts | 6 ++- .../scenes/retention/retentionPeopleLogic.ts | 5 ++- .../trends/viz/ActionsHorizontalBar.tsx | 2 +- .../scenes/trends/viz/ActionsLineGraph.tsx | 6 +-- frontend/src/scenes/trends/viz/ActionsPie.tsx | 2 +- 13 files changed, 43 insertions(+), 35 deletions(-) diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx index b4ef15a8bea8f..391c13b50a213 100644 --- a/frontend/src/lib/constants.tsx +++ b/frontend/src/lib/constants.tsx @@ -172,6 +172,7 @@ export const FEATURE_FLAGS = { PRODUCT_SPECIFIC_ONBOARDING: 'product-specific-onboarding', // owner: @raquelmsmith REDIRECT_SIGNUPS_TO_INSTANCE: 'redirect-signups-to-instance', // owner: @raquelmsmith APPS_AND_EXPORTS_UI: 'apps-and-exports-ui', // owner: @benjackwhite + HOGQL_INSIGHTS: 'hogql-insights-preview', // owner: @mariusandra HOGQL_INSIGHTS_LIFECYCLE: 'hogql-insights-lifecycle', // owner: @mariusandra HOGQL_INSIGHTS_PATHS: 'hogql-insights-paths', // owner: @webjunkie HOGQL_INSIGHTS_RETENTION: 'hogql-insights-retention', // owner: @webjunkie diff --git a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts b/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts index 50562340715af..62158a7a16bcc 100644 --- a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts +++ b/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts @@ -384,7 +384,8 @@ export const dataNodeLogic = kea([ ], hogQLInsightsRetentionFlagEnabled: [ (s) => [s.featureFlags], - (featureFlags) => !!featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_RETENTION], + (featureFlags) => + !!(featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS] || featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_RETENTION]), ], query: [(_, p) => [p.query], (query) => query], newQuery: [ diff --git a/frontend/src/queries/nodes/InsightViz/TrendsSeries.tsx b/frontend/src/queries/nodes/InsightViz/TrendsSeries.tsx index 4136358dac1dc..fc65ff00a670d 100644 --- a/frontend/src/queries/nodes/InsightViz/TrendsSeries.tsx +++ b/frontend/src/queries/nodes/InsightViz/TrendsSeries.tsx @@ -78,7 +78,8 @@ export function TrendsSeries(): JSX.Element | null { mathAvailability={mathAvailability} propertiesTaxonomicGroupTypes={propertiesTaxonomicGroupTypes} actionsTaxonomicGroupTypes={ - featureFlags[FEATURE_FLAGS.DATA_WAREHOUSE] && featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS] + featureFlags[FEATURE_FLAGS.DATA_WAREHOUSE] && + (featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS] || featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS]) ? [ TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions, diff --git a/frontend/src/queries/query.ts b/frontend/src/queries/query.ts index e2149303733b6..cc688988d845a 100644 --- a/frontend/src/queries/query.ts +++ b/frontend/src/queries/query.ts @@ -146,28 +146,22 @@ export async function query( let response: NonNullable const logParams: Record = {} const startTime = performance.now() - - const hogQLInsightsLifecycleFlagEnabled = Boolean( - featureFlagLogic.findMounted()?.values.featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS_LIFECYCLE] - ) - const hogQLInsightsPathsFlagEnabled = Boolean( - featureFlagLogic.findMounted()?.values.featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS_PATHS] - ) - const hogQLInsightsRetentionFlagEnabled = Boolean( - featureFlagLogic.findMounted()?.values.featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS_RETENTION] - ) - const hogQLInsightsTrendsFlagEnabled = Boolean( - featureFlagLogic.findMounted()?.values.featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS] - ) - const hogQLInsightsStickinessFlagEnabled = Boolean( - featureFlagLogic.findMounted()?.values.featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS_STICKINESS] - ) - const hogQLInsightsFunnelsFlagEnabled = Boolean( - featureFlagLogic.findMounted()?.values.featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS_FUNNELS] - ) - const hogQLInsightsLiveCompareEnabled = Boolean( - featureFlagLogic.findMounted()?.values.featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHT_LIVE_COMPARE] - ) + const allFlags = featureFlagLogic.findMounted()?.values.featureFlags ?? {} + + const hogQLInsightsFlagEnabled = Boolean(allFlags[FEATURE_FLAGS.HOGQL_INSIGHTS]) + const hogQLInsightsLifecycleFlagEnabled = + hogQLInsightsFlagEnabled || Boolean(allFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_LIFECYCLE]) + const hogQLInsightsPathsFlagEnabled = + hogQLInsightsFlagEnabled || Boolean(allFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_PATHS]) + const hogQLInsightsRetentionFlagEnabled = + hogQLInsightsFlagEnabled || Boolean(allFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_RETENTION]) + const hogQLInsightsTrendsFlagEnabled = + hogQLInsightsFlagEnabled || Boolean(allFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS]) + const hogQLInsightsStickinessFlagEnabled = + hogQLInsightsFlagEnabled || Boolean(allFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_STICKINESS]) + const hogQLInsightsFunnelsFlagEnabled = + hogQLInsightsFlagEnabled || Boolean(allFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_FUNNELS]) + const hogQLInsightsLiveCompareEnabled = Boolean(allFlags[FEATURE_FLAGS.HOGQL_INSIGHT_LIVE_COMPARE]) async function fetchLegacyUrl(): Promise> { const response = await api.getResponse(legacyUrl!) diff --git a/frontend/src/scenes/funnels/funnelDataLogic.ts b/frontend/src/scenes/funnels/funnelDataLogic.ts index 5a1e708eb6b59..3080f0db0560f 100644 --- a/frontend/src/scenes/funnels/funnelDataLogic.ts +++ b/frontend/src/scenes/funnels/funnelDataLogic.ts @@ -85,7 +85,9 @@ export const funnelDataLogic = kea([ hogQLInsightsFunnelsFlagEnabled: [ (s) => [s.featureFlags], (featureFlags): boolean => { - return !!featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_FUNNELS] + return !!( + featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS] || featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_FUNNELS] + ) }, ], querySource: [ diff --git a/frontend/src/scenes/insights/insightDataLogic.ts b/frontend/src/scenes/insights/insightDataLogic.ts index 78ed36c747f90..822bfe41dcffb 100644 --- a/frontend/src/scenes/insights/insightDataLogic.ts +++ b/frontend/src/scenes/insights/insightDataLogic.ts @@ -145,6 +145,7 @@ export const insightDataLogic = kea([ } const maintainLegacy = !( + featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS] || (featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS_LIFECYCLE] && isLifecycleQuery(sourceQuery)) || (featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS_PATHS] && isPathsQuery(sourceQuery)) || (featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS_RETENTION] && isRetentionQuery(sourceQuery)) || diff --git a/frontend/src/scenes/insights/views/BoldNumber/BoldNumber.tsx b/frontend/src/scenes/insights/views/BoldNumber/BoldNumber.tsx index f18fbeebfefb1..7f76c110bd55f 100644 --- a/frontend/src/scenes/insights/views/BoldNumber/BoldNumber.tsx +++ b/frontend/src/scenes/insights/views/BoldNumber/BoldNumber.tsx @@ -99,7 +99,7 @@ export function BoldNumber({ showPersonsModal = true }: ChartParams): JSX.Elemen const resultSeries = insightData?.result?.[0] as TrendResult | undefined const isTrendsQueryWithFeatureFlagOn = - featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS] && + (featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS] || featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS]) && isTrends && query && isInsightVizNode(query) && @@ -178,7 +178,7 @@ function BoldNumberComparison({ showPersonsModal }: Pick([ ], hogQLInsightsPathsFlagEnabled: [ (s) => [s.featureFlags], - (featureFlags) => !!featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_PATHS], + (featureFlags) => + !!(featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS] || featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_PATHS]), ], }), diff --git a/frontend/src/scenes/retention/retentionModalLogic.ts b/frontend/src/scenes/retention/retentionModalLogic.ts index 9aba029d17c2c..3310d730a1699 100644 --- a/frontend/src/scenes/retention/retentionModalLogic.ts +++ b/frontend/src/scenes/retention/retentionModalLogic.ts @@ -67,7 +67,11 @@ export const retentionModalLogic = kea([ exploreUrl: [ (s) => [s.actorsQuery, s.featureFlags], (actorsQuery, featureFlags): string | null => { - if (!actorsQuery || !featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS_RETENTION]) { + if ( + !actorsQuery || + (!featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS] && + !featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS_RETENTION]) + ) { return null } const query: DataTableNode = { diff --git a/frontend/src/scenes/retention/retentionPeopleLogic.ts b/frontend/src/scenes/retention/retentionPeopleLogic.ts index 35daa1f0bd176..7bfd81aafe341 100644 --- a/frontend/src/scenes/retention/retentionPeopleLogic.ts +++ b/frontend/src/scenes/retention/retentionPeopleLogic.ts @@ -18,7 +18,10 @@ import type { retentionPeopleLogicType } from './retentionPeopleLogicType' const DEFAULT_RETENTION_LOGIC_KEY = 'default_retention_key' const hogQLInsightsRetentionFlagEnabled = (): boolean => - Boolean(featureFlagLogic.findMounted()?.values.featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS_RETENTION]) + Boolean( + featureFlagLogic.findMounted()?.values.featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS] || + featureFlagLogic.findMounted()?.values.featureFlags?.[FEATURE_FLAGS.HOGQL_INSIGHTS_RETENTION] + ) export const retentionPeopleLogic = kea([ props({} as InsightLogicProps), diff --git a/frontend/src/scenes/trends/viz/ActionsHorizontalBar.tsx b/frontend/src/scenes/trends/viz/ActionsHorizontalBar.tsx index ded94e7815490..54c935d954b99 100644 --- a/frontend/src/scenes/trends/viz/ActionsHorizontalBar.tsx +++ b/frontend/src/scenes/trends/viz/ActionsHorizontalBar.tsx @@ -76,7 +76,7 @@ export function ActionsHorizontalBar({ showPersonsModal = true }: ChartParams): }, [indexedResults]) const isTrendsQueryWithFeatureFlagOn = - featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS] && + (featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS] || featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS]) && isTrends && query && isInsightVizNode(query) && diff --git a/frontend/src/scenes/trends/viz/ActionsLineGraph.tsx b/frontend/src/scenes/trends/viz/ActionsLineGraph.tsx index b7f3ba8a46d0f..f2484752ce038 100644 --- a/frontend/src/scenes/trends/viz/ActionsLineGraph.tsx +++ b/frontend/src/scenes/trends/viz/ActionsLineGraph.tsx @@ -55,21 +55,21 @@ export function ActionsLineGraph({ [] const isLifecycleQueryWithFeatureFlagOn = - featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_LIFECYCLE] && + (featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS] || featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_LIFECYCLE]) && isLifecycle && query && isInsightVizNode(query) && isLifecycleQuery(query.source) const isStickinessQueryWithFeatureFlagOn = - featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_STICKINESS] && + (featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS] || featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_STICKINESS]) && isStickiness && query && isInsightVizNode(query) && isStickinessQuery(query.source) const isTrendsQueryWithFeatureFlagOn = - featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS] && + (featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS] || featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS]) && isTrends && query && isInsightVizNode(query) && diff --git a/frontend/src/scenes/trends/viz/ActionsPie.tsx b/frontend/src/scenes/trends/viz/ActionsPie.tsx index 839e06f0d71b6..36ff7166bc574 100644 --- a/frontend/src/scenes/trends/viz/ActionsPie.tsx +++ b/frontend/src/scenes/trends/viz/ActionsPie.tsx @@ -57,7 +57,7 @@ export function ActionsPie({ const showAggregation = !pieChartVizOptions?.hideAggregation const isTrendsQueryWithFeatureFlagOn = - featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS] && + (featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS] || featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS]) && isTrends && query && isInsightVizNode(query) &&