Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Implement new onboarding/provisioning flow progress layout (#4441)
hq10440d365773e
diff --git a/lib/plausible_web/components/flow_progress.ex b/lib/plausible_web/components/flow_progress.exnew file mode 100644index 0000000000..5dce847d51--- /dev/null+++ b/lib/plausible_web/components/flow_progress.ex@@ -0,0 +1,87 @@+defmodule PlausibleWeb.Components.FlowProgress do+ @moduledoc """+ Component for provisioning/registration flows displaying+ progress status.+ """+ use Phoenix.Component++ @flows %{+ "register" => [+ "Register",+ "Activate account",+ "Add site info",+ "Install snippet",+ "Verify snippet"+ ],+ "invitation" => [+ "Register",+ "Activate account"+ ],+ "provisioning" => [+ "Add site info",+ "Install snippet",+ "Verify snippet"+ ]+ }++ @values @flows |> Enum.flat_map(fn {_, steps} -> steps end) |> Enum.uniq()++ def flows, do: @flows++ attr :flow, :string, required: true+ attr :current_step, :string, required: true, values: @values++ def render(assigns) do+ steps = Map.get(flows(), assigns.flow, [])+ current_step_idx = Enum.find_index(steps, &(&1 == assigns.current_step))++ assigns =+ assign(assigns,+ steps: steps,+ current_step_idx: current_step_idx+ )++ ~H"""+ <div :if={not Enum.empty?(@steps)} class="mt-6 hidden md:block" id="flow-progress">+ <div class="flex items-center justify-between max-w-3xl mx-auto my-8">+ <%= for {step, idx} <- Enum.with_index(@steps) do %>+ <div class="flex items-center text-xs">+ <div+ :if={idx < @current_step_idx}+ class="w-5 h-5 bg-green-500 dark:bg-green-600 text-white rounded-full flex items-center justify-center"+ >+ <Heroicons.check class="w-4 h-4" />+ </div>+ <div+ :if={idx == @current_step_idx}+ class="w-5 h-5 bg-indigo-600 text-white rounded-full flex items-center justify-center font-semibold"+ >+ <%= idx + 1 %>+ </div>+ <div+ :if={idx > @current_step_idx}+ class="w-5 h-5 bg-gray-300 text-white dark:bg-gray-800 rounded-full flex items-center justify-center"+ >+ <%= idx + 1 %>+ </div>+ <span :if={idx < @current_step_idx} class="ml-2 text-gray-500">+ <%= step %>+ </span>+ <span+ :if={idx == @current_step_idx}+ class="ml-2 font-semibold text-black dark:text-gray-300"+ >+ <%= step %>+ </span>+ <span :if={idx > @current_step_idx} class="ml-2 text-gray-500">+ <%= step %>+ </span>+ </div>+ <div :if={idx + 1 != length(@steps)} class="flex-1 h-px bg-gray-300 mx-4 dark:bg-gray-800 ">+ </div>+ <% end %>+ </div>+ </div>+ """+ end+enddiff --git a/lib/plausible_web/controllers/auth_controller.ex b/lib/plausible_web/controllers/auth_controller.exindex a7b58b3382..89ee79ca4a 100644--- a/lib/plausible_web/controllers/auth_controller.ex+++ b/lib/plausible_web/controllers/auth_controller.ex@@ -63,10 +63,10 @@ defmodule PlausibleWeb.AuthController doconn = set_user_session(conn, user)if user.email_verified do- redirect(conn, to: Routes.site_path(conn, :new))+ redirect(conn, to: Routes.site_path(conn, :new, flow: "register"))elseAuth.EmailVerification.issue_code(user)- redirect(conn, to: Routes.auth_path(conn, :activate_form))+ redirect(conn, to: Routes.auth_path(conn, :activate_form, flow: "register"))endendend@@ -79,19 +79,20 @@ defmodule PlausibleWeb.AuthController doredirect(conn, to: Routes.site_path(conn, :index))elseAuth.EmailVerification.issue_code(user)- redirect(conn, to: Routes.auth_path(conn, :activate_form))+ redirect(conn, to: Routes.auth_path(conn, :activate_form, flow: "invitation"))endendend- def activate_form(conn, _params) do+ def activate_form(conn, params) douser = conn.assigns.current_user+ flow = params["flow"] || "register"render(conn, "activate.html",has_email_code?: Plausible.Users.has_email_code?(user),- has_any_invitations?: Plausible.Site.Memberships.pending?(user.email),has_any_memberships?: Plausible.Site.Memberships.any?(user),- layout: {PlausibleWeb.LayoutView, "focus.html"}+ layout: {PlausibleWeb.LayoutView, "focus.html"},+ form_submit_url: "/activate?flow=#{flow}")end@@ -101,6 +102,8 @@ defmodule PlausibleWeb.AuthController dohas_any_invitations? = Plausible.Site.Memberships.pending?(user.email)has_any_memberships? = Plausible.Site.Memberships.any?(user)+ flow = conn.params["flow"]+case Auth.EmailVerification.verify_code(user, code) do:ok ->cond do@@ -108,28 +111,28 @@ defmodule PlausibleWeb.AuthController dohandle_email_updated(conn)has_any_invitations? ->- redirect(conn, to: Routes.site_path(conn, :index))+ redirect(conn, to: Routes.site_path(conn, :index, flow: flow))true ->- redirect(conn, to: Routes.site_path(conn, :new))+ redirect(conn, to: Routes.site_path(conn, :new, flow: flow))end{:error, :incorrect} ->render(conn, "activate.html",error: "Incorrect activation code",has_email_code?: true,- has_any_invitations?: has_any_invitations?,has_any_memberships?: has_any_memberships?,- layout: {PlausibleWeb.LayoutView, "focus.html"}+ layout: {PlausibleWeb.LayoutView, "focus.html"},+ form_submit_url: "/activate?flow=#{flow}"){:error, :expired} ->render(conn, "activate.html",error: "Code is expired, please request another one",has_email_code?: false,- has_any_invitations?: has_any_invitations?,has_any_memberships?: has_any_memberships?,- layout: {PlausibleWeb.LayoutView, "focus.html"}+ layout: {PlausibleWeb.LayoutView, "focus.html"},+ form_submit_url: "/activate?flow=#{flow}")endenddiff --git a/lib/plausible_web/controllers/site_controller.ex b/lib/plausible_web/controllers/site_controller.exindex f895a237a5..fedadf0420 100644--- a/lib/plausible_web/controllers/site_controller.ex+++ b/lib/plausible_web/controllers/site_controller.ex@@ -13,21 +13,24 @@ defmodule PlausibleWeb.SiteController do[:owner, :admin, :super_admin] when action not in [:new, :create_site])- def new(conn, _params) do+ def new(conn, params) do+ flow = params["flow"] || "register"current_user = conn.assigns[:current_user]render(conn, "new.html",changeset: Plausible.Site.changeset(%Plausible.Site{}),- first_site?: Quota.Usage.site_usage(current_user) == 0,site_limit: Quota.Limits.site_limit(current_user),site_limit_exceeded?: Quota.ensure_can_add_new_site(current_user) != :ok,- layout: {PlausibleWeb.LayoutView, "focus.html"}+ layout: {PlausibleWeb.LayoutView, "focus.html"},+ form_submit_url: "/sites?flow=#{flow}",+ flow: flow)enddef create_site(conn, %{"site" => site_params}) douser = conn.assigns[:current_user]first_site? = Quota.Usage.site_usage(user) == 0+ flow = conn.params["flow"]case Sites.create(user, site_params) do{:ok, %{site: site}} ->@@ -37,7 +40,11 @@ defmodule PlausibleWeb.SiteController doendredirect(conn,- external: Routes.site_path(conn, :add_snippet, site.domain, site_created: true)+ external:+ Routes.site_path(conn, :add_snippet, site.domain,+ site_created: true,+ flow: flow+ )){:error, {:over_limit, limit}} ->@@ -46,7 +53,9 @@ defmodule PlausibleWeb.SiteController dofirst_site?: first_site?,site_limit: limit,site_limit_exceeded?: true,- layout: {PlausibleWeb.LayoutView, "focus.html"}+ layout: {PlausibleWeb.LayoutView, "focus.html"},+ flow: flow,+ form_submit_url: "/sites?flow=#{flow}"){:error, _, changeset, _} ->@@ -55,12 +64,15 @@ defmodule PlausibleWeb.SiteController dofirst_site?: first_site?,site_limit: Quota.Limits.site_limit(user),site_limit_exceeded?: false,- layout: {PlausibleWeb.LayoutView, "focus.html"}+ layout: {PlausibleWeb.LayoutView, "focus.html"},+ flow: flow,+ form_submit_url: "/sites?flow=#{flow}")endend- def add_snippet(conn, _params) do+ def add_snippet(conn, params) do+ flow = params["flow"] || "register"user = conn.assigns[:current_user]site = conn.assigns[:site]@@ -78,7 +90,8 @@ defmodule PlausibleWeb.SiteController dosite: site,skip_plausible_tracking: true,is_first_site: is_first_site,- layout: {PlausibleWeb.LayoutView, "focus.html"}+ layout: {PlausibleWeb.LayoutView, "focus.html"},+ form_submit_url: "/#{URI.encode_www_form(site.domain)}?flow=#{flow}")enddiff --git a/lib/plausible_web/controllers/stats_controller.ex b/lib/plausible_web/controllers/stats_controller.exindex 104de278c9..ea63e65c15 100644--- a/lib/plausible_web/controllers/stats_controller.ex+++ b/lib/plausible_web/controllers/stats_controller.ex@@ -79,11 +79,20 @@ defmodule PlausibleWeb.StatsController do)!stats_start_date && can_see_stats? ->- render(conn, "waiting_first_pageview.html",+ render_opts = [site: site,dogfood_page_path: dogfood_page_path,connect_live_socket: true- )+ ]++ render_opts =+ if conn.params["flow"] do+ Keyword.put(render_opts, :layout, {PlausibleWeb.LayoutView, "focus.html"})+ else+ render_opts+ end++ render(conn, "waiting_first_pageview.html", render_opts)Sites.locked?(site) ->site = Plausible.Repo.preload(site, :owner)diff --git a/lib/plausible_web/live/components/verification.ex b/lib/plausible_web/live/components/verification.exindex 07a79e022b..1d10657518 100644--- a/lib/plausible_web/live/components/verification.ex+++ b/lib/plausible_web/live/components/verification.ex@@ -17,13 +17,14 @@ defmodule PlausibleWeb.Live.Components.Verification doattr :success?, :boolean, default: falseattr :interpretation, Plausible.Verification.Diagnostics.Result, default: nilattr :attempts, :integer, default: 0+ attr :flow, :string, default: ""def render(assigns) do~H"""<divclass={["dark:text-gray-100 text-center bg-white dark:bg-gray-800 flex flex-col",- if(not @modal?, do: "shadow-md rounded px-8 pt-6 pb-4 mb-4 mt-16 h-96", else: "h-72")+ if(not @modal?, do: "shadow-md rounded px-8 pt-6 pb-4 mb-4 mt-4 h-96", else: "h-72")]}id="progress-indicator">@@ -108,7 +109,7 @@ defmodule PlausibleWeb.Live.Components.Verification do<% end %><%= if not @success? and not @modal? do %>Need to see the snippet again?- <.styled_link href={"/#{URI.encode_www_form(@domain)}/snippet"}>+ <.styled_link href={"/#{URI.encode_www_form(@domain)}/snippet?flow=#{@flow}"}>Click here</.styled_link><br /> Run verification later and go to Site Settings?diff --git a/lib/plausible_web/live/register_form.ex b/lib/plausible_web/live/register_form.exindex 637e05bb96..fca4fca342 100644--- a/lib/plausible_web/live/register_form.ex+++ b/lib/plausible_web/live/register_form.ex@@ -62,7 +62,7 @@ defmodule PlausibleWeb.Live.RegisterForm dodef render(assigns) do~H"""- <div class="mx-auto mt-6 text-center dark:text-gray-300">+ <div class="mx-auto text-center dark:text-gray-300"><h1 class="text-3xl font-black"><%= if ce?() or @live_action == :register_from_invitation_form do %>Register your <%= Plausible.product_name() %> account@@ -70,10 +70,23 @@ defmodule PlausibleWeb.Live.RegisterForm doRegister your 30-day free trial<% end %></h1>- <div class="text-xl font-medium">Set up privacy-friendly analytics with just a few clicks</div>+ <div class="text-xl font-medium mt-2">+ Set up privacy-friendly analytics with just a few clicks+ </div></div>- <div class="w-full max-w-3xl mt-4 mx-auto flex flex-shrink-0">+ <PlausibleWeb.Components.FlowProgress.render+ :if={@live_action == :register_form}+ flow="register"+ current_step="Register"+ />+ <PlausibleWeb.Components.FlowProgress.render+ :if={@live_action == :register_from_invitation_form}+ flow="invitation"+ current_step="Register"+ />++ <div class="w-full max-w-3xl mx-auto flex flex-shrink-0"><.form:let={f}for={@form}@@ -176,9 +189,6 @@ defmodule PlausibleWeb.Live.RegisterForm do) %> instead.</p></.form>- <div :if={@live_action == :register_form} class="pt-12 pl-8 hidden md:block">- <%= PlausibleWeb.AuthView.render("_onboarding_steps.html", current_step: 0) %>- </div></div>"""enddiff --git a/lib/plausible_web/live/sites.ex b/lib/plausible_web/live/sites.exindex 334f3ce459..d9621fee6e 100644--- a/lib/plausible_web/live/sites.ex+++ b/lib/plausible_web/live/sites.ex@@ -73,7 +73,7 @@ defmodule PlausibleWeb.Live.Sites doYou don't have any sites yet.</p><div class="mt-4 flex sm:ml-4 sm:mt-0">- <a href="/sites/new" class="button">+ <a href="/sites/new?flow=provisioning" class="button">+ Add Website</a></div>diff --git a/lib/plausible_web/live/verification.ex b/lib/plausible_web/live/verification.exindex de294d85df..5b50cf6945 100644--- a/lib/plausible_web/live/verification.ex+++ b/lib/plausible_web/live/verification.ex@@ -26,6 +26,7 @@ defmodule PlausibleWeb.Live.Verification doreport_to: session["report_to"] || self(),delay: session["slowdown"] || 500,slowdown: session["slowdown"] || 500,+ flow: session["flow"] || "",checks_pid: nil,attempts: 0)@@ -75,6 +76,7 @@ defmodule PlausibleWeb.Live.Verification dodomain={@domain}id="verification-standalone"attempts={@attempts}+ flow={@flow}/>"""enddiff --git a/lib/plausible_web/templates/auth/_onboarding_steps.html.heex b/lib/plausible_web/templates/auth/_onboarding_steps.html.heexdeleted file mode 100644index 8bea9804b9..0000000000--- a/lib/plausible_web/templates/auth/_onboarding_steps.html.heex+++ /dev/null@@ -1,52 +0,0 @@-<div class="pt-6 px-4 sm:px-6 lg:px-8">- <nav class="flex justify-center">- <ol class="space-y-6">- <%= for {step, index} <- Enum.with_index(["Register", "Activate account", "Add site info", "Install snippet"]) do %>- <%= if index < @current_step do %>- <!-- Complete Step -->- <li class="flex items-start">- <span class="flex-shrink-0 relative h-5 w-5 flex items-center justify-center">- <svg- class="h-full w-full text-indigo-600 dark:text-indigo-500"- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 20 20"- fill="currentColor"- >- <path- fill-rule="evenodd"- d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"- clip-rule="evenodd"- />- </svg>- </span>- <span class="ml-3 text-sm font-medium text-gray-500 dark:text-gray-300">- <%= step %>- </span>- </li>- <% end %>- <%= if index == @current_step do %>- <!-- Current Step -->- <li class="flex items-start">- <span class="flex-shrink-0 h-5 w-5 relative flex items-center justify-center">- <span class="absolute h-4 w-4 rounded-full bg-indigo-200 dark:bg-indigo-100"></span>- <span class="relative block w-2 h-2 bg-indigo-600 dark:bg-indigo-500 rounded-full">- </span>- </span>- <span class="ml-3 text-sm font-medium text-indigo-600 dark:text-indigo-500">- <%= step %>- </span>- </li>- <% end %>- <%= if index > @current_step do %>- <!-- Upcoming Step -->- <li class="flex items-start">- <div class="flex-shrink-0 h-5 w-5 relative flex items-center justify-center">- <div class="h-2 w-2 bg-gray-300 dark:bg-gray-700 rounded-full"></div>- </div>- <p class="ml-3 text-sm font-medium text-gray-500 dark:text-gray-300"><%= step %></p>- </li>- <% end %>- <% end %>- </ol>- </nav>-</div>diff --git a/lib/plausible_web/templates/auth/activate.html.heex b/lib/plausible_web/templates/auth/activate.html.heexindex a1c8e2aa60..9067509cad 100644--- a/lib/plausible_web/templates/auth/activate.html.heex+++ b/lib/plausible_web/templates/auth/activate.html.heex@@ -1,6 +1,11 @@+<PlausibleWeb.Components.FlowProgress.render+ flow={@conn.params["flow"]}+ current_step="Activate account"+/>+<div class="w-full max-w-3xl mt-4 mx-auto flex"><%= if @has_email_code? do %>- <%= form_for @conn, "/activate", [class: "w-full max-w-lg mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 py-6 mb-4 mt-8"], fn f -> %>+ <%= form_for @conn, @form_submit_url, [class: "w-full max-w-lg mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 py-6 mb-4 mt-8"], fn f -> %><h2 class="text-xl font-black dark:text-gray-100"><%= if @has_any_memberships? do %>Verify your email address@@ -102,10 +107,4 @@) %></div><% end %>-- <%= if !@has_any_invitations? and !@has_any_memberships? do %>- <div class="pt-12 pl-8 hidden md:block">- <%= render(PlausibleWeb.AuthView, "_onboarding_steps.html", current_step: 1) %>- </div>- <% end %></div>diff --git a/lib/plausible_web/templates/auth/register_success.html.eex b/lib/plausible_web/templates/auth/register_success.html.eexdeleted file mode 100644index 2a9f8c277b..0000000000--- a/lib/plausible_web/templates/auth/register_success.html.eex+++ /dev/null@@ -1,34 +0,0 @@-<div class="mx-auto mt-6 text-center dark:text-gray-300">- <h1 class="text-3xl font-black">Register your 30-day unlimited-use free trial</h1>- <div class="text-xl font-medium">Set up privacy-friendly analytics with just a few clicks</div>-</div>---<div class="w-full max-w-3xl mt-4 mx-auto flex">- <%= form_for @conn, "/claim-activation", [class: "w-full max-w-lg mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 py-6 mb-4 mt-8", id: "register-form"], fn f -> %>- <h2 class="text-xl font-black dark:text-gray-100">Activate your account</h2>-- <div class="mt-2 text-sm text-gray-500 dark:text-gray-200 leading-tight">- Please enter the 4-digit code we sent to <b><%= @email %></b>- </div>-- <div class="mt-12 flex items-stretch flex-grow">- <div>- <%= text_input f, :code, class: "tracking-widest font-medium shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-36 px-8 border-gray-300 dark:border-gray-500 rounded-l-md dark:text-gray-200 dark:bg-gray-900", oninput: "this.value=this.value.replace(/[^0-9]/g, ''); if (this.value.length >= 4) document.getElementById('submit').focus()", onclick: "this.select();", maxlength: "4", placeholder: "••••", style: "letter-spacing: 10px;" %>- <%= error_tag f, :name %>- </div>- <button id="submit" class="button rounded-l-none">Activate →</button>- </div>-- <div class="mt-16 text-sm">- Didn't receive an email?- </div>- <div class="mt-2 text-sm text-gray-500 leading-tight">- Please check your spam folder and <a class="underline text-indigo-500" href="https://plausible.io/contact">contact us</a> if the problem persists- </div>- <% end %>-- <div class="pt-12 pl-8 hidden md:block">- <%= render(PlausibleWeb.AuthView, "_onboarding_steps.html", current_step: 1) %>- </div>-</div>diff --git a/lib/plausible_web/templates/layout/focus.html.heex b/lib/plausible_web/templates/layout/focus.html.heexindex 744647dec5..e464e1a407 100644--- a/lib/plausible_web/templates/layout/focus.html.heex+++ b/lib/plausible_web/templates/layout/focus.html.heex@@ -19,28 +19,34 @@<%= render("_tracking.html", assigns) %></head><body class="flex flex-col h-full bg-gray-100 dark:bg-gray-900">- <div class="w-full mt-12 text-center">- <a href={home_dest(@conn)}>- <%= img_tag(- PlausibleWeb.Router.Helpers.static_path(- @conn,- logo_path("logo_dark.svg")- ),- class: "w-44 hidden dark:inline",- alt: "Plausible logo",- loading: "lazy"- ) %>- <%= img_tag(- PlausibleWeb.Router.Helpers.static_path(- @conn,- logo_path("logo_light.svg")- ),- class: "w-44 inline dark:hidden",- alt: "Plausible logo",- loading: "lazy"- ) %>- </a>- </div>+ <nav class="relative z-20 py-8">+ <div class="container print:max-w-full">+ <nav class="relative flex items-center justify-between sm:h-10 md:justify-center">+ <div class="flex items-center flex-1 md:absolute md:inset-y-0 md:left-0">+ <a href={home_dest(@conn)}>+ <%= img_tag(+ PlausibleWeb.Router.Helpers.static_path(+ @conn,+ logo_path("logo_dark.svg")+ ),+ class: "w-44 -mt-2 hidden dark:inline",+ alt: "Plausible logo",+ loading: "lazy"+ ) %>+ <%= img_tag(+ PlausibleWeb.Router.Helpers.static_path(+ @conn,+ logo_path("logo_light.svg")+ ),+ class: "w-44 -mt-2 inline dark:hidden",+ alt: "Plausible logo",+ loading: "lazy"+ ) %>+ </a>+ </div>+ </nav>+ </div>+ </nav><%= if assigns[:flash] do %><%= render("_flash.html", assigns) %>diff --git a/lib/plausible_web/templates/site/new.html.heex b/lib/plausible_web/templates/site/new.html.heexindex 502be286db..6b58a57298 100644--- a/lib/plausible_web/templates/site/new.html.heex+++ b/lib/plausible_web/templates/site/new.html.heex@@ -1,5 +1,7 @@+<PlausibleWeb.Components.FlowProgress.render flow={@flow} current_step="Add site info" />+<div class="w-full max-w-3xl mt-4 mx-auto flex">- <%= form_for @changeset, "/sites", [class: "max-w-lg w-full mx-auto bg-white dark:bg-gray-800 shadow-lg rounded px-8 pt-6 pb-8 mb-4 mt-8"], fn f -> %>+ <%= form_for @changeset, @form_submit_url, [class: "max-w-lg w-full mx-auto bg-white dark:bg-gray-800 shadow-lg rounded px-8 pt-6 pb-8 mb-4 mt-8"], fn f -> %><h2 class="text-xl font-black dark:text-gray-100 mb-4">Your website details</h2><PlausibleWeb.Components.Billing.Notice.limit_exceeded@@ -96,10 +98,4 @@disabled: @site_limit_exceeded?) %><% end %>-- <%= if @first_site? do %>- <div class="pt-12 pl-8 hidden md:block">- <%= render(PlausibleWeb.AuthView, "_onboarding_steps.html", current_step: 2) %>- </div>- <% end %></div>diff --git a/lib/plausible_web/templates/site/snippet.html.heex b/lib/plausible_web/templates/site/snippet.html.heexindex 8f4495ef4f..28430bd0a0 100644--- a/lib/plausible_web/templates/site/snippet.html.heex+++ b/lib/plausible_web/templates/site/snippet.html.heex@@ -3,8 +3,13 @@site={@site}/>+<PlausibleWeb.Components.FlowProgress.render+ flow={@conn.params["flow"]}+ current_step="Install snippet"+/>+<div class="w-full max-w-3xl mt-4 mx-auto flex">- <%= form_for @conn, "/", [class: "max-w-lg w-full mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 pt-6 pb-8 mb-4 mt-8"], fn f -> %>+ <%= form_for @conn, @form_submit_url, [class: "max-w-lg w-full mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 pt-6 pb-8 mb-4 mt-8"], fn f -> %><h2 class="text-xl font-bold dark:text-gray-100">Add JavaScript snippet</h2><div class="mt-4"><p :if={Plausible.Verification.enabled?()} class="dark:text-gray-100">@@ -72,13 +77,7 @@end %><%= link(button_label,class: "button mt-4 w-full",- to: "/#{URI.encode_www_form(@site.domain)}"+ to: @form_submit_url) %><% end %>-- <%= if @is_first_site do %>- <div class="pt-12 pl-8 hidden md:block">- <%= render(PlausibleWeb.AuthView, "_onboarding_steps.html", current_step: 3) %>- </div>- <% end %></div>diff --git a/lib/plausible_web/templates/stats/waiting_first_pageview.html.heex b/lib/plausible_web/templates/stats/waiting_first_pageview.html.heexindex 86c1b06545..ed7199c98f 100644--- a/lib/plausible_web/templates/stats/waiting_first_pageview.html.heex+++ b/lib/plausible_web/templates/stats/waiting_first_pageview.html.heex@@ -11,6 +11,12 @@setInterval(updateStatus, 5000)</script>++<PlausibleWeb.Components.FlowProgress.render+ flow={@conn.params["flow"]}+ current_step="Verify snippet"+/>+<div class="w-full max-w-md mx-auto mt-8"><%= if @site.locked do %><div@@ -31,7 +37,7 @@<div class="block pulsating-circle top-1/2 left-1/2"></div><p class="text-gray-600 dark:text-gray-400 text-xs absolute left-0 bottom-0 mb-6 w-full text-center leading-normal">Need to see the snippet again?- <.styled_link href={"/#{URI.encode_www_form(@site.domain)}/snippet"}>+ <.styled_link href={"/#{URI.encode_www_form(@site.domain)}/snippet?flow=#{@conn.params[~s|flow|]}"}>Click here</.styled_link>@@ -67,7 +73,8 @@session: %{"site_id" => @site.id,"domain" => @site.domain,- "slowdown" => @conn.private[:verification_slowdown]+ "slowdown" => @conn.private[:verification_slowdown],+ "flow" => @conn.params["flow"]}) %></div>diff --git a/test/plausible_web/components/flow_progress_test.exs b/test/plausible_web/components/flow_progress_test.exsnew file mode 100644index 0000000000..5ef644ad85--- /dev/null+++ b/test/plausible_web/components/flow_progress_test.exs@@ -0,0 +1,59 @@+defmodule PlausibleWeb.Components.FlowProgressTest do+ use Plausible.DataCase++ import Plausible.LiveViewTest, only: [render_component: 2]+ import Plausible.Test.Support.HTML++ alias PlausibleWeb.Components.FlowProgress++ test "no flow or unknown flow renders nothing" do+ rendered =+ render_component(&FlowProgress.render/1,+ flow: nil,+ current_step: "unhandled"+ )++ assert rendered == ""++ rendered =+ render_component(&FlowProgress.render/1,+ flow: "unhandled",+ current_step: "unhandled"+ )++ assert rendered == ""+ end++ test "register" do+ rendered =+ render_component(&FlowProgress.render/1,+ flow: "register",+ current_step: "Register"+ )++ assert text_of_element(rendered, "#flow-progress") ==+ "1 Register 2 Activate account 3 Add site info 4 Install snippet 5 Verify snippet"+ end++ test "invitation" do+ rendered =+ render_component(&FlowProgress.render/1,+ flow: "invitation",+ current_step: "Register"+ )++ assert text_of_element(rendered, "#flow-progress") ==+ "1 Register 2 Activate account"+ end++ test "provisioning" do+ rendered =+ render_component(&FlowProgress.render/1,+ flow: "provisioning",+ current_step: "Add site info"+ )++ assert text_of_element(rendered, "#flow-progress") ==+ "1 Add site info 2 Install snippet 3 Verify snippet"+ end+enddiff --git a/test/plausible_web/controllers/auth_controller_test.exs b/test/plausible_web/controllers/auth_controller_test.exsindex f9ce207fcd..f2a75faca0 100644--- a/test/plausible_web/controllers/auth_controller_test.exs+++ b/test/plausible_web/controllers/auth_controller_test.exs@@ -69,7 +69,7 @@ defmodule PlausibleWeb.AuthControllerTest do})- assert redirected_to(conn, 302) == "/activate"+ assert redirected_to(conn, 302) == "/activate?flow=register"endtest "logs the user in", %{conn: conn} do@@ -167,7 +167,7 @@ defmodule PlausibleWeb.AuthControllerTest do})- assert redirected_to(conn, 302) == "/activate"+ assert redirected_to(conn, 302) == "/activate?flow=invitation"endtest "logs the user in", %{conn: conn, invitation: invitation} do@@ -290,7 +290,7 @@ defmodule PlausibleWeb.AuthControllerTest douser = Repo.get_by(Plausible.Auth.User, id: user.id)assert user.email_verified- assert redirected_to(conn) == "/sites/new"+ assert redirected_to(conn) == "/sites/new?flow="endtest "redirects to /sites if user has invitation", %{conn: conn, user: user} do@@ -303,7 +303,7 @@ defmodule PlausibleWeb.AuthControllerTest doconn = post(conn, "/activate", %{code: verification.code})- assert redirected_to(conn) == "/sites"+ assert redirected_to(conn) == "/sites?flow="endtest "removes used up verification code", %{conn: conn, user: user} dodiff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exsindex 2d4ac6d738..d5792ef2ed 100644--- a/test/plausible_web/controllers/site_controller_test.exs+++ b/test/plausible_web/controllers/site_controller_test.exs@@ -25,18 +25,16 @@ defmodule PlausibleWeb.SiteControllerTest doassert html_response(conn, 200) =~ "Your website details"end- test "shows onboarding steps if it's the first site for the user", %{conn: conn} do- conn = get(conn, "/sites/new")+ test "shows onboarding steps regardless of sites provisioned", %{conn: conn1, user: user} do+ conn = get(conn1, "/sites/new")assert html_response(conn, 200) =~ "Add site info"- end- test "does not show onboarding steps if user has a site already", %{conn: conn, user: user} doinsert(:site, members: [user], domain: "test-site.com")- conn = get(conn, "/sites/new")+ conn = get(conn1, "/sites/new")- refute html_response(conn, 200) =~ "Add site info"+ assert html_response(conn, 200) =~ "Add site info"endtest "does not display limit notice when user is on an enterprise plan", %{@@ -245,7 +243,7 @@ defmodule PlausibleWeb.SiteControllerTest do})assert redirected_to(conn) ==- "/#{URI.encode_www_form("éxample.com")}/snippet?site_created=true"+ "/#{URI.encode_www_form("éxample.com")}/snippet?site_created=true&flow="assert site = Repo.get_by(Plausible.Site, domain: "éxample.com")assert site.timezone == "Europe/London"@@ -343,7 +341,7 @@ defmodule PlausibleWeb.SiteControllerTest do}})- assert redirected_to(conn) == "/example.com/snippet?site_created=true"+ assert redirected_to(conn) == "/example.com/snippet?site_created=true&flow="assert Repo.get_by(Plausible.Site, domain: "example.com")end@@ -363,7 +361,7 @@ defmodule PlausibleWeb.SiteControllerTest do}})- assert redirected_to(conn) == "/example.com/snippet?site_created=true"+ assert redirected_to(conn) == "/example.com/snippet?site_created=true&flow="assert Plausible.Billing.Quota.Usage.site_usage(user) == 3end@@ -377,7 +375,7 @@ defmodule PlausibleWeb.SiteControllerTest do}})- assert redirected_to(conn) == "/example.com/snippet?site_created=true"+ assert redirected_to(conn) == "/example.com/snippet?site_created=true&flow="assert Repo.get_by(Plausible.Site, domain: "example.com")endend@@ -459,7 +457,7 @@ defmodule PlausibleWeb.SiteControllerTest do})assert redirected_to(conn) ==- "/example.com/snippet?site_created=true"+ "/example.com/snippet?site_created=true&flow="endenddiff --git a/test/plausible_web/live/components/verification_test.exs b/test/plausible_web/live/components/verification_test.exsindex 4f10a5ed03..caec04d1a5 100644--- a/test/plausible_web/live/components/verification_test.exs+++ b/test/plausible_web/live/components/verification_test.exs@@ -18,7 +18,7 @@ defmodule PlausibleWeb.Live.Components.VerificationTest doassert text_of_element(html, @progress) =="We're visiting your site to ensure that everything is working"- assert element_exists?(html, ~s|a[href="/example.com/snippet"]|)+ assert element_exists?(html, ~s|a[href="/example.com/snippet?flow="]|)assert element_exists?(html, ~s|a[href="/example.com/settings/general"]|)assert element_exists?(html, @pulsating_circle)refute class_of_element(html, @pulsating_circle) =~ "hidden"