diff --git a/assets/js/dashboard/filters.js b/assets/js/dashboard/filters.js index bf66a5a26..9ae721d31 100644 --- a/assets/js/dashboard/filters.js +++ b/assets/js/dashboard/filters.js @@ -174,7 +174,7 @@ class Filters extends React.Component { } renderDropdownFilter(history, [key, value], query) { - if (['goal', 'props'].includes(key)) { + if ('props' == key) { return (
{this.filterText(key, value, query)} @@ -201,7 +201,7 @@ class Filters extends React.Component { renderListFilter(history, [key, value], query) { return ( - {['goal', 'props'].includes(key) ? ( + {'props' == key ? ( {this.filterText(key, value, query)} diff --git a/assets/js/dashboard/query.js b/assets/js/dashboard/query.js index 2c98a9061..823e24c0f 100644 --- a/assets/js/dashboard/query.js +++ b/assets/js/dashboard/query.js @@ -162,7 +162,7 @@ export function eventName(query) { export const formattedFilters = { 'goal': 'Goal', - 'props': 'Props', + 'props': 'Goal properties', 'source': 'Source', 'utm_medium': 'UTM Medium', 'utm_source': 'UTM Source', diff --git a/assets/js/dashboard/stats/modals/filter.js b/assets/js/dashboard/stats/modals/filter.js index 4aea6e78a..2149e1f01 100644 --- a/assets/js/dashboard/stats/modals/filter.js +++ b/assets/js/dashboard/stats/modals/filter.js @@ -22,7 +22,7 @@ class FilterModal extends React.Component { preventSuggestions: true } - this.editableGoals = Object.keys(this.state.query.filters).filter(filter => !['goal', 'props'].includes(filter)) + this.editableGoals = Object.keys(this.state.query.filters).filter(filter => !['props'].includes(filter)) this.renderSelector = this.renderSelector.bind(this) this.fetchSuggestions = this.fetchSuggestions.bind(this) this.handleKeydown = this.handleKeydown.bind(this) @@ -166,7 +166,7 @@ class FilterModal extends React.Component { {suggestions.map((suggestion, index) => ( { this.setState({ updatedValue: suggestion, preventSuggestions: true, suggestions: [] }) }} diff --git a/lib/plausible/stats/clickhouse.ex b/lib/plausible/stats/clickhouse.ex index 732bf03f9..752d2e9a9 100644 --- a/lib/plausible/stats/clickhouse.ex +++ b/lib/plausible/stats/clickhouse.ex @@ -1718,10 +1718,24 @@ defmodule Plausible.Stats.Clickhouse do select: {e.screen_size}, where: fragment("? ilike ?", e.screen_size, ^filter_query) ) + + "goal" -> + nil end - ClickhouseRepo.all(q) - |> Enum.map(fn {suggestion} -> suggestion end) - |> Enum.filter(fn suggestion -> suggestion != "" end) + if filter_name == "goal" do + Repo.all(from g in Plausible.Goal, where: g.domain == ^site.domain) + |> Enum.map(fn x -> if x.event_name, do: x.event_name, else: "Visit #{x.page_path}" end) + |> Enum.filter(fn goal -> + String.contains?( + String.downcase(goal), + String.downcase(filter_search) || filter_search == "" + ) + end) + else + ClickhouseRepo.all(q) + |> Enum.map(fn {suggestion} -> suggestion end) + |> Enum.filter(fn suggestion -> suggestion != "" end) + end end end