Skip to content

Commit

Permalink
Handle custom events with empty URL and path properties gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
zoldar committed May 14, 2024
1 parent 519a41e commit b410777
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/plausible/stats/imported.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule Plausible.Stats.Imported do

@no_ref "Direct / None"
@not_set "(not set)"
@none "(none)"

@property_to_table_mappings %{
"visit:source" => "imported_sources",
Expand Down Expand Up @@ -472,13 +473,17 @@ defmodule Plausible.Stats.Imported do
defp group_imported_by(q, :url) do
q
|> group_by([i], i.link_url)
|> select_merge([i], %{breakdown_prop_value: i.link_url})
|> select_merge([i], %{
breakdown_prop_value: fragment("if(not empty(?), ?, ?)", i.link_url, i.link_url, @none)
})
end

defp group_imported_by(q, :path) do
q
|> group_by([i], i.path)
|> select_merge([i], %{breakdown_prop_value: i.path})
|> select_merge([i], %{
breakdown_prop_value: fragment("if(not empty(?), ?, ?)", i.path, i.path, @none)
})
end

defp select_joined_dimension(q, :city) do
Expand Down

0 comments on commit b410777

Please sign in to comment.