diff --git a/guard/config/config.exs b/guard/config/config.exs index 290ad37ca..7141f6e27 100644 --- a/guard/config/config.exs +++ b/guard/config/config.exs @@ -126,4 +126,7 @@ config :guard, Guard.OrganizationCleaner, config :guard, :hard_destroy_grace_period_days, 30 +config :guard, :posthog_api_key, "" +config :guard, :posthog_host, "https://app.posthog.com" + import_config "#{config_env()}.exs" diff --git a/guard/config/runtime.exs b/guard/config/runtime.exs index e66b553d1..5ba711ada 100644 --- a/guard/config/runtime.exs +++ b/guard/config/runtime.exs @@ -166,6 +166,9 @@ config :guard, :hide_gitlab_login_page, System.get_env("HIDE_GITLAB_LOGIN_PAGE") == "true" +config :guard, :posthog_api_key, System.get_env("POSTHOG_API_KEY") +config :guard, :posthog_host, System.get_env("POSTHOG_HOST") || "https://app.posthog.com" + if System.get_env("AMQP_URL") != nil do config :amqp, connections: [ diff --git a/guard/lib/guard/id/api.ex b/guard/lib/guard/id/api.ex index 7294e58f7..5bfc50d15 100644 --- a/guard/lib/guard/id/api.ex +++ b/guard/lib/guard/id/api.ex @@ -188,6 +188,12 @@ defmodule Guard.Id.Api do end defp render_signup_page(conn, assigns) do + assigns = + Keyword.merge(assigns, + posthog_api_key: Application.get_env(:guard, :posthog_api_key, ""), + posthog_host: Application.get_env(:guard, :posthog_host, "https://app.posthog.com") + ) + html_content = Guard.TemplateRenderer.render_template([assigns: assigns], "signup.html") conn @@ -326,6 +332,12 @@ defmodule Guard.Id.Api do end defp render_login_page(conn, assigns) do + assigns = + Keyword.merge(assigns, + posthog_api_key: Application.get_env(:guard, :posthog_api_key, ""), + posthog_host: Application.get_env(:guard, :posthog_host, "https://app.posthog.com") + ) + html_content = Guard.TemplateRenderer.render_template([assigns: assigns], "login.html") conn diff --git a/guard/templates/login.html.eex b/guard/templates/login.html.eex index abdeaa030..5542a255a 100644 --- a/guard/templates/login.html.eex +++ b/guard/templates/login.html.eex @@ -41,6 +41,17 @@ + <% if @assigns[:posthog_api_key] && @assigns[:posthog_api_key] != "" do %> + + <% end %>