Skip to content

Commit

Permalink
refactor(hogql): remove persons related params from insight filters (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr authored Sep 26, 2023
1 parent 8597f7a commit 0b9e7ea
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ describe('filtersToQueryNode', () => {
funnel_correlation_person_entity: { a: 1 },
funnel_correlation_person_converted: 'true',
funnel_custom_steps: [1, 2, 3],
funnel_advanced: true,
layout: FunnelLayout.horizontal,
funnel_step: 1,
entrance_period_start: 'abc',
Expand All @@ -371,7 +370,6 @@ describe('filtersToQueryNode', () => {
funnel_from_step: 1,
funnel_to_step: 2,
funnel_step_reference: FunnelStepReference.total,
funnel_step_breakdown: 1,
breakdown_attribution_type: BreakdownAttributionType.AllSteps,
breakdown_attribution_value: 1,
bin_count: 'auto',
Expand All @@ -384,14 +382,7 @@ describe('filtersToQueryNode', () => {
funnel_to_step: 1,
},
],
funnel_correlation_person_entity: { a: 1 },
funnel_correlation_person_converted: 'true',
funnel_custom_steps: [1, 2, 3],
funnel_advanced: true,
layout: FunnelLayout.horizontal,
funnel_step: 1,
entrance_period_start: 'abc',
drop_off: true,
hidden_legend_breakdowns: ['Chrome', 'Safari'],
},
}
Expand Down Expand Up @@ -465,9 +456,6 @@ describe('filtersToQueryNode', () => {
funnel_filter: { a: 1 },
exclude_events: ['e', 'f'],
step_limit: 1,
path_start_key: 'g',
path_end_key: 'h',
path_dropoff_key: 'i',
path_replacements: true,
local_path_cleaning_filters: [{ alias: 'home' }],
edge_limit: 1,
Expand All @@ -486,7 +474,6 @@ describe('filtersToQueryNode', () => {
compare: true,
show_legend: true,
hidden_legend_keys: { 0: true, 10: true },
stickiness_days: 2,
shown_as: ShownAsValue.STICKINESS,
display: ChartDisplayType.ActionsLineGraph,
}
Expand All @@ -499,7 +486,6 @@ describe('filtersToQueryNode', () => {
compare: true,
show_legend: true,
hidden_legend_indexes: [0, 10],
stickiness_days: 2,
shown_as: ShownAsValue.STICKINESS,
display: ChartDisplayType.ActionsLineGraph,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,14 @@ export const filtersToQueryNode = (filters: Partial<FilterType>): InsightQueryNo
funnel_from_step: filters.funnel_from_step,
funnel_to_step: filters.funnel_to_step,
funnel_step_reference: filters.funnel_step_reference,
funnel_step_breakdown: filters.funnel_step_breakdown,
breakdown_attribution_type: filters.breakdown_attribution_type,
breakdown_attribution_value: filters.breakdown_attribution_value,
bin_count: filters.bin_count,
funnel_window_interval_unit: filters.funnel_window_interval_unit,
funnel_window_interval: filters.funnel_window_interval,
funnel_order_type: filters.funnel_order_type,
exclusions: filters.exclusions,
funnel_correlation_person_entity: filters.funnel_correlation_person_entity,
funnel_correlation_person_converted: filters.funnel_correlation_person_converted,
funnel_custom_steps: filters.funnel_custom_steps,
funnel_advanced: filters.funnel_advanced,
layout: filters.layout,
funnel_step: filters.funnel_step,
entrance_period_start: filters.entrance_period_start,
drop_off: filters.drop_off,
hidden_legend_breakdowns: cleanHiddenLegendSeries(filters.hidden_legend_keys),
funnel_aggregate_by_hogql: filters.funnel_aggregate_by_hogql,
})
Expand Down Expand Up @@ -238,9 +230,6 @@ export const filtersToQueryNode = (filters: Partial<FilterType>): InsightQueryNo
funnel_filter: filters.funnel_filter,
exclude_events: filters.exclude_events,
step_limit: filters.step_limit,
path_start_key: filters.path_start_key,
path_end_key: filters.path_end_key,
path_dropoff_key: filters.path_dropoff_key,
path_replacements: filters.path_replacements,
local_path_cleaning_filters: filters.local_path_cleaning_filters,
edge_limit: filters.edge_limit,
Expand All @@ -256,7 +245,6 @@ export const filtersToQueryNode = (filters: Partial<FilterType>): InsightQueryNo
compare: filters.compare,
show_legend: filters.show_legend,
hidden_legend_indexes: cleanHiddenLegendIndexes(filters.hidden_legend_keys),
stickiness_days: filters.stickiness_days,
shown_as: filters.shown_as,
show_values_on_series: filters.show_values_on_series,
})
Expand Down
62 changes: 3 additions & 59 deletions frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@
},
"FunnelsFilter": {
"additionalProperties": false,
"description": "`FunnelsFilterType` minus everything inherited from `FilterType` and `hidden_legend_keys` replaced by `hidden_legend_breakdowns`",
"description": "`FunnelsFilterType` minus everything inherited from `FilterType` and persons modal related params and `hidden_legend_keys` replaced by `hidden_legend_breakdowns`",
"properties": {
"bin_count": {
"$ref": "#/definitions/BinCountValue"
Expand All @@ -905,65 +905,21 @@
"breakdown_attribution_value": {
"type": "number"
},
"drop_off": {
"type": "boolean"
},
"entrance_period_start": {
"type": "string"
},
"exclusions": {
"items": {
"$ref": "#/definitions/FunnelExclusion"
},
"type": "array"
},
"funnel_advanced": {
"type": "boolean"
},
"funnel_aggregate_by_hogql": {
"type": "string"
},
"funnel_correlation_person_converted": {
"enum": ["true", "false"],
"type": "string"
},
"funnel_correlation_person_entity": {
"type": "object"
},
"funnel_custom_steps": {
"items": {
"type": "number"
},
"type": "array"
},
"funnel_from_step": {
"type": "number"
},
"funnel_order_type": {
"$ref": "#/definitions/StepOrderValue"
},
"funnel_step": {
"type": "number"
},
"funnel_step_breakdown": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"type": "number"
},
"type": "array"
},
{
"type": "number"
},
{
"type": "null"
}
]
},
"funnel_step_reference": {
"$ref": "#/definitions/FunnelStepReference"
},
Expand Down Expand Up @@ -1472,7 +1428,7 @@
},
"PathsFilter": {
"additionalProperties": false,
"description": "`PathsFilterType` minus everything inherited from `FilterType`",
"description": "`PathsFilterType` minus everything inherited from `FilterType` and persons modal related params",
"properties": {
"edge_limit": {
"type": "number"
Expand Down Expand Up @@ -1510,12 +1466,6 @@
"min_edge_weight": {
"type": "number"
},
"path_dropoff_key": {
"type": "string"
},
"path_end_key": {
"type": "string"
},
"path_groupings": {
"items": {
"type": "string"
Expand All @@ -1525,9 +1475,6 @@
"path_replacements": {
"type": "boolean"
},
"path_start_key": {
"type": "string"
},
"path_type": {
"$ref": "#/definitions/PathType"
},
Expand Down Expand Up @@ -2051,7 +1998,7 @@
},
"StickinessFilter": {
"additionalProperties": false,
"description": "`StickinessFilterType` minus everything inherited from `FilterType` and `hidden_legend_keys` replaced by `hidden_legend_indexes`",
"description": "`StickinessFilterType` minus everything inherited from `FilterType` and persons modal related params and `hidden_legend_keys` replaced by `hidden_legend_indexes`",
"properties": {
"compare": {
"type": "boolean"
Expand All @@ -2073,9 +2020,6 @@
},
"shown_as": {
"$ref": "#/definitions/ShownAsValue"
},
"stickiness_days": {
"type": "number"
}
},
"type": "object"
Expand Down
27 changes: 19 additions & 8 deletions frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,19 @@ export interface TrendsQuery extends InsightsQueryBase {
response?: TrendsQueryResponse
}

/** `FunnelsFilterType` minus everything inherited from `FilterType` and
* `hidden_legend_keys` replaced by `hidden_legend_breakdowns` */
/** `FunnelsFilterType` minus everything inherited from `FilterType` and persons modal related params
* and `hidden_legend_keys` replaced by `hidden_legend_breakdowns` */
export type FunnelsFilter = Omit<
FunnelsFilterType & { hidden_legend_breakdowns?: string[] },
keyof FilterType | 'hidden_legend_keys'
| keyof FilterType
| 'hidden_legend_keys'
| 'funnel_step_breakdown'
| 'funnel_correlation_person_entity'
| 'funnel_correlation_person_converted'
| 'entrance_period_start'
| 'drop_off'
| 'funnel_step'
| 'funnel_custom_steps'
>
export interface FunnelsQuery extends InsightsQueryBase {
kind: NodeKind.FunnelsQuery
Expand All @@ -419,19 +427,22 @@ export interface RetentionQuery extends InsightsQueryBase {
retentionFilter?: RetentionFilter
}

/** `PathsFilterType` minus everything inherited from `FilterType` */
export type PathsFilter = Omit<PathsFilterType, keyof FilterType>
/** `PathsFilterType` minus everything inherited from `FilterType` and persons modal related params */
export type PathsFilter = Omit<
PathsFilterType,
keyof FilterType | 'path_start_key' | 'path_end_key' | 'path_dropoff_key'
>
export interface PathsQuery extends InsightsQueryBase {
kind: NodeKind.PathsQuery
/** Properties specific to the paths insight */
pathsFilter?: PathsFilter
}

/** `StickinessFilterType` minus everything inherited from `FilterType` and
* `hidden_legend_keys` replaced by `hidden_legend_indexes` */
/** `StickinessFilterType` minus everything inherited from `FilterType` and persons modal related params
* and `hidden_legend_keys` replaced by `hidden_legend_indexes` */
export type StickinessFilter = Omit<
StickinessFilterType & { hidden_legend_indexes?: number[] },
keyof FilterType | 'hidden_legend_keys'
keyof FilterType | 'hidden_legend_keys' | 'stickiness_days'
>
export interface StickinessQuery extends InsightsQueryBase {
kind: NodeKind.StickinessQuery
Expand Down
1 change: 0 additions & 1 deletion frontend/src/scenes/insights/utils/cleanFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ export function cleanFilters(
...(filters.funnel_window_interval ? { funnel_window_interval: filters.funnel_window_interval } : {}),
...(filters.funnel_order_type ? { funnel_order_type: filters.funnel_order_type } : {}),
...(filters.hidden_legend_keys ? { hidden_legend_keys: filters.hidden_legend_keys } : {}),
...(filters.funnel_advanced ? { funnel_advanced: filters.funnel_advanced } : {}),
...(filters.funnel_aggregate_by_hogql
? { funnel_aggregate_by_hogql: filters.funnel_aggregate_by_hogql }
: {}),
Expand Down
53 changes: 33 additions & 20 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1668,53 +1668,62 @@ export interface TrendsFilterType extends FilterType {
// number of intervals, e.g. for a day interval, we may want to smooth over
// 7 days to remove weekly variation. Smoothing is performed as a moving average.
smoothing_intervals?: number
compare?: boolean
formula?: string
shown_as?: ShownAsValue
display?: ChartDisplayType
breakdown_histogram_bin_count?: number // trends breakdown histogram bin count

// frontend only
show_legend?: boolean // used to show/hide legend next to insights graph
hidden_legend_keys?: Record<string, boolean | undefined> // used to toggle visibilities in table and legend
compare?: boolean
aggregation_axis_format?: AggregationAxisFormat // a fixed format like duration that needs calculation
aggregation_axis_prefix?: string // a prefix to add to the aggregation axis e.g. £
aggregation_axis_postfix?: string // a postfix to add to the aggregation axis e.g. %
formula?: string
shown_as?: ShownAsValue
display?: ChartDisplayType
show_values_on_series?: boolean
show_percent_stack_view?: boolean
breakdown_histogram_bin_count?: number // trends breakdown histogram bin count
}

export interface StickinessFilterType extends FilterType {
compare?: boolean
show_legend?: boolean // used to show/hide legend next to insights graph
hidden_legend_keys?: Record<string, boolean | undefined> // used to toggle visibilities in table and legend
stickiness_days?: number
shown_as?: ShownAsValue
display?: ChartDisplayType

// frontend only
show_legend?: boolean // used to show/hide legend next to insights graph
hidden_legend_keys?: Record<string, boolean | undefined> // used to toggle visibilities in table and legend
show_values_on_series?: boolean

// persons only
stickiness_days?: number
}

export interface FunnelsFilterType extends FilterType {
funnel_viz_type?: FunnelVizType // parameter sent to funnels API for time conversion code path
funnel_from_step?: number // used in time to convert: initial step index to compute time to convert
funnel_to_step?: number // used in time to convert: ending step index to compute time to convert
funnel_step_reference?: FunnelStepReference // whether conversion shown in graph should be across all steps or just from the previous step
funnel_step_breakdown?: string | number[] | number | null // used in steps breakdown: persons modal
breakdown_attribution_type?: BreakdownAttributionType // funnels breakdown attribution type
breakdown_attribution_value?: number // funnels breakdown attribution specific step value
bin_count?: BinCountValue // used in time to convert: number of bins to show in histogram
funnel_window_interval_unit?: FunnelConversionWindowTimeUnit // minutes, days, weeks, etc. for conversion window
funnel_window_interval?: number | undefined // length of conversion window
funnel_order_type?: StepOrderValue
exclusions?: FunnelExclusion[] // used in funnel exclusion filters
funnel_correlation_person_entity?: Record<string, any> // Funnel Correlation Persons Filter
funnel_correlation_person_converted?: 'true' | 'false' // Funnel Correlation Persons Converted - success or failure counts
funnel_custom_steps?: number[] // used to provide custom steps for which to get people in a funnel - primarily for correlation use
funnel_advanced?: boolean // used to toggle advanced options on or off
funnel_aggregate_by_hogql?: string

// frontend only
layout?: FunnelLayout // used only for funnels
funnel_step?: number
funnel_step_reference?: FunnelStepReference // whether conversion shown in graph should be across all steps or just from the previous step
hidden_legend_keys?: Record<string, boolean | undefined> // used to toggle visibilities in table and legend

// persons only
entrance_period_start?: string // this and drop_off is used for funnels time conversion date for the persons modal
drop_off?: boolean
hidden_legend_keys?: Record<string, boolean | undefined> // used to toggle visibilities in table and legend
funnel_aggregate_by_hogql?: string
funnel_step?: number
funnel_step_breakdown?: string | number[] | number | null // used in steps breakdown: persons modal
funnel_custom_steps?: number[] // used to provide custom steps for which to get people in a funnel - primarily for correlation use
funnel_correlation_person_entity?: Record<string, any> // Funnel Correlation Persons Filter
funnel_correlation_person_converted?: 'true' | 'false' // Funnel Correlation Persons Converted - success or failure counts
}
export interface PathsFilterType extends FilterType {
path_type?: PathType
Expand All @@ -1727,14 +1736,16 @@ export interface PathsFilterType extends FilterType {
funnel_filter?: Record<string, any> // Funnel Filter used in Paths
exclude_events?: string[] // Paths Exclusion type
step_limit?: number // Paths Step Limit
path_start_key?: string // Paths People Start Key
path_end_key?: string // Paths People End Key
path_dropoff_key?: string // Paths People Dropoff Key
path_replacements?: boolean
local_path_cleaning_filters?: PathCleaningFilter[]
edge_limit?: number | undefined // Paths edge limit
min_edge_weight?: number | undefined // Paths
max_edge_weight?: number | undefined // Paths

// persons only
path_start_key?: string // Paths People Start Key
path_end_key?: string // Paths People End Key
path_dropoff_key?: string // Paths People Dropoff Key
}
export interface RetentionFilterType extends FilterType {
retention_type?: RetentionType
Expand All @@ -1746,6 +1757,8 @@ export interface RetentionFilterType extends FilterType {
}
export interface LifecycleFilterType extends FilterType {
shown_as?: ShownAsValue

// frontend only
show_values_on_series?: boolean
toggledLifecycles?: LifecycleToggle[]
}
Expand Down
Loading

0 comments on commit 0b9e7ea

Please sign in to comment.