From 5b69061885c4a42fb8a66cb34b68466515651826 Mon Sep 17 00:00:00 2001 From: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com> Date: Mon, 1 Dec 2025 13:17:13 +0000 Subject: [PATCH] Consolidated views <> revenue goals: add comment + fix typespec (#5921) * add comment + fix typespec * Update lib/plausible/goals/goals.ex Co-authored-by: Adrian Gruntkowski --------- Co-authored-by: Adrian Gruntkowski --- lib/plausible/goals/goals.ex | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/plausible/goals/goals.ex b/lib/plausible/goals/goals.ex index 2899e0c632..8602046fa5 100644 --- a/lib/plausible/goals/goals.ex +++ b/lib/plausible/goals/goals.ex @@ -36,11 +36,23 @@ defmodule Plausible.Goals do {:ok, Goal.t()} | {:error, Changeset.t()} | {:error, :upgrade_required} + | {:error, :revenue_goals_unavailable} @doc """ Creates a Goal for a site. If the created goal is a revenue goal, it sets site.updated_at to be refreshed by the sites cache, as revenue goals are used during ingestion. + + Returns `{:ok, goal}` or `{:error, changeset}` when creation fails due to + invalid fields. It can also return: + + * `{:error, :upgrade_required}` - Adding a revenue goal is not allowed + for team's subscription. + + * `{:error, :revenue_goals_unavailable}` - When the site is a consolidated + view and the goal created is a revenue goal. Revenue goal creation is not + allowed for consolidated views due to the inability to force a single + currency on a goal across all consolidated sites. """ def create(site, params, opts \\ []) do Repo.transaction(fn ->