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
Page Scroll Goals: migration step 2 (#5034)
RobertJoonas2579bbea7b16
diff --git a/lib/plausible/goal/schema.ex b/lib/plausible/goal/schema.exindex 8f2e29febe..84d76cb991 100644--- a/lib/plausible/goal/schema.ex+++ b/lib/plausible/goal/schema.ex@@ -8,6 +8,7 @@ defmodule Plausible.Goal doschema "goals" dofield :event_name, :stringfield :page_path, :string+ field :scroll_threshold, :integer, default: -1field :display_name, :stringon_ee do@@ -23,7 +24,7 @@ defmodule Plausible.Goal dotimestamps()end- @fields [:id, :site_id, :event_name, :page_path, :display_name] +++ @fields [:id, :site_id, :event_name, :page_path, :scroll_threshold, :display_name] ++on_ee(do: [:currency], else: [])@max_event_name_length 120@@ -40,6 +41,9 @@ defmodule Plausible.Goal do|> maybe_put_display_name()|> unique_constraint(:event_name, name: :goals_event_name_unique)|> unique_constraint(:page_path, name: :goals_page_path_unique)+ |> unique_constraint([:page_path, :scroll_threshold],+ name: :goals_page_path_and_scroll_threshold_unique+ )|> unique_constraint(:display_name, name: :goals_site_id_display_name_index)|> validate_length(:event_name, max: @max_event_name_length)|> check_constraint(:event_name,diff --git a/test/plausible/goals_test.exs b/test/plausible/goals_test.exsindex ede9287ba3..d57cedfcea 100644--- a/test/plausible/goals_test.exs+++ b/test/plausible/goals_test.exs@@ -34,8 +34,11 @@ defmodule Plausible.GoalsTest dotest "create/2 fails to create the same pageview goal twice" dosite = new_site()- {:ok, _} = Goals.create(site, %{"page_path" => "foo bar"})- assert {:error, changeset} = Goals.create(site, %{"page_path" => "foo bar"})+ {:ok, _} = Goals.create(site, %{"page_path" => "foo bar", "display_name" => "one"})++ assert {:error, changeset} =+ Goals.create(site, %{"page_path" => "foo bar", "display_name" => "two"})+assert {"has already been taken", _} = changeset.errors[:page_path]end