Skip to content

Commit

Permalink
Fix dogfooding invitation event (#4023)
Browse files Browse the repository at this point in the history
* Fix dogfooding invitation event

* Fix small build
  • Loading branch information
aerosol authored Apr 22, 2024
1 parent 7ae855c commit 148413a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
29 changes: 18 additions & 11 deletions lib/plausible_web/live/register_form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,24 @@ defmodule PlausibleWeb.Live.RegisterForm do
defp add_user(socket, user) do
case Repo.insert(user) do
{:ok, _user} ->
metrics_params =
if socket.assigns.invitation do
%{
event_name: "Signup via invitation",
params: %{u: "/register/invitation/:invitation_id"}
}
else
%{event_name: "Signup", params: %{}}
end

{:noreply, push_event(socket, "send-metrics", metrics_params)}
on_full_build do
metrics_params =
if socket.assigns.invitation do
%{
event_name: "Signup via invitation",
params: %{
url:
Path.join(PlausibleWeb.Endpoint.url(), "/register/invitation/:invitation_id")
}
}
else
%{event_name: "Signup", params: %{}}
end

{:noreply, push_event(socket, "send-metrics", metrics_params)}
else
{:noreply, socket}
end

{:error, changeset} ->
{:noreply,
Expand Down
8 changes: 6 additions & 2 deletions test/plausible_web/live/register_form_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ defmodule PlausibleWeb.Live.RegisterFormTest do

html = lv |> element("form") |> render_submit()

assert_push_event(lv, "send-metrics", %{event_name: "Signup", params: %{}})
on_full_build do
assert_push_event(lv, "send-metrics", %{event_name: "Signup", params: %{}})
end

assert [
csrf_input,
Expand Down Expand Up @@ -159,7 +161,9 @@ defmodule PlausibleWeb.Live.RegisterFormTest do

html = lv |> element("form") |> render_submit()

assert_push_event(lv, "send-metrics", %{event_name: "Signup via invitation", params: %{}})
on_full_build do
assert_push_event(lv, "send-metrics", %{event_name: "Signup via invitation", params: %{}})
end

assert [
csrf_input,
Expand Down

0 comments on commit 148413a

Please sign in to comment.