Implement user notes in CRM and HelpScout integration (#4611)

* Implement user notes in CRM and HelpScout integration

* Update HS tests

* Make slight markup and styling changes
This commit is contained in:
Adrian Gruntkowski 2024-09-25 16:56:33 +02:00 committed by GitHub
parent e11fd159df
commit 9d997a74d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 28 additions and 5 deletions

View File

@ -88,6 +88,7 @@ defmodule Plausible.HelpScout do
{:ok,
%{
email: user.email,
notes: user.notes,
status_label: status_label(user),
status_link:
Routes.kaffy_resource_url(PlausibleWeb.Endpoint, :show, :auth, :user, user.id),

View File

@ -42,6 +42,17 @@ defmodule PlausibleWeb.HelpScoutView do
<p class="label">
Owner of <b><a href={@sites_link} target="_blank"><%= @sites_count %> sites</a></b>
</p>
<p class="value"></p>
</div>
<div :if={@notes} class="notes">
<p class="label">
<b>Notes</b>
</p>
<div class="value">
<%= Phoenix.HTML.Format.text_to_html(@notes, escape: true) %>
</div>
</div>
<% end %>
</.layout>
@ -140,6 +151,10 @@ defmodule PlausibleWeb.HelpScoutView do
margin-bottom: 1.25em;
font-weight: bold;
}
.notes .value {
font-weight: normal;
}
</style>
</head>

View File

@ -35,6 +35,9 @@ defmodule Plausible.Auth.User do
field :previous_email, :string
field :accept_traffic_until, :date
# Field for purely informational purposes in CRM context
field :notes, :string
# A field only used as a manual override - allow subscribing
# to any plan, even when exceeding its pageview limit
field :allow_next_upgrade_override, :boolean
@ -113,7 +116,8 @@ defmodule Plausible.Auth.User do
:theme,
:trial_expiry_date,
:allow_next_upgrade_override,
:accept_traffic_until
:accept_traffic_until,
:notes
])
|> validate_required([:email, :name, :email_verified])
|> maybe_bump_accept_traffic_until()

View File

@ -20,7 +20,8 @@ defmodule Plausible.Auth.UserAdmin 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

View File

@ -104,9 +104,9 @@ defmodule PlausibleWeb.HelpScoutControllerTest do
end
end
describe "shows/2" do
describe "show/2" do
test "returns details on success", %{conn: conn} do
user = insert(:user, email: "hs.match@plausible.test")
user = insert(:user, email: "hs.match@plausible.test", notes: "Some note\nwith new line")
conn =
conn
@ -115,7 +115,9 @@ defmodule PlausibleWeb.HelpScoutControllerTest do
"/helpscout/show?conversation_id=123&customer_id=500&email=hs.match@plausible.test"
)
assert html_response(conn, 200) =~ "/crm/auth/user/#{user.id}"
assert html = html_response(conn, 200)
assert html =~ "/crm/auth/user/#{user.id}"
assert html =~ "Some note<br>\nwith new line"
end
test "returns error when cookie is missing", %{conn: conn} do