Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Fix crash when calculating visit duration with 0 sessions

Uku Taht968d280304bc
diff --git a/lib/plausible/stats/fragments.ex b/lib/plausible/stats/fragments.ex
index 0c27f65e4c..692233f107 100644
--- a/lib/plausible/stats/fragments.ex
+++ b/lib/plausible/stats/fragments.ex
@@ -25,7 +25,7 @@ defmodule Plausible.Stats.Fragments do
defmacro visit_duration() do
quote do
- fragment("toUInt32(round(avg(duration * sign)))")
+ fragment("toUInt32(ifNotFinite(round(avg(duration * sign)), 0))")
end
end