Skip to content

Commit

Permalink
feat(hogql): feature preview flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra committed Mar 27, 2024
1 parent 8d55545 commit 61c73cf
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 35 deletions.
1 change: 1 addition & 0 deletions frontend/src/lib/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
],
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: [
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/queries/nodes/InsightViz/TrendsSeries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
38 changes: 16 additions & 22 deletions frontend/src/queries/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,28 +146,22 @@ export async function query<N extends DataNode = DataNode>(
let response: NonNullable<N['response']>
const logParams: Record<string, any> = {}
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<Record<string, any>> {
const response = await api.getResponse(legacyUrl!)
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/scenes/funnels/funnelDataLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ export const funnelDataLogic = kea<funnelDataLogicType>([
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: [
Expand Down
1 change: 1 addition & 0 deletions frontend/src/scenes/insights/insightDataLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export const insightDataLogic = kea<insightDataLogicType>([
}

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)) ||
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/insights/views/BoldNumber/BoldNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down Expand Up @@ -178,7 +178,7 @@ function BoldNumberComparison({ showPersonsModal }: Pick<ChartParams, 'showPerso
: 'No change from'

const isTrendsQueryWithFeatureFlagOn =
featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS] &&
(featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS] || featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_TRENDS]) &&
isTrends &&
query &&
isInsightVizNode(query) &&
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/scenes/paths/pathsDataLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ export const pathsDataLogic = kea<pathsDataLogicType>([
],
hogQLInsightsPathsFlagEnabled: [
(s) => [s.featureFlags],
(featureFlags) => !!featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_PATHS],
(featureFlags) =>
!!(featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS] || featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS_PATHS]),
],
}),

Expand Down
6 changes: 5 additions & 1 deletion frontend/src/scenes/retention/retentionModalLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ export const retentionModalLogic = kea<retentionModalLogicType>([
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 = {
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/scenes/retention/retentionPeopleLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<retentionPeopleLogicType>([
props({} as InsightLogicProps),
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/trends/viz/ActionsHorizontalBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/scenes/trends/viz/ActionsLineGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/trends/viz/ActionsPie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down

0 comments on commit 61c73cf

Please sign in to comment.