Skip to content

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

Expose `teams.notes` in CRM/HelpScout (#5151)

hq1b7912c665e2c
diff --git a/extra/lib/plausible/help_scout.ex b/extra/lib/plausible/help_scout.ex
index 02952cc14d..8362efb023 100644
--- a/extra/lib/plausible/help_scout.ex
+++ b/extra/lib/plausible/help_scout.ex
@@ -122,7 +122,7 @@ defmodule Plausible.HelpScout do
{:ok,
%{
email: user.email,
- notes: user.notes,
+ notes: notes(user, team),
status_label: status_label(team, subscription),
status_link: status_link,
plan_label: plan_label(subscription, plan),
@@ -393,4 +393,16 @@ defmodule Plausible.HelpScout do
defp config() do
Application.fetch_env!(:plausible, __MODULE__)
end
+
+ defp notes(user, team) do
+ notes =
+ [
+ user.notes,
+ team && team.notes
+ ]
+ |> Enum.reject(&is_nil/1)
+ |> Enum.join("\n")
+
+ if notes != "", do: notes
+ end
end
diff --git a/lib/plausible/teams/team.ex b/lib/plausible/teams/team.ex
index 9cd7240deb..d9a57aaab1 100644
--- a/lib/plausible/teams/team.ex
+++ b/lib/plausible/teams/team.ex
@@ -29,6 +29,9 @@ defmodule Plausible.Teams.Team do
field :setup_complete, :boolean, default: false
field :setup_at, :naive_datetime
+ # Field for purely informational purposes in CRM context
+ field :notes, :string
+
embeds_one :grace_period, Plausible.Teams.GracePeriod, on_replace: :update
has_many :sites, Plausible.Site
@@ -50,6 +53,7 @@ defmodule Plausible.Teams.Team do
team
|> cast(params, [
:name,
+ :notes,
:trial_expiry_date,
:allow_next_upgrade_override,
:accept_traffic_until
diff --git a/lib/plausible/teams/team_admin.ex b/lib/plausible/teams/team_admin.ex
index b60e8d062c..90ed12ed22 100644
--- a/lib/plausible/teams/team_admin.ex
+++ b/lib/plausible/teams/team_admin.ex
@@ -69,7 +69,8 @@ defmodule Plausible.Teams.TeamAdmin do
allow_next_upgrade_override: nil,
accept_traffic_until: %{
help_text: "Change will take up to 15 minutes to propagate"
- }
+ },
+ notes: %{type: :textarea, rows: 6}
]
end