Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions guard/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 3 additions & 0 deletions guard/config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
12 changes: 12 additions & 0 deletions guard/lib/guard/id/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions guard/templates/login.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@
<meta name="twitter:data1" content="1 minute" />
<meta name="twitter:label2" content="Written by" />
<meta name="twitter:data2" content="Semaphore Team" />
<% if @assigns[:posthog_api_key] && @assigns[:posthog_api_key] != "" do %>
<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="init Ce js Ls Te Fs Ds capture Ye calculateEventProperties Us register register_once register_for_session unregister unregister_for_session Ws getFeatureFlag getFeatureFlagPayload isFeatureEnabled reloadFeatureFlags updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures on onFeatureFlags onSurveysLoaded onSessionId getSurveys getActiveMatchingSurveys renderSurvey displaySurvey canRenderSurvey canRenderSurveyAsync identify setPersonProperties group resetGroups setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags reset get_distinct_id getGroups get_session_id get_session_replay_url alias set_config startSessionRecording stopSessionRecording sessionRecordingStarted captureException loadToolbar get_property getSessionProperty Bs zs createPersonProfile Hs Ms Gs opt_in_capturing opt_out_capturing has_opted_in_capturing has_opted_out_capturing get_explicit_consent_status is_capturing clear_opt_in_out_capturing Ns debug L qs getPageViewId captureTraceFeedback captureTraceMetric".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);

posthog.init('<%= @assigns[:posthog_api_key] %>', {
api_host: '<%= @assigns[:posthog_host] %>',
defaults: '2025-05-24',
person_profiles: 'identified_only'
});
</script>
<% end %>
</head>
<body class="page-template-default page page-id-19406 wp-embed-responsive no-sidebar">
<div id="page" class="site no-header-no-footer green v8theme ">
Expand Down
11 changes: 11 additions & 0 deletions guard/templates/signup.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@
<meta name="twitter:data1" content="1 minute">
<meta name="twitter:label2" content="Written by">
<meta name="twitter:data2" content="Semaphore Team">
<% if @assigns[:posthog_api_key] && @assigns[:posthog_api_key] != "" do %>
<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="init Ce js Ls Te Fs Ds capture Ye calculateEventProperties Us register register_once register_for_session unregister unregister_for_session Ws getFeatureFlag getFeatureFlagPayload isFeatureEnabled reloadFeatureFlags updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures on onFeatureFlags onSurveysLoaded onSessionId getSurveys getActiveMatchingSurveys renderSurvey displaySurvey canRenderSurvey canRenderSurveyAsync identify setPersonProperties group resetGroups setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags reset get_distinct_id getGroups get_session_id get_session_replay_url alias set_config startSessionRecording stopSessionRecording sessionRecordingStarted captureException loadToolbar get_property getSessionProperty Bs zs createPersonProfile Hs Ms Gs opt_in_capturing opt_out_capturing has_opted_in_capturing has_opted_out_capturing get_explicit_consent_status is_capturing clear_opt_in_out_capturing Ns debug L qs getPageViewId captureTraceFeedback captureTraceMetric".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);

posthog.init('<%= @assigns[:posthog_api_key] %>', {
api_host: '<%= @assigns[:posthog_host] %>',
defaults: '2025-05-24',
person_profiles: 'identified_only'
});
</script>
<% end %>
</head>
<body class="page-template-default page page-id-19406 wp-embed-responsive no-sidebar">
<header>
Expand Down