Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Fix billing usage section
Uku Taht06177b84e6a4
diff --git a/lib/plausible/billing/billing.ex b/lib/plausible/billing/billing.exindex 1e605f182a..c9059d68f2 100644--- a/lib/plausible/billing/billing.ex+++ b/lib/plausible/billing/billing.ex@@ -183,8 +183,8 @@ defmodule Plausible.Billing doEnum.reduce(user.sites, {0, 0}, fn site, {pageviews, custom_events} ->usage = Plausible.Stats.Clickhouse.usage(site)- {pageviews + Map.get(usage, :pageviews, 0),- custom_events + Map.get(usage, :custom_events, 0)}+ {pageviews + Map.get(usage, "pageviews", 0),+ custom_events + Map.get(usage, "custom_events", 0)}end)enddiff --git a/lib/plausible/stats/clickhouse.ex b/lib/plausible/stats/clickhouse.exindex 27f0cba00c..29e9d97857 100644--- a/lib/plausible/stats/clickhouse.ex+++ b/lib/plausible/stats/clickhouse.ex@@ -181,13 +181,12 @@ defmodule Plausible.Stats.Clickhouse dofrom e in "events",where: e.domain == ^site.domain,where: e.timestamp >= ^first_datetime and e.timestamp < ^last_datetime,- group_by: e.name,- select: {e.name, fragment("count(*)")}+ group_by: fragment("name"),+ select: {+ fragment("if(? = 'pageview', 'pageviews', 'custom_events') as name", e.name),+ fragment("count(*)")+ })- |> Enum.map(fn {ev_name, count} ->- ev_name = if ev_name == "pageview", do: :pageviews, else: :custom_events- {ev_name, count}- end)|> Enum.into(%{})end