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
Convert to verified routes (#6660)
Adrian Gruntkowski30abd272b511
diff --git a/extra/lib/plausible/customer_support/resource.ex b/extra/lib/plausible/customer_support/resource.exindex e50925eabe..799bd8ed58 100644--- a/extra/lib/plausible/customer_support/resource.ex+++ b/extra/lib/plausible/customer_support/resource.ex@@ -21,8 +21,9 @@ defmodule Plausible.CustomerSupport.Resource dodefmacro __using__(type: type) doquote do@behaviour Plausible.CustomerSupport.Resource+ use PlausibleWeb.VerifiedRoutes+alias Plausible.CustomerSupport.Resource- alias PlausibleWeb.Router.Helpers, as: Routesimport Ecto.Queryalias Plausible.Repodiff --git a/extra/lib/plausible/customer_support/resource/site.ex b/extra/lib/plausible/customer_support/resource/site.exindex 56fbc8aaaf..6fff6fcb0d 100644--- a/extra/lib/plausible/customer_support/resource/site.ex+++ b/extra/lib/plausible/customer_support/resource/site.ex@@ -5,7 +5,7 @@ defmodule Plausible.CustomerSupport.Resource.Site do@impl truedef path(id) do- Routes.customer_support_site_path(PlausibleWeb.Endpoint, :show, id)+ ~p"/cs/sites/site/#{id}"end@impl truediff --git a/extra/lib/plausible/customer_support/resource/team.ex b/extra/lib/plausible/customer_support/resource/team.exindex 9e94162618..578232e47b 100644--- a/extra/lib/plausible/customer_support/resource/team.ex+++ b/extra/lib/plausible/customer_support/resource/team.ex@@ -6,7 +6,7 @@ defmodule Plausible.CustomerSupport.Resource.Team do@impl truedef path(id) do- Routes.customer_support_team_path(PlausibleWeb.Endpoint, :show, id)+ ~p"/cs/teams/team/#{id}"end@impl truediff --git a/extra/lib/plausible/customer_support/resource/user.ex b/extra/lib/plausible/customer_support/resource/user.exindex 758fa6c784..c4a432602e 100644--- a/extra/lib/plausible/customer_support/resource/user.ex+++ b/extra/lib/plausible/customer_support/resource/user.ex@@ -5,7 +5,7 @@ defmodule Plausible.CustomerSupport.Resource.User do@impl truedef path(id) do- Routes.customer_support_user_path(PlausibleWeb.Endpoint, :show, id)+ ~p"/cs/users/user/#{id}"end@impl truediff --git a/extra/lib/plausible/help_scout.ex b/extra/lib/plausible/help_scout.exindex c1bf99fd43..c205e4c57d 100644--- a/extra/lib/plausible/help_scout.ex+++ b/extra/lib/plausible/help_scout.ex@@ -3,6 +3,8 @@ defmodule Plausible.HelpScout doHelpScout callback API logic."""+ use PlausibleWeb.VerifiedRoutes+import Ecto.Queryalias Plausible.Billing@@ -11,8 +13,6 @@ defmodule Plausible.HelpScout doalias Plausible.Repoalias Plausible.Teams- alias PlausibleWeb.Router.Helpers, as: Routes-require Plausible.Billing.Subscription.Status@base_api_url "https://api.helpscout.net"@@ -110,12 +110,7 @@ defmodule Plausible.HelpScout do}end)- user_link =- Routes.customer_support_user_url(- PlausibleWeb.Endpoint,- :show,- user.id- )+ user_link = url(~p"/cs/users/user/#{user.id}"){:ok,%{@@ -139,17 +134,9 @@ defmodule Plausible.HelpScout dostatus_link =if team do- Routes.customer_support_team_url(- PlausibleWeb.Endpoint,- :show,- team.id- )+ url(~p"/cs/teams/team/#{team.id}")else- Routes.customer_support_user_url(- PlausibleWeb.Endpoint,- :show,- user.id- )+ url(~p"/cs/users/user/#{user.id}")end{:ok,diff --git a/extra/lib/plausible_web/controllers/sso_controller.ex b/extra/lib/plausible_web/controllers/sso_controller.exindex 7f31625d36..5a8802fc46 100644--- a/extra/lib/plausible_web/controllers/sso_controller.ex+++ b/extra/lib/plausible_web/controllers/sso_controller.ex@@ -7,8 +7,6 @@ defmodule PlausibleWeb.SSOController doalias Plausible.Auth.SSOalias PlausibleWeb.LoginPreference- alias PlausibleWeb.Router.Helpers, as: Routes-plug Plausible.Plugs.AuthorizeTeamAccess,[:owner] when action in [:sso_settings]@@ -21,7 +19,7 @@ defmodule PlausibleWeb.SSOController docase {login_preference, params["prefer"], error} do{nil, nil, nil} ->- redirect(conn, to: Routes.auth_path(conn, :login_form, return_to: params["return_to"]))+ redirect(conn, to: ~p"/login?#{[return_to: params["return_to"]]}")_ ->render(conn, "login_form.html",@@ -36,13 +34,7 @@ defmodule PlausibleWeb.SSOController do{:ok, %{sso_integration: integration}} <- SSO.Domains.lookup(email) doredirect(conn,to:- Routes.sso_path(- conn,- :saml_signin,- integration.identifier,- email: email,- return_to: params["return_to"]- )+ ~p"/sso/saml/signin/#{integration.identifier}?#{[email: email, return_to: params["return_to"]]}")else{:error, :not_found} ->@@ -51,7 +43,7 @@ defmodule PlausibleWeb.SSOController do:login_error,"We couldn't find a Single Sign-On account for that email.")- |> redirect(to: Routes.sso_path(conn, :login_form))+ |> redirect(to: ~p"/sso/login"){:error, {:rate_limit, _}} ->Auth.log_failed_login_attempt("too many login attempts for #{email}")@@ -109,7 +101,7 @@ defmodule PlausibleWeb.SSOController do)elseconn- |> redirect(to: Routes.site_path(conn, :index))+ |> redirect(to: ~p"/sites")endend@@ -128,7 +120,7 @@ defmodule PlausibleWeb.SSOController doconn|> put_flash(:success, "Session logged out successfully")- |> redirect(to: Routes.sso_path(conn, :team_sessions))+ |> redirect(to: ~p"/settings/sso/sessions")enddefp saml_adapter() dodiff --git a/extra/lib/plausible_web/live/customer_support.ex b/extra/lib/plausible_web/live/customer_support.exindex d5de1e0ae7..4dd5d9836f 100644--- a/extra/lib/plausible_web/live/customer_support.ex+++ b/extra/lib/plausible_web/live/customer_support.ex@@ -9,11 +9,7 @@ defmodule PlausibleWeb.Live.CustomerSupport do@impl truedef mount(params, _session, socket) douri =- Routes.customer_support_path(- PlausibleWeb.Endpoint,- :index,- Map.take(params, ["filter_text"])- )+ ~p"/cs?#{[filter_text: params["filter_text"]]}"|> URI.new!(){:ok,diff --git a/extra/lib/plausible_web/live/customer_support/components/layout.ex b/extra/lib/plausible_web/live/customer_support/components/layout.exindex 8997ab164e..42d5aa73e8 100644--- a/extra/lib/plausible_web/live/customer_support/components/layout.ex+++ b/extra/lib/plausible_web/live/customer_support/components/layout.ex@@ -95,16 +95,14 @@ defmodule PlausibleWeb.CustomerSupport.Components.Layout do<h2 class="text-xl font-semibold text-gray-900 dark:text-gray-100 sm:text-2xl sm:truncate flex-shrink-0"><.linkreplace- patch={- Routes.customer_support_path(PlausibleWeb.Endpoint, :index, %{filter_text: @filter_text})- }+ patch={~p"/cs?#{[filter_text: @filter_text]}"}>💬 Customer Support</.link></h2><.styled_linkclass="text-sm flex-shrink-0"- patch={Routes.customer_support_trial_prospects_path(PlausibleWeb.Endpoint, :index)}+ patch={~p"/cs/trial-prospects"}>🔥 Trial prospects</.styled_link>diff --git a/extra/lib/plausible_web/live/customer_support/live.ex b/extra/lib/plausible_web/live/customer_support/live.exindex 61ca979f93..9353eb9845 100644--- a/extra/lib/plausible_web/live/customer_support/live.ex+++ b/extra/lib/plausible_web/live/customer_support/live.ex@@ -17,7 +17,6 @@ defmodule PlausibleWeb.CustomerSupport.Live doalias PlausibleWeb.CustomerSupport.Components.Layoutimport PlausibleWeb.CustomerSupport.Liveimport PlausibleWeb.Components.Generic- alias PlausibleWeb.Router.Helpers, as: Routesdef mount(_params, _session, socket) do{:ok, socket}diff --git a/extra/lib/plausible_web/live/customer_support/site.ex b/extra/lib/plausible_web/live/customer_support/site.exindex 88d450e2bd..c886f369f4 100644--- a/extra/lib/plausible_web/live/customer_support/site.ex+++ b/extra/lib/plausible_web/live/customer_support/site.ex@@ -31,7 +31,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.Site do{:noreply, go_to_tab(socket, tab, params, :site, tab_component(tab))}else- {:noreply, redirect(socket, to: Routes.customer_support_path(socket, :index))}+ {:noreply, redirect(socket, to: ~p"/cs")}endend@@ -82,9 +82,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.Site do</p><p class="text-sm font-medium">Team:- <.styled_link patch={- Routes.customer_support_team_path(PlausibleWeb.Endpoint, :show, @site.team.id)- }>+ <.styled_link patch={~p"/cs/teams/team/#{@site.team.id}"}>{@site.team.name}</.styled_link></p>diff --git a/extra/lib/plausible_web/live/customer_support/site/components/overview.ex b/extra/lib/plausible_web/live/customer_support/site/components/overview.exindex c67ee6cb93..6b74fdd4a1 100644--- a/extra/lib/plausible_web/live/customer_support/site/components/overview.ex+++ b/extra/lib/plausible_web/live/customer_support/site/components/overview.ex@@ -20,14 +20,14 @@ defmodule PlausibleWeb.CustomerSupport.Site.Components.Overview do<.styled_linknew_tab={true}- href={Routes.stats_path(PlausibleWeb.Endpoint, :stats, @site.domain, [])}+ href={stats_path(@site.domain)}>Dashboard</.styled_link><.styled_linknew_tab={true}- href={Routes.site_path(PlausibleWeb.Endpoint, :settings_general, @site.domain, [])}+ href={~p"/#{@site.domain}/settings/general"}>Settings</.styled_link>@@ -98,7 +98,7 @@ defmodule PlausibleWeb.CustomerSupport.Site.Components.Overview dosite = socket.assigns.site{:ok, _} = Plausible.Site.Removal.run(site)- navigate_with_success(Routes.customer_support_path(socket, :index), "Site deleted")+ navigate_with_success(~p"/cs", "Site deleted"){:noreply, socket}endenddiff --git a/extra/lib/plausible_web/live/customer_support/site/components/people.ex b/extra/lib/plausible_web/live/customer_support/site/components/people.exindex f3d284ede6..f33f07984a 100644--- a/extra/lib/plausible_web/live/customer_support/site/components/people.ex+++ b/extra/lib/plausible_web/live/customer_support/site/components/people.ex@@ -33,7 +33,7 @@ defmodule PlausibleWeb.CustomerSupport.Site.Components.People do<.td :if={kind == :membership}><.styled_linkclass="flex items-center"- patch={Routes.customer_support_user_path(PlausibleWeb.Endpoint, :show, person.id)}+ patch={~p"/cs/users/user/#{person.id}"}><imgsrc={Plausible.Auth.User.profile_img_url(person)}diff --git a/extra/lib/plausible_web/live/customer_support/team.ex b/extra/lib/plausible_web/live/customer_support/team.exindex bdcb8d505c..66b2b397f0 100644--- a/extra/lib/plausible_web/live/customer_support/team.ex+++ b/extra/lib/plausible_web/live/customer_support/team.ex@@ -35,7 +35,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.Team do{:noreply, go_to_tab(socket, tab, params, :team, tab_component(tab))}else- {:noreply, redirect(socket, to: Routes.customer_support_path(socket, :index))}+ {:noreply, redirect(socket, to: ~p"/cs")}endenddiff --git a/extra/lib/plausible_web/live/customer_support/team/components/audit.ex b/extra/lib/plausible_web/live/customer_support/team/components/audit.exindex 937aee3a27..b6a700fdc6 100644--- a/extra/lib/plausible_web/live/customer_support/team/components/audit.ex+++ b/extra/lib/plausible_web/live/customer_support/team/components/audit.ex@@ -163,11 +163,14 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.Audit dopagination_params = get_pagination_params(params)team = socket.assigns.team- query_params = %{"tab" => "audit"} |> Map.merge(pagination_params)+ query_params =+ %{"tab" => "audit"}+ |> Map.merge(pagination_params)+ |> Map.to_list(){:noreply,push_patch(socket,- to: Routes.customer_support_team_path(PlausibleWeb.Endpoint, :show, team.id, query_params)+ to: ~p"/cs/teams/team/#{team.id}?#{query_params}")}end@@ -228,7 +231,7 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.Audit do/><.styled_link- patch={Routes.customer_support_user_path(PlausibleWeb.Endpoint, :show, @user.id)}+ patch={~p"/cs/users/user/#{@user.id}"}class="cursor-pointer flex block items-center">{@user.name}diff --git a/extra/lib/plausible_web/live/customer_support/team/components/consolidated_views.ex b/extra/lib/plausible_web/live/customer_support/team/components/consolidated_views.exindex 3331436bef..e8d35ac43a 100644--- a/extra/lib/plausible_web/live/customer_support/team/components/consolidated_views.ex+++ b/extra/lib/plausible_web/live/customer_support/team/components/consolidated_views.ex@@ -5,6 +5,7 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.ConsolidatedViews dothis team."""use PlausibleWeb, :live_component+import PlausibleWeb.CustomerSupport.Livealias Plausible.ConsolidatedViewalias Plausible.Stats@@ -57,7 +58,7 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.ConsolidatedViews do<.td><.styled_linknew_tab={true}- href={Routes.stats_path(PlausibleWeb.Endpoint, :stats, consolidated_view.domain, [])}+ href={stats_path(consolidated_view.domain)}>Dashboard</.styled_link>diff --git a/extra/lib/plausible_web/live/customer_support/team/components/members.ex b/extra/lib/plausible_web/live/customer_support/team/components/members.exindex 4597156802..bbc22de8ee 100644--- a/extra/lib/plausible_web/live/customer_support/team/components/members.ex+++ b/extra/lib/plausible_web/live/customer_support/team/components/members.ex@@ -24,7 +24,7 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.Members do<.td truncate><div :if={member.id != 0}><.styled_link- patch={Routes.customer_support_user_path(PlausibleWeb.Endpoint, :show, member.id)}+ patch={~p"/cs/users/user/#{member.id}"}class="cursor-pointer flex block items-center"><imgdiff --git a/extra/lib/plausible_web/live/customer_support/team/components/overview.ex b/extra/lib/plausible_web/live/customer_support/team/components/overview.exindex b840703db1..82b3fcbb63 100644--- a/extra/lib/plausible_web/live/customer_support/team/components/overview.ex+++ b/extra/lib/plausible_web/live/customer_support/team/components/overview.ex@@ -159,7 +159,7 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.Overview dodef handle_event("delete-team", _params, socket) docase Plausible.Teams.delete(socket.assigns.team) do{:ok, :deleted} ->- navigate_with_success(Routes.customer_support_path(socket, :index), "Team deleted")+ navigate_with_success(~p"/cs", "Team deleted"){:noreply, socket}{:error, :active_subscription} ->diff --git a/extra/lib/plausible_web/live/customer_support/team/components/sites.ex b/extra/lib/plausible_web/live/customer_support/team/components/sites.exindex 3b8c6b31c7..99420e1941 100644--- a/extra/lib/plausible_web/live/customer_support/team/components/sites.ex+++ b/extra/lib/plausible_web/live/customer_support/team/components/sites.ex@@ -31,7 +31,7 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.Sites dohourly_stats = build_hourly_stats(sites, socket)uri =- Routes.customer_support_team_path(PlausibleWeb.Endpoint, :show, team.id, tab: "sites")+ ~p"/cs/teams/team/#{team.id}?#{[tab: "sites"]}"|> URI.parse(){:ok,@@ -127,7 +127,7 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.Sites doclass="size-4 flex-shrink-0 mt-px mr-2"/><.styled_link- patch={Routes.customer_support_site_path(PlausibleWeb.Endpoint, :show, site.id)}+ patch={~p"/cs/sites/site/#{site.id}"}class="cursor-pointer flex block items-center">{site.domain}@@ -143,7 +143,7 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.Sites do<.td><.styled_linknew_tab={true}- href={Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain, [])}+ href={stats_path(site.domain)}>Dashboard</.styled_link>@@ -151,7 +151,7 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.Sites do<.td><.styled_linknew_tab={true}- href={Routes.site_path(PlausibleWeb.Endpoint, :settings_general, site.domain, [])}+ href={~p"/#{site.domain}/settings/general"}>Settings</.styled_link>diff --git a/extra/lib/plausible_web/live/customer_support/team/components/sso.ex b/extra/lib/plausible_web/live/customer_support/team/components/sso.exindex ed4d816dbb..112993f76c 100644--- a/extra/lib/plausible_web/live/customer_support/team/components/sso.ex+++ b/extra/lib/plausible_web/live/customer_support/team/components/sso.ex@@ -87,9 +87,7 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.SSO dosocket =socket|> assign(sso_integration: nil)- |> push_navigate(- to: Routes.customer_support_team_path(socket, :show, socket.assigns.team.id)- )+ |> push_navigate(to: ~p"/cs/teams/team/#{socket.assigns.team.id}")success("SSO integration removed")diff --git a/extra/lib/plausible_web/live/customer_support/trial_prospects.ex b/extra/lib/plausible_web/live/customer_support/trial_prospects.exindex 872bb02553..ced4cf8850 100644--- a/extra/lib/plausible_web/live/customer_support/trial_prospects.ex+++ b/extra/lib/plausible_web/live/customer_support/trial_prospects.ex@@ -65,9 +65,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TrialProspects do</:thead><:tbody :let={p}><.td>- <.styled_link patch={- Routes.customer_support_team_path(PlausibleWeb.Endpoint, :show, p.team.id)- }>+ <.styled_link patch={~p"/cs/teams/team/#{p.team.id}"}>{p.team.name}</.styled_link><div :if={owner_email(p.team)} class="text-xs text-gray-500 dark:text-gray-400">@@ -97,11 +95,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TrialProspects doid="trial-prospects-pagination"uri={URI.new!(- Routes.customer_support_trial_prospects_path(PlausibleWeb.Endpoint, :index,- sort_by: @sort_by,- sort_direction: @sort_direction,- page: @page_number- )+ ~p"/cs/trial-prospects?#{[sort_by: @sort_by, sort_direction: @sort_direction, page: @page_number]}")}page_number={@page_number}@@ -131,12 +125,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TrialProspects do~H"""<.th><.link- patch={- Routes.customer_support_trial_prospects_path(PlausibleWeb.Endpoint, :index,- sort_by: @by,- sort_direction: @next_direction- )- }+ patch={~p"/cs/trial-prospects?#{[sort_by: @by, sort_direction: @next_direction]}"}class="cursor-pointer select-none inline-flex items-center gap-1 hover:text-indigo-600 dark:hover:text-indigo-400">{@label}diff --git a/extra/lib/plausible_web/live/customer_support/user.ex b/extra/lib/plausible_web/live/customer_support/user.exindex c1ef154795..b658f2e3fe 100644--- a/extra/lib/plausible_web/live/customer_support/user.ex+++ b/extra/lib/plausible_web/live/customer_support/user.ex@@ -30,7 +30,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.User do{:noreply, go_to_tab(socket, tab, params, :user, tab_component(tab))}else- {:noreply, redirect(socket, to: Routes.customer_support_path(socket, :index))}+ {:noreply, redirect(socket, to: ~p"/cs")}endenddiff --git a/extra/lib/plausible_web/live/customer_support/user/components/keys.ex b/extra/lib/plausible_web/live/customer_support/user/components/keys.exindex 311c9f73f5..da90c7461e 100644--- a/extra/lib/plausible_web/live/customer_support/user/components/keys.ex+++ b/extra/lib/plausible_web/live/customer_support/user/components/keys.ex@@ -24,9 +24,7 @@ defmodule PlausibleWeb.CustomerSupport.User.Components.Keys do<:tbody :let={api_key}><.td :if={is_nil(api_key.team)}>N/A</.td><.td :if={api_key.team}>- <.styled_link patch={- Routes.customer_support_team_path(PlausibleWeb.Endpoint, :show, api_key.team.id)- }>+ <.styled_link patch={~p"/cs/teams/team/#{api_key.team.id}"}>{api_key.team.name}</.styled_link></.td>diff --git a/extra/lib/plausible_web/live/customer_support/user/components/overview.ex b/extra/lib/plausible_web/live/customer_support/user/components/overview.exindex 77ee4a47be..1b7f7b8526 100644--- a/extra/lib/plausible_web/live/customer_support/user/components/overview.ex+++ b/extra/lib/plausible_web/live/customer_support/user/components/overview.ex@@ -38,9 +38,7 @@ defmodule PlausibleWeb.CustomerSupport.User.Components.Overview do</:thead><:tbody :let={membership}><.td>- <.styled_link patch={- Routes.customer_support_team_path(PlausibleWeb.Endpoint, :show, membership.team.id)- }>+ <.styled_link patch={~p"/cs/teams/team/#{membership.team.id}"}>{membership.team.name}</.styled_link></.td>@@ -86,7 +84,7 @@ defmodule PlausibleWeb.CustomerSupport.User.Components.Overview docase Plausible.Auth.delete_user(user) do{:ok, _} ->- navigate_with_success(Routes.customer_support_path(socket, :index), "User deleted")+ navigate_with_success(~p"/cs", "User deleted"){:noreply, socket}{:error, :active_subscription} ->diff --git a/extra/lib/plausible_web/live/funnel_settings.ex b/extra/lib/plausible_web/live/funnel_settings.exindex 4b79dd945a..9318f05e61 100644--- a/extra/lib/plausible_web/live/funnel_settings.ex+++ b/extra/lib/plausible_web/live/funnel_settings.ex@@ -99,7 +99,7 @@ defmodule PlausibleWeb.Live.FunnelSettings do</p><.button_linkclass="mt-4"- href={PlausibleWeb.Router.Helpers.site_path(@socket, :settings_goals, @domain)}+ href={~p"/#{@domain}/settings/goals"}>Set up goals →</.button_link>diff --git a/extra/lib/plausible_web/live/sso_management.ex b/extra/lib/plausible_web/live/sso_management.exindex 2f57dde32c..9b81f58835 100644--- a/extra/lib/plausible_web/live/sso_management.ex+++ b/extra/lib/plausible_web/live/sso_management.ex@@ -7,7 +7,6 @@ defmodule PlausibleWeb.Live.SSOManagement doalias Plausible.Auth.SSOalias Plausible.Teams- alias PlausibleWeb.Router.Helpers, as: Routesuse Plausible.Auth.SSO.Domain.Status@refresh_integration_interval :timer.seconds(5)@@ -731,10 +730,6 @@ defmodule PlausibleWeb.Live.SSOManagement doenddefp saml_acs_url(integration) do- Routes.sso_url(- PlausibleWeb.Endpoint,- :saml_consume,- integration.identifier- )+ url(~p"/sso/saml/consume/#{integration.identifier}")endenddiff --git a/extra/lib/plausible_web/plugins/api/controllers/funnels.ex b/extra/lib/plausible_web/plugins/api/controllers/funnels.exindex 93fb3da151..eeefc643ea 100644--- a/extra/lib/plausible_web/plugins/api/controllers/funnels.ex+++ b/extra/lib/plausible_web/plugins/api/controllers/funnels.ex@@ -25,7 +25,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.Funnels docase Plausible.Plugins.API.Funnels.create(site, body_params) do{:ok, funnel} ->- headers = [{"location", plugins_api_funnels_url(conn, :get, funnel.id)}]+ headers = [{"location", url(~p"/api/plugins/v1/funnels/#{funnel.id}")}]conn|> prepend_resp_headers(headers)diff --git a/extra/lib/plausible_web/plugins/api/views/funnel.ex b/extra/lib/plausible_web/plugins/api/views/funnel.exindex 8ee9a67b55..6b544c2942 100644--- a/extra/lib/plausible_web/plugins/api/views/funnel.ex+++ b/extra/lib/plausible_web/plugins/api/views/funnel.ex@@ -13,7 +13,12 @@ defmodule PlausibleWeb.Plugins.API.Views.Funnel do%{funnels:render_many(funnels, __MODULE__, "funnel.json", authorized_site: site, as: :funnel),- meta: render_metadata_links(metadata, :plugins_api_funnels_url, :index, conn.query_params)+ meta:+ render_metadata_links(+ metadata,+ fn params -> url(~p"/api/plugins/v1/funnels?#{params}") end,+ conn.query_params+ )}end@@ -25,7 +30,12 @@ defmodule PlausibleWeb.Plugins.API.Views.Funnel do%{funnels:render_many(funnels, __MODULE__, "funnel.json", authorized_site: site, as: :funnel),- meta: render_metadata_links(%{}, :plugins_api_funnels_url, :index, conn.query_params)+ meta:+ render_metadata_links(+ %{},+ fn params -> url(~p"/api/plugins/v1/funnels?#{params}") end,+ conn.query_params+ )}enddiff --git a/extra/lib/plausible_web/plugs/handle_expired_session.ex b/extra/lib/plausible_web/plugs/handle_expired_session.exindex 230c5a9f1f..607139acd8 100644--- a/extra/lib/plausible_web/plugs/handle_expired_session.ex+++ b/extra/lib/plausible_web/plugs/handle_expired_session.ex@@ -5,9 +5,9 @@ defmodule Plausible.Plugs.HandleExpiredSession douse Plausible- import Plug.Conn+ use PlausibleWeb.VerifiedRoutes- alias PlausibleWeb.Router.Helpers, as: Routes+ import Plug.Conndef init(_) do[]@@ -39,12 +39,7 @@ defmodule Plausible.Plugs.HandleExpiredSession doconn|> Phoenix.Controller.redirect(to:- Routes.sso_path(conn, :login_form,- prefer: "manual",- email: email,- autosubmit: true,- return_to: return_to- )+ ~p"/sso/login?#{[prefer: "manual", email: email, autosubmit: true, return_to: return_to]}")|> halt()end@@ -52,12 +47,7 @@ defmodule Plausible.Plugs.HandleExpiredSession dodefp trigger_sso_login(conn, email) doconn|> Phoenix.Controller.redirect(- to:- Routes.sso_path(conn, :login_form,- prefer: "manual",- email: email,- autosubmit: true- )+ to: ~p"/sso/login?#{[prefer: "manual", email: email, autosubmit: true]}")|> halt()enddiff --git a/extra/lib/plausible_web/plugs/secure_sso.ex b/extra/lib/plausible_web/plugs/secure_sso.exindex 39d30b20dd..a4709fa51c 100644--- a/extra/lib/plausible_web/plugs/secure_sso.ex+++ b/extra/lib/plausible_web/plugs/secure_sso.ex@@ -3,7 +3,7 @@ defmodule PlausibleWeb.Plugs.SecureSSO doPlug for securing SSO routes by setting proper policies in headers."""- alias PlausibleWeb.Router.Helpers, as: Routes+ use PlausibleWeb.VerifiedRoutes@csp """default-src 'none';@@ -23,7 +23,7 @@ defmodule PlausibleWeb.Plugs.SecureSSO do@impl truedef call(conn, _) dononce = :crypto.strong_rand_bytes(18) |> Base.encode64()- csp_report_path = Routes.sso_path(conn, :csp_report)+ csp_report_path = ~p"/sso/saml/csp-report"conn|> put_private(:sso_nonce, nonce)diff --git a/extra/lib/plausible_web/sso/fake_saml_adapter.ex b/extra/lib/plausible_web/sso/fake_saml_adapter.exindex dccb42098e..3455186761 100644--- a/extra/lib/plausible_web/sso/fake_saml_adapter.ex+++ b/extra/lib/plausible_web/sso/fake_saml_adapter.ex@@ -3,12 +3,12 @@ defmodule PlausibleWeb.SSO.FakeSAMLAdapter doFake implementation of SAML authentication interface."""+ use PlausibleWeb.VerifiedRoutes+alias Plausible.Authalias Plausible.Auth.SSOalias Plausible.Repo- alias PlausibleWeb.Router.Helpers, as: Routes-def signin(conn, params) doconn|> Phoenix.Controller.put_layout(false)@@ -60,9 +60,7 @@ defmodule PlausibleWeb.SSO.FakeSAMLAdapter do:login_error,"We couldn't find a Single Sign-On account for that email.")- |> Phoenix.Controller.redirect(- to: Routes.sso_path(conn, :login_form, return_to: params["return_to"])- )+ |> Phoenix.Controller.redirect(to: ~p"/sso/login?#{[return_to: params["return_to"]]}")endenddiff --git a/extra/lib/plausible_web/sso/real_saml_adapter.ex b/extra/lib/plausible_web/sso/real_saml_adapter.exindex dc5235ba3d..9ffd0b92db 100644--- a/extra/lib/plausible_web/sso/real_saml_adapter.ex+++ b/extra/lib/plausible_web/sso/real_saml_adapter.ex@@ -2,9 +2,9 @@ defmodule PlausibleWeb.SSO.RealSAMLAdapter do@moduledoc """Real implementation of SAML authentication interface."""- alias Plausible.Auth.SSO+ use PlausibleWeb.VerifiedRoutes- alias PlausibleWeb.Router.Helpers, as: Routes+ alias Plausible.Auth.SSO@deflate "urn:oasis:names:tc:SAML:2.0:bindings:URL-Encoding:DEFLATE"@@ -54,9 +54,7 @@ defmodule PlausibleWeb.SSO.RealSAMLAdapter do:login_error,"We couldn't find a Single Sign-On account for that email.")- |> Phoenix.Controller.redirect(- to: Routes.sso_path(conn, :login_form, return_to: return_to)- )+ |> Phoenix.Controller.redirect(to: ~p"/sso/login?#{[return_to: return_to]}")endend@@ -74,7 +72,7 @@ defmodule PlausibleWeb.SSO.RealSAMLAdapter do{:error, :session_expired} ->conn|> Phoenix.Controller.put_flash(:login_error, "Session expired.")- |> Phoenix.Controller.redirect(to: Routes.sso_path(conn, :login_form))+ |> Phoenix.Controller.redirect(to: ~p"/sso/login")endend@@ -237,8 +235,6 @@ defmodule PlausibleWeb.SSO.RealSAMLAdapter dodefp login_error(conn, cookie, login_error) doconn|> Phoenix.Controller.put_flash(:login_error, login_error)- |> Phoenix.Controller.redirect(- to: Routes.sso_path(conn, :login_form, return_to: cookie.return_to)- )+ |> Phoenix.Controller.redirect(to: ~p"/sso/login?#{[return_to: cookie.return_to]}")endenddiff --git a/extra/lib/plausible_web/templates/help_scout/layout.html.heex b/extra/lib/plausible_web/templates/help_scout/layout.html.heexindex 15f124da0e..14b6eede40 100644--- a/extra/lib/plausible_web/templates/help_scout/layout.html.heex+++ b/extra/lib/plausible_web/templates/help_scout/layout.html.heex@@ -5,7 +5,7 @@<meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Plausible · HelpScout Integration</title>- <link rel="stylesheet" href={Routes.static_path(@conn, "/css/app.css")} />+ <link rel="stylesheet" href={~p"/css/app.css"} /></head><body class="flex flex-col bg-gray-50">{@inner_content}diff --git a/extra/lib/plausible_web/templates/sso/login_form.html.heex b/extra/lib/plausible_web/templates/sso/login_form.html.heexindex 46bd800435..2446340437 100644--- a/extra/lib/plausible_web/templates/sso/login_form.html.heex+++ b/extra/lib/plausible_web/templates/sso/login_form.html.heex@@ -10,7 +10,7 @@:let={f}id="sso-login-form"for={@conn}- action={Routes.sso_path(@conn, :login)}+ action={~p"/sso/login"}class="flex flex-col gap-y-6"><div class="flex flex-col gap-y-2">@@ -42,10 +42,7 @@<p class="text-sm text-center text-gray-500 dark:text-gray-400"><.styled_link href={- Routes.auth_path(@conn, :login_form,- return_to: @conn.params["return_to"],- prefer: "manual"- )+ ~p"/login?#{[return_to: @conn.params["return_to"], prefer: "manual"]}"}>Use password instead</.styled_link>diff --git a/extra/lib/plausible_web/templates/sso/provision_issue.html.heex b/extra/lib/plausible_web/templates/sso/provision_issue.html.heexindex c76b61a62e..af888d4077 100644--- a/extra/lib/plausible_web/templates/sso/provision_issue.html.heex+++ b/extra/lib/plausible_web/templates/sso/provision_issue.html.heex@@ -30,7 +30,7 @@</p><p :if={[email protected][:current_user]}>- <.styled_link href={Routes.auth_path(@conn, :login_form, prefer: "manual")}>+ <.styled_link href={~p"/login?#{[prefer: "manual"]}"}>Sign in with email and password</.styled_link>to resolve the issue.diff --git a/extra/lib/plausible_web/templates/sso/provision_notice.html.heex b/extra/lib/plausible_web/templates/sso/provision_notice.html.heexindex e278edbe7d..3d55e7af04 100644--- a/extra/lib/plausible_web/templates/sso/provision_notice.html.heex+++ b/extra/lib/plausible_web/templates/sso/provision_notice.html.heex@@ -10,8 +10,7 @@has turned off email and password logins, so you can only sign in with your organization's Single Sign-On.</p><p>- To access this team,- <.styled_link href={Routes.auth_path(@conn, :logout)}>sign out</.styled_link>+ To access this team, <.styled_link href={~p"/logout"}>sign out</.styled_link>and sign in with SSO.</p></div>diff --git a/extra/lib/plausible_web/templates/sso/saml_signin.html.heex b/extra/lib/plausible_web/templates/sso/saml_signin.html.heexindex e70be63538..7941a5368c 100644--- a/extra/lib/plausible_web/templates/sso/saml_signin.html.heex+++ b/extra/lib/plausible_web/templates/sso/saml_signin.html.heex@@ -24,7 +24,7 @@:let={f}id="sso-req-form"for={@conn}- action={Routes.sso_path(@conn, :saml_consume, @integration_id)}+ action={~p"/sso/saml/consume/#{@integration_id}"}><.input type="hidden" field={f[:email]} /><.input type="hidden" field={f[:return_to]} />diff --git a/extra/lib/plausible_web/templates/sso/team_sessions.html.heex b/extra/lib/plausible_web/templates/sso/team_sessions.html.heexindex 0b9ac3a194..1ba19b82d3 100644--- a/extra/lib/plausible_web/templates/sso/team_sessions.html.heex+++ b/extra/lib/plausible_web/templates/sso/team_sessions.html.heex@@ -25,7 +25,7 @@<.td :if={@current_user_session.id == session.id} actions>Current session</.td><.td :if={@current_user_session.id != session.id} actions><.delete_button- href={Routes.sso_path(@conn, :delete_session, session.id)}+ href={~p"/settings/sso/sessions/#{session.id}"}method="delete"data-confirm="Are you sure you want to log out this session?"/>diff --git a/lib/plausible_web.ex b/lib/plausible_web.exindex 6dbfb8cfff..a3540d01c8 100644--- a/lib/plausible_web.ex+++ b/lib/plausible_web.ex@@ -8,7 +8,7 @@ defmodule PlausibleWeb douse Plausibleuse Phoenix.LiveView, global_prefixes: ~w(x-)use PlausibleWeb.Live.Flash-+ use PlausibleWeb.VerifiedRoutesuse PlausibleWeb.Live.AuthContextunless :no_sentry_context in unquote(opts) do@@ -19,7 +19,6 @@ defmodule PlausibleWeb douse Plausible.Audit.LiveContextend- alias PlausibleWeb.Router.Helpers, as: Routesalias Phoenix.LiveView.JSimport PlausibleWeb.Components.Generic@@ -31,32 +30,32 @@ defmodule PlausibleWeb dodef live_component doquote douse Phoenix.LiveComponent, global_prefixes: ~w(x-)+ use PlausibleWeb.VerifiedRoutesimport PlausibleWeb.Components.Genericimport PlausibleWeb.Components.Settingsimport PlausibleWeb.Live.Components.Formalias Phoenix.LiveView.JS- alias PlausibleWeb.Router.Helpers, as: Routesendenddef component doquote douse Phoenix.Component, global_prefixes: ~w(x-)+ use PlausibleWeb.VerifiedRoutesimport PlausibleWeb.Components.Genericimport PlausibleWeb.Components.Settingsimport PlausibleWeb.Live.Components.Formalias Phoenix.LiveView.JS- alias PlausibleWeb.Router.Helpers, as: Routesendenddef controller doquote douse Phoenix.Controller, formats: [html: "View", json: "View"]+ use PlausibleWeb.VerifiedRoutesimport Plug.Connimport PlausibleWeb.ControllerHelpers- alias PlausibleWeb.Router.Helpers, as: Routesendend@@ -69,11 +68,11 @@ defmodule PlausibleWeb doimport Phoenix.Controller, only: [view_module: 1]use Phoenix.Component, global_prefixes: ~w(x-)+ use PlausibleWeb.VerifiedRoutesimport PlausibleWeb.Components.Genericimport PlausibleWeb.Components.Settingsimport PlausibleWeb.Live.Components.Form- alias PlausibleWeb.Router.Helpers, as: Routesendend@@ -87,18 +86,18 @@ defmodule PlausibleWeb doimport Phoenix.Controller, only: [view_module: 1]use Phoenix.Component+ use PlausibleWeb.VerifiedRoutesimport PlausibleWeb.Components.Genericimport PlausibleWeb.Components.Settingsimport PlausibleWeb.Live.Components.Form- alias PlausibleWeb.Router.Helpers, as: Routesendendenddef router doquote do- use Phoenix.Router+ use Phoenix.Router, helpers: falseimport Plug.Connimport Phoenix.Controllerend@@ -113,8 +112,9 @@ defmodule PlausibleWeb dodef plugins_api_controller doquote douse Phoenix.Controller, formats: [:json]+ use PlausibleWeb.VerifiedRoutes+import Plug.Conn- import PlausibleWeb.Router.Helpersalias PlausibleWeb.Plugins.API.Schemasalias PlausibleWeb.Plugins.API.Views@@ -130,14 +130,16 @@ defmodule PlausibleWeb dodef plugins_api_view doquote douse Phoenix.View, root: ""+ use PlausibleWeb.VerifiedRoutes- alias PlausibleWeb.Router.Helpers- import PlausibleWeb.Plugins.API.Views.Pagination, only: [render_metadata_links: 4]+ import PlausibleWeb.Plugins.API.Views.Pagination, only: [render_metadata_links: 3]endenddef open_api_schema doquote do+ use PlausibleWeb.VerifiedRoutes+require OpenApiSpexalias OpenApiSpex.Schemaalias PlausibleWeb.Plugins.API.Schemasdiff --git a/lib/plausible_web/components/billing/billing.ex b/lib/plausible_web/components/billing/billing.exindex d2c670ca59..12a021629b 100644--- a/lib/plausible_web/components/billing/billing.ex+++ b/lib/plausible_web/components/billing/billing.ex@@ -225,7 +225,7 @@ defmodule PlausibleWeb.Components.Billing dodefp dashboard_url(nil, _date_range), do: nildefp dashboard_url(domain, date_range) do- base = Routes.stats_path(PlausibleWeb.Endpoint, :stats, domain, [])+ base = stats_path(domain)base <>"?period=custom&from=#{Date.to_iso8601(date_range.first)}&to=#{Date.to_iso8601(date_range.last)}"@@ -350,7 +350,7 @@ defmodule PlausibleWeb.Components.Billing doif Mix.env() == :dev dodef start_paddle_checkout_expr(paddle_product_id, _team, _user) do- "window.location = '#{Routes.dev_subscription_path(PlausibleWeb.Endpoint, :create_form, paddle_product_id)}'"+ "window.location = '#{~p"/dev/billing/create-subscription-form/#{paddle_product_id}"}'"enddef paddle_script(assigns), do: ~H""@@ -369,7 +369,7 @@ defmodule PlausibleWeb.Components.Billing doemail: user.email,disableLogout: true,passthrough: passthrough,- success: Routes.billing_path(PlausibleWeb.Endpoint, :upgrade_success),+ success: ~p"/billing/upgrade-success",theme: "none"})@@ -441,7 +441,7 @@ defmodule PlausibleWeb.Components.Billing do~H"""<.styled_linkclass={"inline-block font-medium " <> @link_class}- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}+ href={~p"/billing/choose-plan"}>upgrade your subscription.</.styled_link>diff --git a/lib/plausible_web/components/billing/notice.ex b/lib/plausible_web/components/billing/notice.exindex c1c69519ce..9feff0470a 100644--- a/lib/plausible_web/components/billing/notice.ex+++ b/lib/plausible_web/components/billing/notice.ex@@ -16,7 +16,7 @@ defmodule PlausibleWeb.Components.Billing.Notice do>To keep your stats running smoothly, it’s time to upgrade your subscription to match your growing usage.<.link- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}+ href={~p"/billing/choose-plan"}class="whitespace-nowrap font-semibold">Upgrade now <span aria-hidden="true"> →</span>@@ -33,7 +33,7 @@ defmodule PlausibleWeb.Components.Billing.Notice do>To keep your stats running smoothly, it’s time to upgrade your subscription to match your growing usage.<.link- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}+ href={~p"/billing/choose-plan"}class="whitespace-nowrap font-semibold">Upgrade now <span aria-hidden="true"> →</span>@@ -53,7 +53,7 @@ defmodule PlausibleWeb.Components.Billing.Notice do>Since you’ve outgrown your current subscription tier, it’s time to upgrade to match your growing usage.<.link- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}+ href={~p"/billing/choose-plan"}class="whitespace-nowrap font-semibold">Upgrade now <span aria-hidden="true"> →</span>@@ -267,7 +267,7 @@ defmodule PlausibleWeb.Components.Billing.Notice doNo action is required. Occasional traffic spikes are normal, and we'll keep tracking your stats as usual. Upgrading now gives you room to grow if higher traffic continues.</p><div class="flex gap-3 items-center">- <.button_link href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)} mt?={false}>+ <.button_link href={~p"/billing/choose-plan"} mt?={false}>Upgrade</.button_link><.button_link@@ -290,7 +290,7 @@ defmodule PlausibleWeb.Components.Billing.Notice do<p class="text-pretty">Upgrading lets you add more as your team grows.</p>- <.button_link href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)} mt?={false}>+ <.button_link href={~p"/billing/choose-plan"} mt?={false}>Upgrade</.button_link></div>@@ -305,7 +305,7 @@ defmodule PlausibleWeb.Components.Billing.Notice do<p class="text-pretty">Upgrading lets you add more sites as you grow.</p>- <.button_link href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)} mt?={false}>+ <.button_link href={~p"/billing/choose-plan"} mt?={false}>Upgrade</.button_link></div>@@ -324,7 +324,7 @@ defmodule PlausibleWeb.Components.Billing.Notice do<p class="text-pretty">Upgrading gives you room to grow.</p>- <.button_link href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)} mt?={false}>+ <.button_link href={~p"/billing/choose-plan"} mt?={false}>Upgrade</.button_link></div>@@ -340,7 +340,7 @@ defmodule PlausibleWeb.Components.Billing.Notice doNo action is required. Occasional traffic spikes are normal, but upgrading now gives you room to grow if higher traffic continues.</p><div class="flex gap-3 items-center">- <.button_link href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)} mt?={false}>+ <.button_link href={~p"/billing/choose-plan"} mt?={false}>Upgrade</.button_link><.button_link@@ -364,7 +364,7 @@ defmodule PlausibleWeb.Components.Billing.Notice doNo action is required. Occasional traffic spikes are normal, but upgrading now gives you room to grow if higher traffic continues.</p><div class="flex gap-3 items-center">- <.button_link href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)} mt?={false}>+ <.button_link href={~p"/billing/choose-plan"} mt?={false}>Upgrade</.button_link><.button_link@@ -388,7 +388,7 @@ defmodule PlausibleWeb.Components.Billing.Notice doTo ensure uninterrupted access to your stats, please upgrade to a plan that fits your current usage.</p><div class="flex gap-3 items-center">- <.button_link href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)} mt?={false}>+ <.button_link href={~p"/billing/choose-plan"} mt?={false}>Upgrade</.button_link><.button_link@@ -432,7 +432,7 @@ defmodule PlausibleWeb.Components.Billing.Notice doTo ensure uninterrupted access to your stats, please upgrade to a plan that fits your current usage {@deadline_text}.</p><div class="flex gap-3 items-center">- <.button_link href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)} mt?={false}>+ <.button_link href={~p"/billing/choose-plan"} mt?={false}>Upgrade</.button_link><.button_link@@ -456,7 +456,7 @@ defmodule PlausibleWeb.Components.Billing.Notice doYour stats are still being tracked, but dashboard access is temporarily locked because your site exceeded your plan's pageview limit for two consecutive billing cycles. Upgrade to restore access.</p><div class="flex gap-3 items-center">- <.button_link href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)} mt?={false}>+ <.button_link href={~p"/billing/choose-plan"} mt?={false}>Upgrade</.button_link><.button_link@@ -481,7 +481,7 @@ defmodule PlausibleWeb.Components.Billing.Notice do</p><.button_linkid="upgrade-or-change-plan-link"- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}+ href={~p"/billing/choose-plan"}mt?={false}>Choose a plan@@ -499,7 +499,7 @@ defmodule PlausibleWeb.Components.Billing.Notice doYou have access to your stats until <span class="font-semibold inline"><%= Calendar.strftime(@subscription.next_bill_date, "%b %-d, %Y") %></span>.<.linkclass="underline inline-block"- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}+ href={~p"/billing/choose-plan"}>Upgrade your subscription</.link>diff --git a/lib/plausible_web/components/billing/plan_box.ex b/lib/plausible_web/components/billing/plan_box.exindex c403c2d563..b4d9253910 100644--- a/lib/plausible_web/components/billing/plan_box.ex+++ b/lib/plausible_web/components/billing/plan_box.ex@@ -392,7 +392,7 @@ defmodule PlausibleWeb.Components.Billing.PlanBox do~H"""<buttonid={"#{@kind}-checkout"}- onclick={"if (#{@confirmed}) {window.location = '#{Routes.billing_path(PlausibleWeb.Endpoint, :change_plan_preview, @paddle_product_id)}'}"}+ onclick={"if (#{@confirmed}) {window.location = '#{~p"/billing/change-plan/preview/#{@paddle_product_id}"}'}"}class={["w-full mt-6 block rounded-md py-2 px-3 text-center text-sm font-semibold leading-6 text-white",!@checkout_disabled && "bg-indigo-600 hover:bg-indigo-500",diff --git a/lib/plausible_web/components/captcha.ex b/lib/plausible_web/components/captcha.exindex 5c4e99b590..0629ff5fb0 100644--- a/lib/plausible_web/components/captcha.ex+++ b/lib/plausible_web/components/captcha.ex@@ -3,6 +3,7 @@ defmodule PlausibleWeb.Components.Captcha doFriendly Captcha widget shared between the registration and password-reset forms."""use Phoenix.Component, global_prefixes: ~w(x-)+ use PlausibleWeb.VerifiedRoutes@reset_event "reset-frc-captcha"@@ -39,12 +40,7 @@ defmodule PlausibleWeb.Components.Captcha do<scriptid="frc-captcha-script"type="module"- src={- PlausibleWeb.Router.Helpers.static_path(- PlausibleWeb.Endpoint,- "/js/friendly-captcha/site.min.js"- )- }+ src={~p"/js/friendly-captcha/site.min.js"}asyncdefer>@@ -52,12 +48,7 @@ defmodule PlausibleWeb.Components.Captcha do<scriptid="frc-captcha-script-compat"nomodule- src={- PlausibleWeb.Router.Helpers.static_path(- PlausibleWeb.Endpoint,- "/js/friendly-captcha/site.compat.min.js"- )- }+ src={~p"/js/friendly-captcha/site.compat.min.js"}asyncdefer>diff --git a/lib/plausible_web/components/generic.ex b/lib/plausible_web/components/generic.exindex d0e0e786a9..9f34557667 100644--- a/lib/plausible_web/components/generic.ex+++ b/lib/plausible_web/components/generic.ex@@ -4,9 +4,9 @@ defmodule PlausibleWeb.Components.Generic do"""use Phoenix.Component, global_prefixes: ~w(x-)- import PlausibleWeb.Components.Icons+ use PlausibleWeb.VerifiedRoutes- alias PlausibleWeb.Router.Helpers, as: Routes+ import PlausibleWeb.Components.Icons@notice_themes %{gray: %{@@ -1314,7 +1314,7 @@ defmodule PlausibleWeb.Components.Generic dodef upgrade_pill(assigns) do~H"""<.link- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}+ href={~p"/billing/choose-plan"}class="inline-block"{@rest}>diff --git a/lib/plausible_web/components/layout.ex b/lib/plausible_web/components/layout.exindex cfc5d0cde0..f81b68a8bc 100644--- a/lib/plausible_web/components/layout.ex+++ b/lib/plausible_web/components/layout.ex@@ -8,13 +8,13 @@ defmodule PlausibleWeb.Components.Layout dodef logo(assigns) do~H"""<img- src={logo_url("logo_dark.svg")}+ src={logo_path("logo_dark.svg")}class={[@class, "hidden dark:inline"]}alt="Plausible logo"loading="lazy"/><img- src={logo_url("logo_light.svg")}+ src={logo_path("logo_light.svg")}class={[@class, "inline dark:hidden"]}alt="Plausible logo"loading="lazy"@@ -22,25 +22,22 @@ defmodule PlausibleWeb.Components.Layout do"""end- defp logo_url(filename),- do: PlausibleWeb.Router.Helpers.static_path(PlausibleWeb.Endpoint, logo_path(filename))-def favicon(assigns) do~H"""<linkrel="apple-touch-icon"sizes="180x180"- href={PlausibleWeb.Router.Helpers.static_path(@conn, logo_path("apple-touch-icon.png"))}+ href={logo_path("apple-touch-icon.png")}/><linkrel="icon"sizes="32x32"- href={PlausibleWeb.Router.Helpers.static_path(@conn, logo_path("favicon.ico"))}+ href={logo_path("favicon.ico")}/><linkrel="icon"type="image/svg+xml"- href={PlausibleWeb.Router.Helpers.static_path(@conn, logo_path("favicon.svg"))}+ href={logo_path("favicon.svg")}/>"""enddiff --git a/lib/plausible_web/components/layouts.ex b/lib/plausible_web/components/layouts.exindex 548373adcf..8dbe07e616 100644--- a/lib/plausible_web/components/layouts.ex+++ b/lib/plausible_web/components/layouts.ex@@ -53,17 +53,17 @@ defmodule PlausibleWeb.Layouts do<div data-iframe-height></div><scripttype="text/javascript"- src={Routes.static_path(PlausibleWeb.Endpoint, "/js/embed.content.js")}+ src={~p"/js/embed.content.js"}></script><% end %><.footer :if={@footer?} />- <script type="text/javascript" src={Routes.static_path(PlausibleWeb.Endpoint, "/js/app.js")}>+ <script type="text/javascript" src={~p"/js/app.js"}></script><%= if @load_dashboard_js? do %><scripttype="text/javascript"- src={Routes.static_path(PlausibleWeb.Endpoint, "/js/dashboard.js")}+ src={~p"/js/dashboard.js"}></script><% end %>diff --git a/lib/plausible_web/components/layouts/footer.html.heex b/lib/plausible_web/components/layouts/footer.html.heexindex e81121eaf6..d0fd551c2f 100644--- a/lib/plausible_web/components/layouts/footer.html.heex+++ b/lib/plausible_web/components/layouts/footer.html.heex@@ -4,12 +4,7 @@<div class="my-8 xl:my-0"><h4 class="font-semibold tracking-wider text-gray-300 leading-5"><img- src={- PlausibleWeb.Router.Helpers.static_path(- PlausibleWeb.Endpoint,- PlausibleWeb.LayoutView.logo_path("logo_dark.svg")- )- }+ src={PlausibleWeb.LayoutView.logo_path("logo_dark.svg")}class="inline-block w-32 mr-1"alt="Plausible logo"loading="lazy"diff --git a/lib/plausible_web/components/layouts/header.html.heex b/lib/plausible_web/components/layouts/header.html.heexindex c7bd7bd055..233fb42659 100644--- a/lib/plausible_web/components/layouts/header.html.heex+++ b/lib/plausible_web/components/layouts/header.html.heex@@ -38,7 +38,7 @@<div class="w-px h-4 bg-indigo-500/30 dark:bg-indigo-200/30" aria-hidden="true"></div><.styled_link- href={Routes.settings_path(PlausibleWeb.Endpoint, :subscription)}+ href={~p"/settings/billing/subscription"}class="plausible-event-name=Trial+Notification+Upgrade+Click text-sm font-medium dark:!text-indigo-400 dark:hover:!text-indigo-300">Choose a plan@@ -69,14 +69,14 @@current_team={@current_team}/><.dropdown_divider />- <.dropdown_item href={Routes.settings_path(PlausibleWeb.Endpoint, :index)}>+ <.dropdown_item href={~p"/settings"}>Account settings</.dropdown_item><div :if={@my_team && @my_team.id == @current_team.id}><.dropdown_itemclass="flex"- href={Routes.team_setup_path(PlausibleWeb.Endpoint, :setup)}+ href={~p"/team/setup"}><span data-test="create-a-team-cta" class="flex-1">Create a team@@ -88,7 +88,7 @@<div :if={Plausible.Teams.setup?(@current_team)}><.dropdown_itemclass="flex"- href={Routes.settings_path(PlausibleWeb.Endpoint, :team_general)}+ href={~p"/settings/team/general"}><span class="flex-1">Team settingsdiff --git a/lib/plausible_web/components/team/notice.ex b/lib/plausible_web/components/team/notice.exindex ccfc2d2dea..5848159bda 100644--- a/lib/plausible_web/components/team/notice.ex+++ b/lib/plausible_web/components/team/notice.ex@@ -18,7 +18,7 @@ defmodule PlausibleWeb.Team.Notice do<p>You can also create a team and assign different roles to team members, such as admin,editor, viewer or billing. Team members will gain access to all your sites. <.styled_link href={- Routes.team_setup_path(PlausibleWeb.Endpoint, :setup)+ ~p"/team/setup"}>Create your team here</.styled_link>.@@ -51,7 +51,7 @@ defmodule PlausibleWeb.Team.Notice do<.notice theme={:gray} class="mt-4"><p>Team members automatically have access to this site.- <.styled_link href={Routes.settings_path(PlausibleWeb.Endpoint, :team_general)}>+ <.styled_link href={~p"/settings/team/general"}>View team members</.styled_link></p>@@ -78,7 +78,7 @@ defmodule PlausibleWeb.Team.Notice do<:actions><.button_linkmethod="post"- href={Routes.invitation_path(PlausibleWeb.Endpoint, :reject_invitation, i.invitation_id)}+ href={~p"/settings/team/invitations/#{i.invitation_id}/reject"}phx-value-invitation-id={i.invitation_id}theme="ghost"size="sm"@@ -89,7 +89,7 @@ defmodule PlausibleWeb.Team.Notice do</.button_link><.button_linkmethod="post"- href={Routes.invitation_path(PlausibleWeb.Endpoint, :accept_invitation, i.invitation_id)}+ href={~p"/settings/team/invitations/#{i.invitation_id}/accept"}theme="secondary"size="sm"class="order-1 md:order-2"@@ -161,13 +161,7 @@ defmodule PlausibleWeb.Team.Notice do<:actions><.button_linkmethod="post"- href={- Routes.invitation_path(- PlausibleWeb.Endpoint,- :reject_invitation,- @invitation.transfer_id- )- }+ href={~p"/settings/team/invitations/#{@invitation.transfer_id}/reject"}theme="ghost"size="sm"class="order-3 md:order-1"@@ -178,13 +172,7 @@ defmodule PlausibleWeb.Team.Notice do<.button_link:if={@can_accept?}method="post"- href={- Routes.invitation_path(- PlausibleWeb.Endpoint,- :accept_invitation,- @invitation.transfer_id- )- }+ href={~p"/settings/team/invitations/#{@invitation.transfer_id}/accept"}theme="secondary"size="sm"class="order-1 md:order-2"@@ -208,7 +196,7 @@ defmodule PlausibleWeb.Team.Notice do<PrimaDropdown.dropdown_itemas={&link/1}id={"ownership-accept-item-upgrade-#{@invitation.transfer_id}"}- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}+ href={~p"/billing/choose-plan"}>Upgrade to accept</PrimaDropdown.dropdown_item>@@ -216,12 +204,7 @@ defmodule PlausibleWeb.Team.Notice doas={fn a -> link(Map.put(a, :method, "post")) end}id={"ownership-accept-item-members-#{@invitation.transfer_id}"}href={- Routes.invitation_path(- PlausibleWeb.Endpoint,- :accept_invitation,- @invitation.transfer_id,- skip_site_members_transfer: "true"- )+ ~p"/settings/team/invitations/#{@invitation.transfer_id}/accept?#{[skip_site_members_transfer: "true"]}"}>Accept without members@@ -230,7 +213,7 @@ defmodule PlausibleWeb.Team.Notice do</PrimaDropdown.dropdown><.button_link:if={not @can_accept? and not @can_accept_without_members?}- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}+ href={~p"/billing/choose-plan"}theme="secondary"size="sm"class="order-1 md:order-3"@@ -262,7 +245,7 @@ defmodule PlausibleWeb.Team.Notice do<:actions><.button_linkmethod="post"- href={Routes.invitation_path(PlausibleWeb.Endpoint, :reject_invitation, i.invitation_id)}+ href={~p"/settings/team/invitations/#{i.invitation_id}/reject"}theme="ghost"size="sm"class="order-2 md:order-1"@@ -272,7 +255,7 @@ defmodule PlausibleWeb.Team.Notice do</.button_link><.button_linkmethod="post"- href={Routes.invitation_path(PlausibleWeb.Endpoint, :accept_invitation, i.invitation_id)}+ href={~p"/settings/team/invitations/#{i.invitation_id}/accept"}theme="secondary"size="sm"class="order-1 md:order-2"diff --git a/lib/plausible_web/controllers/auth_controller.ex b/lib/plausible_web/controllers/auth_controller.exindex 57a2cc6d8d..71c3b088bf 100644--- a/lib/plausible_web/controllers/auth_controller.ex+++ b/lib/plausible_web/controllers/auth_controller.ex@@ -128,7 +128,7 @@ defmodule PlausibleWeb.AuthController doredirect(conn, to: redirect_path)true ->- redirect(conn, to: Routes.site_path(conn, :new, flow: flow))+ redirect(conn, to: ~p"/sites/new?#{[flow: flow]}")end{:error, :incorrect} ->@@ -156,12 +156,12 @@ defmodule PlausibleWeb.AuthController doconn|> put_flash(:success, "Activation code was sent to #{user.email}")- |> redirect(to: Routes.auth_path(conn, :activate_form))+ |> redirect(to: ~p"/activate")else{:error, {:rate_limit, _}} ->conn|> put_flash(:error, "Too many code requests. Please wait before requesting another.")- |> redirect(to: Routes.auth_path(conn, :activate_form))+ |> redirect(to: ~p"/activate")endend@@ -240,7 +240,7 @@ defmodule PlausibleWeb.AuthController do|> UserAuth.log_out_user()|> put_flash(:login_title, "Password updated successfully")|> put_flash(:login_instructions, "Please sign in with your new credentials")- |> redirect(to: Routes.auth_path(conn, :login_form))+ |> redirect(to: ~p"/login")endon_ee do@@ -250,7 +250,7 @@ defmodule PlausibleWeb.AuthController docase {login_preference, params["prefer"], error} do{"sso", nil, nil} ->- redirect(conn, to: Routes.sso_path(conn, :login_form, return_to: params["return_to"]))+ redirect(conn, to: ~p"/sso/login?#{[return_to: params["return_to"]]}")_ ->render_login_form(conn)@@ -295,16 +295,13 @@ defmodule PlausibleWeb.AuthController doPlausibleWeb.Flows.invitation()end- Routes.auth_path(conn, :activate_form,- flow: flow,- team_identifier: params["team_identifier"]- )+ ~p"/activate?#{[flow: flow, team_identifier: params["team_identifier"]]}"params["register_action"] == "register_from_invitation_form" ->accept_team_invitation(conn, params["team_identifier"], user)params["register_action"] == "register_form" ->- Routes.site_path(conn, :new)+ ~p"/sites/new"true ->params["return_to"]@@ -344,7 +341,7 @@ defmodule PlausibleWeb.AuthController doconn|> TwoFactor.Session.set_2fa_user(user)- |> redirect(to: Routes.auth_path(conn, :verify_2fa, query_params))+ |> redirect(to: ~p"/2fa/verify?#{query_params}")endend@@ -363,22 +360,22 @@ defmodule PlausibleWeb.AuthController dodefp accept_team_invitation(conn, team_identifier, user, params \\ [])- defp accept_team_invitation(conn, no_identifier, _user, params)+ defp accept_team_invitation(_conn, no_identifier, _user, params)when no_identifier in ["", nil] do- Routes.site_path(conn, :index, params)+ ~p"/sites?#{params}"end- defp accept_team_invitation(conn, team_identifier, user, extra_params) do+ defp accept_team_invitation(_conn, team_identifier, user, extra_params) doparams = Keyword.merge([__team: team_identifier], extra_params)# We try switching to the team no matter the invitation presence or acceptance outcome.case Teams.Invitations.find_by_team_identifier(team_identifier, user) do{:ok, invitation} ->{_, _} = Teams.Invitations.accept_team_invitation(invitation, user)- Routes.site_path(conn, :index, params)+ ~p"/sites?#{params}"{:error, :invitation_not_found} ->- Routes.site_path(conn, :index, params)+ ~p"/sites?#{params}"endend@@ -407,7 +404,7 @@ defmodule PlausibleWeb.AuthController do{:error, :already_setup} ->conn|> put_flash(:error, "Two-Factor Authentication is already setup for this account.")- |> redirect(to: Routes.settings_path(conn, :security) <> "#update-2fa")+ |> redirect(to: ~p"/settings/security#update-2fa")endend@@ -415,7 +412,7 @@ defmodule PlausibleWeb.AuthController doif Auth.TOTP.initiated?(conn.assigns.current_user) dorender(conn, "verify_2fa_setup.html")else- redirect(conn, to: Routes.settings_path(conn, :security) <> "#update-2fa")+ redirect(conn, to: ~p"/settings/security#update-2fa")endend@@ -444,7 +441,7 @@ defmodule PlausibleWeb.AuthController do{:error, :not_initiated} ->conn|> put_flash(:error, "Please enable Two-Factor Authentication for this account first.")- |> redirect(to: Routes.settings_path(conn, :security) <> "#update-2fa")+ |> redirect(to: ~p"/settings/security#update-2fa")endend@@ -454,12 +451,12 @@ defmodule PlausibleWeb.AuthController doconn|> TwoFactor.Session.clear_remember_2fa()|> put_flash(:success, "Two-Factor Authentication is disabled")- |> redirect(to: Routes.settings_path(conn, :security) <> "#update-2fa")+ |> redirect(to: ~p"/settings/security#update-2fa"){:error, :invalid_password} ->conn|> put_flash(:error, "Incorrect password provided")- |> redirect(to: Routes.settings_path(conn, :security) <> "#update-2fa")+ |> redirect(to: ~p"/settings/security#update-2fa")endend@@ -473,12 +470,12 @@ defmodule PlausibleWeb.AuthController do{:error, :invalid_password} ->conn|> put_flash(:error, "Incorrect password provided")- |> redirect(to: Routes.settings_path(conn, :security) <> "#update-2fa")+ |> redirect(to: ~p"/settings/security#update-2fa"){:error, :not_enabled} ->conn|> put_flash(:error, "Please enable Two-Factor Authentication for this account first.")- |> redirect(to: Routes.settings_path(conn, :security) <> "#update-2fa")+ |> redirect(to: ~p"/settings/security#update-2fa")endend@@ -572,14 +569,14 @@ defmodule PlausibleWeb.AuthController do{:error, :not_found} ->conn- |> redirect(to: Routes.auth_path(conn, :login_form))+ |> redirect(to: ~p"/login")endenddefp handle_email_updated(conn) doconn|> put_flash(:success, "Email updated successfully")- |> redirect(to: Routes.settings_path(conn, :security) <> "#update-email")+ |> redirect(to: ~p"/settings/security#update-email")enddef delete_me(conn, params) do@@ -593,7 +590,7 @@ defmodule PlausibleWeb.AuthController do:error,"You have an active subscription which must be canceled first.")- |> redirect(to: Routes.settings_path(conn, :danger_zone))+ |> redirect(to: ~p"/settings/danger-zone"){:error, :is_only_team_owner} ->conn@@ -601,7 +598,7 @@ defmodule PlausibleWeb.AuthController do:error,"You can't delete your account when you are the only owner on a team.")- |> redirect(to: Routes.settings_path(conn, :danger_zone))+ |> redirect(to: ~p"/settings/danger-zone")endend@@ -618,9 +615,9 @@ defmodule PlausibleWeb.AuthController do{:ok, %{site: site, context: context}} ->redirect_url =if context == "import" do- Routes.site_path(conn, :settings_imports_exports, site.domain)+ ~p"/#{site.domain}/settings/imports-exports"else- Routes.site_path(conn, :settings_integrations, site.domain)+ ~p"/#{site.domain}/settings/integrations"endcond do@@ -681,11 +678,7 @@ defmodule PlausibleWeb.AuthController dodefp google_import_callback(conn, site, token_data, expires_at) doredirect(conn,to:- Routes.google_analytics_path(conn, :property_form, site.domain,- access_token: Map.fetch!(token_data, "access_token"),- refresh_token: Map.fetch!(token_data, "refresh_token"),- expires_at: NaiveDateTime.to_iso8601(expires_at)- )+ ~p"/#{site.domain}/import/google-analytics/property?#{[access_token: Map.fetch!(token_data, "access_token"), refresh_token: Map.fetch!(token_data, "refresh_token"), expires_at: NaiveDateTime.to_iso8601(expires_at)]}")end@@ -723,7 +716,7 @@ defmodule PlausibleWeb.AuthController doconflict_target: :site_id)- redirect(conn, to: Routes.site_path(conn, :settings_integrations, site.domain))+ redirect(conn, to: ~p"/#{site.domain}/settings/integrations")enddefp check_callback_site_permission(site, current_user) do@@ -737,7 +730,7 @@ defmodule PlausibleWeb.AuthController doenddefp generic_oauth_error_response(conn, redirect_url \\ nil) do- redirect_url = redirect_url || Routes.auth_path(conn, :login_form)+ redirect_url = redirect_url || ~p"/login"conn|> put_flash(@@ -748,6 +741,6 @@ defmodule PlausibleWeb.AuthController doenddefp redirect_to_login(conn) do- redirect(conn, to: Routes.auth_path(conn, :login_form))+ redirect(conn, to: ~p"/login")endenddiff --git a/lib/plausible_web/controllers/billing_controller.ex b/lib/plausible_web/controllers/billing_controller.exindex 5d65988af1..a85a53c9ac 100644--- a/lib/plausible_web/controllers/billing_controller.ex+++ b/lib/plausible_web/controllers/billing_controller.ex@@ -23,7 +23,7 @@ defmodule PlausibleWeb.BillingController doteam = conn.assigns.current_teamif Plausible.Teams.Billing.enterprise_configured?(team) do- redirect(conn, to: Routes.billing_path(conn, :upgrade_to_enterprise_plan))+ redirect(conn, to: ~p"/billing/upgrade-to-enterprise-plan")elserender(conn, "choose_plan.html",live_module: PlausibleWeb.Live.ChoosePlan,@@ -57,7 +57,7 @@ defmodule PlausibleWeb.BillingController doSubscription.Status.past_due(),Subscription.Status.paused()]) ->- redirect(conn, to: Routes.settings_path(conn, :subscription))+ redirect(conn, to: ~p"/settings/billing/subscription")subscribed_to_latest? ->render(conn, "change_enterprise_plan_contact_us.html", skip_plausible_tracking: true)@@ -85,7 +85,7 @@ defmodule PlausibleWeb.BillingController docase preview_subscription(subscription, new_plan_id) do{:ok, {subscription, preview_info}} ->render(conn, "change_plan_preview.html",- back_link: Routes.billing_path(conn, :choose_plan),+ back_link: ~p"/billing/choose-plan",skip_plausible_tracking: true,subscription: subscription,preview_info: preview_info@@ -106,7 +106,7 @@ defmodule PlausibleWeb.BillingController doconn|> put_flash(:error, msg)- |> redirect(to: Routes.billing_path(conn, :choose_plan))+ |> redirect(to: ~p"/billing/choose-plan")endend@@ -117,7 +117,7 @@ defmodule PlausibleWeb.BillingController do{:ok, _subscription} ->conn|> put_flash(:success, "Plan changed successfully")- |> redirect(to: Routes.settings_path(conn, :subscription))+ |> redirect(to: ~p"/settings/billing/subscription"){:error, e} ->msg =@@ -148,7 +148,7 @@ defmodule PlausibleWeb.BillingController doconn|> put_flash(:error, msg)- |> redirect(to: Routes.settings_path(conn, :subscription))+ |> redirect(to: ~p"/settings/billing/subscription")endenddiff --git a/lib/plausible_web/controllers/google_analytics_controller.ex b/lib/plausible_web/controllers/google_analytics_controller.exindex 7d85452cc0..941e3fb715 100644--- a/lib/plausible_web/controllers/google_analytics_controller.ex+++ b/lib/plausible_web/controllers/google_analytics_controller.ex@@ -19,7 +19,7 @@ defmodule PlausibleWeb.GoogleAnalyticsController do) dosite = conn.assigns.site- redirect_route = Routes.site_path(conn, :settings_imports_exports, site.domain)+ redirect_route = ~p"/#{site.domain}/settings/imports-exports"result = Google.API.list_properties(access_token)@@ -101,7 +101,7 @@ defmodule PlausibleWeb.GoogleAnalyticsController do) dosite = conn.assigns.site- redirect_route = Routes.site_path(conn, :settings_imports_exports, site.domain)+ redirect_route = ~p"/#{site.domain}/settings/imports-exports"with {:ok, api_start_date} <- Google.API.get_analytics_start_date(access_token, property),{:ok, api_end_date} <- Google.API.get_analytics_end_date(access_token, property),@@ -109,14 +109,7 @@ defmodule PlausibleWeb.GoogleAnalyticsController do{:ok, start_date, end_date} <- Imported.clamp_dates(site, api_start_date, api_end_date) doredirect(conn,to:- Routes.google_analytics_path(conn, :confirm, site.domain,- property: property,- access_token: access_token,- refresh_token: refresh_token,- expires_at: expires_at,- start_date: Date.to_iso8601(start_date),- end_date: Date.to_iso8601(end_date)- )+ ~p"/#{site.domain}/import/google-analytics/confirm?#{[property: property, access_token: access_token, refresh_token: refresh_token, expires_at: expires_at, start_date: Date.to_iso8601(start_date), end_date: Date.to_iso8601(end_date)]}")else{:error, error} when error in [:no_data, :no_time_window] ->@@ -182,7 +175,7 @@ defmodule PlausibleWeb.GoogleAnalyticsController dostart_date = Date.from_iso8601!(start_date)end_date = Date.from_iso8601!(end_date)- redirect_route = Routes.site_path(conn, :settings_imports_exports, site.domain)+ redirect_route = ~p"/#{site.domain}/settings/imports-exports"case Google.API.get_property(access_token, property) do{:ok, %{name: property_name, id: property}} ->@@ -263,7 +256,7 @@ defmodule PlausibleWeb.GoogleAnalyticsController dostart_date = Date.from_iso8601!(start_date)end_date = Date.from_iso8601!(end_date)- redirect_route = Routes.site_path(conn, :settings_imports_exports, site.domain)+ redirect_route = ~p"/#{site.domain}/settings/imports-exports"import_opts = [label: property,diff --git a/lib/plausible_web/controllers/invitation_controller.ex b/lib/plausible_web/controllers/invitation_controller.exindex 5aea6bca4e..7ca8cd4bea 100644--- a/lib/plausible_web/controllers/invitation_controller.ex+++ b/lib/plausible_web/controllers/invitation_controller.ex@@ -38,11 +38,11 @@ defmodule PlausibleWeb.InvitationController doif site doconn|> put_flash(:success, "You now have access to #{site.domain}")- |> redirect(to: Routes.stats_path(conn, :stats, site.domain, []))+ |> redirect(to: stats_path(site.domain))elseconn|> put_flash(:success, "You now have access to \"#{team.name}\" team")- |> redirect(to: Routes.site_path(conn, :index, __team: team.identifier))+ |> redirect(to: ~p"/sites?#{[__team: team.identifier]}")end{:error, :invitation_not_found} ->@@ -108,12 +108,12 @@ defmodule PlausibleWeb.InvitationController doconn|> put_flash(:success, "You have removed the invitation for #{email}")- |> redirect(to: Routes.site_path(conn, :settings_people, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/people"){:error, :invitation_not_found} ->conn|> put_flash(:error, "Invitation missing or already removed")- |> redirect(to: Routes.site_path(conn, :settings_people, conn.assigns.site.domain))+ |> redirect(to: ~p"/#{conn.assigns.site.domain}/settings/people")endend@@ -124,17 +124,17 @@ defmodule PlausibleWeb.InvitationController do{:ok, invitation} ->conn|> put_flash(:success, "You have removed the invitation for #{invitation.email}")- |> redirect(to: Routes.settings_path(conn, :team_general))+ |> redirect(to: ~p"/settings/team/general"){:error, :invitation_not_found} ->conn|> put_flash(:error, "Invitation missing or already removed")- |> redirect(to: Routes.settings_path(conn, :team_general))+ |> redirect(to: ~p"/settings/team/general"){:error, :permission_denied} ->conn|> put_flash(:error, "You are not allowed to remove invitations")- |> redirect(to: Routes.settings_path(conn, :team_general))+ |> redirect(to: ~p"/settings/team/general")endendenddiff --git a/lib/plausible_web/controllers/settings_controller.ex b/lib/plausible_web/controllers/settings_controller.exindex 749a2bfe28..2e821801d1 100644--- a/lib/plausible_web/controllers/settings_controller.ex+++ b/lib/plausible_web/controllers/settings_controller.ex@@ -25,7 +25,7 @@ defmodule PlausibleWeb.SettingsController do[deny: :sso] when action in [:update_name, :update_email, :update_password]def index(conn, _params) do- redirect(conn, to: Routes.settings_path(conn, :preferences))+ redirect(conn, to: ~p"/settings/preferences")enddef team_general(conn, _params) do@@ -39,7 +39,7 @@ defmodule PlausibleWeb.SettingsController do{:ok, _user} ->conn|> put_flash(:success, "Team name changed")- |> redirect(to: Routes.settings_path(conn, :team_general) <> "#update-name")+ |> redirect(to: ~p"/settings/team/general#update-name"){:error, changeset} ->render_team_general(conn, team_name_changeset: changeset)@@ -63,7 +63,7 @@ defmodule PlausibleWeb.SettingsController do)elseconn- |> redirect(to: Routes.site_path(conn, :index))+ |> redirect(to: ~p"/sites")endend@@ -75,12 +75,12 @@ defmodule PlausibleWeb.SettingsController do{:ok, _} ->conn|> put_flash(:success, "2FA is now required for all team members.")- |> redirect(to: Routes.settings_path(conn, :team_general))+ |> redirect(to: ~p"/settings/team/general"){:error, _} ->conn|> put_flash(:error, "Failed to enforce 2FA for all team members.")- |> redirect(to: Routes.settings_path(conn, :team_general))+ |> redirect(to: ~p"/settings/team/general")endend@@ -92,17 +92,17 @@ defmodule PlausibleWeb.SettingsController do{:ok, _} ->conn|> put_flash(:success, "2FA is no longer enforced for team members.")- |> redirect(to: Routes.settings_path(conn, :team_general))+ |> redirect(to: ~p"/settings/team/general"){:error, :invalid_password} ->conn|> put_flash(:error, "Incorrect password provided.")- |> redirect(to: Routes.settings_path(conn, :team_general))+ |> redirect(to: ~p"/settings/team/general"){:error, _} ->conn|> put_flash(:error, "Failed to disable enforcing 2FA for all team members.")- |> redirect(to: Routes.settings_path(conn, :team_general))+ |> redirect(to: ~p"/settings/team/general")endend@@ -111,15 +111,15 @@ defmodule PlausibleWeb.SettingsController do{:ok, _} ->conn|> put_flash(:success, "You have left \"#{Teams.name(conn.assigns.current_team)}\"")- |> redirect(to: Routes.site_path(conn, :index, __team: "none"))+ |> redirect(to: ~p"/sites?#{[__team: "none"]}"){:error, :only_one_owner} ->conn|> put_flash(:error, "You can't leave as you are the only Owner on the team")- |> redirect(to: Routes.settings_path(conn, :team_general))+ |> redirect(to: ~p"/settings/team/general"){:error, :membership_not_found} ->- redirect(conn, to: Routes.site_path(conn, :index, __team: "none"))+ redirect(conn, to: ~p"/sites?#{[__team: "none"]}")endend@@ -132,7 +132,7 @@ defmodule PlausibleWeb.SettingsController doenddef redirect_invoices(conn, _params) do- redirect(conn, to: Routes.settings_path(conn, :subscription))+ redirect(conn, to: ~p"/settings/billing/subscription")enddef api_keys(conn, _params) do@@ -173,12 +173,12 @@ defmodule PlausibleWeb.SettingsController do{:ok, _api_key} ->conn|> put_flash(:success, "API key created successfully")- |> redirect(to: Routes.settings_path(conn, :api_keys) <> "#api-keys")+ |> redirect(to: ~p"/settings/api-keys#api-keys"){:error, :upgrade_required} ->conn|> put_flash(:error, "Your current subscription plan does not include Sites API access")- |> redirect(to: Routes.settings_path(conn, :new_api_key))+ |> redirect(to: ~p"/settings/api-keys/new"){:error, changeset} ->render(conn, "new_api_key.html",@@ -193,12 +193,12 @@ defmodule PlausibleWeb.SettingsController do:ok ->conn|> put_flash(:success, "API key revoked successfully")- |> redirect(to: Routes.settings_path(conn, :api_keys) <> "#api-keys")+ |> redirect(to: ~p"/settings/api-keys#api-keys"){:error, :not_found} ->conn|> put_flash(:error, "Could not find API Key to delete")- |> redirect(to: Routes.settings_path(conn, :api_keys) <> "#api-keys")+ |> redirect(to: ~p"/settings/api-keys#api-keys")endend@@ -228,7 +228,7 @@ defmodule PlausibleWeb.SettingsController do{:ok, :deleted} ->conn|> put_flash(:success, ~s|Team "#{Plausible.Teams.name(team)}" deleted|)- |> redirect(to: Routes.site_path(conn, :index, __team: "none"))+ |> redirect(to: ~p"/sites?#{[__team: "none"]}"){:error, :active_subscription} ->conn@@ -236,7 +236,7 @@ defmodule PlausibleWeb.SettingsController do:error,"Team has an active subscription. You must cancel it first.")- |> redirect(to: Routes.settings_path(conn, :team_danger_zone))+ |> redirect(to: ~p"/settings/team/delete")endend@@ -249,7 +249,7 @@ defmodule PlausibleWeb.SettingsController do{:ok, _user} ->conn|> put_flash(:success, "Name changed")- |> redirect(to: Routes.settings_path(conn, :preferences) <> "#update-name")+ |> redirect(to: ~p"/settings/preferences#update-name"){:error, changeset} ->render_preferences(conn, name_changeset: changeset)@@ -263,7 +263,7 @@ defmodule PlausibleWeb.SettingsController do{:ok, _user} ->conn|> put_flash(:success, "Theme changed")- |> redirect(to: Routes.settings_path(conn, :preferences) <> "#update-theme")+ |> redirect(to: ~p"/settings/preferences#update-theme"){:error, changeset} ->render_preferences(conn, theme_changeset: changeset)@@ -296,7 +296,7 @@ defmodule PlausibleWeb.SettingsController dohandle_email_updated(conn)elseAuth.EmailVerification.issue_code(user)- redirect(conn, to: Routes.auth_path(conn, :activate_form))+ redirect(conn, to: ~p"/activate")endelse{:error, %Ecto.Changeset{} = changeset} ->@@ -320,7 +320,7 @@ defmodule PlausibleWeb.SettingsController do{:ok, user} ->conn|> put_flash(:success, "Email changed back to #{user.email}")- |> redirect(to: Routes.settings_path(conn, :security) <> "#update-email")+ |> redirect(to: ~p"/settings/security#update-email"){:error, _} ->conn@@ -328,7 +328,7 @@ defmodule PlausibleWeb.SettingsController do:error,"Could not cancel email update because previous email has already been taken")- |> redirect(to: Routes.auth_path(conn, :activate_form))+ |> redirect(to: ~p"/activate")endend@@ -342,7 +342,7 @@ defmodule PlausibleWeb.SettingsController doconn|> put_flash(:success, "Your password is now changed")- |> redirect(to: Routes.settings_path(conn, :security) <> "#update-password")+ |> redirect(to: ~p"/settings/security#update-password")else{:error, %Ecto.Changeset{} = changeset} ->render_security(conn, password_changeset: changeset)@@ -391,7 +391,7 @@ defmodule PlausibleWeb.SettingsController doconn|> put_flash(:success, "Session logged out successfully")- |> redirect(to: Routes.settings_path(conn, :security) <> "#user-sessions")+ |> redirect(to: ~p"/settings/security#user-sessions")enddefp do_update_password(user, params) do@@ -429,6 +429,6 @@ defmodule PlausibleWeb.SettingsController dodefp handle_email_updated(conn) doconn|> put_flash(:success, "Email updated")- |> redirect(to: Routes.settings_path(conn, :security) <> "#update-email")+ |> redirect(to: ~p"/settings/security#update-email")endenddiff --git a/lib/plausible_web/controllers/site/membership_controller.ex b/lib/plausible_web/controllers/site/membership_controller.exindex adf2a2eab1..9b56b69f73 100644--- a/lib/plausible_web/controllers/site/membership_controller.ex+++ b/lib/plausible_web/controllers/site/membership_controller.ex@@ -58,7 +58,7 @@ defmodule PlausibleWeb.Site.MembershipController do:success,"#{email} has been invited to #{site_domain} as #{PlausibleWeb.SiteView.with_indefinite_article("#{invitation.role}")}")- |> redirect(to: Routes.site_path(conn, :settings_people, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/people"){:error, :already_a_member} ->render(conn, "invite_member_form.html",@@ -89,7 +89,7 @@ defmodule PlausibleWeb.Site.MembershipController doconn|> put_flash(:error, error_msg)- |> redirect(to: Routes.site_path(conn, :settings_people, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/people")endend@@ -114,9 +114,9 @@ defmodule PlausibleWeb.Site.MembershipController doredirect_target =if guest_membership.team_membership.user_id == current_user.id andguest_membership.role == :viewer do- Routes.stats_path(conn, :stats, site.domain, [])+ stats_path(site.domain)else- Routes.site_path(conn, :settings_people, site.domain)+ ~p"/#{site.domain}/settings/people"endconn@@ -129,7 +129,7 @@ defmodule PlausibleWeb.Site.MembershipController do{:error, _} ->conn|> put_flash(:error, "You are not allowed to grant the #{new_role_str} role")- |> redirect(to: Routes.site_path(conn, :settings_people, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/people")endend@@ -141,9 +141,9 @@ defmodule PlausibleWeb.Site.MembershipController doredirect_target =if user_id == conn.assigns[:current_user].id do- Routes.site_path(conn, :index)+ ~p"/sites"else- Routes.site_path(conn, :settings_people, site.domain)+ ~p"/#{site.domain}/settings/people"endconn@@ -158,7 +158,7 @@ defmodule PlausibleWeb.Site.MembershipController do:success,"User has been removed from #{site.domain}")- |> redirect(to: Routes.site_path(conn, :settings_people, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/people")endendenddiff --git a/lib/plausible_web/controllers/site_controller.ex b/lib/plausible_web/controllers/site_controller.exindex 9aac75d9bc..97d3586285 100644--- a/lib/plausible_web/controllers/site_controller.ex+++ b/lib/plausible_web/controllers/site_controller.ex@@ -46,7 +46,7 @@ defmodule PlausibleWeb.SiteController doendredirect(conn,- to: Routes.site_path(conn, :installation, site.domain, flow: flow)+ to: ~p"/#{site.domain}/installation?#{[flow: flow]}"){:error, _, :permission_denied, _} ->@@ -60,7 +60,7 @@ defmodule PlausibleWeb.SiteController do{:error, _, changeset, _} ->case check_can_already_access(changeset, user) do{:ok, domain} ->- redirect(conn, to: Routes.stats_path(PlausibleWeb.Endpoint, :stats, domain, []))+ redirect(conn, to: stats_path(domain)){:error, :no_access} ->render_new_site_form(conn, flow, changeset: changeset)@@ -92,7 +92,7 @@ defmodule PlausibleWeb.SiteController doenddef settings(conn, %{"domain" => domain}) do- redirect(conn, to: Routes.site_path(conn, :settings_general, domain))+ redirect(conn, to: ~p"/#{domain}/settings/general")enddef settings_general(conn, _params) do@@ -255,7 +255,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "Google integration saved successfully")- |> redirect(to: Routes.site_path(conn, :settings_integrations, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/integrations")enddef delete_google_auth(conn, _params) do@@ -268,7 +268,7 @@ defmodule PlausibleWeb.SiteController doendput_flash(conn, :success, "Google account unlinked from Plausible")- redirect(conn, to: Routes.site_path(conn, :settings_integrations, site.domain))+ redirect(conn, to: ~p"/#{site.domain}/settings/integrations")enddef update_settings(conn, %{"site" => site_params}) do@@ -282,7 +282,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_session(site_session_key, nil)|> put_flash(:success, "Your site settings have been saved")- |> redirect(to: Routes.site_path(conn, :settings_general, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/general"){:error, changeset} ->conn@@ -302,7 +302,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "#{site.domain} stats will be reset in a few minutes")- |> redirect(to: Routes.site_path(conn, :settings_danger_zone, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/danger-zone")enddef delete_site(conn, _params) do@@ -323,7 +323,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "Stats for #{site.domain} are now public.")- |> redirect(to: Routes.site_path(conn, :settings_visibility, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/visibility")enddef make_private(conn, _params) do@@ -334,7 +334,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "Stats for #{site.domain} are now private.")- |> redirect(to: Routes.site_path(conn, :settings_visibility, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/visibility")enddef enable_weekly_report(conn, _params) do@@ -351,7 +351,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "You will receive an email report every Monday going forward")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports")enddef disable_weekly_report(conn, _params) do@@ -360,7 +360,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "You will not receive weekly email reports going forward")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports")enddef add_weekly_report_recipient(conn, %{"recipient" => recipient}) do@@ -372,7 +372,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "Added #{recipient} as a recipient for the weekly report")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports")enddef remove_weekly_report_recipient(conn, %{"recipient" => recipient}) do@@ -387,7 +387,7 @@ defmodule PlausibleWeb.SiteController do:success,"Removed #{recipient} as a recipient for the weekly report")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports")enddef enable_monthly_report(conn, _params) do@@ -405,7 +405,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "You will receive an email report every month going forward")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports")enddef disable_monthly_report(conn, _params) do@@ -414,7 +414,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "You will not receive monthly email reports going forward")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports")enddef add_monthly_report_recipient(conn, %{"recipient" => recipient}) do@@ -426,7 +426,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "Added #{recipient} as a recipient for the monthly report")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports")enddef remove_monthly_report_recipient(conn, %{"recipient" => recipient}) do@@ -441,7 +441,7 @@ defmodule PlausibleWeb.SiteController do:success,"Removed #{recipient} as a recipient for the monthly report")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports")enddef enable_traffic_change_notification(conn, %{"type" => type}) do@@ -463,12 +463,12 @@ defmodule PlausibleWeb.SiteController do{:ok, _} ->conn|> put_flash(:success, "Traffic #{type} notifications enabled")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports"){:error, _} ->conn|> put_flash(:error, "Unable to create a #{type} notification")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports")endend@@ -483,7 +483,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "Traffic #{type} notifications disabled")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports")enddef update_traffic_change_notification(conn, %{@@ -500,7 +500,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "Notification settings updated")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports")enddef add_traffic_change_notification_recipient(conn, %{"recipient" => recipient, "type" => type}) do@@ -512,7 +512,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "Added #{recipient} as a recipient for the traffic spike notification")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports")enddef remove_traffic_change_notification_recipient(conn, %{@@ -530,7 +530,7 @@ defmodule PlausibleWeb.SiteController do:success,"Removed #{recipient} as a recipient for the monthly report")- |> redirect(to: Routes.site_path(conn, :settings_email_reports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/email-reports")enddef forget_import(conn, %{"import_id" => import_id}) do@@ -552,7 +552,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "Imported data has been cleared")- |> redirect(to: Routes.site_path(conn, :settings_imports_exports, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/imports-exports")enddef forget_imported(conn, _params) do@@ -579,7 +579,7 @@ defmodule PlausibleWeb.SiteController doconn|> put_flash(:success, "Imported data has been cleared")- |> redirect(to: Routes.site_path(conn, :settings_integrations, site.domain))+ |> redirect(to: ~p"/#{site.domain}/settings/integrations")endon_ee do@@ -593,7 +593,7 @@ defmodule PlausibleWeb.SiteController doelseconn|> put_flash(:error, "Export not found")- |> redirect(to: Routes.site_path(conn, :settings_imports_exports, domain))+ |> redirect(to: ~p"/#{domain}/settings/imports-exports")endendelse@@ -610,7 +610,7 @@ defmodule PlausibleWeb.SiteController doelseconn|> put_flash(:error, "Export not found")- |> redirect(to: Routes.site_path(conn, :settings_imports_exports, domain))+ |> redirect(to: ~p"/#{domain}/settings/imports-exports")endendenddiff --git a/lib/plausible_web/controllers/stats_controller.ex b/lib/plausible_web/controllers/stats_controller.exindex 3ff0d0125c..68e779db16 100644--- a/lib/plausible_web/controllers/stats_controller.ex+++ b/lib/plausible_web/controllers/stats_controller.ex@@ -79,7 +79,7 @@ defmodule PlausibleWeb.StatsController docond doconsolidated_view? and not consolidated_view_available? and site_role != :super_admin ->- redirect(conn, to: Routes.site_path(conn, :index))+ redirect(conn, to: ~p"/sites")not can_see_stats? ->site = Plausible.Repo.preload(site, :owners)@@ -193,8 +193,7 @@ defmodule PlausibleWeb.StatsController do)if shared_link do- new_link_format =- Routes.stats_path(conn, :shared_link, shared_link.site.domain, [], auth: slug)+ new_link_format = shared_stats_path(shared_link.site.domain, auth: slug)redirect(conn, to: new_link_format)else@@ -287,13 +286,7 @@ defmodule PlausibleWeb.StatsController do|> put_resp_cookie(shared_link_cookie_name(slug), token)|> redirect(to:- Routes.stats_path(- conn,- :shared_link,- shared_link.site.domain,- star_path,- auth: slug- ) <>+ shared_stats_path(shared_link.site.domain, [auth: slug], star_path) <>query_string_fragment)elsediff --git a/lib/plausible_web/email.ex b/lib/plausible_web/email.exindex 788af7d641..3a32d30b5b 100644--- a/lib/plausible_web/email.ex+++ b/lib/plausible_web/email.ex@@ -4,6 +4,8 @@ defmodule PlausibleWeb.Email do"""use Plausible+ use PlausibleWeb.VerifiedRoutes+import Bamboo.Emailimport Bamboo.PostmarkHelper@@ -508,11 +510,7 @@ defmodule PlausibleWeb.Email doenddownload_url =- PlausibleWeb.Router.Helpers.site_url(- PlausibleWeb.Endpoint,- :download_export,- site.domain- ) <> "?__team=#{site.team.identifier}"+ url(~p"/#{site.domain}/download/export?#{[__team: site.team.identifier]}")priority_email()|> to(user)diff --git a/lib/plausible_web/live/change_domain.ex b/lib/plausible_web/live/change_domain.exindex c3d71009e0..cec8d50834 100644--- a/lib/plausible_web/live/change_domain.ex+++ b/lib/plausible_web/live/change_domain.ex@@ -5,7 +5,6 @@ defmodule PlausibleWeb.Live.ChangeDomain douse Plausibleuse PlausibleWeb, :live_view- alias PlausibleWeb.Router.Helpers, as: Routesalias PlausibleWeb.Live.ChangeDomain.Formalias Phoenix.LiveView.AsyncResult@@ -91,7 +90,7 @@ defmodule PlausibleWeb.Live.ChangeDomain do</:item><:item>Return to- <.styled_link href={Routes.site_path(@socket, :settings_general, @site.domain)}>+ <.styled_link href={~p"/#{@site.domain}/settings/general"}>Site Settings</.styled_link></:item>@@ -125,7 +124,7 @@ defmodule PlausibleWeb.Live.ChangeDomain do</:item><:item>Return to- <.styled_link href={Routes.site_path(@socket, :settings_general, @site.domain)}>+ <.styled_link href={~p"/#{@site.domain}/settings/general"}>Site Settings</.styled_link></:item>@@ -242,7 +241,7 @@ defmodule PlausibleWeb.Live.ChangeDomain docontinuous tracking. The easiest way to fix that is to simply follow your<.styled_linknew_tab- href={Routes.site_path(PlausibleWeb.Endpoint, :installation, @site.domain)}+ href={~p"/#{@site.domain}/installation"}>installation instructions</.styled_link>@@ -320,6 +319,6 @@ defmodule PlausibleWeb.Live.ChangeDomain do{:noreply,socket|> assign(site: updated_site)- |> push_patch(to: Routes.site_path(socket, :success, updated_site.domain))}+ |> push_patch(to: ~p"/#{updated_site.domain}/change-domain/success")}endenddiff --git a/lib/plausible_web/live/change_domain/form.ex b/lib/plausible_web/live/change_domain/form.exindex 231b62901d..20c2bcf326 100644--- a/lib/plausible_web/live/change_domain/form.ex+++ b/lib/plausible_web/live/change_domain/form.ex@@ -35,7 +35,7 @@ defmodule PlausibleWeb.Live.ChangeDomain.Form doclass="mt-1 flex text-sm text-red-500 leading-4.5 text-pretty">You already own this site. See its - <.styled_link href={Routes.site_path(@socket, :settings_general, @already_owned_domain)}>+ <.styled_link href={~p"/#{@already_owned_domain}/settings/general"}>settings</.styled_link></p>diff --git a/lib/plausible_web/live/choose_plan.ex b/lib/plausible_web/live/choose_plan.exindex 4dc2b0c253..9c5e477cfe 100644--- a/lib/plausible_web/live/choose_plan.ex+++ b/lib/plausible_web/live/choose_plan.ex@@ -6,7 +6,6 @@ defmodule PlausibleWeb.Live.ChoosePlan doalias PlausibleWeb.Components.Billing.{PlanBox, Notice, PageviewSlider}alias Plausible.Billing.{Plans, Quota, PlanBenefits}- alias PlausibleWeb.Router.Helpers, as: Routes@contact_link "https://plausible.io/contact"@billing_faq_link "https://plausible.io/docs/billing"@@ -142,7 +141,7 @@ defmodule PlausibleWeb.Live.ChoosePlan do<div class="mt-6 w-full md:flex"><a- href={Routes.settings_path(PlausibleWeb.Endpoint, :subscription)}+ href={~p"/settings/billing/subscription"}class="hidden md:flex md:w-1/6 h-max md:mt-2 text-indigo-600 hover:text-indigo-700 dark:text-indigo-500 dark:hover:text-indigo-400 text-sm font-semibold gap-1 items-center transition-colors duration-150"><span>←</span>@@ -161,7 +160,7 @@ defmodule PlausibleWeb.Live.ChoosePlan do</div><div class="md:hidden mt-6 max-w-md mx-auto"><a- href={Routes.settings_path(PlausibleWeb.Endpoint, :subscription)}+ href={~p"/settings/billing/subscription"}class="text-indigo-600 hover:text-indigo-700 dark:text-indigo-500 dark:hover:text-indigo-600 text-sm font-semibold">← Back to settings@@ -256,7 +255,7 @@ defmodule PlausibleWeb.Live.ChoosePlan doPlease see your full usage report (including sites and team members) under the<aclass="inline font-medium text-indigo-600 dark:text-indigo-500 hover:text-indigo-700 dark:hover:text-indigo-400 transition-colors duration-150"- href={Routes.settings_path(PlausibleWeb.Endpoint, :subscription)}+ href={~p"/settings/billing/subscription"}>"Subscription" section</a>diff --git a/lib/plausible_web/live/components/verification_banner.ex b/lib/plausible_web/live/components/verification_banner.exindex 6920bf84b3..6083eb5aea 100644--- a/lib/plausible_web/live/components/verification_banner.ex+++ b/lib/plausible_web/live/components/verification_banner.ex@@ -6,8 +6,9 @@ defmodule PlausibleWeb.Live.Components.VerificationBanner douse Phoenix.LiveComponentuse Plausible+ use PlausibleWeb.VerifiedRoutes+alias Phoenix.LiveView.JS- alias PlausibleWeb.Router.Helpers, as: Routesalias Plausible.InstallationSupport.{State, Result}import PlausibleWeb.Components.Generic@@ -198,12 +199,7 @@ defmodule PlausibleWeb.Live.Components.VerificationBanner do<.button_link:if={not @offer_custom_url_input?}mt?={false}- href={- Routes.site_path(PlausibleWeb.Endpoint, :installation, @domain,- flow: @flow,- return_to: "dashboard"- )- }+ href={~p"/#{@domain}/installation?#{[flow: @flow, return_to: "dashboard"]}"}theme="ghost"size="sm"class="hover:bg-gray-600/10 dark:hover:bg-white/10 hover:border-transparent dark:hover:border-transparent"@@ -270,10 +266,7 @@ defmodule PlausibleWeb.Live.Components.VerificationBanner dodefp review_installation_link_sentence(assigns) doreview_installation_url =- Routes.site_path(PlausibleWeb.Endpoint, :installation, assigns.domain,- flow: assigns.flow,- return_to: "dashboard"- )+ ~p"/#{assigns.domain}/installation?#{[flow: assigns.flow, return_to: "dashboard"]}"render_recommendation("See your installation instructions again here", [%{text: "here", href: review_installation_url}diff --git a/lib/plausible_web/live/csv_export.ex b/lib/plausible_web/live/csv_export.exindex a83d19f8b3..97cb6f8c99 100644--- a/lib/plausible_web/live/csv_export.ex+++ b/lib/plausible_web/live/csv_export.ex@@ -107,7 +107,7 @@ defmodule PlausibleWeb.Live.CSVExport do<.downloadstorage={@storage}export={@export}- href={Routes.site_path(@socket, :download_export, @site.domain)}+ href={~p"/#{@site.domain}/download/export"}/><% end %>"""@@ -227,9 +227,7 @@ defmodule PlausibleWeb.Live.CSVExport do{:error, :no_data} ->socket|> put_flash(:error, "There is no data to export")- |> redirect(- to: Routes.site_path(socket, :settings_imports_exports, socket.assigns.site.domain)- )+ |> redirect(to: ~p"/#{socket.assigns.site.domain}/settings/imports-exports")end{:noreply, socket}diff --git a/lib/plausible_web/live/csv_import.ex b/lib/plausible_web/live/csv_import.exindex 1dfc899a4d..64c47dca1d 100644--- a/lib/plausible_web/live/csv_import.ex+++ b/lib/plausible_web/live/csv_import.ex@@ -221,7 +221,7 @@ defmodule PlausibleWeb.Live.CSVImport do)redirect_to =- Routes.site_path(socket, :settings_imports_exports, site.domain)+ ~p"/#{site.domain}/settings/imports-exports"{:noreply, redirect(socket, to: redirect_to)}enddiff --git a/lib/plausible_web/live/goal_settings.ex b/lib/plausible_web/live/goal_settings.exindex 457502db67..002c3e36c5 100644--- a/lib/plausible_web/live/goal_settings.ex+++ b/lib/plausible_web/live/goal_settings.ex@@ -81,7 +81,7 @@ defmodule PlausibleWeb.Live.GoalSettings do<%= on_ee do %><p :if={Plausible.Sites.regular?(@site)} data-test-id="setup-funnels-cta">You can also- <.styled_link href={Routes.site_path(@socket, :settings_funnels, @domain)}>+ <.styled_link href={~p"/#{@domain}/settings/funnels"}>compose goals into funnels.</.styled_link></p>diff --git a/lib/plausible_web/live/goal_settings/list.ex b/lib/plausible_web/live/goal_settings/list.exindex 2b3f6924ce..af4e94fd28 100644--- a/lib/plausible_web/live/goal_settings/list.ex+++ b/lib/plausible_web/live/goal_settings/list.ex@@ -86,7 +86,7 @@ defmodule PlausibleWeb.Live.GoalSettings.List do</:tooltip_content><.styled_linkclass="w-max flex items-center text-sm"- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}+ href={~p"/billing/choose-plan"}data-test-id="feature-unavailable-cta"><Heroicons.lock_closed class="size-3.5 mr-1 stroke-2" /> Upgradediff --git a/lib/plausible_web/live/installation.ex b/lib/plausible_web/live/installation.exindex 28b9d100a5..b5870bd8b1 100644--- a/lib/plausible_web/live/installation.ex+++ b/lib/plausible_web/live/installation.ex@@ -364,20 +364,16 @@ defmodule PlausibleWeb.Live.Installation docond doassigns.return_to == "dashboard" ->{"Back to dashboard",- Routes.stats_path(PlausibleWeb.Endpoint, :stats, assigns.domain,- verify_installation: true,- flow: assigns.flow- )}+ stats_path(assigns.domain, verify_installation: true, flow: assigns.flow)}assigns.flow == Flows.review() ->- {"Back to settings",- Routes.site_path(PlausibleWeb.Endpoint, :settings_general, assigns.domain)}+ {"Back to settings", ~p"/#{assigns.domain}/settings/general"}assigns.flow == Flows.provisioning() ->- {"Back to sites", Routes.site_path(PlausibleWeb.Endpoint, :index)}+ {"Back to sites", ~p"/sites"}true ->- {"Skip", Routes.site_path(PlausibleWeb.Endpoint, :index)}+ {"Skip", ~p"/sites"}endassigns = assign(assigns, label: label, href: href)@@ -420,12 +416,9 @@ defmodule PlausibleWeb.Live.Installation dodestination =on_ee do- Routes.stats_path(socket, :stats, domain,- verify_installation: true,- flow: socket.assigns.flow- )+ stats_path(domain, verify_installation: true, flow: socket.assigns.flow)else- Routes.stats_path(socket, :stats, domain, [])+ stats_path(domain)end{:noreply, redirect(socket, to: destination)}diff --git a/lib/plausible_web/live/register_form.ex b/lib/plausible_web/live/register_form.exindex e28e9c041b..c2175a5abf 100644--- a/lib/plausible_web/live/register_form.ex+++ b/lib/plausible_web/live/register_form.ex@@ -80,7 +80,7 @@ defmodule PlausibleWeb.Live.RegisterForm dofor={@form}id="register-form"class="flex flex-col gap-y-6"- action={Routes.auth_path(@socket, :login)}+ action={~p"/login"}onsubmit={form_submit_event(@invitation, @signup_previous_error)}phx-change="validate"phx-submit="register"@@ -255,7 +255,7 @@ defmodule PlausibleWeb.Live.RegisterForm dosocket =socket|> put_flash(:error, message)- |> redirect(to: Routes.auth_path(socket, :login_form))+ |> redirect(to: ~p"/login"){:noreply, socket}end@@ -276,7 +276,7 @@ defmodule PlausibleWeb.Live.RegisterForm dosocket =socket|> put_flash(:error, message)- |> redirect(to: Routes.auth_path(socket, :login_form))+ |> redirect(to: ~p"/login"){:noreply, socket}enddiff --git a/lib/plausible_web/live/registration_context.ex b/lib/plausible_web/live/registration_context.exindex cf0b5cb2aa..62704b9754 100644--- a/lib/plausible_web/live/registration_context.ex+++ b/lib/plausible_web/live/registration_context.ex@@ -3,9 +3,9 @@ defmodule PlausibleWeb.Live.RegistrationContext doLive context toggling registration according to selfhosted state."""- import Phoenix.LiveView+ use PlausibleWeb.VerifiedRoutes- alias PlausibleWeb.Router.Helpers, as: Routes+ import Phoenix.LiveViewdef on_mount(context, _params, _session, socket) docase Plausible.Auth.check_registration_enabled(context) do@@ -16,7 +16,7 @@ defmodule PlausibleWeb.Live.RegistrationContext dosocket =socket|> put_flash(:error, message)- |> redirect(to: Routes.auth_path(socket, :login_form))+ |> redirect(to: ~p"/login"){:halt, socket}enddiff --git a/lib/plausible_web/live/site_transfer_settings.ex b/lib/plausible_web/live/site_transfer_settings.exindex 86adf458cd..cc0a791d15 100644--- a/lib/plausible_web/live/site_transfer_settings.ex+++ b/lib/plausible_web/live/site_transfer_settings.ex@@ -11,7 +11,6 @@ defmodule PlausibleWeb.Live.SiteTransferSettings doalias Plausible.Teamsalias PlausibleWeb.Live.SiteTransferSettings.Form- alias PlausibleWeb.Router.Helpers, as: Routesdef mount(_params, %{"domain" => domain}, socket) douser = socket.assigns.current_user@@ -39,13 +38,10 @@ defmodule PlausibleWeb.Live.SiteTransferSettings do{"The site is already in your personal sites.", nil}is_nil(my_team) ->- {"You don't have an active subscription.",- Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan) <> "?__team=none"}+ {"You don't have an active subscription.", ~p"/billing/choose-plan?#{[__team: "none"]}"}true ->- {nil,- Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan) <>- "?__team=#{my_team.identifier}"}+ {nil, ~p"/billing/choose-plan?#{[__team: my_team.identifier]}"}endinitial_destination =@@ -244,7 +240,7 @@ defmodule PlausibleWeb.Live.SiteTransferSettings do{:noreply,socket|> put_flash(:success, "Site team was changed")- |> redirect(to: Routes.site_path(socket, :index, __team: destination_team.identifier))}+ |> redirect(to: ~p"/sites?#{[__team: destination_team.identifier]}")}{:error, :no_plan} when my_team? ->{:noreply,@@ -277,7 +273,7 @@ defmodule PlausibleWeb.Live.SiteTransferSettings do{:noreply,socket|> put_flash(:success, "Site transfer request has been sent to #{email}")- |> redirect(to: Routes.site_path(socket, :settings_people, site.domain))}+ |> redirect(to: ~p"/#{site.domain}/settings/people")}{:error, %Ecto.Changeset{} = changeset} ->message =diff --git a/lib/plausible_web/live/sites.ex b/lib/plausible_web/live/sites.exindex 1dc3d950cb..fee9e193c2 100644--- a/lib/plausible_web/live/sites.ex+++ b/lib/plausible_web/live/sites.ex@@ -122,7 +122,7 @@ defmodule PlausibleWeb.Live.Sites do<.unstyled_link:if={Teams.setup?(@current_team)}data-test-id="team-settings-link"- href={Routes.settings_path(@socket, :team_general)}+ href={~p"/settings/team/general"}class="shrink-0"><Heroicons.cog_6_tooth class="hidden group-hover:inline size-5 dark:text-gray-100 text-gray-900" />@@ -150,7 +150,7 @@ defmodule PlausibleWeb.Live.Sites do<PrimaDropdown.dropdown_itemas={&link/1}id="add-site-dropdown-menuitem-1"- href={Routes.site_path(@socket, :new, %{flow: PlausibleWeb.Flows.provisioning()})}+ href={~p"/sites/new?#{[flow: PlausibleWeb.Flows.provisioning()]}"}><Heroicons.plus class={PrimaDropdown.dropdown_item_icon_class()} /> Add website</PrimaDropdown.dropdown_item>@@ -166,7 +166,7 @@ defmodule PlausibleWeb.Live.Sites do<.button_link:if={!@consolidated_view_cta_dismissed?}- href={"/sites/new?flow=#{PlausibleWeb.Flows.provisioning()}"}+ href={~p"/sites/new?#{[flow: PlausibleWeb.Flows.provisioning()]}"}mt?={false}><Heroicons.plus class="size-4" /> Add website@@ -206,7 +206,7 @@ defmodule PlausibleWeb.Live.Sites do</.button_link><.button_link:if={not Teams.setup?(@current_team) and @has_sites? and length(@teams) == 1}- href={Routes.site_path(@socket, :index, __team: hd(@teams).identifier)}+ href={~p"/sites?#{[__team: hd(@teams).identifier]}"}theme="secondary"mt?={false}>@@ -227,7 +227,7 @@ defmodule PlausibleWeb.Live.Sites do:for={team <- @teams}as={&link/1}id={"go-to-team-dropdown-menuitem-#{team.identifier}"}- href={Routes.site_path(@socket, :index, __team: team.identifier)}+ href={~p"/sites?#{[__team: team.identifier]}"}>{Teams.name(team)}</PrimaDropdown.dropdown_item>@@ -269,7 +269,7 @@ defmodule PlausibleWeb.Live.Sites do<.pagination:if={@sites.total_pages > 1}id="sites-pagination"- uri={URI.new!(Routes.site_path(@socket, :index, @uri_params))}+ uri={URI.new!(~p"/sites?#{@uri_params}")}page_number={@sites.page_number}total_pages={@sites.total_pages}>@@ -310,7 +310,7 @@ defmodule PlausibleWeb.Live.Sites do<div class="mt-1 text-sm text-gray-900/80 dark:text-gray-100/60"><p>To access the sites you own, you need to subscribe to a monthly or yearly payment plan.- <.styled_link href={Routes.settings_path(PlausibleWeb.Endpoint, :subscription)}>+ <.styled_link href={~p"/settings/billing/subscription"}>Upgrade now →</.styled_link></p>@@ -345,7 +345,7 @@ defmodule PlausibleWeb.Live.Sites do</p><div class="flex gap-x-2"><.button_link- href={Routes.team_setup_path(PlausibleWeb.Endpoint, :setup)}+ href={~p"/team/setup"}mt?={false}>Create team@@ -381,7 +381,7 @@ defmodule PlausibleWeb.Live.Sites do<div class="flex gap-x-2"><.button_link:if={@can_manage_consolidated_view?}- href={PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)}+ href={url(~p"/billing/choose-plan")}mt?={false}>Upgrade@@ -437,7 +437,7 @@ defmodule PlausibleWeb.Live.Sites doclass="relative row-span-2"><.unstyled_link- href={Routes.stats_path(PlausibleWeb.Endpoint, :stats, @consolidated_view.domain, [])}+ href={stats_path(@consolidated_view.domain)}class="flex flex-col justify-between gap-6 h-full bg-white p-5 dark:bg-gray-900 rounded-md shadow-sm cursor-pointer hover:shadow-md transition-shadow duration-150"><div class="flex flex-col flex-1 justify-between gap-y-5">@@ -561,9 +561,7 @@ defmodule PlausibleWeb.Live.Sites do><.unstyled_linkhref={- Routes.stats_path(- PlausibleWeb.Endpoint,- :stats,+ stats_path(@site.domain,if(@needs_verification?,do: [verify_installation: true, flow: PlausibleWeb.Flows.provisioning()],@@ -638,7 +636,7 @@ defmodule PlausibleWeb.Live.Sites do:if={@can_manage?}id={"#{@dropdown_id}-item-1"}as={&link/1}- href={Routes.site_path(PlausibleWeb.Endpoint, :settings_general, @site.domain)}+ href={~p"/#{@site.domain}/settings/general"}><Heroicons.cog_6_tooth class={PrimaDropdown.dropdown_item_icon_class()} /> Settings</PrimaDropdown.dropdown_item>@@ -1030,7 +1028,7 @@ defmodule PlausibleWeb.Live.Sites dosocket|> assign(:uri_params, uri_params)|> assign(:filter_text, trimmed)- |> push_patch(to: Routes.site_path(socket, :index, uri_params), replace: true)+ |> push_patch(to: ~p"/sites?#{uri_params}", replace: true)enddefp reset_pagination(socket) do@@ -1054,7 +1052,7 @@ defmodule PlausibleWeb.Live.Sites dosocket|> assign(:uri_params, uri_params)- |> push_patch(to: Routes.site_path(socket, :index, uri_params), replace: true)+ |> push_patch(to: ~p"/sites?#{uri_params}", replace: true)enddefp hash_domain(domain) dodiff --git a/lib/plausible_web/live/subscription_settings.ex b/lib/plausible_web/live/subscription_settings.exindex ea3ada30a6..889b0d53ba 100644--- a/lib/plausible_web/live/subscription_settings.ex+++ b/lib/plausible_web/live/subscription_settings.ex@@ -10,14 +10,13 @@ defmodule PlausibleWeb.Live.SubscriptionSettings doimport PlausibleWeb.Components.Billing.Helpersalias Plausible.Teams- alias PlausibleWeb.Router.Helpers, as: Routesdef mount(_params, _session, socket) doteam = socket.assigns.current_teamif Teams.setup?(team) &&socket.assigns.current_team_role not in Plausible.Billing.allowed_roles() do- {:ok, redirect(socket, to: Routes.site_path(socket, :index))}+ {:ok, redirect(socket, to: ~p"/sites")}elsesubscription = Teams.Billing.get_subscription(team)invoices = Plausible.Billing.paddle_api().get_invoices(subscription)@@ -80,7 +79,7 @@ defmodule PlausibleWeb.Live.SubscriptionSettings do</p></div><.button_link- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}+ href={~p"/billing/choose-plan"}mt?={false}id="upgrade-or-change-plan-link">@@ -136,7 +135,7 @@ defmodule PlausibleWeb.Live.SubscriptionSettings donot (Plausible.Teams.Billing.enterprise_configured?(@current_team) &&Plausible.Billing.Subscriptions.halted?(@subscription))}- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}+ href={~p"/billing/choose-plan"}mt?={false}id="upgrade-or-change-plan-link">diff --git a/lib/plausible_web/live/team_management.ex b/lib/plausible_web/live/team_management.exindex 196d650193..7441d7c7bb 100644--- a/lib/plausible_web/live/team_management.ex+++ b/lib/plausible_web/live/team_management.ex@@ -225,14 +225,14 @@ defmodule PlausibleWeb.Live.TeamManagement docase Teams.Memberships.team_role(current_team, current_user) do{:ok, role} when role in [:viewer, :billing, :editor] ->redirect(socket,- to: Routes.settings_path(socket, :team_general, __team: current_team.identifier)+ to: ~p"/settings/team/general?#{[__team: current_team.identifier]}"){:ok, _} ->reset(socket){:error, :not_a_member} ->- redirect(socket, to: Routes.site_path(socket, :index, __team: "none"))+ redirect(socket, to: ~p"/sites?#{[__team: "none"]}")end{:error, :permission_denied} ->diff --git a/lib/plausible_web/live/team_setup.ex b/lib/plausible_web/live/team_setup.exindex 4c61c4cc69..47068dd575 100644--- a/lib/plausible_web/live/team_setup.ex+++ b/lib/plausible_web/live/team_setup.ex@@ -7,7 +7,6 @@ defmodule PlausibleWeb.Live.TeamSetup doalias Plausible.Teamsalias Plausible.Teams.Management.Layout- alias PlausibleWeb.Router.Helpers, as: Routesdef mount(_params, _session, socket) dosocket =@@ -15,7 +14,7 @@ defmodule PlausibleWeb.Live.TeamSetup do%Teams.Team{setup_complete: true} ->socket|> put_flash(:success, "Your team has already been created")- |> redirect(to: Routes.settings_path(socket, :team_general))+ |> redirect(to: ~p"/settings/team/general")%Teams.Team{} = team ->suggested_name = Teams.Team.suggested_name(socket.assigns.current_user.name)@@ -31,7 +30,7 @@ defmodule PlausibleWeb.Live.TeamSetup do_ ->socket|> put_flash(:error, "You cannot create any team just yet")- |> redirect(to: Routes.site_path(socket, :index))+ |> redirect(to: ~p"/sites")end{:ok, socket}@@ -231,10 +230,7 @@ defmodule PlausibleWeb.Live.TeamSetup dosocket|> put_flash(:success, "Your team is now created")|> redirect(- to:- Routes.settings_path(socket, :team_general,- __team: socket.assigns.current_team.identifier- )+ to: ~p"/settings/team/general?#{[__team: socket.assigns.current_team.identifier]}")}{:error, {:over_limit, limit}} ->diff --git a/lib/plausible_web/live/tracking_settings.ex b/lib/plausible_web/live/tracking_settings.exindex d6c4992464..c2dabffe8e 100644--- a/lib/plausible_web/live/tracking_settings.ex+++ b/lib/plausible_web/live/tracking_settings.ex@@ -202,9 +202,7 @@ defmodule PlausibleWeb.Live.TrackingSettings doenddefp review_installation_path(site) do- Routes.site_path(PlausibleWeb.Endpoint, :installation, site.domain,- flow: PlausibleWeb.Flows.review()- )+ ~p"/#{site.domain}/installation?#{[flow: PlausibleWeb.Flows.review()]}"endon_ee dodiff --git a/lib/plausible_web/mjml/stats_report.ex b/lib/plausible_web/mjml/stats_report.exindex 5f049e5af3..12147e30e6 100644--- a/lib/plausible_web/mjml/stats_report.ex+++ b/lib/plausible_web/mjml/stats_report.ex@@ -3,5 +3,6 @@ defmodule PlausibleWeb.MJML.StatsReport doMJML rendered for the weekly or monthly report e-mail"""+ use PlausibleWeb.VerifiedRoutesuse MjmlEEx, mjml_template: "templates/stats_report.mjml.eex"enddiff --git a/lib/plausible_web/mjml/templates/stats_report.mjml.eex b/lib/plausible_web/mjml/templates/stats_report.mjml.eexindex 33f4f96e10..8d4fe1f18e 100644--- a/lib/plausible_web/mjml/templates/stats_report.mjml.eex+++ b/lib/plausible_web/mjml/templates/stats_report.mjml.eex@@ -213,7 +213,7 @@<%= if @site_member? do %><mj-section><mj-column>- <mj-button href="<%= PlausibleWeb.Router.Helpers.auth_url(PlausibleWeb.Endpoint, :login_form) %>">+ <mj-button href="<%= url(~p"/login") %>">Login to view your dashboard</mj-button></mj-column>diff --git a/lib/plausible_web/plugins/api/controllers/goals.ex b/lib/plausible_web/plugins/api/controllers/goals.exindex 066a999886..9b0d87ab8d 100644--- a/lib/plausible_web/plugins/api/controllers/goals.ex+++ b/lib/plausible_web/plugins/api/controllers/goals.ex@@ -32,7 +32,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.Goals docase API.Goals.create(site, goal_or_goals) do{:ok, goals} ->location_headers =- Enum.map(goals, &{"location", plugins_api_goals_url(conn, :get, &1.id)})+ Enum.map(goals, &{"location", url(~p"/api/plugins/v1/goals/#{&1.id}")})conn|> prepend_resp_headers(location_headers)diff --git a/lib/plausible_web/plugins/api/controllers/shared_links.ex b/lib/plausible_web/plugins/api/controllers/shared_links.exindex 55b0ea8536..2deaa77fa8 100644--- a/lib/plausible_web/plugins/api/controllers/shared_links.ex+++ b/lib/plausible_web/plugins/api/controllers/shared_links.ex@@ -66,7 +66,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinks doconn|> put_view(Views.SharedLink)|> put_status(:created)- |> put_resp_header("location", plugins_api_shared_links_url(conn, :get, shared_link.id))+ |> put_resp_header("location", url(~p"/api/plugins/v1/shared_links/#{shared_link.id}"))|> render("shared_link.json", shared_link: shared_link, authorized_site: site)enddiff --git a/lib/plausible_web/plugins/api/views/goal.ex b/lib/plausible_web/plugins/api/views/goal.exindex 07e5a6f010..346a015054 100644--- a/lib/plausible_web/plugins/api/views/goal.ex+++ b/lib/plausible_web/plugins/api/views/goal.ex@@ -12,7 +12,12 @@ defmodule PlausibleWeb.Plugins.API.Views.Goal do}) do%{goals: render_many(goals, __MODULE__, "goal.json", authorized_site: site, as: :goal),- meta: render_metadata_links(metadata, :plugins_api_goals_url, :index, conn.query_params)+ meta:+ render_metadata_links(+ metadata,+ fn params -> url(~p"/api/plugins/v1/goals?#{params}") end,+ conn.query_params+ )}end@@ -23,7 +28,12 @@ defmodule PlausibleWeb.Plugins.API.Views.Goal do}) do%{goals: render_many(goals, __MODULE__, "goal.json", authorized_site: site, as: :goal),- meta: render_metadata_links(%{}, :plugins_api_goals_url, :index, conn.query_params)+ meta:+ render_metadata_links(+ %{},+ fn params -> url(~p"/api/plugins/v1/goals?#{params}") end,+ conn.query_params+ )}enddiff --git a/lib/plausible_web/plugins/api/views/pagination.ex b/lib/plausible_web/plugins/api/views/pagination.exindex b539b12160..b00254342c 100644--- a/lib/plausible_web/plugins/api/views/pagination.ex+++ b/lib/plausible_web/plugins/api/views/pagination.ex@@ -7,9 +7,7 @@ defmodule PlausibleWeb.Plugins.API.Views.Pagination donamespace: PlausibleWeb.Plugins.API,root: ""- alias PlausibleWeb.Router.Helpers-- def render_metadata_links(meta, helper_fn, helper_fn_args, existing_params \\ %{}) do+ def render_metadata_links(meta, route_fn, existing_params \\ %{}) dorender(__MODULE__, "pagination.json", %{meta: meta,url_helper: fn query_params ->@@ -19,13 +17,9 @@ defmodule PlausibleWeb.Plugins.API.Views.Pagination doquery_params|> Enum.into(%{})|> Map.merge(existing_params)+ |> Map.to_list()- args = [- PlausibleWeb.Endpoint- | List.wrap(helper_fn_args) ++ [query_params]- ]-- apply(Helpers, helper_fn, args)+ route_fn.(query_params)end})enddiff --git a/lib/plausible_web/plugins/api/views/shared_link.ex b/lib/plausible_web/plugins/api/views/shared_link.exindex f007055fae..cbdfb622dc 100644--- a/lib/plausible_web/plugins/api/views/shared_link.ex+++ b/lib/plausible_web/plugins/api/views/shared_link.ex@@ -17,7 +17,11 @@ defmodule PlausibleWeb.Plugins.API.Views.SharedLink doas: :shared_link),meta:- render_metadata_links(metadata, :plugins_api_shared_links_url, :index, conn.query_params)+ render_metadata_links(+ metadata,+ fn params -> url(~p"/api/plugins/v1/shared_links?#{params}") end,+ conn.query_params+ )}enddiff --git a/lib/plausible_web/plugs/authorize_team_access.ex b/lib/plausible_web/plugs/authorize_team_access.exindex cf260e9a27..cf0c45a3f1 100644--- a/lib/plausible_web/plugs/authorize_team_access.ex+++ b/lib/plausible_web/plugs/authorize_team_access.ex@@ -7,7 +7,7 @@ defmodule Plausible.Plugs.AuthorizeTeamAccess doso that existing notices can be displayed still."""- alias PlausibleWeb.Router.Helpers, as: Routes+ use PlausibleWeb.VerifiedRoutesimport Plug.Conn@@ -30,7 +30,7 @@ defmodule Plausible.Plugs.AuthorizeTeamAccess doconnelseconn- |> Phoenix.Controller.redirect(to: Routes.site_path(conn, :index))+ |> Phoenix.Controller.redirect(to: ~p"/sites")|> halt()endelsediff --git a/lib/plausible_web/plugs/maybe_disable_registration.ex b/lib/plausible_web/plugs/maybe_disable_registration.exindex d578d3d018..84fdb4952c 100644--- a/lib/plausible_web/plugs/maybe_disable_registration.ex+++ b/lib/plausible_web/plugs/maybe_disable_registration.ex@@ -3,11 +3,11 @@ defmodule PlausibleWeb.Plugs.MaybeDisableRegistration doPlug toggling registration according to selfhosted state."""+ use PlausibleWeb.VerifiedRoutes+import Phoenix.Controllerimport Plug.Conn- alias PlausibleWeb.Router.Helpers, as: Routes-def init(opts) dooptsend@@ -20,7 +20,7 @@ defmodule PlausibleWeb.Plugs.MaybeDisableRegistration do{:error, _, message} ->conn|> put_flash(:error, message)- |> redirect(to: Routes.auth_path(conn, :login_form))+ |> redirect(to: ~p"/login")|> halt()endenddiff --git a/lib/plausible_web/plugs/require_account.ex b/lib/plausible_web/plugs/require_account.exindex 7ab0a83591..67fa0848df 100644--- a/lib/plausible_web/plugs/require_account.ex+++ b/lib/plausible_web/plugs/require_account.ex@@ -1,7 +1,8 @@defmodule PlausibleWeb.RequireAccountPlug do@moduledoc false- alias PlausibleWeb.Router.Helpers, as: Routes+ use PlausibleWeb.VerifiedRoutes+import Plug.Conn@unverified_email_exceptions [@@ -55,7 +56,7 @@ defmodule PlausibleWeb.RequireAccountPlug doif conn.path_info not in @force_2fa_exceptions and must_enable_2fa?(user, team) doconn- |> Phoenix.Controller.redirect(to: Routes.auth_path(conn, :force_initiate_2fa_setup))+ |> Phoenix.Controller.redirect(to: ~p"/2fa/setup/force-initiate")|> halt()elseconn@@ -70,10 +71,10 @@ defmodule PlausibleWeb.RequireAccountPlug doconn.request_pathend- Routes.auth_path(conn, :login_form, return_to: return_to)+ ~p"/login?#{[return_to: return_to]}"end- defp redirect_to(conn), do: Routes.auth_path(conn, :login_form)+ defp redirect_to(_conn), do: ~p"/login"defp must_enable_2fa?(user, team) when is_nil(user) or is_nil(team), do: falsediff --git a/lib/plausible_web/plugs/restrict_user_type.ex b/lib/plausible_web/plugs/restrict_user_type.exindex 8b1c2a055d..155e4d7542 100644--- a/lib/plausible_web/plugs/restrict_user_type.ex+++ b/lib/plausible_web/plugs/restrict_user_type.ex@@ -3,9 +3,9 @@ defmodule Plausible.Plugs.RestrictUserType doPlug for restricting user access by type."""- import Plug.Conn+ use PlausibleWeb.VerifiedRoutes- alias PlausibleWeb.Router.Helpers, as: Routes+ import Plug.Conndef init(opts) doKeyword.fetch!(opts, :deny)@@ -16,7 +16,7 @@ defmodule Plausible.Plugs.RestrictUserType doif user && Plausible.Users.type(user) == deny_type doconn- |> Phoenix.Controller.redirect(to: Routes.site_path(conn, :index))+ |> Phoenix.Controller.redirect(to: ~p"/sites")|> halt()elseconndiff --git a/lib/plausible_web/plugs/sso_team_access.ex b/lib/plausible_web/plugs/sso_team_access.exindex 1d917f39fd..964dda34e7 100644--- a/lib/plausible_web/plugs/sso_team_access.ex+++ b/lib/plausible_web/plugs/sso_team_access.ex@@ -14,7 +14,7 @@ defmodule Plausible.Plugs.SSOTeamAccess doimport Phoenix.Controller, only: [redirect: 2]import Plug.Conn- alias PlausibleWeb.Router.Helpers, as: Routes+ use PlausibleWeb.VerifiedRoutesdef call(conn, _opts) docurrent_user = conn.assigns[:current_user]@@ -37,10 +37,10 @@ defmodule Plausible.Plugs.SSOTeamAccess doconn =case Plausible.Auth.SSO.check_ready_to_provision(user, team) do:ok ->- redirect(conn, to: Routes.sso_path(conn, :provision_notice))+ redirect(conn, to: ~p"/sso/notice"){:error, issue} ->- redirect(conn, to: Routes.sso_path(conn, :provision_issue, issue: issue))+ redirect(conn, to: ~p"/sso/issue?#{[issue: issue]}")endhalt(conn)diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.exindex 127038318b..d34baef1cf 100644--- a/lib/plausible_web/router.ex+++ b/lib/plausible_web/router.ex@@ -505,8 +505,8 @@ defmodule PlausibleWeb.Router doscope "/", PlausibleWeb dopipe_through [:shared_link]- get "/share/:domain/*path", StatsController, :shared_linkpost "/share/:slug/authenticate", StatsController, :authenticate_shared_link+ get "/share/:domain/*path", StatsController, :shared_link, warn_on_verify: trueendscope "/settings", PlausibleWeb do@@ -668,7 +668,7 @@ defmodule PlausibleWeb.Router doput "/:domain/settings/google", SiteController, :update_google_authdelete "/:domain/settings/google-search", SiteController, :delete_google_authdelete "/:domain/settings/google-import", SiteController, :delete_google_auth- delete "/:domain", SiteController, :delete_site+ delete "/:domain", SiteController, :delete_site, warn_on_verify: truedelete "/:domain/stats", SiteController, :reset_statsget "/:domain/import/google-analytics/property",@@ -741,8 +741,8 @@ defmodule PlausibleWeb.Router doput "/:domain/settings", SiteController, :update_settings- get "/:domain", StatsController, :stats- get "/:domain/*path", StatsController, :stats+ get "/:domain", StatsController, :stats, warn_on_verify: true+ get "/:domain/*path", StatsController, :stats, warn_on_verify: trueendendenddiff --git a/lib/plausible_web/templates/auth/activate.html.heex b/lib/plausible_web/templates/auth/activate.html.heexindex 67b61d6e01..9e709ce659 100644--- a/lib/plausible_web/templates/auth/activate.html.heex+++ b/lib/plausible_web/templates/auth/activate.html.heex@@ -37,7 +37,7 @@<.styled_link href="/activate/request-code" method="post">Resend code</.styled_link>or<%= if @has_any_memberships? do %>- <.styled_link method="post" href={Routes.settings_path(@conn, :cancel_update_email)}>+ <.styled_link method="post" href={~p"/settings/security/email/cancel"}>use my previous email</.styled_link><% else %>@@ -75,7 +75,7 @@<p class="mt-6 text-sm text-gray-500 dark:text-gray-400 text-center">Wrong email?<%= if @has_any_memberships? do %>- <.styled_link method="post" href={Routes.settings_path(@conn, :cancel_update_email)}>+ <.styled_link method="post" href={~p"/settings/security/email/cancel"}>use my previous email</.styled_link><% else %>diff --git a/lib/plausible_web/templates/auth/force_initiate_2fa_setup.html.heex b/lib/plausible_web/templates/auth/force_initiate_2fa_setup.html.heexindex 562f84b97c..7533c25a2c 100644--- a/lib/plausible_web/templates/auth/force_initiate_2fa_setup.html.heex+++ b/lib/plausible_web/templates/auth/force_initiate_2fa_setup.html.heex@@ -18,7 +18,7 @@<div class="w-full"><.formid="initiate-2fa-form"- action={Routes.auth_path(@conn, :initiate_2fa_setup, force: "true")}+ action={~p"/2fa/setup/initiate?#{[force: "true"]}"}for={@conn.params}method="post">diff --git a/lib/plausible_web/templates/auth/generate_2fa_recovery_codes.html.heex b/lib/plausible_web/templates/auth/generate_2fa_recovery_codes.html.heexindex 760bd967b9..1759e6ba63 100644--- a/lib/plausible_web/templates/auth/generate_2fa_recovery_codes.html.heex+++ b/lib/plausible_web/templates/auth/generate_2fa_recovery_codes.html.heex@@ -40,7 +40,7 @@<buttonid="finish"class="button w-full mt-4"- onclick={"location.replace('#{Routes.settings_path(@conn, :security) <> "#update-2fa"}')"}+ onclick={"location.replace('#{~p"/settings/security#update-2fa"}')"}>Finish</button>diff --git a/lib/plausible_web/templates/auth/initiate_2fa_setup.html.heex b/lib/plausible_web/templates/auth/initiate_2fa_setup.html.heexindex 1b67b37db2..bddab2c899 100644--- a/lib/plausible_web/templates/auth/initiate_2fa_setup.html.heex+++ b/lib/plausible_web/templates/auth/initiate_2fa_setup.html.heex@@ -14,7 +14,7 @@<.focus_list><:item>Changed your mind?- <.styled_link href={Routes.settings_path(@conn, :security) <> "#update-2fa"}>+ <.styled_link href={~p"/settings/security#update-2fa"}>Go back to Settings</.styled_link></:item>@@ -57,7 +57,7 @@<.unstyled_linkid="proceed"class="button w-full"- href={Routes.auth_path(@conn, :verify_2fa_setup_form)}+ href={~p"/2fa/setup/verify"}>Proceed</.unstyled_link>diff --git a/lib/plausible_web/templates/auth/login_form.html.heex b/lib/plausible_web/templates/auth/login_form.html.heexindex f94fea8de9..b43698efd4 100644--- a/lib/plausible_web/templates/auth/login_form.html.heex+++ b/lib/plausible_web/templates/auth/login_form.html.heex@@ -60,10 +60,7 @@<span>Continue with<.styled_link href={- Routes.sso_path(@conn, :login_form,- return_to: @conn.params["return_to"],- prefer: "manual"- )+ ~p"/sso/login?#{[return_to: @conn.params["return_to"], prefer: "manual"]}"}>SSO</.styled_link>diff --git a/lib/plausible_web/templates/auth/password_reset_request_form.html.heex b/lib/plausible_web/templates/auth/password_reset_request_form.html.heexindex 22aa7c7fd2..4cc4b7a212 100644--- a/lib/plausible_web/templates/auth/password_reset_request_form.html.heex+++ b/lib/plausible_web/templates/auth/password_reset_request_form.html.heex@@ -6,7 +6,7 @@<.form:let={f}for={@conn}- action={Routes.auth_path(@conn, :password_reset_request)}+ action={~p"/password/request-reset"}class="flex flex-col gap-y-6"><div class="flex flex-col gap-y-2">diff --git a/lib/plausible_web/templates/auth/verify_2fa.html.heex b/lib/plausible_web/templates/auth/verify_2fa.html.heexindex ad59e8a5bc..6c7508990d 100644--- a/lib/plausible_web/templates/auth/verify_2fa.html.heex+++ b/lib/plausible_web/templates/auth/verify_2fa.html.heex@@ -5,7 +5,7 @@<.auth_container><.form:let={f}- action={Routes.auth_path(@conn, :verify_2fa, Map.take(@conn.query_params, ["return_to"]))}+ action={~p"/2fa/verify?#{[return_to: @conn.query_params["return_to"]]}"}for={@conn.params}class="flex flex-col gap-y-6"onsubmit="document.getElementById('verify-button').disabled = true"@@ -35,7 +35,7 @@<div class="mt-6 flex flex-col gap-y-2 text-sm text-gray-500 dark:text-gray-400 text-center"><p>Can't access your authenticator app?- <.styled_link href={Routes.auth_path(@conn, :verify_2fa_recovery_code_form)}>+ <.styled_link href={~p"/2fa/use_recovery_code"}>Use a recovery code</.styled_link></p>diff --git a/lib/plausible_web/templates/auth/verify_2fa_recovery_code.html.heex b/lib/plausible_web/templates/auth/verify_2fa_recovery_code.html.heexindex 6e5d1c784d..c47a2b8a71 100644--- a/lib/plausible_web/templates/auth/verify_2fa_recovery_code.html.heex+++ b/lib/plausible_web/templates/auth/verify_2fa_recovery_code.html.heex@@ -6,7 +6,7 @@<.form:let={f}for={@conn.params}- action={Routes.auth_path(@conn, :verify_2fa_recovery_code)}+ action={~p"/2fa/use_recovery_code"}class="flex flex-col gap-y-6"onsubmit="document.getElementById('use-code-button').disabled = true">@@ -45,7 +45,7 @@<div class="mt-6 flex flex-col gap-y-2 text-sm text-gray-500 dark:text-gray-400 text-center"><p>- <.styled_link href={Routes.auth_path(@conn, :verify_2fa)}>+ <.styled_link href={~p"/2fa/verify"}>Use authenticator app instead</.styled_link></p>diff --git a/lib/plausible_web/templates/auth/verify_2fa_setup.html.heex b/lib/plausible_web/templates/auth/verify_2fa_setup.html.heexindex 7c9c35b59e..0fe1f7bf66 100644--- a/lib/plausible_web/templates/auth/verify_2fa_setup.html.heex+++ b/lib/plausible_web/templates/auth/verify_2fa_setup.html.heex@@ -11,13 +11,13 @@<.focus_list><:item>Changed your mind?- <.styled_link href={Routes.settings_path(@conn, :security) <> "#update-2fa"}>+ <.styled_link href={~p"/settings/security#update-2fa"}>Go back to Settings</.styled_link></:item><:item>Having trouble?- <.styled_link method="post" href={Routes.auth_path(@conn, :initiate_2fa_setup)}>+ <.styled_link method="post" href={~p"/2fa/setup/initiate"}>Start over</.styled_link></:item>@@ -27,7 +27,7 @@<.form:let={f}for={@conn.params}- action={Routes.auth_path(@conn, :verify_2fa_setup)}+ action={~p"/2fa/setup/verify"}id="verify-2fa-form"onsubmit="document.getElementById('verify-button').disabled = true">diff --git a/lib/plausible_web/templates/billing/change_plan_preview.html.heex b/lib/plausible_web/templates/billing/change_plan_preview.html.heexindex 51b0024787..b9b62b984d 100644--- a/lib/plausible_web/templates/billing/change_plan_preview.html.heex+++ b/lib/plausible_web/templates/billing/change_plan_preview.html.heex@@ -86,7 +86,7 @@</span><span class="flex space-betwee rounded-md shadow-xs"><.button_link- href={Routes.billing_path(@conn, :change_plan, @preview_info["plan_id"])}+ href={~p"/billing/change-plan/#{@preview_info["plan_id"]}"}method="post">Confirm plan changediff --git a/lib/plausible_web/templates/billing/upgrade_success.html.heex b/lib/plausible_web/templates/billing/upgrade_success.html.heexindex 62ca21b86c..c3f17198a9 100644--- a/lib/plausible_web/templates/billing/upgrade_success.html.heex+++ b/lib/plausible_web/templates/billing/upgrade_success.html.heex@@ -19,8 +19,8 @@</div><script>- const PING_SUBSCRIPTION_API = "<%= Routes.billing_path(@conn, :ping_subscription) %>"- const REDIRECT_TO = "<%= Routes.settings_path(@conn, :subscription) %>"+ const PING_SUBSCRIPTION_API = "<%= ~p"/billing/subscription/ping" %>"+ const REDIRECT_TO = "<%= ~p"/settings/billing/subscription" %>"const PING_EVERY_MS = 2000const TIMEOUT_AFTER_MS = 15000diff --git a/lib/plausible_web/templates/billing/upgrade_to_enterprise_plan.html.heex b/lib/plausible_web/templates/billing/upgrade_to_enterprise_plan.html.heexindex e3cc10448e..4ea0b627bc 100644--- a/lib/plausible_web/templates/billing/upgrade_to_enterprise_plan.html.heex+++ b/lib/plausible_web/templates/billing/upgrade_to_enterprise_plan.html.heex@@ -41,13 +41,7 @@<span class="inline-flex w-full rounded-md shadow-xs"><.linkid="preview-changes"- href={- Routes.billing_path(- @conn,- :change_plan_preview,- @latest_enterprise_plan.paddle_plan_id- )- }+ href={~p"/billing/change-plan/preview/#{@latest_enterprise_plan.paddle_plan_id}"}class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-indigo-600 border border-transparent leading-5 rounded-md hover:bg-indigo-500 focus:outline-hidden focus:border-indigo-700 focus:ring active:bg-indigo-700 transition ease-in-out duration-150"><svg fill="currentColor" viewBox="0 0 20 20" class="inline w-4 h-4 mr-2">diff --git a/lib/plausible_web/templates/email/dashboard_locked.html.heex b/lib/plausible_web/templates/email/dashboard_locked.html.heexindex c780672657..3d6b73d272 100644--- a/lib/plausible_web/templates/email/dashboard_locked.html.heex+++ b/lib/plausible_web/templates/email/dashboard_locked.html.heex@@ -7,12 +7,12 @@ During the last billing cycle ({PlausibleWeb.TextHelpers.format_date_range()}), your account recorded {PlausibleWeb.AuthView.delimit_integer(@usage.last_cycle.total)} billable pageviews. In the billing cycle before that ({PlausibleWeb.TextHelpers.format_date_range(@usage.penultimate_cycle.date_range)}), the usage was {PlausibleWeb.AuthView.delimit_integer(@usage.penultimate_cycle.total)} billable pageviews. Note that billable pageviews include both standard pageviews and custom events. In your-<a href={PlausibleWeb.Router.Helpers.settings_url(PlausibleWeb.Endpoint, :subscription) <> "?__team=#{@team.identifier}"}>account settings</a>, you'll find an overview of your usage and limits.+<a href={url(~p"/settings/billing/subscription?#{[__team: @team.identifier]}")}>account settings</a>, you'll find an overview of your usage and limits.<br /><br /><%= if @suggested_volume == :enterprise do %>Your usage exceeds our standard plans, so please reply back to this email for a tailored quote.<% else %>- <a href={PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan) <> "?__team=#{@team.identifier}"}>Click here to upgrade your subscription</a>. We recommend you upgrade to the {@suggested_volume} pageviews/month plan. The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire.+ <a href={url(~p"/billing/choose-plan?#{[__team: @team.identifier]}")}>Click here to upgrade your subscription</a>. We recommend you upgrade to the {@suggested_volume} pageviews/month plan. The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire.<br /><br />If your usage decreases in the future, you can switch to a lower plan at any time. Any credit balance will automatically apply to future payments. If your traffic has already returned to within your plan limits, your dashboard will automatically unlock at the start of your next billing cycle. No action needed.<% end %>diff --git a/lib/plausible_web/templates/email/existing_user_invitation.html.heex b/lib/plausible_web/templates/email/existing_user_invitation.html.heexindex 9825298082..c84627d235 100644--- a/lib/plausible_web/templates/email/existing_user_invitation.html.heex+++ b/lib/plausible_web/templates/email/existing_user_invitation.html.heex@@ -1,4 +1,4 @@{@inviter.email} has invited you to the {@site.domain} site on {Plausible.product_name()}.-<a href={Routes.site_url(PlausibleWeb.Endpoint, :index) <> "?__team=none"}>Click here</a>+<a href={url(~p"/sites?#{[__team: "none"]}")}>Click here</a>to view and respond to the invitation. The invitationwill expire 48 hours after this email is sent. If this invitation has expired, please contact the person who invited you to ask them to resend it.diff --git a/lib/plausible_web/templates/email/existing_user_team_invitation.html.heex b/lib/plausible_web/templates/email/existing_user_team_invitation.html.heexindex e0e27977b7..3cfa10fd3b 100644--- a/lib/plausible_web/templates/email/existing_user_team_invitation.html.heex+++ b/lib/plausible_web/templates/email/existing_user_team_invitation.html.heex@@ -1,4 +1,4 @@{@inviter.email} has invited you to the "{@team.name}" team on {Plausible.product_name()}.-<a href={Routes.site_url(PlausibleWeb.Endpoint, :index)}>Click here</a>+<a href={url(~p"/sites")}>Click here</a>to view and respond to the invitation. The invitationwill expire 48 hours after this email is sent.diff --git a/lib/plausible_web/templates/email/force_2fa_enabled.html.heex b/lib/plausible_web/templates/email/force_2fa_enabled.html.heexindex 87da4c6c6c..e21e2d95b6 100644--- a/lib/plausible_web/templates/email/force_2fa_enabled.html.heex+++ b/lib/plausible_web/templates/email/force_2fa_enabled.html.heex@@ -1,8 +1,6 @@{@enabling_user.email} has enabled a 2FA requirement for the "{@team.name}" team.<br /><br />Please-<a href={- Routes.auth_url(PlausibleWeb.Endpoint, :force_initiate_2fa_setup, __team: @team.identifier)-}>+<a href={url(~p"/2fa/setup/force-initiate?#{[__team: @team.identifier]}")}>set up 2FA now</a>to keep access to your team on Plausible. The setup takes about a minute with any authenticator app.<br /><br />diff --git a/lib/plausible_web/templates/email/guest_invitation_accepted.html.heex b/lib/plausible_web/templates/email/guest_invitation_accepted.html.heexindex 36223c80c2..18ce3a8e51 100644--- a/lib/plausible_web/templates/email/guest_invitation_accepted.html.heex+++ b/lib/plausible_web/templates/email/guest_invitation_accepted.html.heex@@ -1,5 +1,5 @@{@invitee_email} has accepted your invitation to {@site.domain}.-<a href={Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @site.domain) <> "?__team=#{@team.identifier}"}>+<a href={url(~p"/#{@site.domain}/settings/general?#{[__team: @team.identifier]}")}>Click here</a>to view site settings.diff --git a/lib/plausible_web/templates/email/guest_invitation_rejected.html.heex b/lib/plausible_web/templates/email/guest_invitation_rejected.html.heexindex f81c0f2737..efa038b952 100644--- a/lib/plausible_web/templates/email/guest_invitation_rejected.html.heex+++ b/lib/plausible_web/templates/email/guest_invitation_rejected.html.heex@@ -1,5 +1,7 @@{@guest_invitation.team_invitation.email} has rejected your invitation to {@guest_invitation.site.domain}.-<a href={Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @guest_invitation.site.domain) <> "?__team=#{@team.identifier}"}>+<a href={+ url(~p"/#{@guest_invitation.site.domain}/settings/general?#{[__team: @team.identifier]}")+}>Click here</a>to view site settings.diff --git a/lib/plausible_web/templates/email/guest_to_team_member_promotion.html.heex b/lib/plausible_web/templates/email/guest_to_team_member_promotion.html.heexindex fda3d6c9bb..0de162e2a9 100644--- a/lib/plausible_web/templates/email/guest_to_team_member_promotion.html.heex+++ b/lib/plausible_web/templates/email/guest_to_team_member_promotion.html.heex@@ -1,5 +1,5 @@{@inviter.email} has promoted you to a team member in the "{@team.name}" team on {Plausible.product_name()}.-<a href={PlausibleWeb.Router.Helpers.site_url(PlausibleWeb.Endpoint, :index) <> "?__team=#{@team.identifier}"}>+<a href={url(~p"/sites?#{[__team: @team.identifier]}")}>Click here</a>to view sites managed by the team.diff --git a/lib/plausible_web/templates/email/new_user_invitation.html.heex b/lib/plausible_web/templates/email/new_user_invitation.html.heexindex 6c58b52d5f..5961e928f0 100644--- a/lib/plausible_web/templates/email/new_user_invitation.html.heex+++ b/lib/plausible_web/templates/email/new_user_invitation.html.heex@@ -1,11 +1,5 @@{@inviter.email} has invited you to join the {@site.domain} site on {Plausible.product_name()}.-<a href={- Routes.auth_url(- PlausibleWeb.Endpoint,- :register_from_invitation_form,- @invitation_id- )-}>+<a href={url(~p"/register/invitation/#{@invitation_id}")}>Click here</a>to create your account. The link is valid for 48 hours after this email is sent. <br /><br />diff --git a/lib/plausible_web/templates/email/new_user_team_invitation.html.heex b/lib/plausible_web/templates/email/new_user_team_invitation.html.heexindex f7487af1e7..b61b591955 100644--- a/lib/plausible_web/templates/email/new_user_team_invitation.html.heex+++ b/lib/plausible_web/templates/email/new_user_team_invitation.html.heex@@ -1,11 +1,5 @@{@inviter.email} has invited you to join the "{@team.name}" team on {Plausible.product_name()}.-<a href={- Routes.auth_url(- PlausibleWeb.Endpoint,- :register_from_invitation_form,- @invitation_id- )-}>+<a href={url(~p"/register/invitation/#{@invitation_id}")}>Click here</a>to create your account. The link is valid for 48 hours after this email is sent. <br /><br />diff --git a/lib/plausible_web/templates/email/over_limit.html.heex b/lib/plausible_web/templates/email/over_limit.html.heexindex ff020d6dff..06c9b924cd 100644--- a/lib/plausible_web/templates/email/over_limit.html.heex+++ b/lib/plausible_web/templates/email/over_limit.html.heex@@ -8,12 +8,12 @@ During the last billing cycle ({PlausibleWeb.TextHelpers.format_date_range()}), your account recorded {PlausibleWeb.AuthView.delimit_integer(@usage.last_cycle.total)} billable pageviews. In the billing cycle before that ({PlausibleWeb.TextHelpers.format_date_range(@usage.penultimate_cycle.date_range)}), your account used {PlausibleWeb.AuthView.delimit_integer(@usage.penultimate_cycle.total)} billable pageviews. Note that billable pageviews include both standard pageviews and custom events. In your-<a href={plausible_url() <> PlausibleWeb.Router.Helpers.settings_path(PlausibleWeb.Endpoint, :subscription) <> "?__team=#{@team.identifier}"}>account settings</a>, you'll find an overview of your usage and limits.+<a href={url(~p"/settings/billing/subscription?#{[__team: @team.identifier]}")}>account settings</a>, you'll find an overview of your usage and limits.<br /><br /><%= if @suggested_volume == :enterprise do %>Your usage exceeds our standard plans, so please reply back to this email for a tailored quote.<% else %>- <a href={PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan) <> "?__team=#{@team.identifier}"}>Click here to upgrade your subscription</a>. We recommend you upgrade to the {@suggested_volume} pageviews/month plan. The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire.+ <a href={url(~p"/billing/choose-plan?#{[__team: @team.identifier]}")}>Click here to upgrade your subscription</a>. We recommend you upgrade to the {@suggested_volume} pageviews/month plan. The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire.<br /><br />If your usage decreases in the future, you can switch to a lower plan at any time. Any credit balance will automatically apply to future payments.<% end %>diff --git a/lib/plausible_web/templates/email/ownership_transfer_accepted.html.heex b/lib/plausible_web/templates/email/ownership_transfer_accepted.html.heexindex 15e95ec23f..34b6620bbf 100644--- a/lib/plausible_web/templates/email/ownership_transfer_accepted.html.heex+++ b/lib/plausible_web/templates/email/ownership_transfer_accepted.html.heex@@ -1,12 +1,12 @@{@new_owner_email} has accepted the ownership transfer of {@site.domain}. They will be responsible for billing of it goingforward<%= if @initiator_as_guest_editor? do %>and your role has been changed to <b>guest editor</b>.- <a href={Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @site.domain) <> "?__team=none"}>+ <a href={url(~p"/#{@site.domain}/settings/general?#{[__team: "none"]}")}>Click here</a>to view site settings.<% else %>- <a href={Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @site.domain) <> "?__team=#{@team.identifier}"}>+ <a href={url(~p"/#{@site.domain}/settings/general?#{[__team: @team.identifier]}")}>Click here</a>to view site settings.diff --git a/lib/plausible_web/templates/email/ownership_transfer_rejected.html.heex b/lib/plausible_web/templates/email/ownership_transfer_rejected.html.heexindex 9950537900..eafe5f631d 100644--- a/lib/plausible_web/templates/email/ownership_transfer_rejected.html.heex+++ b/lib/plausible_web/templates/email/ownership_transfer_rejected.html.heex@@ -1,5 +1,5 @@{@site_transfer.email} has rejected the ownership transfer of {@site_transfer.site.domain}.-<a href={Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @site_transfer.site.domain) <> "?__team=#{@team.identifier}"}>+<a href={url(~p"/#{@site_transfer.site.domain}/settings/general?#{[__team: @team.identifier]}")}>Click here</a>to view site settings.diff --git a/lib/plausible_web/templates/email/ownership_transfer_request.html.heex b/lib/plausible_web/templates/email/ownership_transfer_request.html.heexindex 9d5f1ea21c..ded39317a4 100644--- a/lib/plausible_web/templates/email/ownership_transfer_request.html.heex+++ b/lib/plausible_web/templates/email/ownership_transfer_request.html.heex@@ -1,11 +1,10 @@{@inviter.email} has requested to transfer the ownership of {@site.domain} site on {Plausible.product_name()} to you. Please accept the request within 48 hours.<%= if @new_owner_account do %>- <a href={Routes.site_url(PlausibleWeb.Endpoint, :index)}>Click here</a>- to view and respond to the invitation.+ <a href={url(~p"/sites")}>Click here</a> to view and respond to the invitation.<% else %><aphx-no-format- href={Routes.auth_url(PlausibleWeb.Endpoint, :register_from_invitation_form, @invitation_id)}+ href={url(~p"/register/invitation/#{@invitation_id}")}>Click here</a> to create your account. <br /><br />Plausible is a lightweight and open-source website analytics tool. We hope you like our simple and ethical approach to tracking website visitors.<% end %>diff --git a/lib/plausible_web/templates/email/site_member_removed.html.heex b/lib/plausible_web/templates/email/site_member_removed.html.heexindex dd3aca6200..e34aed890f 100644--- a/lib/plausible_web/templates/email/site_member_removed.html.heex+++ b/lib/plausible_web/templates/email/site_member_removed.html.heex@@ -1,4 +1,4 @@An administrator of {@guest_membership.site.domain} has removed you as a member. You won't be able to see the stats anymore.<br /><br />-<a href={Routes.site_url(PlausibleWeb.Endpoint, :index) <> "?__team=none"}>Click here</a>+<a href={url(~p"/sites?#{[__team: "none"]}")}>Click here</a>to view your sites.diff --git a/lib/plausible_web/templates/email/team_changed.html.heex b/lib/plausible_web/templates/email/team_changed.html.heexindex 64a49751ba..916a7b0c20 100644--- a/lib/plausible_web/templates/email/team_changed.html.heex+++ b/lib/plausible_web/templates/email/team_changed.html.heex@@ -1,5 +1,5 @@{@user.email} has transferred {@site.domain} to the "{@team.name}" team on Plausible Analytics.-<a href={Routes.stats_url(PlausibleWeb.Endpoint, :stats, @site.domain, []) <> "?__team=#{@team.identifier}"}>+<a href={stats_url(@site.domain, __team: @team.identifier)}>Click here</a>to view the stats.diff --git a/lib/plausible_web/templates/email/team_invitation_accepted.html.heex b/lib/plausible_web/templates/email/team_invitation_accepted.html.heexindex 47a4e5008e..687b548925 100644--- a/lib/plausible_web/templates/email/team_invitation_accepted.html.heex+++ b/lib/plausible_web/templates/email/team_invitation_accepted.html.heex@@ -1,5 +1,5 @@{@invitee_email} has accepted your invitation to "{@team.name}" team.-<a href={Routes.settings_url(PlausibleWeb.Endpoint, :team_general) <> "?__team=#{@team.identifier}"}>+<a href={url(~p"/settings/team/general?#{[__team: @team.identifier]}")}>Click here</a>to view team settings.diff --git a/lib/plausible_web/templates/email/team_invitation_rejected.html.heex b/lib/plausible_web/templates/email/team_invitation_rejected.html.heexindex 4290c2cbc7..2ad5bdc87d 100644--- a/lib/plausible_web/templates/email/team_invitation_rejected.html.heex+++ b/lib/plausible_web/templates/email/team_invitation_rejected.html.heex@@ -1,5 +1,5 @@{@team_invitation.email} has rejected your invitation to \"{@team.name}\" team.-<a href={Routes.settings_url(PlausibleWeb.Endpoint, :team_general) <> "?__team=#{@team.identifier}"}>+<a href={url(~p"/settings/team/general?__team=#{@team.identifier}")}>Click here</a>to view team settings.diff --git a/lib/plausible_web/templates/email/team_member_left.html.heex b/lib/plausible_web/templates/email/team_member_left.html.heexindex e1a2a5cada..44c52dccb4 100644--- a/lib/plausible_web/templates/email/team_member_left.html.heex+++ b/lib/plausible_web/templates/email/team_member_left.html.heex@@ -1,3 +1,2 @@You are no longer a member of "{@team_membership.team.name}" team. <br /><br />-<a href={Routes.site_url(PlausibleWeb.Endpoint, :index) <> "?__team=none"}>Click here</a>-to view your sites.+<a href={url(~p"/sites?#{[__team: "none"]}")}>Click here</a> to view your sites.diff --git a/lib/plausible_web/templates/email/team_member_removed.html.heex b/lib/plausible_web/templates/email/team_member_removed.html.heexindex 2d849b1fd6..1731ac93f6 100644--- a/lib/plausible_web/templates/email/team_member_removed.html.heex+++ b/lib/plausible_web/templates/email/team_member_removed.html.heex@@ -1,3 +1,2 @@An administrator of "{@team_membership.team.name}" team has removed you as a member. <br /><br />-<a href={Routes.site_url(PlausibleWeb.Endpoint, :index) <> "?__team=none"}>Click here</a>-to view your sites.+<a href={url(~p"/sites?#{[__team: "none"]}")}>Click here</a> to view your sites.diff --git a/lib/plausible_web/templates/email/trial_ending_today.html.heex b/lib/plausible_web/templates/email/trial_ending_today.html.heexindex a6245a43ee..5732a1ac42 100644--- a/lib/plausible_web/templates/email/trial_ending_today.html.heex+++ b/lib/plausible_web/templates/email/trial_ending_today.html.heex@@ -9,7 +9,7 @@ So far, your account has used {PlausibleWeb.AuthView.delimit_integer(@usage)} biThis exceeds our standard plans. Once the trial ends, your dashboard will be locked. Please reply to this email and we'll prepare a custom plan for your volume.<% else %>To keep your dashboard unlocked and your stats collecting without interruption, select the {@suggested_volume} pageviews/month plan.<br /><br />- <a href={PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan) <> "?__team=#{@team.identifier}"}>+ <a href={url(~p"/billing/choose-plan?#{[__team: @team.identifier]}")}>Upgrade your account</a><% end %>diff --git a/lib/plausible_web/templates/email/trial_over_email.html.heex b/lib/plausible_web/templates/email/trial_over_email.html.heexindex 48dc08538d..1944486a94 100644--- a/lib/plausible_web/templates/email/trial_over_email.html.heex+++ b/lib/plausible_web/templates/email/trial_over_email.html.heex@@ -1,7 +1,7 @@Your Plausible trial has expired and your dashboard is now locked.<br /><br />We’re still recording visitor stats in the background, so nothing is lost while you decide.<br /><br />When you’re ready, upgrade your account to unlock your dashboard and continue without interruption.<br /><br />-<a href={PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan) <> "?__team=#{@team.identifier}"}>+<a href={url(~p"/billing/choose-plan?#{[__team: @team.identifier]}")}>Upgrade your account</a><br /><br />diff --git a/lib/plausible_web/templates/email/trial_upgrade_email.html.heex b/lib/plausible_web/templates/email/trial_upgrade_email.html.heexindex 77843ee9ec..35df73728f 100644--- a/lib/plausible_web/templates/email/trial_upgrade_email.html.heex+++ b/lib/plausible_web/templates/email/trial_upgrade_email.html.heex@@ -10,7 +10,7 @@ In the last month, your account has used {PlausibleWeb.AuthView.delimit_integer(This is more than our standard plans, so please reply back to this email to get a quote for your volume.<% else %>Based on that we recommend you select a {@suggested_volume} pageviews/month plan. <br /><br />- <a href={PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan) <> "?__team=#{@team.identifier}"}>+ <a href={url(~p"/billing/choose-plan?#{[__team: @team.identifier]}")}>Upgrade now</a><br /><br />diff --git a/lib/plausible_web/templates/error/404_error.html.heex b/lib/plausible_web/templates/error/404_error.html.heexindex 1c8ba3795a..ac9e31ac61 100644--- a/lib/plausible_web/templates/error/404_error.html.heex+++ b/lib/plausible_web/templates/error/404_error.html.heex@@ -8,7 +8,7 @@<div class="mt-4 flex"><.button_link:if={[email protected][:current_user]}- href={Routes.auth_path(@conn, :login_form, return_to: url_path(@conn))}+ href={~p"/login?#{[return_to: url_path(@conn)]}"}class="mr-4">Log indiff --git a/lib/plausible_web/templates/error/server_error.html.heex b/lib/plausible_web/templates/error/server_error.html.heexindex dd9d66cda2..82601ebaa4 100644--- a/lib/plausible_web/templates/error/server_error.html.heex+++ b/lib/plausible_web/templates/error/server_error.html.heex@@ -47,7 +47,7 @@:let={f}for={%{}}as={:error}- action={Routes.error_report_path(PlausibleWeb.Endpoint, :submit_error_report)}+ action={~p"/error_report"}><.input type="hidden" field={f[:trace_id]} value={@trace_id} /><PlausibleWeb.Live.Components.Form.label for="user_feedback">diff --git a/lib/plausible_web/templates/google_analytics/confirm.html.heex b/lib/plausible_web/templates/google_analytics/confirm.html.heexindex 578c07f18a..00c58e5e4b 100644--- a/lib/plausible_web/templates/google_analytics/confirm.html.heex+++ b/lib/plausible_web/templates/google_analytics/confirm.html.heex@@ -3,7 +3,7 @@for={@conn}class="max-w-md w-full mx-auto bg-white dark:bg-gray-900 shadow-md rounded-sm px-8 pt-6 pb-8 mb-4 mt-8"onsubmit="confirmButton.disabled = true; return true;"- action={Routes.google_analytics_path(@conn, :import, @site.domain)}+ action={~p"/#{@site.domain}/settings/google-import"}><h2 class="text-xl font-black dark:text-gray-100">Import from Google Analytics</h2>@@ -45,12 +45,7 @@<p class="text-sm mt-4 sm:mt-0 dark:text-gray-100"><ahref={- Routes.google_analytics_path(@conn, :property, @site.domain,- property: @selected_property,- access_token: @access_token,- refresh_token: @refresh_token,- expires_at: @expires_at- )+ ~p"/#{@site.domain}/import/google-analytics/property?#{[property: @selected_property, access_token: @access_token, refresh_token: @refresh_token, expires_at: @expires_at]}"}class="underline text-indigo-600">diff --git a/lib/plausible_web/templates/google_analytics/property_form.html.heex b/lib/plausible_web/templates/google_analytics/property_form.html.heexindex b9ff6cf26e..2f5cc37bbd 100644--- a/lib/plausible_web/templates/google_analytics/property_form.html.heex+++ b/lib/plausible_web/templates/google_analytics/property_form.html.heex@@ -10,7 +10,7 @@:let={f}for={@conn}onsubmit="continueButton.disabled = true; return true;"- action={Routes.google_analytics_path(@conn, :property, @site.domain)}+ action={~p"/#{@site.domain}/import/google-analytics/property"}><.input type="hidden" field={f[:access_token]} /><.input type="hidden" field={f[:refresh_token]} />@@ -34,7 +34,7 @@<div class="mt-6 flex flex-col-reverse sm:flex-row justify-between items-center"><p class="mt-4 sm:mt-0 dark:text-gray-100"><a- href={Routes.site_path(@conn, :settings_imports_exports, @site.domain)}+ href={~p"/#{@site.domain}/settings/imports-exports"}class="underline text-indigo-600">Go backdiff --git a/lib/plausible_web/templates/layout/app.html.heex b/lib/plausible_web/templates/layout/app.html.heexindex 086dbcf99f..9d05f7cf3f 100644--- a/lib/plausible_web/templates/layout/app.html.heex+++ b/lib/plausible_web/templates/layout/app.html.heex@@ -24,7 +24,7 @@{assigns[:title] ||"Plausible · Simple, privacy-friendly alternative to Google Analytics"}</title>- <link rel="stylesheet" href={Routes.static_path(@conn, "/css/app.css")} />+ <link rel="stylesheet" href={~p"/css/app.css"} /><PlausibleWeb.Components.Layout.theme_script {Map.take(assigns, [:current_user, :theme])} />{render("_tracking.html", assigns)}</head>diff --git a/lib/plausible_web/templates/layout/base_error.html.heex b/lib/plausible_web/templates/layout/base_error.html.heexindex 27311b6dcc..f2f3012d36 100644--- a/lib/plausible_web/templates/layout/base_error.html.heex+++ b/lib/plausible_web/templates/layout/base_error.html.heex@@ -6,7 +6,7 @@<meta name="viewport" content="width=device-width, initial-scale=1.0" /><PlausibleWeb.Components.Layout.favicon conn={@conn} /><title>Plausible · Web analytics</title>- <link rel="stylesheet" href={Routes.static_path(PlausibleWeb.Endpoint, "/css/app.css")} />+ <link rel="stylesheet" href={~p"/css/app.css"} /></head><body class="flex flex-col h-full bg-gray-100 dark:bg-gray-900"><div class="w-full my-8 text-center">@@ -17,7 +17,7 @@{@inner_content}- <script type="text/javascript" src={Routes.static_path(PlausibleWeb.Endpoint, "/js/app.js")}>+ <script type="text/javascript" src={~p"/js/app.js"}></script></body></html>diff --git a/lib/plausible_web/templates/page/index.html.heex b/lib/plausible_web/templates/page/index.html.heexindex 6a7b4e0f8e..16b0807315 100644--- a/lib/plausible_web/templates/page/index.html.heex+++ b/lib/plausible_web/templates/page/index.html.heex@@ -16,12 +16,12 @@<:footer><.focus_list><:item>- <.styled_link href={Routes.auth_path(@conn, :login)}>+ <.styled_link href={~p"/login"}>Login</.styled_link></:item><:item :if={Plausible.Auth.check_registration_enabled() == :ok}>- <.styled_link href={Routes.auth_path(@conn, :register_form)}>+ <.styled_link href={~p"/register"}>Register</.styled_link></:item>diff --git a/lib/plausible_web/templates/settings/api_keys.html.heex b/lib/plausible_web/templates/settings/api_keys.html.heexindex 04cd79b67c..3120b342a4 100644--- a/lib/plausible_web/templates/settings/api_keys.html.heex+++ b/lib/plausible_web/templates/settings/api_keys.html.heex@@ -21,13 +21,13 @@Access your stats through the Plausible API.<.styled_link href="https://plausible.io/docs/stats-api">Learn more</.styled_link></p>- <.button_link href={Routes.settings_path(@conn, :new_api_key)}>+ <.button_link href={~p"/settings/api-keys/new"}>New API Key</.button_link></div><% else %><.filter_bar filtering_enabled?={false}>- <.button_link mt?={false} href={Routes.settings_path(@conn, :new_api_key)}>+ <.button_link mt?={false} href={~p"/settings/api-keys/new"}>New API Key</.button_link></.filter_bar>@@ -63,7 +63,7 @@<.td actions><.delete_buttonmethod="delete"- href={Routes.settings_path(@conn, :delete_api_key, api_key.id)}+ href={~p"/settings/api-keys/#{api_key.id}"}data-confirm="Are you sure you want to revoke this key? This action cannot be reversed."/></.td>diff --git a/lib/plausible_web/templates/settings/danger_zone.html.heex b/lib/plausible_web/templates/settings/danger_zone.html.heexindex 4d5fcad39e..f1cb0d9d54 100644--- a/lib/plausible_web/templates/settings/danger_zone.html.heex+++ b/lib/plausible_web/templates/settings/danger_zone.html.heex@@ -13,9 +13,7 @@You're the sole owner of one or more teams. To delete your account, either add another owner or delete each of the following team(s):<ul class="w-full py-4"><li :for={team <- @solely_owned_teams} class="pt-1">- <.styled_link href={- Routes.settings_path(@conn, :team_general, __team: team.identifier)- }>+ <.styled_link href={~p"/settings/team/general?#{[__team: team.identifier]}"}>{Plausible.Teams.name(team)}</.styled_link></li>diff --git a/lib/plausible_web/templates/settings/new_api_key.html.heex b/lib/plausible_web/templates/settings/new_api_key.html.heexindex 5cfbee0fd8..df0322f999 100644--- a/lib/plausible_web/templates/settings/new_api_key.html.heex+++ b/lib/plausible_web/templates/settings/new_api_key.html.heex@@ -2,7 +2,7 @@<:title>Create new API key</:title><div x-data="{ submitDisabled: false }">- <.form :let={f} for={@changeset} action={Routes.settings_path(@conn, :api_keys)}>+ <.form :let={f} for={@changeset} action={~p"/settings/api-keys"}><.input type="text" field={f[:name]} label="Name" placeholder="Development" /><input :if={ce?()} type="hidden" name={f[:type].name} value={f[:type].value} />diff --git a/lib/plausible_web/templates/settings/preferences.html.heex b/lib/plausible_web/templates/settings/preferences.html.heexindex 4bf2c054d4..635d2394b9 100644--- a/lib/plausible_web/templates/settings/preferences.html.heex+++ b/lib/plausible_web/templates/settings/preferences.html.heex@@ -5,7 +5,7 @@</:title><.form:let={f}- action={Routes.settings_path(@conn, :update_name)}+ action={~p"/settings/preferences/name"}for={@name_changeset}method="post">@@ -32,7 +32,7 @@</:title><.form:let={f}- action={Routes.settings_path(@conn, :update_theme)}+ action={~p"/settings/preferences/theme"}for={@theme_changeset}method="post">diff --git a/lib/plausible_web/templates/settings/security.html.heex b/lib/plausible_web/templates/settings/security.html.heexindex 9b5b0cfcb6..24724862b6 100644--- a/lib/plausible_web/templates/settings/security.html.heex+++ b/lib/plausible_web/templates/settings/security.html.heex@@ -8,7 +8,7 @@</:subtitle><.form:let={f}- action={Routes.settings_path(@conn, :update_email)}+ action={~p"/settings/security/email"}for={@email_changeset}method="post">@@ -61,7 +61,7 @@</:subtitle><.form:let={f}- action={Routes.settings_path(@conn, :update_password)}+ action={~p"/settings/security/password"}for={@password_changeset}method="post">@@ -142,7 +142,7 @@<div :if={not @totp_enabled?}><.form- action={Routes.auth_path(@conn, :initiate_2fa_setup)}+ action={~p"/2fa/setup/initiate"}for={@conn.params}method="post">@@ -156,7 +156,7 @@id="disable-2fa-modal"state_param="disable2FAOpen"form_data={@conn.params}- form_target={Routes.auth_path(@conn, :disable_2fa)}+ form_target={~p"/2fa/disable"}title="Disable Two-Factor Authentication?"><:icon>@@ -192,7 +192,7 @@id="regenerate-2fa-modal"state_param="regenerate2FAOpen"form_data={@conn.params}- form_target={Routes.auth_path(@conn, :generate_2fa_recovery_codes)}+ form_target={~p"/2fa/recovery_codes"}onsubmit="document.getElementById('generate-2fa-recovery-button').disabled = true"title="Generate New Recovery Codes?">@@ -259,7 +259,7 @@<.td :if={@current_user_session.id == session.id} actions>Current session</.td><.td :if={@current_user_session.id != session.id} actions><.delete_button- href={Routes.settings_path(@conn, :delete_session, session.id)}+ href={~p"/settings/security/user-sessions/#{session.id}"}method="delete"data-confirm="Are you sure you want to log out this session?"/>diff --git a/lib/plausible_web/templates/settings/team_danger_zone.html.heex b/lib/plausible_web/templates/settings/team_danger_zone.html.heexindex 552c430cb6..1621fbc814 100644--- a/lib/plausible_web/templates/settings/team_danger_zone.html.heex+++ b/lib/plausible_web/templates/settings/team_danger_zone.html.heex@@ -14,7 +14,7 @@<% else %><.button_linkdata-confirm="Deleting the team will also delete all the associated sites and data. This action cannot be reversed. Are you sure?"- href={Routes.settings_path(@conn, :delete_team)}+ href={~p"/settings/team/delete"}method="delete"theme="danger"mt?={false}diff --git a/lib/plausible_web/templates/settings/team_general.html.heex b/lib/plausible_web/templates/settings/team_general.html.heexindex e4b4e069aa..1093c2fcc0 100644--- a/lib/plausible_web/templates/settings/team_general.html.heex+++ b/lib/plausible_web/templates/settings/team_general.html.heex@@ -8,7 +8,7 @@</:subtitle><.form:let={f}- action={Routes.settings_path(@conn, :update_team_name)}+ action={~p"/settings/team/general/name"}for={@team_name_changeset}method="post">@@ -57,7 +57,7 @@x-data="{disableTeamForce2FAOpen: false}"><.form- action={Routes.settings_path(@conn, :disable_team_force_2fa)}+ action={~p"/settings/team/force_2fa/disable"}for={@conn.params}method="post">@@ -73,7 +73,7 @@id="disable-force-2fa-modal"state_param="disableTeamForce2FAOpen"form_data={@conn.params}- form_target={Routes.settings_path(@conn, :disable_team_force_2fa)}+ form_target={~p"/settings/team/force_2fa/disable"}title="Stop enforcing 2FA?"><:icon>@@ -109,7 +109,7 @@<div :if={not @force_2fa_enabled? and @current_team_role == :owner} id="enable-force-2fa"><.form- action={Routes.settings_path(@conn, :enable_team_force_2fa)}+ action={~p"/settings/team/force_2fa/enable"}for={@conn.params}method="post">@@ -128,7 +128,7 @@<:subtitle>Remove yourself from this team as a member.</:subtitle><.button_linkdata-confirm="Are you sure you want to leave this team?"- href={Routes.settings_path(@conn, :leave_team)}+ href={~p"/settings/team/leave"}method="post"theme="danger"mt?={false}diff --git a/lib/plausible_web/templates/site/membership/invite_member_form.html.heex b/lib/plausible_web/templates/site/membership/invite_member_form.html.heexindex 0b124747ae..c983643e6a 100644--- a/lib/plausible_web/templates/site/membership/invite_member_form.html.heex+++ b/lib/plausible_web/templates/site/membership/invite_member_form.html.heex@@ -9,7 +9,7 @@analytics. Invitations expire after 48 hours.</:subtitle>- <.form :let={f} for={@conn} action={Routes.membership_path(@conn, :invite_member, @site.domain)}>+ <.form :let={f} for={@conn} action={~p"/sites/#{@site.domain}/memberships/invite"}><PlausibleWeb.Components.Billing.Notice.limit_exceeded:if={Map.get(assigns, :is_at_limit, false)}current_user={@current_user}diff --git a/lib/plausible_web/templates/site/onboarding_new_site.html.heex b/lib/plausible_web/templates/site/onboarding_new_site.html.heexindex 330d8465dd..c5a2bf95d6 100644--- a/lib/plausible_web/templates/site/onboarding_new_site.html.heex+++ b/lib/plausible_web/templates/site/onboarding_new_site.html.heex@@ -11,6 +11,6 @@current_user={@current_user}current_team={@current_team}back_button_text="Skip"- back_button_href={Routes.site_path(@conn, :index)}+ back_button_href={~p"/sites"}/></Layouts.onboarding>diff --git a/lib/plausible_web/templates/site/provisioning_new_site.html.heex b/lib/plausible_web/templates/site/provisioning_new_site.html.heexindex 1102a4c2e7..8721eaf3ce 100644--- a/lib/plausible_web/templates/site/provisioning_new_site.html.heex+++ b/lib/plausible_web/templates/site/provisioning_new_site.html.heex@@ -16,6 +16,6 @@current_user={@current_user}current_team={@current_team}back_button_text="Back to sites"- back_button_href={Routes.site_path(@conn, :index)}+ back_button_href={~p"/sites"}/></Layouts.app>diff --git a/lib/plausible_web/templates/site/settings_danger_zone.html.heex b/lib/plausible_web/templates/site/settings_danger_zone.html.heexindex ed0bbd96c4..ba3f947e5a 100644--- a/lib/plausible_web/templates/site/settings_danger_zone.html.heex+++ b/lib/plausible_web/templates/site/settings_danger_zone.html.heex@@ -12,7 +12,7 @@<:title>Reset stats</:title><:subtitle>Reset all stats but keep the site configuration intact.</:subtitle><.button_link- href={Routes.site_path(@conn, :reset_stats, @site.domain)}+ href={~p"/#{@site.domain}/stats"}method="delete"data-confirm="Resetting the stats cannot be reversed. Are you sure?"theme="danger"@@ -26,7 +26,7 @@<:title>Delete site</:title><:subtitle>Permanently delete all stats and site settings.</:subtitle><.button_link- href={Routes.site_path(@conn, :delete_site, @site.domain)}+ href={stats_path(@site.domain)}theme="danger"method="delete"data-confirm="Deleting the site data cannot be reversed. Are you sure?"diff --git a/lib/plausible_web/templates/site/settings_email_reports.html.heex b/lib/plausible_web/templates/site/settings_email_reports.html.heexindex 3a533e626f..c7775c0555 100644--- a/lib/plausible_web/templates/site/settings_email_reports.html.heex+++ b/lib/plausible_web/templates/site/settings_email_reports.html.heex@@ -2,10 +2,12 @@<% email_reports = [weekly: %{report: @weekly_report,- disable_route: :disable_weekly_report,- enable_route: :enable_weekly_report,- remove_route: :remove_weekly_report_recipient,- add_route: :add_weekly_report_recipient,+ disable_route: ~p"/sites/#{@site.domain}/weekly-report/disable",+ enable_route: ~p"/sites/#{@site.domain}/weekly-report/enable",+ remove_route_fn: fn recipient ->+ ~p"/sites/#{@site.domain}/weekly-report/recipients/#{recipient}"+ end,+ add_route: ~p"/sites/#{@site.domain}/weekly-report/recipients",heading: "Weekly email reports",subtitle: "Send weekly analytics reports to as many addresses as you wish.",toggle: "Send a weekly email report every Monday",@@ -13,10 +15,12 @@},monthly: %{report: @monthly_report,- disable_route: :disable_monthly_report,- enable_route: :enable_monthly_report,- remove_route: :remove_monthly_report_recipient,- add_route: :add_monthly_report_recipient,+ disable_route: ~p"/sites/#{@site.domain}/monthly-report/disable",+ enable_route: ~p"/sites/#{@site.domain}/monthly-report/enable",+ remove_route_fn: fn recipient ->+ ~p"/sites/#{@site.domain}/monthly-report/recipients/#{recipient}"+ end,+ add_route: ~p"/sites/#{@site.domain}/monthly-report/recipients",heading: "Monthly email reports",subtitle: "Send monthly analytics reports to as many addresses as you wish.",toggle: "Send a monthly email report on 1st of the month",@@ -34,10 +38,7 @@<.formfor={nil}- action={- (meta.report && Routes.site_path(@conn, meta.disable_route, @site.domain)) ||- Routes.site_path(@conn, meta.enable_route, @site.domain)- }+ action={(meta.report && meta.disable_route) || meta.enable_route}method="post"><div>@@ -68,14 +69,7 @@<.td actions><.delete_buttonmethod="delete"- href={- Routes.site_path(- @conn,- meta.remove_route,- @site.domain,- recipient- )- }+ href={meta.remove_route_fn.(recipient)}/></.td></:tbody>@@ -85,7 +79,7 @@:let={f}class="mt-4"for={@conn}- action={Routes.site_path(@conn, meta.add_route, @site.domain)}+ action={meta.add_route}method="post"><div class="flex items-end gap-x-2">@@ -134,8 +128,8 @@for={nil}action={(meta.notification &&- Routes.site_path(@conn, :disable_traffic_change_notification, @site.domain, type)) ||- Routes.site_path(@conn, :enable_traffic_change_notification, @site.domain, type)+ ~p"/sites/#{@site.domain}/traffic-change-notification/#{type}/disable") ||+ ~p"/sites/#{@site.domain}/traffic-change-notification/#{type}/enable"}method="post">@@ -149,7 +143,7 @@:if={meta.notification}class="mt-4"for={Plausible.Site.TrafficChangeNotification.changeset(meta.notification, %{})}- action={Routes.site_path(@conn, :update_traffic_change_notification, @site.domain, type)}+ action={~p"/sites/#{@site.domain}/traffic-change-notification/#{type}"}><div class="flex items-end gap-x-4"><PlausibleWeb.Live.Components.Form.input@@ -186,13 +180,7 @@<.delete_buttonmethod="delete"href={- Routes.site_path(- @conn,- :remove_traffic_change_notification_recipient,- @site.domain,- type,- recipient- )+ ~p"/sites/#{@site.domain}/traffic-change-notification/#{type}/recipients/#{recipient}"}/></.td>@@ -205,14 +193,7 @@:let={f}for={@conn}class="mt-4"- action={- Routes.site_path(- @conn,- :add_traffic_change_notification_recipient,- @site.domain,- type- )- }+ action={~p"/sites/#{@site.domain}/traffic-change-notification/#{type}/recipients"}><div class="flex items-end gap-x-4"><PlausibleWeb.Live.Components.Form.inputdiff --git a/lib/plausible_web/templates/site/settings_general.html.heex b/lib/plausible_web/templates/site/settings_general.html.heexindex 5bbd8c3750..738f2c964d 100644--- a/lib/plausible_web/templates/site/settings_general.html.heex+++ b/lib/plausible_web/templates/site/settings_general.html.heex@@ -8,7 +8,7 @@<.settings_row label="Site domain" docs="change-domain-name"><span class="text-gray-800 dark:text-gray-200">{@site.domain}</span><.styled_link- href={Routes.site_path(@conn, :change_domain, @site.domain)}+ href={~p"/#{@site.domain}/change-domain"}aria-label="Change domain"class="text-sm">diff --git a/lib/plausible_web/templates/site/settings_integrations.html.heex b/lib/plausible_web/templates/site/settings_integrations.html.heexindex 8b4778cdfd..b58ce971eb 100644--- a/lib/plausible_web/templates/site/settings_integrations.html.heex+++ b/lib/plausible_web/templates/site/settings_integrations.html.heex@@ -23,7 +23,7 @@<.button_linktheme="danger"- href={Routes.site_path(@conn, :delete_google_auth, @site.domain)}+ href={~p"/#{@site.domain}/settings/google-search"}method="delete">Unlink Google accountdiff --git a/lib/plausible_web/templates/site/settings_people.html.heex b/lib/plausible_web/templates/site/settings_people.html.heexindex cdfc2a37dc..c745bcb3b4 100644--- a/lib/plausible_web/templates/site/settings_people.html.heex+++ b/lib/plausible_web/templates/site/settings_people.html.heex@@ -18,7 +18,7 @@<.filter_bar :if={@site_role in [:owner, :admin]} filtering_enabled?={false}><.button_linkmt?={false}- href={Routes.membership_path(@conn, :invite_member_form, @site.domain)}+ href={~p"/sites/#{@site.domain}/memberships/invite"}>Invite new guest</.button_link>@@ -67,13 +67,7 @@<% else %><.dropdown_itemhref={- Routes.membership_path(- @conn,- :update_role_by_user,- @site.domain,- membership.user.id,- "editor"- )+ ~p"/sites/#{@site.domain}/memberships/u/#{membership.user.id}/role/editor"}method="put"disabled={@site_role not in [:owner, :admin] or membership.role == "editor"}@@ -85,13 +79,7 @@</.dropdown_item><.dropdown_itemhref={- Routes.membership_path(- @conn,- :update_role_by_user,- @site.domain,- membership.user.id,- "viewer"- )+ ~p"/sites/#{@site.domain}/memberships/u/#{membership.user.id}/role/viewer"}method="put"disabled={@site_role not in [:owner, :admin] or membership.role == "viewer"}@@ -103,14 +91,7 @@</.dropdown_item><.dropdown_divider /><.dropdown_item- href={- Routes.membership_path(- @conn,- :remove_member_by_user,- @site.domain,- membership.user.id- )- }+ href={~p"/sites/#{@site.domain}/memberships/u/#{membership.user.id}"}class="!text-red-600 hover:text-red-600 dark:!text-red-500 dark:hover:!text-red-400"method="delete"disabled={@site_role not in [:owner, :admin]}@@ -146,14 +127,7 @@<.td actions><.delete_button:if={@site_role in [:owner, :admin]}- href={- Routes.invitation_path(- @conn,- :remove_invitation,- @site.domain,- invitation.invitation_id- )- }+ href={~p"/sites/#{@site.domain}/invitations/#{invitation.invitation_id}"}method="delete"/></.td>diff --git a/lib/plausible_web/templates/site/settings_visibility.html.heex b/lib/plausible_web/templates/site/settings_visibility.html.heexindex 4ae15e3fe9..241c5a357e 100644--- a/lib/plausible_web/templates/site/settings_visibility.html.heex+++ b/lib/plausible_web/templates/site/settings_visibility.html.heex@@ -9,8 +9,8 @@<.formaction={- (@site.public && Routes.site_path(@conn, :make_private, @site.domain)) ||- Routes.site_path(@conn, :make_public, @site.domain)+ (@site.public && ~p"/sites/#{@site.domain}/make-private") ||+ ~p"/sites/#{@site.domain}/make-public"}aria-label="Make stats publicly available"method="post"@@ -20,7 +20,7 @@Make stats publicly available on<.unstyled_linkclass="text-indigo-500"- href={Routes.stats_path(@conn, :stats, @site.domain, [])}+ href={stats_path(@site.domain)}>{PlausibleWeb.StatsView.pretty_stats_url(@site)}</.unstyled_link>diff --git a/lib/plausible_web/templates/stats/shared_link_password.html.heex b/lib/plausible_web/templates/stats/shared_link_password.html.heexindex ed5b629971..0269010da4 100644--- a/lib/plausible_web/templates/stats/shared_link_password.html.heex+++ b/lib/plausible_web/templates/stats/shared_link_password.html.heex@@ -6,7 +6,7 @@<.form:let={f}for={@conn}- action={Routes.stats_path(@conn, :authenticate_shared_link, @link.slug) <> "?#{@query_string}"}+ action={~p"/share/#{@link.slug}/authenticate" <> "?#{@query_string}"}method="post"><div class="my-6">diff --git a/lib/plausible_web/templates/stats/site_locked.html.heex b/lib/plausible_web/templates/stats/site_locked.html.heexindex ae34b59102..87ca5bd0b7 100644--- a/lib/plausible_web/templates/stats/site_locked.html.heex+++ b/lib/plausible_web/templates/stats/site_locked.html.heex@@ -37,14 +37,14 @@</p><p class="mt-4 text-sm text-gray-600 dark:text-gray-300">You can configure your- <.styled_link href={Routes.site_path(@conn, :settings_general, @site.domain)}>+ <.styled_link href={~p"/#{@site.domain}/settings/general"}>site settings</.styled_link>but your access to the dashboard is restricted.</p></div><div class="w-full text-center">- <.button_link href={Routes.settings_path(@conn, :subscription)}>+ <.button_link href={~p"/settings/billing/subscription"}>Manage my subscription</.button_link></div>@@ -55,7 +55,7 @@</p></div><div class="mt-6 w-full text-center">- <.button_link href={Routes.site_path(@conn, :index)}>Back to my sites</.button_link>+ <.button_link href={~p"/sites"}>Back to my sites</.button_link></div><% _ -> %><div class="mt-3 text-gray-600 dark:text-gray-300 text-center text-sm">@@ -66,7 +66,7 @@</div><%= if @conn.assigns[:current_user] do %><div class="mt-6 w-full text-center">- <.button_link href={Routes.site_path(@conn, :index)}>Back to my sites</.button_link>+ <.button_link href={~p"/sites"}>Back to my sites</.button_link></div><% end %><% end %>diff --git a/lib/plausible_web/user_auth.ex b/lib/plausible_web/user_auth.exindex e5f48340e1..c08a3bedbd 100644--- a/lib/plausible_web/user_auth.ex+++ b/lib/plausible_web/user_auth.ex@@ -5,11 +5,11 @@ defmodule PlausibleWeb.UserAuth douse Plausible+ use PlausibleWeb.VerifiedRoutes+alias Plausible.Authalias PlausibleWeb.TwoFactor- alias PlausibleWeb.Router.Helpers, as: Routes-on_ee do@type login_subject() :: Auth.User.t() | Auth.SSO.Identity.t()else@@ -53,9 +53,7 @@ defmodule PlausibleWeb.UserAuth do:login_error,"We couldn't find a Single Sign-On account for that email.")- |> Phoenix.Controller.redirect(- to: Routes.sso_path(conn, :login_form, return_to: redirect_path)- )+ |> Phoenix.Controller.redirect(to: ~p"/sso/login?#{[return_to: redirect_path]}"){:error, :over_limit} ->error = "Team can't accept more members. Please contact the owner."@@ -63,9 +61,7 @@ defmodule PlausibleWeb.UserAuth doconn|> log_out_user()|> Phoenix.Controller.put_flash(:login_error, error)- |> Phoenix.Controller.redirect(- to: Routes.sso_path(conn, :login_form, return_to: redirect_path)- )+ |> Phoenix.Controller.redirect(to: ~p"/sso/login?#{[return_to: redirect_path]}"){:error, reason, _team, _user}when reason in [:multiple_memberships, :active_personal_team] ->@@ -73,9 +69,7 @@ defmodule PlausibleWeb.UserAuth doconn|> log_out_user()- |> Phoenix.Controller.redirect(- to: Routes.sso_path(conn, :provision_issue, issue: issue)- )+ |> Phoenix.Controller.redirect(to: ~p"/sso/issue?#{[issue: issue]}")endendend@@ -136,11 +130,11 @@ defmodule PlausibleWeb.UserAuth do|> put_token_in_session(token)end- defp login_redirect_path(conn, redirect_path) do+ defp login_redirect_path(_conn, redirect_path) doif String.starts_with?(redirect_path || "", "/") doredirect_pathelse- Routes.site_path(conn, :index)+ ~p"/sites"endenddiff --git a/lib/plausible_web/verified_routes.ex b/lib/plausible_web/verified_routes.exnew file mode 100644index 0000000000..cab8dd18da--- /dev/null+++ b/lib/plausible_web/verified_routes.ex@@ -0,0 +1,73 @@+defmodule PlausibleWeb.VerifiedRoutes do+ @moduledoc """+ Convenience macro to be used everywhere where verified routes are used.+ """+ use Plausible++ defmacro __using__(_) do+ # Follows the same logic as `Plug.Static` setup in `PlausibleWeb.Endpoint`+ static_paths = ~w(css js images favicon.ico)++ static_paths =+ on_ee do+ static_paths+ else+ static_paths ++ ["robots.txt"]+ end++ quote do+ use Phoenix.VerifiedRoutes,+ router: PlausibleWeb.Router,+ endpoint: PlausibleWeb.Endpoint,+ statics: unquote(static_paths)++ import unquote(__MODULE__)+ end+ end++ def stats_path(domain, params \\ []) when is_binary(domain) and byte_size(domain) > 0 do+ Phoenix.VerifiedRoutes.unverified_path(+ PlausibleWeb.Endpoint,+ PlausibleWeb.Router,+ "/#{encode_segment(domain)}",+ params+ )+ end++ def shared_stats_path(domain, params \\ [], star_path \\ nil)+ when is_binary(domain) and byte_size(domain) > 0 do+ path = "/share/#{encode_segment(domain)}/"++ path =+ if is_list(star_path) and star_path != [] do+ path <> encode_path(star_path)+ else+ path+ end++ Phoenix.VerifiedRoutes.unverified_path(+ PlausibleWeb.Endpoint,+ PlausibleWeb.Router,+ path,+ params+ )+ end++ def stats_url(domain, params \\ []) when is_binary(domain) and byte_size(domain) > 0 do+ Phoenix.VerifiedRoutes.unverified_url(+ PlausibleWeb.Endpoint,+ "/#{URI.encode_www_form(domain)}",+ params+ )+ end++ defp encode_path([str | _] = path) when is_binary(str) do+ Enum.map_join(path, "/", &encode_segment/1)+ end++ defp encode_segment(data) do+ data+ |> Phoenix.Param.to_param()+ |> URI.encode(&URI.char_unreserved?/1)+ end+enddiff --git a/lib/plausible_web/views/email_view.ex b/lib/plausible_web/views/email_view.exindex d9d41c8830..7383de3dbf 100644--- a/lib/plausible_web/views/email_view.ex+++ b/lib/plausible_web/views/email_view.ex@@ -7,13 +7,12 @@ defmodule PlausibleWeb.EmailView doenddef choose_plan_url(team) do- PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan) <>- "?__team=#{team.identifier}"+ url(~p"/billing/choose-plan?#{[__team: team.identifier]}")endon_ee dodef customer_support_team_url(team) do- PlausibleWeb.Router.Helpers.customer_support_team_url(PlausibleWeb.Endpoint, :show, team.id)+ url(~p"/cs/teams/team/#{team.id}")endelsedef customer_support_team_url(_team), do: nildiff --git a/lib/plausible_web/views/layout_view.ex b/lib/plausible_web/views/layout_view.exindex 247a1eadc7..9ca656a173 100644--- a/lib/plausible_web/views/layout_view.ex+++ b/lib/plausible_web/views/layout_view.ex@@ -43,9 +43,9 @@ defmodule PlausibleWeb.LayoutView dodef logo_path(filename) doif ee?() do- Path.join("/images/ee/", filename)+ ~p"/images/ee/#{filename}"else- Path.join("/images/ce/", filename)+ ~p"/images/ce/#{filename}"endend@@ -199,7 +199,7 @@ defmodule PlausibleWeb.LayoutView do</.dropdown_item><.dropdown_item:if={@pinned_team}- href={Routes.site_path(PlausibleWeb.Endpoint, :index, __team: @pinned_team.identifier)}+ href={~p"/sites?#{[__team: @pinned_team.identifier]}"}><div class="flex items-center justify-between gap-2" role="none"><p class="font-semibold truncate min-w-0 text-gray-900 dark:text-gray-100">@@ -211,7 +211,7 @@ defmodule PlausibleWeb.LayoutView do<div class="max-h-[200px] overflow-y-auto"><.dropdown_item:for={team <- @other_teams}- href={Routes.site_path(PlausibleWeb.Endpoint, :index, __team: team.identifier)}+ href={~p"/sites?#{[__team: team.identifier]}"}><pclass="font-medium truncate text-gray-900 dark:text-gray-100 pr-4"diff --git a/lib/workers/traffic_change_notifier.ex b/lib/workers/traffic_change_notifier.exindex b026e02eaa..1ea9579503 100644--- a/lib/workers/traffic_change_notifier.ex+++ b/lib/workers/traffic_change_notifier.ex@@ -4,11 +4,12 @@ defmodule Plausible.Workers.TrafficChangeNotifier do"""use Plausibleuse Plausible.Repo++ use PlausibleWeb.VerifiedRoutes+alias Plausible.Stats.{Clickhouse, ParsedQueryParams, QueryBuilder}alias Plausible.Site.TrafficChangeNotification- alias PlausibleWeb.Router.Helpers, as: Routes-use Oban.Worker, queue: :spike_notifications@min_interval_hours 12@@ -80,8 +81,7 @@ defmodule Plausible.Workers.TrafficChangeNotifier dodefp send_spike_notification(recipient_email, site, stats) dodashboard_link =if site_member?(site, recipient_email) do- Routes.stats_url(PlausibleWeb.Endpoint, :stats, site.domain, []) <>- "?__team=#{site.team.identifier}"+ stats_url(site.domain, __team: site.team.identifier)endtemplate =@@ -100,15 +100,14 @@ defmodule Plausible.Workers.TrafficChangeNotifier dodashboard_link =if site_member? do- Routes.stats_url(PlausibleWeb.Endpoint, :stats, site.domain, []) <>- "?__team=#{site.team.identifier}"+ stats_url(site.domain, __team: site.team.identifier)endinstallation_link =if site_member? and Plausible.Sites.regular?(site) do- Routes.site_url(PlausibleWeb.Endpoint, :installation, site.domain,- flow: PlausibleWeb.Flows.review()- ) <> "&__team=#{site.team.identifier}"+ url(+ ~p"/#{site.domain}/installation?#{[flow: PlausibleWeb.Flows.review(), __team: site.team.identifier]}"+ )endtemplate =diff --git a/test/plausible/help_scout_test.exs b/test/plausible/help_scout_test.exsindex 018353c6d5..eb8ed8dde4 100644--- a/test/plausible/help_scout_test.exs+++ b/test/plausible/help_scout_test.exs@@ -8,8 +8,6 @@ defmodule Plausible.HelpScoutTest doalias Plausible.HelpScoutalias Plausible.Repo- alias PlausibleWeb.Router.Helpers, as: Routes-require Plausible.Billing.Subscription.Status@v4_business_monthly_plan_id "857105"@@ -59,7 +57,7 @@ defmodule Plausible.HelpScoutTest dostub_help_scout_requests(email)team = team_of(user)- crm_url = Routes.customer_support_team_url(PlausibleWeb.Endpoint, :show, team.id)+ crm_url = url(~p"/cs/teams/team/#{team.id}")assert {:ok,%{@@ -442,7 +440,7 @@ defmodule Plausible.HelpScoutTest doteam = team_of(user)- crm_url = Routes.customer_support_team_url(PlausibleWeb.Endpoint, :show, team.id)+ crm_url = url(~p"/cs/teams/team/#{team.id}")assert {:ok,%{@@ -480,7 +478,7 @@ defmodule Plausible.HelpScoutTest donew_site(owner: user2)team2 = team_of(user2)- crm_url = Routes.customer_support_team_url(PlausibleWeb.Endpoint, :show, team2.id)+ crm_url = url(~p"/cs/teams/team/#{team2.id}")assert {:ok,%{diff --git a/test/plausible_web/controllers/api/paddle_controller_test.exs b/test/plausible_web/controllers/api/paddle_controller_test.exsindex f2bd0e35c9..d712711286 100644--- a/test/plausible_web/controllers/api/paddle_controller_test.exs+++ b/test/plausible_web/controllers/api/paddle_controller_test.exs@@ -35,13 +35,13 @@ defmodule PlausibleWeb.Api.PaddleControllerTest do# NOTE: signature check happens soonerassert_raise RuntimeError, ~r/Invalid passthrough sent via Paddle/, fn ->- post(conn, Routes.paddle_path(conn, :webhook), @webhook_body)+ post(conn, ~p"/api/paddle/webhook", @webhook_body)endendtest "not verified when signature is corrupted", %{conn: conn} docorrupted = Map.put(@webhook_body, "p_signature", Base.encode64("123 fake signature"))- conn = post(conn, Routes.paddle_path(conn, :webhook), corrupted)+ conn = post(conn, ~p"/api/paddle/webhook", corrupted)assert conn.status == 400endend@@ -50,7 +50,7 @@ defmodule PlausibleWeb.Api.PaddleControllerTest dotest "retrieves successfully", %{conn: conn} doexpect_get_prices_response(get_prices_body("USD"))- conn = get(conn, Routes.paddle_path(conn, :currency))+ conn = get(conn, ~p"/api/paddle/currency")assert_receive :paddle_queriedassert json_response(conn, 200) == %{"currency" => "$"}end@@ -58,20 +58,20 @@ defmodule PlausibleWeb.Api.PaddleControllerTest dotest "caches per ip", %{conn: initial_conn} doexpect_get_prices_response(get_prices_body("USD"))- conn = get(initial_conn, Routes.paddle_path(initial_conn, :currency))+ conn = get(initial_conn, ~p"/api/paddle/currency")assert json_response(conn, 200) == %{"currency" => "$"}assert_receive :paddle_queriedexpect_get_prices_response(get_prices_body("GBP"))- conn = get(initial_conn, Routes.paddle_path(initial_conn, :currency))+ conn = get(initial_conn, ~p"/api/paddle/currency")assert json_response(conn, 200) == %{"currency" => "$"}refute_receive :paddle_queriednew_ip =Plug.Conn.put_req_header(initial_conn, "x-forwarded-for", random_ip())- conn = get(new_ip, Routes.paddle_path(initial_conn, :currency))+ conn = get(new_ip, ~p"/api/paddle/currency")assert json_response(conn, 200) == %{"currency" => "£"}assert_receive :paddle_queriedend@@ -79,7 +79,7 @@ defmodule PlausibleWeb.Api.PaddleControllerTest dotest "falls back to EUR when paddle fails to respond", %{conn: conn} doexpect_get_prices_response(%{"response" => %{}})- conn = get(conn, Routes.paddle_path(conn, :currency))+ conn = get(conn, ~p"/api/paddle/currency")assert_receive :paddle_queriedassert json_response(conn, 200) == %{"currency" => "€"}end@@ -87,12 +87,12 @@ defmodule PlausibleWeb.Api.PaddleControllerTest dotest "does not cache failed fetches", %{conn: initial_conn} doexpect_get_prices_response(%{"response" => %{}})- conn = get(initial_conn, Routes.paddle_path(initial_conn, :currency))+ conn = get(initial_conn, ~p"/api/paddle/currency")assert json_response(conn, 200) == %{"currency" => "€"}expect_get_prices_response(get_prices_body("USD"))- conn = get(initial_conn, Routes.paddle_path(initial_conn, :currency))+ conn = get(initial_conn, ~p"/api/paddle/currency")assert json_response(conn, 200) == %{"currency" => "$"}enddiff --git a/test/plausible_web/controllers/api/stats_controller/authorization_test.exs b/test/plausible_web/controllers/api/stats_controller/authorization_test.exsindex 1f3d640685..18311b5a7d 100644--- a/test/plausible_web/controllers/api/stats_controller/authorization_test.exs+++ b/test/plausible_web/controllers/api/stats_controller/authorization_test.exs@@ -6,7 +6,7 @@ defmodule PlausibleWeb.Api.StatsController.AuthorizationTest do[date_range: "day", metrics: ["visitors"], filters: []]|> Keyword.merge(params)- post(conn, Routes.stats_path(conn, :query, site.domain), params)+ post(conn, ~p"/api/stats/#{site.domain}/query", params)enddescribe "API authorization - as anonymous user" dodiff --git a/test/plausible_web/controllers/auth_controller_test.exs b/test/plausible_web/controllers/auth_controller_test.exsindex 0e21403f2f..29dc6023b0 100644--- a/test/plausible_web/controllers/auth_controller_test.exs+++ b/test/plausible_web/controllers/auth_controller_test.exs@@ -232,7 +232,7 @@ defmodule PlausibleWeb.AuthControllerTest doassert %{sessions: [%{token: token}]} = user |> Repo.reload!() |> Repo.preload(:sessions)assert get_session(conn, :user_token) == token- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"endtest "logs the user in, accepts team invite and redirects to team sites index", %{@@ -261,7 +261,7 @@ defmodule PlausibleWeb.AuthControllerTest doassert %{sessions: [%{token: token}]} = user |> Repo.reload!() |> Repo.preload(:sessions)assert get_session(conn, :user_token) == token- assert redirected_to(conn, 302) == Routes.site_path(conn, :index, __team: team.identifier)+ assert redirected_to(conn, 302) == ~p"/sites?#{[__team: team.identifier]}"assert_team_membership(user, team, :viewer)end@@ -293,7 +293,7 @@ defmodule PlausibleWeb.AuthControllerTest doassert %{sessions: [%{token: token}]} = user |> Repo.reload!() |> Repo.preload(:sessions)assert get_session(conn, :user_token) == token- assert redirected_to(conn, 302) == Routes.site_path(conn, :index, __team: team.identifier)+ assert redirected_to(conn, 302) == ~p"/sites?#{[__team: team.identifier]}"endend@@ -450,7 +450,7 @@ defmodule PlausibleWeb.AuthControllerTest doconn = post(conn, "/activate", %{code: code, team_identifier: team.identifier})assert redirected_to(conn) ==- Routes.site_path(conn, :index, __team: team.identifier, flow: "")+ ~p"/sites?#{[__team: team.identifier, flow: ""]}"assert_team_membership(user, team, :viewer)end@@ -471,7 +471,7 @@ defmodule PlausibleWeb.AuthControllerTest doconn = post(conn, "/activate", %{code: code, team_identifier: team.identifier})assert redirected_to(conn) ==- Routes.site_path(conn, :index, __team: team.identifier, flow: "")+ ~p"/sites?#{[__team: team.identifier, flow: ""]}"endtest "removes used up verification code", %{conn: conn, user: user} do@@ -575,10 +575,10 @@ defmodule PlausibleWeb.AuthControllerTest dopost(conn, "/login",email: user.email,password: "password",- return_to: Routes.settings_path(conn, :index)+ return_to: ~p"/settings")- assert redirected_to(conn, 302) == Routes.settings_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/settings"endtest "valid email and password with 2FA enabled - sets 2FA session and redirects", %{@@ -592,7 +592,7 @@ defmodule PlausibleWeb.AuthControllerTest doconn = post(conn, "/login", email: user.email, password: "password")- assert redirected_to(conn, 302) == Routes.auth_path(conn, :verify_2fa_form)+ assert redirected_to(conn, 302) == ~p"/2fa/verify"assert fetch_cookies(conn).cookies["session_2fa"].current_2fa_user_id == user.idrefute get_session(conn)["user_token"]@@ -610,7 +610,7 @@ defmodule PlausibleWeb.AuthControllerTest doconn = post(conn, "/login", email: user.email, password: "password")- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert conn.resp_cookies["session_2fa"].max_age == 0assert %{sessions: [%{token: token}]} = user |> Repo.reload!() |> Repo.preload(:sessions)@@ -630,7 +630,7 @@ defmodule PlausibleWeb.AuthControllerTest doconn = post(conn, "/login", email: user.email, password: "password")- assert redirected_to(conn, 302) == Routes.auth_path(conn, :verify_2fa_form)+ assert redirected_to(conn, 302) == ~p"/2fa/verify"assert fetch_cookies(conn).cookies["session_2fa"].current_2fa_user_id == user.idrefute get_session(conn, :user_token)@@ -653,7 +653,7 @@ defmodule PlausibleWeb.AuthControllerTest doconn = post(conn, "/login", email: owner.email, password: "password")- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert conn.resp_cookies["session_2fa"].max_age == 0assert %{sessions: [%{token: token}]} = owner |> Repo.reload!() |> Repo.preload(:sessions)@@ -914,7 +914,7 @@ defmodule PlausibleWeb.AuthControllerTest dotest "refuses to delete SSO user", %{conn: conn, user: user} doconn = delete(conn, "/me")- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert Repo.reload(user)end@@ -984,7 +984,7 @@ defmodule PlausibleWeb.AuthControllerTest doconn = delete(conn, "/me")- assert redirected_to(conn, 302) == Routes.settings_path(conn, :danger_zone)+ assert redirected_to(conn, 302) == ~p"/settings/danger-zone"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"You have an active subscription which must be canceled first"@@ -1011,7 +1011,7 @@ defmodule PlausibleWeb.AuthControllerTest doconn = delete(conn, "/me")- assert redirected_to(conn, 302) == Routes.settings_path(conn, :danger_zone)+ assert redirected_to(conn, 302) == ~p"/settings/danger-zone"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"You can't delete your account when you are the only owner on a team"@@ -1033,7 +1033,7 @@ defmodule PlausibleWeb.AuthControllerTest doconn = delete(conn, "/me")- assert redirected_to(conn, 302) == Routes.settings_path(conn, :danger_zone)+ assert redirected_to(conn, 302) == ~p"/settings/danger-zone"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"You can't delete your account when you are the only owner on a team"@@ -1168,10 +1168,10 @@ defmodule PlausibleWeb.AuthControllerTest doPhoenix.Token.sign(PlausibleWeb.Endpoint, "google-oauth-state", [site.id, "import"])callback_params = %{"error" => "access_denied", "state" => state}- conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn = get(conn, ~p"/auth/google/callback", callback_params)assert redirected_to(conn, 302) ==- Routes.site_path(conn, :settings_imports_exports, site.domain)+ ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"unable to authenticate your Google Analytics"@@ -1188,10 +1188,10 @@ defmodule PlausibleWeb.AuthControllerTest do])callback_params = %{"error" => "access_denied", "state" => state}- conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn = get(conn, ~p"/auth/google/callback", callback_params)assert redirected_to(conn, 302) ==- Routes.site_path(conn, :settings_integrations, site.domain)+ ~p"/#{site.domain}/settings/integrations"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"unable to authenticate your Google Analytics"@@ -1207,10 +1207,10 @@ defmodule PlausibleWeb.AuthControllerTest doPhoenix.Token.sign(PlausibleWeb.Endpoint, "google-oauth-state", [site.id, "import"])callback_params = %{"error" => "server_error", "state" => state}- conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn = get(conn, ~p"/auth/google/callback", callback_params)assert redirected_to(conn, 302) ==- Routes.site_path(conn, :settings_imports_exports, site.domain)+ ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Google's authentication service is temporarily unavailable"@@ -1229,10 +1229,10 @@ defmodule PlausibleWeb.AuthControllerTest do])callback_params = %{"error" => "temporarily_unavailable", "state" => state}- conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn = get(conn, ~p"/auth/google/callback", callback_params)assert redirected_to(conn, 302) ==- Routes.site_path(conn, :settings_integrations, site.domain)+ ~p"/#{site.domain}/settings/integrations"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Google's authentication service is temporarily unavailable"@@ -1248,10 +1248,10 @@ defmodule PlausibleWeb.AuthControllerTest doPhoenix.Token.sign(PlausibleWeb.Endpoint, "google-oauth-state", [site.id, "import"])callback_params = %{"error" => "unknown", "state" => state}- conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn = get(conn, ~p"/auth/google/callback", callback_params)assert redirected_to(conn, 302) ==- Routes.site_path(conn, :settings_imports_exports, site.domain)+ ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"unable to authenticate your Google Analytics"@@ -1270,10 +1270,10 @@ defmodule PlausibleWeb.AuthControllerTest do])callback_params = %{"error" => "unknown", "state" => state}- conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn = get(conn, ~p"/auth/google/callback", callback_params)assert redirected_to(conn, 302) ==- Routes.site_path(conn, :settings_integrations, site.domain)+ ~p"/#{site.domain}/settings/integrations"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"unable to authenticate your Google Analytics"@@ -1286,9 +1286,9 @@ defmodule PlausibleWeb.AuthControllerTest doPhoenix.Token.sign(PlausibleWeb.Endpoint, "google-oauth-state", [site.id, "import"])callback_params = %{"error" => "access_denied", "state" => state <> "gibberish"}- conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn = get(conn, ~p"/auth/google/callback", callback_params)- assert redirected_to(conn, 302) == Routes.auth_path(conn, :login_form)+ assert redirected_to(conn, 302) == ~p"/login"endtest "rejects error callback with signed state containing non-existent site", %{conn: conn} do@@ -1299,9 +1299,9 @@ defmodule PlausibleWeb.AuthControllerTest doPhoenix.Token.sign(PlausibleWeb.Endpoint, "google-oauth-state", [site.id, "import"])callback_params = %{"error" => "access_denied", "state" => state}- conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn = get(conn, ~p"/auth/google/callback", callback_params)- assert redirected_to(conn, 302) == Routes.auth_path(conn, :login_form)+ assert redirected_to(conn, 302) == ~p"/login"endtest "rejects success callback with tampered state", %{conn: conn} do@@ -1311,9 +1311,9 @@ defmodule PlausibleWeb.AuthControllerTest doPhoenix.Token.sign(PlausibleWeb.Endpoint, "google-oauth-state", [site.id, "import"])callback_params = %{"code" => "CodeForToken", "state" => state <> "gibberish"}- conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn = get(conn, ~p"/auth/google/callback", callback_params)- assert redirected_to(conn, 302) == Routes.auth_path(conn, :login_form)+ assert redirected_to(conn, 302) == ~p"/login"endtest "rejects success callback with signed state containing non-existent site", %{conn: conn} do@@ -1324,9 +1324,9 @@ defmodule PlausibleWeb.AuthControllerTest doPhoenix.Token.sign(PlausibleWeb.Endpoint, "google-oauth-state", [site.id, "import"])callback_params = %{"code" => "CodeForToken", "state" => state}- conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn = get(conn, ~p"/auth/google/callback", callback_params)- assert redirected_to(conn, 302) == Routes.auth_path(conn, :login_form)+ assert redirected_to(conn, 302) == ~p"/login"endtest "success callback rejects state pointing to a site the current user does not own",@@ -1346,9 +1346,9 @@ defmodule PlausibleWeb.AuthControllerTest docallback_params = %{"code" => "CodeForToken", "state" => state}attacker_conn =- get(attacker_conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ get(attacker_conn, ~p"/auth/google/callback", callback_params)- assert redirected_to(attacker_conn, 302) == Routes.auth_path(conn, :login_form)+ assert redirected_to(attacker_conn, 302) == ~p"/login"# confirm no GoogleAuth record was created for the victim's siterefute Repo.exists?(@@ -1365,7 +1365,7 @@ defmodule PlausibleWeb.AuthControllerTest doPhoenix.Token.sign(PlausibleWeb.Endpoint, "google-oauth-state", [site.id, "import"])callback_params = %{"code" => "CodeForToken", "state" => state}- conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn = get(conn, ~p"/auth/google/callback", callback_params)assert redirect_url = redirected_to(conn, 302)@@ -1388,10 +1388,10 @@ defmodule PlausibleWeb.AuthControllerTest do])callback_params = %{"code" => "CodeForToken", "state" => state}- conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn = get(conn, ~p"/auth/google/callback", callback_params)assert redirected_to(conn, 302) ==- Routes.site_path(conn, :settings_integrations, site.domain)+ ~p"/#{site.domain}/settings/integrations"assert_matches %{access_token: "SomeAccessToken",@@ -1419,10 +1419,10 @@ defmodule PlausibleWeb.AuthControllerTest do])callback_params = %{"code" => "CodeForToken", "state" => state}- conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn = get(conn, ~p"/auth/google/callback", callback_params)assert redirected_to(conn, 302) ==- Routes.site_path(conn, :settings_integrations, site.domain)+ ~p"/#{site.domain}/settings/integrations"assert_matches %{access_token: "SomeAccessToken",@@ -1451,10 +1451,10 @@ defmodule PlausibleWeb.AuthControllerTest do])callback_params = %{"code" => "CodeForToken", "state" => state}- conn_first = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn_first = get(conn, ~p"/auth/google/callback", callback_params)assert redirected_to(conn_first, 302) ==- Routes.site_path(conn, :settings_integrations, site.domain)+ ~p"/#{site.domain}/settings/integrations"assert_matches %{access_token: "SomeAccessToken",@@ -1467,10 +1467,10 @@ defmodule PlausibleWeb.AuthControllerTest dofrom ga in Plausible.Site.GoogleAuth, where: ga.site_id == ^site.id)- conn_second = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)+ conn_second = get(conn, ~p"/auth/google/callback", callback_params)assert redirected_to(conn_second, 302) ==- Routes.site_path(conn, :settings_integrations, site.domain)+ ~p"/#{site.domain}/settings/integrations"assert_matches %{access_token: "SomeAccessToken",@@ -1492,7 +1492,7 @@ defmodule PlausibleWeb.AuthControllerTest doconn: conn,user: user} do- conn = post(conn, Routes.auth_path(conn, :initiate_2fa_setup))+ conn = post(conn, ~p"/2fa/setup/initiate")secret = Base.encode32(Repo.reload!(user).totp_secret)@@ -1504,7 +1504,7 @@ defmodule PlausibleWeb.AuthControllerTest doendtest "shows additional notice when `force` parameter set", %{conn: conn} do- conn = post(conn, Routes.auth_path(conn, :initiate_2fa_setup, force: "true"))+ conn = post(conn, ~p"/2fa/setup/initiate?#{[force: "true"]}")assert html = html_response(conn, 200)assert html =~ "You've been redirected here because your team enforces 2FA."@@ -1514,9 +1514,9 @@ defmodule PlausibleWeb.AuthControllerTest do{:ok, user, _} = Auth.TOTP.initiate(user){:ok, _, _} = Auth.TOTP.enable(user, :skip_verify)- conn = post(conn, Routes.auth_path(conn, :initiate_2fa_setup))+ conn = post(conn, ~p"/2fa/setup/initiate")- assert redirected_to(conn, 302) == Routes.settings_path(conn, :security) <> "#update-2fa"+ assert redirected_to(conn, 302) == ~p"/settings/security#update-2fa"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Two-Factor Authentication is already setup"@@ -1529,25 +1529,25 @@ defmodule PlausibleWeb.AuthControllerTest dotest "renders form when 2FA setup is initiated", %{conn: conn, user: user} do{:ok, _, _} = Auth.TOTP.initiate(user)- conn = get(conn, Routes.auth_path(conn, :verify_2fa_setup))+ conn = get(conn, ~p"/2fa/setup/verify")assert html = html_response(conn, 200)assert text_of_attr(html, "form#verify-2fa-form", "action") ==- Routes.auth_path(conn, :verify_2fa_setup)+ ~p"/2fa/setup/verify"assert element_exists?(html, "input[name=code]")assert element_exists?(html,- ~s|a[data-method="post"][data-to="#{Routes.auth_path(conn, :initiate_2fa_setup)}"]|+ ~s|a[data-method="post"][data-to="#{~p"/2fa/setup/initiate"}"]|)endtest "redirects back to settings if 2FA not initiated", %{conn: conn} do- conn = get(conn, Routes.auth_path(conn, :verify_2fa_setup))+ conn = get(conn, ~p"/2fa/setup/verify")- assert redirected_to(conn, 302) == Routes.settings_path(conn, :security) <> "#update-2fa"+ assert redirected_to(conn, 302) == ~p"/settings/security#update-2fa"endend@@ -1561,7 +1561,7 @@ defmodule PlausibleWeb.AuthControllerTest do{:ok, user, _} = Auth.TOTP.initiate(user)code = NimbleTOTP.verification_code(user.totp_secret)- conn = post(conn, Routes.auth_path(conn, :verify_2fa_setup), %{code: code})+ conn = post(conn, ~p"/2fa/setup/verify", %{code: code})assert html = html_response(conn, 200)@@ -1574,7 +1574,7 @@ defmodule PlausibleWeb.AuthControllerTest dotest "renders error on invalid code provided", %{conn: conn, user: user} do{:ok, _, _} = Auth.TOTP.initiate(user)- conn = post(conn, Routes.auth_path(conn, :verify_2fa_setup), %{code: "invalid"})+ conn = post(conn, ~p"/2fa/setup/verify", %{code: "invalid"})assert html_response(conn, 200)@@ -1583,9 +1583,9 @@ defmodule PlausibleWeb.AuthControllerTest doendtest "redirects to settings when 2FA is not initiated", %{conn: conn} do- conn = post(conn, Routes.auth_path(conn, :verify_2fa_setup), %{code: "123123"})+ conn = post(conn, ~p"/2fa/setup/verify", %{code: "123123"})- assert redirected_to(conn, 302) == Routes.settings_path(conn, :security) <> "#update-2fa"+ assert redirected_to(conn, 302) == ~p"/settings/security#update-2fa"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Please enable Two-Factor Authentication"@@ -1599,9 +1599,9 @@ defmodule PlausibleWeb.AuthControllerTest do{:ok, user, _} = Auth.TOTP.initiate(user){:ok, _, _} = Auth.TOTP.enable(user, :skip_verify)- conn = post(conn, Routes.auth_path(conn, :disable_2fa), %{password: "password"})+ conn = post(conn, ~p"/2fa/disable", %{password: "password"})- assert redirected_to(conn, 302) == Routes.settings_path(conn, :security) <> "#update-2fa"+ assert redirected_to(conn, 302) == ~p"/settings/security#update-2fa"assert Phoenix.Flash.get(conn.assigns.flash, :success) =~"Two-Factor Authentication is disabled"@@ -1613,9 +1613,9 @@ defmodule PlausibleWeb.AuthControllerTest do{:ok, user, _} = Auth.TOTP.initiate(user){:ok, _, _} = Auth.TOTP.enable(user, :skip_verify)- conn = post(conn, Routes.auth_path(conn, :disable_2fa), %{password: "invalid"})+ conn = post(conn, ~p"/2fa/disable", %{password: "invalid"})- assert redirected_to(conn, 302) == Routes.settings_path(conn, :security) <> "#update-2fa"+ assert redirected_to(conn, 302) == ~p"/settings/security#update-2fa"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~ "Incorrect password provided"end@@ -1629,9 +1629,9 @@ defmodule PlausibleWeb.AuthControllerTest do{:ok, user, _} = Auth.TOTP.initiate(user){:ok, _, _} = Auth.TOTP.enable(user, :skip_verify)- conn = post(conn, Routes.auth_path(conn, :disable_2fa), %{password: "password"})+ conn = post(conn, ~p"/2fa/disable", %{password: "password"})- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert user |> Repo.reload!() |> Auth.TOTP.enabled?()end@@ -1646,7 +1646,7 @@ defmodule PlausibleWeb.AuthControllerTest do{:ok, _, _} = Auth.TOTP.enable(user, :skip_verify)conn =- post(conn, Routes.auth_path(conn, :generate_2fa_recovery_codes), %{password: "password"})+ post(conn, ~p"/2fa/recovery_codes", %{password: "password"})assert html = html_response(conn, 200)@@ -1659,18 +1659,18 @@ defmodule PlausibleWeb.AuthControllerTest do{:ok, _, _} = Auth.TOTP.enable(user, :skip_verify)conn =- post(conn, Routes.auth_path(conn, :generate_2fa_recovery_codes), %{password: "invalid"})+ post(conn, ~p"/2fa/recovery_codes", %{password: "invalid"})- assert redirected_to(conn, 302) == Routes.settings_path(conn, :security) <> "#update-2fa"+ assert redirected_to(conn, 302) == ~p"/settings/security#update-2fa"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~ "Incorrect password provided"endtest "renders error when 2FA is not enabled", %{conn: conn} doconn =- post(conn, Routes.auth_path(conn, :generate_2fa_recovery_codes), %{password: "password"})+ post(conn, ~p"/2fa/recovery_codes", %{password: "password"})- assert redirected_to(conn, 302) == Routes.settings_path(conn, :security) <> "#update-2fa"+ assert redirected_to(conn, 302) == ~p"/settings/security#update-2fa"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Please enable Two-Factor Authentication"@@ -1690,24 +1690,23 @@ defmodule PlausibleWeb.AuthControllerTest doconn =get(conn,- Routes.auth_path(conn, :verify_2fa_form, return_to: Routes.settings_path(conn, :index))+ ~p"/2fa/verify?#{[return_to: ~p"/settings"]}")assert html = html_response(conn, 200)- assert text_of_attr(html, "form", "action") ==- Routes.auth_path(conn, :verify_2fa, return_to: Routes.settings_path(conn, :index))+ assert text_of_attr(html, "form", "action") == ~p"/2fa/verify?#{[return_to: ~p"/settings"]}"assert element_exists?(html, "input[name=code]")assert element_exists?(html, "input[name=remember_2fa]")assert text_of_attr(html, "input[name=return_to]", "value") ==- Routes.settings_path(conn, :index)+ ~p"/settings"assert element_exists?(html,- "a[href='#{Routes.auth_path(conn, :verify_2fa_recovery_code_form)}']"+ "a[href='#{~p"/2fa/use_recovery_code"}']")end@@ -1718,9 +1717,9 @@ defmodule PlausibleWeb.AuthControllerTest do{:ok, user, _} = Auth.TOTP.initiate(user){:ok, _, _} = Auth.TOTP.enable(user, :skip_verify)- conn = get(conn, Routes.auth_path(conn, :verify_2fa_form))+ conn = get(conn, ~p"/2fa/verify")- assert redirected_to(conn, 302) == Routes.auth_path(conn, :login_form)+ assert redirected_to(conn, 302) == ~p"/login"endtest "redirects to login when 2FA not enabled", %{conn: conn} do@@ -1734,9 +1733,9 @@ defmodule PlausibleWeb.AuthControllerTest do{:ok, _} = Auth.TOTP.disable(user, "password")- conn = get(conn, Routes.auth_path(conn, :verify_2fa_form))+ conn = get(conn, ~p"/2fa/verify")- assert redirected_to(conn, 302) == Routes.auth_path(conn, :login_form)+ assert redirected_to(conn, 302) == ~p"/login"endend@@ -1752,9 +1751,9 @@ defmodule PlausibleWeb.AuthControllerTest docode = NimbleTOTP.verification_code(user.totp_secret)- conn = post(conn, Routes.auth_path(conn, :verify_2fa), %{code: code})+ conn = post(conn, ~p"/2fa/verify", %{code: code})- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert %{sessions: [%{token: token}]} = user |> Repo.reload!() |> Repo.preload(:sessions)assert get_session(conn)["user_token"] == token@@ -1776,7 +1775,7 @@ defmodule PlausibleWeb.AuthControllerTest docode = NimbleTOTP.verification_code(user.totp_secret)conn =- post(conn, Routes.auth_path(conn, :verify_2fa), %{code: code, return_to: "/dummy.site"})+ post(conn, ~p"/2fa/verify", %{code: code, return_to: "/dummy.site"})assert redirected_to(conn, 302) == "/dummy.site"end@@ -1792,9 +1791,9 @@ defmodule PlausibleWeb.AuthControllerTest docode = NimbleTOTP.verification_code(user.totp_secret)- conn = post(conn, Routes.auth_path(conn, :verify_2fa), %{code: code, remember_2fa: "true"})+ conn = post(conn, ~p"/2fa/verify", %{code: code, remember_2fa: "true"})- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert %{sessions: [%{token: token}]} = user |> Repo.reload!() |> Repo.preload(:sessions)assert get_session(conn)["user_token"] == token@@ -1818,9 +1817,9 @@ defmodule PlausibleWeb.AuthControllerTest docode = NimbleTOTP.verification_code(user.totp_secret)- conn = post(conn, Routes.auth_path(conn, :verify_2fa), %{code: code, remember_2fa: "true"})+ conn = post(conn, ~p"/2fa/verify", %{code: code, remember_2fa: "true"})- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert %{sessions: [%{token: token}]} = user |> Repo.reload!() |> Repo.preload(:sessions)assert get_session(conn)["user_token"] == token@@ -1845,9 +1844,9 @@ defmodule PlausibleWeb.AuthControllerTest docode = NimbleTOTP.verification_code(user.totp_secret)- conn = post(conn, Routes.auth_path(conn, :verify_2fa), %{code: code})+ conn = post(conn, ~p"/2fa/verify", %{code: code})- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert %{sessions: [%{token: token}]} = user |> Repo.reload!() |> Repo.preload(:sessions)assert get_session(conn, :user_token) == token@@ -1866,7 +1865,7 @@ defmodule PlausibleWeb.AuthControllerTest doconn = login_with_cookie(conn, user.email, "password")- conn = post(conn, Routes.auth_path(conn, :verify_2fa), %{code: "invalid"})+ conn = post(conn, ~p"/2fa/verify", %{code: "invalid"})assert html_response(conn, 200) =~ "The provided code is invalid"end@@ -1880,9 +1879,9 @@ defmodule PlausibleWeb.AuthControllerTest docode = NimbleTOTP.verification_code(user.totp_secret)- conn = post(conn, Routes.auth_path(conn, :verify_2fa, %{code: code}))+ conn = post(conn, ~p"/2fa/verify?#{[code: code]}")- assert redirected_to(conn, 302) == Routes.auth_path(conn, :login_form)+ assert redirected_to(conn, 302) == ~p"/login"endtest "passes through when 2FA is disabled", %{conn: conn} do@@ -1898,9 +1897,9 @@ defmodule PlausibleWeb.AuthControllerTest do{:ok, _} = Auth.TOTP.disable(user, "password")- conn = post(conn, Routes.auth_path(conn, :verify_2fa), %{code: code})+ conn = post(conn, ~p"/2fa/verify", %{code: code})- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert %{sessions: [%{token: token}]} = user |> Repo.reload!() |> Repo.preload(:sessions)assert get_session(conn)["user_token"] == token@@ -1924,10 +1923,10 @@ defmodule PlausibleWeb.AuthControllerTest doeventually(fn ->Enum.each(1..5, fn _ ->- post(conn, Routes.auth_path(conn, :verify_2fa), %{code: "invalid"})+ post(conn, ~p"/2fa/verify", %{code: "invalid"})end)- conn = post(conn, Routes.auth_path(conn, :verify_2fa), %{code: "invalid"})+ conn = post(conn, ~p"/2fa/verify", %{code: "invalid"}){conn.status == 429, conn}end,@@ -1951,16 +1950,16 @@ defmodule PlausibleWeb.AuthControllerTest doconn = login_with_cookie(conn, user.email, "password")- conn = get(conn, Routes.auth_path(conn, :verify_2fa_recovery_code_form))+ conn = get(conn, ~p"/2fa/use_recovery_code")assert html = html_response(conn, 200)assert text_of_attr(html, "form", "action") ==- Routes.auth_path(conn, :verify_2fa_recovery_code)+ ~p"/2fa/use_recovery_code"assert element_exists?(html, "input[name=recovery_code]")- assert element_exists?(html, "a[href='#{Routes.auth_path(conn, :verify_2fa_form)}']")+ assert element_exists?(html, "a[href='#{~p"/2fa/verify"}']")endtest "redirects to login when cookie not found", %{conn: conn} do@@ -1970,9 +1969,9 @@ defmodule PlausibleWeb.AuthControllerTest do{:ok, user, _} = Auth.TOTP.initiate(user){:ok, _, _} = Auth.TOTP.enable(user, :skip_verify)- conn = get(conn, Routes.auth_path(conn, :verify_2fa_recovery_code_form))+ conn = get(conn, ~p"/2fa/use_recovery_code")- assert redirected_to(conn, 302) == Routes.auth_path(conn, :login_form)+ assert redirected_to(conn, 302) == ~p"/login"endtest "redirects to login when 2FA not enabled", %{conn: conn} do@@ -1986,9 +1985,9 @@ defmodule PlausibleWeb.AuthControllerTest do{:ok, _} = Auth.TOTP.disable(user, "password")- conn = get(conn, Routes.auth_path(conn, :verify_2fa_recovery_code_form))+ conn = get(conn, ~p"/2fa/use_recovery_code")- assert redirected_to(conn, 302) == Routes.auth_path(conn, :login_form)+ assert redirected_to(conn, 302) == ~p"/login"endend@@ -2003,11 +2002,11 @@ defmodule PlausibleWeb.AuthControllerTest doconn = login_with_cookie(conn, user.email, "password")conn =- post(conn, Routes.auth_path(conn, :verify_2fa_recovery_code), %{+ post(conn, ~p"/2fa/use_recovery_code", %{recovery_code: recovery_code})- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert %{sessions: [%{token: token}]} = user |> Repo.reload!() |> Repo.preload(:sessions)assert get_session(conn)["user_token"] == token@@ -2025,7 +2024,7 @@ defmodule PlausibleWeb.AuthControllerTest doconn = login_with_cookie(conn, user.email, "password")conn =- post(conn, Routes.auth_path(conn, :verify_2fa_recovery_code), %{recovery_code: "invalid"})+ post(conn, ~p"/2fa/use_recovery_code", %{recovery_code: "invalid"})assert html_response(conn, 200) =~ "The provided recovery code is invalid"end@@ -2040,10 +2039,10 @@ defmodule PlausibleWeb.AuthControllerTest doconn =post(conn,- Routes.auth_path(conn, :verify_2fa_recovery_code, %{recovery_code: recovery_code})+ ~p"/2fa/use_recovery_code?#{[recovery_code: recovery_code]}")- assert redirected_to(conn, 302) == Routes.auth_path(conn, :login_form)+ assert redirected_to(conn, 302) == ~p"/login"endtest "passes through when 2FA is disabled", %{conn: conn} do@@ -2058,11 +2057,11 @@ defmodule PlausibleWeb.AuthControllerTest do{:ok, _} = Auth.TOTP.disable(user, "password")conn =- post(conn, Routes.auth_path(conn, :verify_2fa_recovery_code), %{+ post(conn, ~p"/2fa/use_recovery_code", %{recovery_code: recovery_code})- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert %{sessions: [%{token: token}]} = user |> Repo.reload!() |> Repo.preload(:sessions)assert get_session(conn)["user_token"] == token@@ -2086,13 +2085,13 @@ defmodule PlausibleWeb.AuthControllerTest doeventually(fn ->Enum.each(1..5, fn _ ->- post(conn, Routes.auth_path(conn, :verify_2fa_recovery_code), %{+ post(conn, ~p"/2fa/use_recovery_code", %{recovery_code: "invalid"})end)conn =- post(conn, Routes.auth_path(conn, :verify_2fa_recovery_code), %{+ post(conn, ~p"/2fa/use_recovery_code", %{recovery_code: "invalid"})@@ -2110,7 +2109,7 @@ defmodule PlausibleWeb.AuthControllerTest dodefp login_with_cookie(conn, email, password) doconn- |> post(Routes.auth_path(conn, :login), %{+ |> post(~p"/login", %{email: email,password: password})diff --git a/test/plausible_web/controllers/billing_controller_test.exs b/test/plausible_web/controllers/billing_controller_test.exsindex 87575e2dd4..af8444bb97 100644--- a/test/plausible_web/controllers/billing_controller_test.exs+++ b/test/plausible_web/controllers/billing_controller_test.exs@@ -14,8 +14,8 @@ defmodule PlausibleWeb.BillingControllerTest do%{conn: conn, user: user} dosubscribe_to_enterprise_plan(user, paddle_plan_id: "123")- conn = get(conn, Routes.billing_path(conn, :choose_plan))- assert redirected_to(conn) == Routes.billing_path(conn, :upgrade_to_enterprise_plan)+ conn = get(conn, ~p"/billing/choose-plan")+ assert redirected_to(conn) == ~p"/billing/upgrade-to-enterprise-plan"endend@@ -31,7 +31,7 @@ defmodule PlausibleWeb.BillingControllerTest doadd_guest(site, role: :viewer)end- conn = post(conn, Routes.billing_path(conn, :change_plan, @v4_growth_plan))+ conn = post(conn, ~p"/billing/change-plan/#{@v4_growth_plan}")assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Unable to subscribe to this plan because the following limits are exceeded: team member limit"@@ -51,7 +51,7 @@ defmodule PlausibleWeb.BillingControllerTest dofor _ <- 1..11, do: new_site(owner: user)- conn = post(conn, Routes.billing_path(conn, :change_plan, @v4_growth_plan))+ conn = post(conn, ~p"/billing/change-plan/#{@v4_growth_plan}")subscription = Plausible.Repo.get_by(Plausible.Billing.Subscription, team_id: team.id)@@ -71,7 +71,7 @@ defmodule PlausibleWeb.BillingControllerTest dogenerate_usage_for(site, 11_000, NaiveDateTime.shift(now, day: -5))generate_usage_for(site, 11_000, NaiveDateTime.shift(now, day: -35))- conn1 = post(conn, Routes.billing_path(conn, :change_plan, @v4_growth_plan))+ conn1 = post(conn, ~p"/billing/change-plan/#{@v4_growth_plan}")subscription = Plausible.Repo.get_by(Plausible.Billing.Subscription, team_id: team.id)@@ -85,7 +85,7 @@ defmodule PlausibleWeb.BillingControllerTest do|> Ecto.Changeset.change(allow_next_upgrade_override: true)|> Plausible.Repo.update!()- conn2 = post(conn, Routes.billing_path(conn, :change_plan, @v4_growth_plan))+ conn2 = post(conn, ~p"/billing/change-plan/#{@v4_growth_plan}")subscription = Plausible.Repo.reload!(subscription)@@ -97,7 +97,7 @@ defmodule PlausibleWeb.BillingControllerTest dosubscribe_to_plan(user, "321321")team = team_of(user)- post(conn, Routes.billing_path(conn, :change_plan, "123123"))+ post(conn, ~p"/billing/change-plan/123123")subscription = Plausible.Repo.get_by(Plausible.Billing.Subscription, team_id: team.id)assert subscription.paddle_plan_id == "123123"@@ -110,7 +110,7 @@ defmodule PlausibleWeb.BillingControllerTest dosetup [:create_user, :create_team, :log_in]test "shows success page after user subscribes", %{conn: conn} do- conn = get(conn, Routes.billing_path(conn, :upgrade_success))+ conn = get(conn, ~p"/billing/upgrade-success")assert html_response(conn, 200) =~ "Your account is being upgraded"end@@ -124,7 +124,7 @@ defmodule PlausibleWeb.BillingControllerTest dotest "displays basic page content", %{conn: conn} dodoc =conn- |> get(Routes.billing_path(conn, :upgrade_to_enterprise_plan))+ |> get(~p"/billing/upgrade-to-enterprise-plan")|> html_response(200)assert doc =~ "Upgrade to Enterprise"@@ -139,7 +139,7 @@ defmodule PlausibleWeb.BillingControllerTest dotest "displays info about the enterprise plan to upgrade to", %{conn: conn} dodoc =conn- |> get(Routes.billing_path(conn, :upgrade_to_enterprise_plan))+ |> get(~p"/billing/upgrade-to-enterprise-plan")|> html_response(200)assert doc =~ ~r/Up to\s*<b>\s*50M\s*<\/b>\s*monthly pageviews/@@ -155,7 +155,7 @@ defmodule PlausibleWeb.BillingControllerTest dodoc =conn- |> get(Routes.billing_path(conn, :upgrade_to_enterprise_plan))+ |> get(~p"/billing/upgrade-to-enterprise-plan")|> html_response(200)assert %{@@ -163,7 +163,7 @@ defmodule PlausibleWeb.BillingControllerTest do"email" => user.email,"passthrough" => "ee:#{ee?()};user:#{user.id};team:#{team.id}","product" => @configured_enterprise_plan_paddle_plan_id,- "success" => Routes.billing_path(PlausibleWeb.Endpoint, :upgrade_success),+ "success" => ~p"/billing/upgrade-success","theme" => "none"} == get_paddle_checkout_params(find(doc, "#paddle-button"))end@@ -175,7 +175,7 @@ defmodule PlausibleWeb.BillingControllerTest dotest "displays basic page content", %{conn: conn} dodoc =conn- |> get(Routes.billing_path(conn, :upgrade_to_enterprise_plan))+ |> get(~p"/billing/upgrade-to-enterprise-plan")|> html_response(200)assert doc =~ "Change subscription plan"@@ -190,7 +190,7 @@ defmodule PlausibleWeb.BillingControllerTest dotest "displays info about the enterprise plan to upgrade to", %{conn: conn} dodoc =conn- |> get(Routes.billing_path(conn, :upgrade_to_enterprise_plan))+ |> get(~p"/billing/upgrade-to-enterprise-plan")|> html_response(200)assert doc =~ ~r/Up to\s*<b>\s*50M\s*<\/b>\s*monthly pageviews/@@ -203,18 +203,14 @@ defmodule PlausibleWeb.BillingControllerTest dotest "preview changes links to :change_plan_preview action", %{conn: conn} dodoc =conn- |> get(Routes.billing_path(conn, :upgrade_to_enterprise_plan))+ |> get(~p"/billing/upgrade-to-enterprise-plan")|> html_response(200)preview_changes_link = find(doc, "#preview-changes")assert text(preview_changes_link) == "Preview changes"assert text_of_attr(preview_changes_link, "href") ==- Routes.billing_path(- PlausibleWeb.Endpoint,- :change_plan_preview,- @configured_enterprise_plan_paddle_plan_id- )+ ~p"/billing/change-plan/preview/#{@configured_enterprise_plan_paddle_plan_id}"endend@@ -226,7 +222,7 @@ defmodule PlausibleWeb.BillingControllerTest dohtml_response =conn- |> get(Routes.billing_path(conn, :change_plan_preview, @v4_business_plan))+ |> get(~p"/billing/change-plan/preview/#{@v4_business_plan}")|> html_response(200)assert html_response =~@@ -240,12 +236,12 @@ defmodule PlausibleWeb.BillingControllerTest dotest "flashes error and redirects to choose-plan page", %{conn: conn, user: user} do# choose-plan enforces at least 1 site, which implies team created, before allowing the user to upgradenew_site(owner: user)- conn = get(conn, Routes.billing_path(conn, :change_plan_preview, @v4_business_plan))+ conn = get(conn, ~p"/billing/change-plan/preview/#{@v4_business_plan}")assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Something went wrong with loading your plan change information. Please try again, or contact us at [email protected] if the issue persists."- assert redirected_to(conn) == Routes.billing_path(conn, :choose_plan)+ assert redirected_to(conn) == ~p"/billing/choose-plan"endend@@ -259,7 +255,7 @@ defmodule PlausibleWeb.BillingControllerTest dotest "renders contact note", %{conn: conn} dodoc =conn- |> get(Routes.billing_path(conn, :upgrade_to_enterprise_plan))+ |> get(~p"/billing/upgrade-to-enterprise-plan")|> html_response(200)assert doc =~ "Looking to adjust your plan?"@@ -275,14 +271,14 @@ defmodule PlausibleWeb.BillingControllerTest dotest "redirects to /settings when past_due", %{conn: conn} = context dosubscribe_enterprise(context, status: Subscription.Status.past_due())- conn = get(conn, Routes.billing_path(conn, :upgrade_to_enterprise_plan))- assert redirected_to(conn) == Routes.settings_path(conn, :subscription)+ conn = get(conn, ~p"/billing/upgrade-to-enterprise-plan")+ assert redirected_to(conn) == ~p"/settings/billing/subscription"endtest "redirects to /settings when paused", %{conn: conn} = context dosubscribe_enterprise(context, status: Subscription.Status.paused())- conn = get(conn, Routes.billing_path(conn, :upgrade_to_enterprise_plan))- assert redirected_to(conn) == Routes.settings_path(conn, :subscription)+ conn = get(conn, ~p"/billing/upgrade-to-enterprise-plan")+ assert redirected_to(conn) == ~p"/settings/billing/subscription"endend@@ -301,7 +297,7 @@ defmodule PlausibleWeb.BillingControllerTest dotest "displays the same content as for a user without a subscription", %{conn: conn} dodoc =conn- |> get(Routes.billing_path(conn, :upgrade_to_enterprise_plan))+ |> get(~p"/billing/upgrade-to-enterprise-plan")|> html_response(200)assert doc =~ "Upgrade to Enterprise"@@ -316,7 +312,7 @@ defmodule PlausibleWeb.BillingControllerTest dotest "still allows to subscribe back to the same plan", %{conn: conn} dodoc =conn- |> get(Routes.billing_path(conn, :upgrade_to_enterprise_plan))+ |> get(~p"/billing/upgrade-to-enterprise-plan")|> html_response(200)assert doc =~ ~r/Up to\s*<b>\s*50M\s*<\/b>\s*monthly pageviews/@@ -332,7 +328,7 @@ defmodule PlausibleWeb.BillingControllerTest dodoc =conn- |> get(Routes.billing_path(conn, :upgrade_to_enterprise_plan))+ |> get(~p"/billing/upgrade-to-enterprise-plan")|> html_response(200)assert %{@@ -340,7 +336,7 @@ defmodule PlausibleWeb.BillingControllerTest do"email" => user.email,"passthrough" => "ee:#{ee?()};user:#{user.id};team:#{team.id}","product" => @configured_enterprise_plan_paddle_plan_id,- "success" => Routes.billing_path(PlausibleWeb.Endpoint, :upgrade_success),+ "success" => ~p"/billing/upgrade-success","theme" => "none"} == get_paddle_checkout_params(find(doc, "#paddle-button"))enddiff --git a/test/plausible_web/controllers/error_report_controller_test.exs b/test/plausible_web/controllers/error_report_controller_test.exsindex 15d262547b..9fd19e5c56 100644--- a/test/plausible_web/controllers/error_report_controller_test.exs+++ b/test/plausible_web/controllers/error_report_controller_test.exs@@ -6,7 +6,6 @@ defmodule PlausibleWeb.ErrorReportControllerTest doimport Phoenix.View- alias PlausibleWeb.Endpointalias PlausibleWeb.ErrorViewalias PlausibleWeb.EmailView@@ -29,7 +28,7 @@ defmodule PlausibleWeb.ErrorReportControllerTest dofor error <- ["500", "502", "503", "504"] dotest "renders the form when sentry metadata present: #{error}", %{user: user} doSentry.put_last_event_id_and_source("some-event-id", :plug)- action_path = Routes.error_report_path(Endpoint, :submit_error_report)+ action_path = ~p"/error_report"assert html =render_to_string(ErrorView, unquote(error) <> ".html", %{@@ -47,7 +46,7 @@ defmodule PlausibleWeb.ErrorReportControllerTest doendtest "submitting the feedback form for authenticated user", %{conn: conn, user: user} do- action_path = Routes.error_report_path(Endpoint, :submit_error_report)+ action_path = ~p"/error_report"conn =post(conn, action_path, %{@@ -71,7 +70,7 @@ defmodule PlausibleWeb.ErrorReportControllerTest doendtest "short feedback is not sent", %{conn: conn} do- action_path = Routes.error_report_path(Endpoint, :submit_error_report)+ action_path = ~p"/error_report"conn =post(conn, action_path, %{@@ -87,7 +86,7 @@ defmodule PlausibleWeb.ErrorReportControllerTest doendtest "submitting no feedback for authenticated user", %{conn: conn} do- action_path = Routes.error_report_path(Endpoint, :submit_error_report)+ action_path = ~p"/error_report"conn =post(conn, action_path, %{@@ -118,7 +117,7 @@ defmodule PlausibleWeb.ErrorReportControllerTest dodescribe "Not logged in" dotest "submitting the feedback form for unauthenticated user", %{conn: conn} do- action_path = Routes.error_report_path(Endpoint, :submit_error_report)+ action_path = ~p"/error_report"conn =post(conn, action_path, %{@@ -140,7 +139,7 @@ defmodule PlausibleWeb.ErrorReportControllerTest doassert text =~ "There has been a server error"assert text =~ "But don't worry, we're on it!"- action_path = Routes.error_report_path(Endpoint, :submit_error_report)+ action_path = ~p"/error_report"refute form_exists?(html, action_path)endenddiff --git a/test/plausible_web/controllers/google_analytics_controller_test.exs b/test/plausible_web/controllers/google_analytics_controller_test.exsindex 5ecfc5712b..b02f6c2513 100644--- a/test/plausible_web/controllers/google_analytics_controller_test.exs+++ b/test/plausible_web/controllers/google_analytics_controller_test.exs@@ -62,12 +62,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"expires_at" => "2022-09-22T20:01:37.112777"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Google Analytics rate limit has been exceeded. Please try again later."@@ -93,12 +88,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"expires_at" => "2022-09-22T20:01:37.112777"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"We were unable to authenticate your Google Analytics account"@@ -126,12 +116,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"expires_at" => "2022-09-22T20:01:37.112777"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"""@@ -161,12 +146,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"expires_at" => "2022-09-22T20:01:37.112777"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Google Analytics API has timed out."@@ -193,12 +173,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"expires_at" => "2022-09-22T20:01:37.112777"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"We were unable to list your Google Analytics properties"@@ -354,12 +329,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"expires_at" => "2022-09-22T20:01:37.112777"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"We were unable to retrieve information from Google Analytics"@@ -387,12 +357,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"expires_at" => "2022-09-22T20:01:37.112777"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Google Analytics rate limit has been exceeded. Please try again later."@@ -420,12 +385,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"expires_at" => "2022-09-22T20:01:37.112777"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Google Analytics authentication seems to have expired."@@ -454,12 +414,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"expires_at" => "2022-09-22T20:01:37.112777"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"""@@ -491,12 +446,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"expires_at" => "2022-09-22T20:01:37.112777"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Google Analytics API has timed out."@@ -528,7 +478,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do})|> html_response(200)- action_url = PlausibleWeb.Router.Helpers.google_analytics_path(conn, :import, site.domain)+ action_url = ~p"/#{site.domain}/settings/google-import"assert text_of_attr(response, "form", "action") == action_url@@ -570,12 +520,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"end_date" => "2024-02-26"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"We were unable to retrieve information from Google Analytics"@@ -605,12 +550,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"end_date" => "2024-02-26"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Google Analytics rate limit has been exceeded. Please try again later."@@ -640,12 +580,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"end_date" => "2024-02-26"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Google Analytics authentication seems to have expired."@@ -677,12 +612,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"end_date" => "2024-02-26"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"""@@ -716,12 +646,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"end_date" => "2024-02-26"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Google Analytics API has timed out."@@ -743,7 +668,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do})assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(conn, :settings_imports_exports, site.domain)+ ~p"/#{site.domain}/settings/imports-exports"[site_import] = Plausible.Imported.list_all_imports(site)@@ -841,12 +766,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do"expires_at" => "2022-09-22T20:01:37.112777"})- assert redirected_to(conn, 302) ==- PlausibleWeb.Router.Helpers.site_path(- conn,- :settings_imports_exports,- site.domain- )+ assert redirected_to(conn, 302) == ~p"/#{site.domain}/settings/imports-exports"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Import failed. No data could be imported because date range overlaps with existing data."diff --git a/test/plausible_web/controllers/help_scout_controller_test.exs b/test/plausible_web/controllers/help_scout_controller_test.exsindex 5bb115f238..0052dd4855 100644--- a/test/plausible_web/controllers/help_scout_controller_test.exs+++ b/test/plausible_web/controllers/help_scout_controller_test.exs@@ -50,7 +50,7 @@ defmodule PlausibleWeb.HelpScoutControllerTest doassert [] = Plug.Conn.get_resp_header(conn, "content-security-policy")html = html_response(conn, 200)- assert html =~ Routes.customer_support_user_path(PlausibleWeb.Endpoint, :show, user.id)+ assert html =~ ~p"/cs/users/user/#{user.id}"assert text_of_attr("input[name=token]", "value") != ""end@@ -133,7 +133,7 @@ defmodule PlausibleWeb.HelpScoutControllerTest do)assert html = html_response(conn, 200)- assert html =~ Routes.customer_support_user_path(PlausibleWeb.Endpoint, :show, user.id)+ assert html =~ ~p"/cs/users/user/#{user.id}"assert html =~ "Some note<br>\nwith new line"end@@ -162,7 +162,7 @@ defmodule PlausibleWeb.HelpScoutControllerTest do)assert html = html_response(conn, 200)- assert html =~ Routes.customer_support_user_path(PlausibleWeb.Endpoint, :show, user.id)+ assert html =~ ~p"/cs/users/user/#{user.id}"assert html =~ "Some user notes"assert html =~ "My personal sites"assert html =~ "HS Integration Test Team"diff --git a/test/plausible_web/controllers/invitation_controller_test.exs b/test/plausible_web/controllers/invitation_controller_test.exsindex 319afa46f4..0f07d663e1 100644--- a/test/plausible_web/controllers/invitation_controller_test.exs+++ b/test/plausible_web/controllers/invitation_controller_test.exs@@ -20,7 +20,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doassert Phoenix.Flash.get(conn.assigns.flash, :success) =="You now have access to #{site.domain}"- assert redirected_to(conn) == Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain)+ assert redirected_to(conn) == stats_path(site.domain)refute Repo.exists?(from(i in Plausible.Teams.Invitation, where: i.email == ^user.email))@@ -53,7 +53,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doinvitation = invite_guest(site, user.email, role: :editor, inviter: owner)c1 = post(conn, "/sites/invitations/#{invitation.invitation_id}/accept")- assert redirected_to(c1) == Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain)+ assert redirected_to(c1) == stats_path(site.domain)assert Phoenix.Flash.get(c1.assigns.flash, :success) =="You now have access to #{site.domain}"@@ -78,8 +78,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doconn = post(conn, "/sites/invitations/#{transfer.transfer_id}/accept")- assert redirected_to(conn, 302) ==- Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain)+ assert redirected_to(conn, 302) == stats_path(site.domain)assert Phoenix.Flash.get(conn.assigns.flash, :success) =~"You now have access to"@@ -141,8 +140,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doconn = post(conn, "/sites/invitations/#{transfer.transfer_id}/accept")- assert redirected_to(conn, 302) ==- Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain)+ assert redirected_to(conn, 302) == stats_path(site.domain)assert Phoenix.Flash.get(conn.assigns.flash, :success) =~"You now have access to"@@ -163,7 +161,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doconn = post(conn, "/sites/invitations/#{transfer.transfer_id}/accept")- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"No existing subscription"@@ -183,7 +181,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doconn = post(conn, "/sites/invitations/#{transfer.transfer_id}/accept")- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Plan limits exceeded: site limit."@@ -210,8 +208,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest do"/sites/invitations/#{transfer.transfer_id}/accept?skip_site_members_transfer=true")- assert redirected_to(conn, 302) ==- Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain)+ assert redirected_to(conn, 302) == stats_path(site.domain)assert Phoenix.Flash.get(conn.assigns.flash, :success) =~"You now have access to"@@ -271,7 +268,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doconn =delete(conn,- Routes.invitation_path(conn, :remove_invitation, site.domain, invitation.invitation_id)+ ~p"/sites/#{site.domain}/invitations/#{invitation.invitation_id}")assert redirected_to(conn, 302) == "/#{URI.encode_www_form(site.domain)}/settings/people"@@ -289,7 +286,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doconn =delete(conn,- Routes.invitation_path(conn, :remove_invitation, site.domain, transfer.transfer_id)+ ~p"/sites/#{site.domain}/invitations/#{transfer.transfer_id}")assert redirected_to(conn, 302) == "/#{URI.encode_www_form(site.domain)}/settings/people"@@ -306,7 +303,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest dodelete(conn,- Routes.invitation_path(conn, :remove_invitation, site.domain, invitation.invitation_id)+ ~p"/sites/#{site.domain}/invitations/#{invitation.invitation_id}")assert Repo.reload(invitation)@@ -323,12 +320,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doinvite_guest(other_site, "[email protected]", role: :editor, inviter: other_user)remove_invitation_path =- Routes.invitation_path(- my_conn,- :remove_invitation,- other_site.domain,- invitation.invitation_id- )+ ~p"/sites/#{other_site.domain}/invitations/#{invitation.invitation_id}"delete(my_conn, remove_invitation_path)@@ -341,12 +333,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doadd_member(team, user: user, role: :admin)remove_invitation_path =- Routes.invitation_path(- conn,- :remove_invitation,- site.domain,- "does_not_exist"- )+ ~p"/sites/#{site.domain}/invitations/does_not_exist"conn = delete(conn, remove_invitation_path)@@ -372,7 +359,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doconn =delete(conn,- Routes.invitation_path(conn, :remove_team_invitation, invitation.invitation_id)+ ~p"/settings/team/invitations/#{invitation.invitation_id}")assert redirected_to(conn, 302) == "/settings/team/general"@@ -394,7 +381,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doconn =delete(conn,- Routes.invitation_path(conn, :remove_team_invitation, invitation.invitation_id)+ ~p"/settings/team/invitations/#{invitation.invitation_id}")assert redirected_to(conn, 302) == "/settings/team/general"@@ -416,11 +403,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doinvite_member(other_team, "[email protected]", role: :editor, inviter: other_user)remove_invitation_path =- Routes.invitation_path(- my_conn,- :remove_team_invitation,- invitation.invitation_id- )+ ~p"/settings/team/invitations/#{invitation.invitation_id}"my_conn = delete(my_conn, remove_invitation_path)@@ -438,11 +421,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest doconn = set_current_team(conn, team)remove_invitation_path =- Routes.invitation_path(- conn,- :remove_team_invitation,- "does_not_exist"- )+ ~p"/settings/team/invitations/does_not_exist"conn = delete(conn, remove_invitation_path)diff --git a/test/plausible_web/controllers/settings_controller_sync_test.exs b/test/plausible_web/controllers/settings_controller_sync_test.exsindex cf8a34aeac..743f978ad7 100644--- a/test/plausible_web/controllers/settings_controller_sync_test.exs+++ b/test/plausible_web/controllers/settings_controller_sync_test.exs@@ -24,12 +24,12 @@ defmodule PlausibleWeb.SettingsControllerSyncTest doassert user.email_verifiedconn =- post(conn, Routes.settings_path(conn, :update_email), %{+ post(conn, ~p"/settings/security/email", %{"user" => %{"email" => "new" <> user.email, "password" => password}})assert redirected_to(conn, 302) ==- Routes.settings_path(conn, :security) <> "#update-email"+ ~p"/settings/security#update-email"updated_user = Repo.reload!(user)diff --git a/test/plausible_web/controllers/settings_controller_test.exs b/test/plausible_web/controllers/settings_controller_test.exsindex a4d59a392f..bfdd0609f5 100644--- a/test/plausible_web/controllers/settings_controller_test.exs+++ b/test/plausible_web/controllers/settings_controller_test.exs@@ -22,8 +22,8 @@ defmodule PlausibleWeb.SettingsControllerTest dosetup [:create_user, :log_in]test "redirects to subscription settings", %{conn: conn} do- conn = get(conn, Routes.settings_path(conn, :redirect_invoices))- assert redirected_to(conn, 302) == Routes.settings_path(conn, :subscription)+ conn = get(conn, ~p"/settings/billing/invoices")+ assert redirected_to(conn, 302) == ~p"/settings/billing/subscription"endend@@ -33,7 +33,7 @@ defmodule PlausibleWeb.SettingsControllerTest do@tag :ee_onlytest "shows subscription", %{conn: conn, user: user} dosubscribe_to_plan(user, "558018")- conn = get(conn, Routes.settings_path(conn, :subscription))+ conn = get(conn, ~p"/settings/billing/subscription")assert html_response(conn, 200) =~ "10k monthly pageviews"assert html_response(conn, 200) =~ "/ month"end@@ -41,7 +41,7 @@ defmodule PlausibleWeb.SettingsControllerTest do@tag :ee_onlytest "shows yearly subscription", %{conn: conn, user: user} dosubscribe_to_plan(user, "590752")- conn = get(conn, Routes.settings_path(conn, :subscription))+ conn = get(conn, ~p"/settings/billing/subscription")assert html_response(conn, 200) =~ "100k monthly pageviews"assert html_response(conn, 200) =~ "/ year"end@@ -49,7 +49,7 @@ defmodule PlausibleWeb.SettingsControllerTest do@tag :ee_onlytest "shows free subscription", %{conn: conn, user: user} dosubscribe_to_plan(user, "free_10k")- conn = get(conn, Routes.settings_path(conn, :subscription))+ conn = get(conn, ~p"/settings/billing/subscription")assert html_response(conn, 200) =~ "10k monthly pageviews"assert html_response(conn, 200) =~ "N/A"end@@ -58,7 +58,7 @@ defmodule PlausibleWeb.SettingsControllerTest dotest "shows enterprise plan subscription", %{conn: conn, user: user} doconfigure_enterprise_plan(user)- conn = get(conn, Routes.settings_path(conn, :subscription))+ conn = get(conn, ~p"/settings/billing/subscription")assert html_response(conn, 200) =~ "20M monthly pageviews"assert html_response(conn, 200) =~ "/ year"end@@ -77,7 +77,7 @@ defmodule PlausibleWeb.SettingsControllerTest dosubscription?: false)- conn = get(conn, Routes.settings_path(conn, :subscription))+ conn = get(conn, ~p"/settings/billing/subscription")assert html_response(conn, 200) =~ "20M monthly pageviews"assert html_response(conn, 200) =~ "/ year"end@@ -86,13 +86,13 @@ defmodule PlausibleWeb.SettingsControllerTest dotest "shows trial state without days-left pill when user has no team yet", %{conn: conn} dodoc =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)upgrade_link = find(doc, "#upgrade-or-change-plan-link")assert text(upgrade_link) =~ "Choose a plan"- assert text_of_attr(upgrade_link, "href") == Routes.billing_path(conn, :choose_plan)+ assert text_of_attr(upgrade_link, "href") == ~p"/billing/choose-plan"assert doc =~ "Your 30-day trial will start when you add your first site"refute doc =~ "days left"end@@ -107,13 +107,13 @@ defmodule PlausibleWeb.SettingsControllerTest dodoc =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)upgrade_link = find(doc, "#upgrade-or-change-plan-link")assert text(upgrade_link) =~ "Choose a plan"- assert text_of_attr(upgrade_link, "href") == Routes.billing_path(conn, :choose_plan)+ assert text_of_attr(upgrade_link, "href") == ~p"/billing/choose-plan"assert doc =~ "days left"refute doc =~ "Your 30-day trial will start when you add your first site"end@@ -127,7 +127,7 @@ defmodule PlausibleWeb.SettingsControllerTest dodoc =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)assert doc =~ "Cancel plan"@@ -135,7 +135,7 @@ defmodule PlausibleWeb.SettingsControllerTest dochange_plan_link = find(doc, "#upgrade-or-change-plan-link")assert text(change_plan_link) == "Change plan"- assert text_of_attr(change_plan_link, "href") == Routes.billing_path(conn, :choose_plan)+ assert text_of_attr(change_plan_link, "href") == ~p"/billing/choose-plan"end@tag :ee_only@@ -147,7 +147,7 @@ defmodule PlausibleWeb.SettingsControllerTest dodoc =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)refute element_exists?(doc, "#upgrade-or-change-plan-link")@@ -162,7 +162,7 @@ defmodule PlausibleWeb.SettingsControllerTest dodoc =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)refute element_exists?(doc, "#upgrade-or-change-plan-link")@@ -180,13 +180,13 @@ defmodule PlausibleWeb.SettingsControllerTest dodoc =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)upgrade_link = find(doc, "#upgrade-or-change-plan-link")assert text(upgrade_link) == "Upgrade"- assert text_of_attr(upgrade_link, "href") == Routes.billing_path(conn, :choose_plan)+ assert text_of_attr(upgrade_link, "href") == ~p"/billing/choose-plan"end@tag :ee_only@@ -196,7 +196,7 @@ defmodule PlausibleWeb.SettingsControllerTest dodoc =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)assert doc =~ "Cancel plan"@@ -206,7 +206,7 @@ defmodule PlausibleWeb.SettingsControllerTest doassert text(change_plan_link) == "Change plan"assert text_of_attr(change_plan_link, "href") ==- Routes.billing_path(conn, :choose_plan)+ ~p"/billing/choose-plan"end@tag :ee_only@@ -220,7 +220,7 @@ defmodule PlausibleWeb.SettingsControllerTest donotice_text =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)|> text_of_element("#global-subscription-cancelled-notice")@@ -239,7 +239,7 @@ defmodule PlausibleWeb.SettingsControllerTest donotice_text =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)|> text_of_element("#global-subscription-cancelled-notice")@@ -262,7 +262,7 @@ defmodule PlausibleWeb.SettingsControllerTest donotice_text =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)|> text_of_element("#global-subscription-cancelled-notice")@@ -277,7 +277,7 @@ defmodule PlausibleWeb.SettingsControllerTest dotest "does not show invoice section for a user with no subscription", %{conn: conn} dohtml =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)refute element_exists?(html, "#invoices")@@ -309,7 +309,7 @@ defmodule PlausibleWeb.SettingsControllerTest dohtml =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)assert html =~@@ -345,7 +345,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Plausible.Teams.with_subscription()|> Map.fetch!(:subscription)- get(conn, Routes.settings_path(conn, :subscription))+ get(conn, ~p"/settings/billing/subscription")|> html_response(200)|> assert_cycles_rendered.()@@ -356,7 +356,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.update!()conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)|> assert_cycles_rendered.()@@ -369,7 +369,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.update!()conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)|> assert_cycles_rendered.()end@@ -403,7 +403,7 @@ defmodule PlausibleWeb.SettingsControllerTest do# for a trial usertrial_html =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)assert_usage.(trial_html)@@ -422,7 +422,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Map.fetch!(:subscription)conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)|> assert_usage.()@@ -433,7 +433,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.update!()conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)|> assert_usage.()@@ -446,7 +446,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.insert!()conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)|> assert_usage.()end@@ -458,7 +458,7 @@ defmodule PlausibleWeb.SettingsControllerTest dohtml =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)sites_usage_text = text_of_element(html, "[data-test-id='sites-usage']")@@ -471,7 +471,7 @@ defmodule PlausibleWeb.SettingsControllerTest dohtml =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)team_member_usage_text = text_of_element(html, "[data-test-id='team-member-usage']")@@ -484,7 +484,7 @@ defmodule PlausibleWeb.SettingsControllerTest dohtml =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)team_member_usage_text = text_of_element(html, "[data-test-id='team-member-usage']")@@ -501,7 +501,7 @@ defmodule PlausibleWeb.SettingsControllerTest dohtml =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)assert html =~ "You don't have any invoices yet."@@ -513,7 +513,7 @@ defmodule PlausibleWeb.SettingsControllerTest dohtml =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)assert html =~ "Dec 24, 2020"@@ -528,7 +528,7 @@ defmodule PlausibleWeb.SettingsControllerTest dohtml =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)assert html =~ "Invoices"@@ -544,7 +544,7 @@ defmodule PlausibleWeb.SettingsControllerTest dohtml =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)assert element_exists?(html, "[data-test-id='total-pageviews-dashboard-link']")@@ -560,7 +560,7 @@ defmodule PlausibleWeb.SettingsControllerTest dohtml =conn- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)refute element_exists?(html, "[data-test-id='total-pageviews-dashboard-link']")@@ -579,7 +579,7 @@ defmodule PlausibleWeb.SettingsControllerTest dohtml =conn|> set_current_team(team)- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")|> html_response(200)assert element_exists?(html, "[data-test-id='total-pageviews-dashboard-link']")@@ -594,7 +594,7 @@ defmodule PlausibleWeb.SettingsControllerTest doconn =conn|> set_current_team(team)- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")assert html_response(conn, 200)end@@ -608,7 +608,7 @@ defmodule PlausibleWeb.SettingsControllerTest doconn =conn|> set_current_team(team)- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")assert html_response(conn, 200)end@@ -622,9 +622,9 @@ defmodule PlausibleWeb.SettingsControllerTest doconn =conn|> set_current_team(team)- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"end@tag :ee_only@@ -636,9 +636,9 @@ defmodule PlausibleWeb.SettingsControllerTest doconn =conn|> set_current_team(team)- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"end@tag :ee_only@@ -650,9 +650,9 @@ defmodule PlausibleWeb.SettingsControllerTest doconn =conn|> set_current_team(team)- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"endtest "allows any role on a non-setup (personal) team to access the page", %{@@ -666,7 +666,7 @@ defmodule PlausibleWeb.SettingsControllerTest doconn =conn|> set_current_team(team)- |> get(Routes.settings_path(conn, :subscription))+ |> get(~p"/settings/billing/subscription")assert html_response(conn, 200)end@@ -676,7 +676,7 @@ defmodule PlausibleWeb.SettingsControllerTest dosetup [:create_user, :log_in]test "renders 2FA section in disabled state", %{conn: conn} do- conn = get(conn, Routes.settings_path(conn, :security))+ conn = get(conn, ~p"/settings/security")assert html_response(conn, 200) =~ "Enable 2FA"end@@ -685,7 +685,7 @@ defmodule PlausibleWeb.SettingsControllerTest do{:ok, user, _} = Auth.TOTP.initiate(user){:ok, _, _} = Auth.TOTP.enable(user, :skip_verify)- conn = get(conn, Routes.settings_path(conn, :security))+ conn = get(conn, ~p"/settings/security")assert html_response(conn, 200) =~ "Disable 2FA"end@@ -699,7 +699,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Auth.UserSession.new_session("Some Device", now: seventy_minutes_ago)|> Repo.insert!()- conn = get(conn, Routes.settings_path(conn, :security))+ conn = get(conn, ~p"/settings/security")assert html = html_response(conn, 200)@@ -708,7 +708,7 @@ defmodule PlausibleWeb.SettingsControllerTest doassert html =~ "Just recently"assert html =~ "Some Device"assert html =~ "1 hour ago"- assert html =~ Routes.settings_path(conn, :delete_session, another_session.id)+ assert html =~ ~p"/settings/security/user-sessions/#{another_session.id}"endend@@ -721,12 +721,12 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Auth.UserSession.new_session("Some Device")|> Repo.insert!()- conn = delete(conn, Routes.settings_path(conn, :delete_session, another_session.id))+ conn = delete(conn, ~p"/settings/security/user-sessions/#{another_session.id}")assert Phoenix.Flash.get(conn.assigns.flash, :success) == "Session logged out successfully"assert redirected_to(conn, 302) ==- Routes.settings_path(conn, :security) <> "#user-sessions"+ ~p"/settings/security#user-sessions"refute Repo.reload(another_session)end@@ -738,9 +738,9 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.insert!()conn = build_conn()- conn = delete(conn, Routes.settings_path(conn, :delete_session, another_session.id))+ conn = delete(conn, ~p"/settings/security/user-sessions/#{another_session.id}")- assert redirected_to(conn, 302) == Routes.auth_path(conn, :login_form)+ assert redirected_to(conn, 302) == ~p"/login"assert Repo.reload(another_session)endend@@ -750,17 +750,17 @@ defmodule PlausibleWeb.SettingsControllerTest dotest "updates user's name", %{conn: conn, user: user} doconn =- post(conn, Routes.settings_path(conn, :update_name), %{"user" => %{"name" => "New name"}})+ post(conn, ~p"/settings/preferences/name", %{"user" => %{"name" => "New name"}})assert redirected_to(conn, 302) ==- Routes.settings_path(conn, :preferences) <> "#update-name"+ ~p"/settings/preferences#update-name"user = Plausible.Repo.get(Plausible.Auth.User, user.id)assert user.name == "New name"endtest "renders form with error if form validations fail", %{conn: conn} do- conn = post(conn, Routes.settings_path(conn, :update_name), %{"user" => %{"name" => ""}})+ conn = post(conn, ~p"/settings/preferences/name", %{"user" => %{"name" => ""}})assert text(html_response(conn, 200)) =~ "can't be blank"end@@ -772,11 +772,11 @@ defmodule PlausibleWeb.SettingsControllerTest dotest "refuses to update for SSO user", %{conn: conn, user: user} doconn =- post(conn, Routes.settings_path(conn, :update_name), %{+ post(conn, ~p"/settings/preferences/name", %{"user" => %{"name" => "New name"}})- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert Repo.reload!(user).name == user.nameend@@ -801,7 +801,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.update!()conn =- post(conn, Routes.settings_path(conn, :update_password), %{+ post(conn, ~p"/settings/security/password", %{"user" => %{"password" => new_password,"old_password" => password,@@ -810,7 +810,7 @@ defmodule PlausibleWeb.SettingsControllerTest do})assert redirected_to(conn, 302) ==- Routes.settings_path(conn, :security) <> "#update-password"+ ~p"/settings/security#update-password"current_hash = Repo.reload!(user).password_hashassert current_hash != original.password_hash@@ -825,7 +825,7 @@ defmodule PlausibleWeb.SettingsControllerTest donew_password = "weak"conn =- post(conn, Routes.settings_path(conn, :update_password), %{+ post(conn, ~p"/settings/security/password", %{"user" => %{"password" => new_password,"old_password" => password,@@ -842,7 +842,7 @@ defmodule PlausibleWeb.SettingsControllerTest donew_password = "super-long-super-secret-999"conn =- post(conn, Routes.settings_path(conn, :update_password), %{+ post(conn, ~p"/settings/security/password", %{"user" => %{"password" => new_password,"old_password" => password,@@ -869,7 +869,7 @@ defmodule PlausibleWeb.SettingsControllerTest docode = NimbleTOTP.verification_code(user.totp_secret)conn =- post(conn, Routes.settings_path(conn, :update_password), %{+ post(conn, ~p"/settings/security/password", %{"user" => %{"password" => new_password,"old_password" => password,@@ -879,7 +879,7 @@ defmodule PlausibleWeb.SettingsControllerTest do})assert redirected_to(conn, 302) ==- Routes.settings_path(conn, :security) <> "#update-password"+ ~p"/settings/security#update-password"current_hash = Repo.reload!(user).password_hashassert current_hash != original.password_hash@@ -900,7 +900,7 @@ defmodule PlausibleWeb.SettingsControllerTest do{:ok, _, _} = Auth.TOTP.enable(user, :skip_verify)conn =- post(conn, Routes.settings_path(conn, :update_password), %{+ post(conn, ~p"/settings/security/password", %{"user" => %{"password" => new_password,"old_password" => password,@@ -927,7 +927,7 @@ defmodule PlausibleWeb.SettingsControllerTest do{:ok, _, _} = Auth.TOTP.enable(user, :skip_verify)conn =- post(conn, Routes.settings_path(conn, :update_password), %{+ post(conn, ~p"/settings/security/password", %{"user" => %{"password" => new_password,"old_password" => password,@@ -941,7 +941,7 @@ defmodule PlausibleWeb.SettingsControllerTest dotest "fails to update with no input", %{conn: conn} doconn =- post(conn, Routes.settings_path(conn, :update_password), %{+ post(conn, ~p"/settings/security/password", %{"user" => %{"password" => "","old_password" => "",@@ -968,7 +968,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.update!()conn =- post(conn, Routes.settings_path(conn, :update_password), %{+ post(conn, ~p"/settings/security/password", %{"user" => %{"password" => new_password,"old_password" => password,@@ -976,7 +976,7 @@ defmodule PlausibleWeb.SettingsControllerTest do}})- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"current_hash = Repo.reload!(user).password_hashassert current_hash == original.password_hash@@ -998,11 +998,11 @@ defmodule PlausibleWeb.SettingsControllerTest doassert user.email_verifiedconn =- post(conn, Routes.settings_path(conn, :update_email), %{+ post(conn, ~p"/settings/security/email", %{"user" => %{"email" => "new" <> user.email, "password" => password}})- assert redirected_to(conn, 302) == Routes.auth_path(conn, :activate)+ assert redirected_to(conn, 302) == ~p"/activate"updated_user = Repo.reload!(user)@@ -1021,33 +1021,33 @@ defmodule PlausibleWeb.SettingsControllerTest do}resp1 =- conn |> post(Routes.settings_path(conn, :update_email), payload) |> html_response(200)+ conn |> post(~p"/settings/security/email", payload) |> html_response(200)assert resp1 =~ "is invalid"refute resp1 =~ "too many requests, try again in an hour"resp2 =- conn |> post(Routes.settings_path(conn, :update_email), payload) |> html_response(200)+ conn |> post(~p"/settings/security/email", payload) |> html_response(200)assert resp2 =~ "is invalid"refute resp2 =~ "too many requests, try again in an hour"resp3 =- conn |> post(Routes.settings_path(conn, :update_email), payload) |> html_response(200)+ conn |> post(~p"/settings/security/email", payload) |> html_response(200)assert resp3 =~ "is invalid"assert resp3 =~ "too many requests, try again in an hour"endtest "renders form with error on no fields filled", %{conn: conn} do- conn = post(conn, Routes.settings_path(conn, :update_email), %{"user" => %{"email" => ""}})+ conn = post(conn, ~p"/settings/security/email", %{"user" => %{"email" => ""}})assert text(html_response(conn, 200)) =~ "can't be blank"endtest "renders form with error on invalid password", %{conn: conn, user: user} doconn =- post(conn, Routes.settings_path(conn, :update_email), %{+ post(conn, ~p"/settings/security/email", %{"user" => %{"password" => "invalid", "email" => "new" <> user.email}})@@ -1064,7 +1064,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.update!()conn =- post(conn, Routes.settings_path(conn, :update_email), %{+ post(conn, ~p"/settings/security/email", %{"user" => %{"password" => password, "email" => other_user.email}})@@ -1082,7 +1082,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.update!()conn =- post(conn, Routes.settings_path(conn, :update_email), %{+ post(conn, ~p"/settings/security/email", %{"user" => %{"password" => password, "email" => user.email}})@@ -1104,11 +1104,11 @@ defmodule PlausibleWeb.SettingsControllerTest doassert user.email_verifiedconn =- post(conn, Routes.settings_path(conn, :update_email), %{+ post(conn, ~p"/settings/security/email", %{"user" => %{"email" => "new" <> user.email, "password" => password}})- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"updated_user = Repo.reload!(user)@@ -1131,10 +1131,10 @@ defmodule PlausibleWeb.SettingsControllerTest do)|> Repo.update!()- conn = post(conn, Routes.settings_path(conn, :cancel_update_email))+ conn = post(conn, ~p"/settings/security/email/cancel")assert redirected_to(conn, 302) ==- Routes.settings_path(conn, :security) <> "#update-email"+ ~p"/settings/security#update-email"updated_user = Repo.reload!(user)@@ -1159,9 +1159,9 @@ defmodule PlausibleWeb.SettingsControllerTest do_other_user = insert(:user, email: user.previous_email)conn =- post(conn, Routes.settings_path(conn, :cancel_update_email))+ post(conn, ~p"/settings/security/email/cancel")- assert redirected_to(conn, 302) == Routes.auth_path(conn, :activate_form)+ assert redirected_to(conn, 302) == ~p"/activate"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~"Could not cancel email update"@@ -1180,7 +1180,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.update!()assert_raise RuntimeError, ~r/Previous email is empty for user/, fn ->- post(conn, Routes.settings_path(conn, :cancel_update_email))+ post(conn, ~p"/settings/security/email/cancel")endendend@@ -1189,7 +1189,7 @@ defmodule PlausibleWeb.SettingsControllerTest dosetup [:create_user, :log_in]test "handles user without a team gracefully", %{conn: conn} do- conn = get(conn, Routes.settings_path(conn, :api_keys))+ conn = get(conn, ~p"/settings/api-keys")assert html_response(conn, 200)end@@ -1204,7 +1204,7 @@ defmodule PlausibleWeb.SettingsControllerTest doinsert(:api_key, user: user)insert(:api_key, user: user, scopes: ["sites:provision:*"])- conn = get(conn, Routes.settings_path(conn, :api_keys))+ conn = get(conn, ~p"/settings/api-keys")assert html = html_response(conn, 200)@@ -1222,7 +1222,7 @@ defmodule PlausibleWeb.SettingsControllerTest doteam = team_of(user)conn =- post(conn, Routes.settings_path(conn, :api_keys), %{+ post(conn, ~p"/settings/api-keys", %{"api_key" => %{"user_id" => user.id,"name" => "all your code are belong to us",@@ -1251,7 +1251,7 @@ defmodule PlausibleWeb.SettingsControllerTest doteam = team_of(user)conn =- post(conn, Routes.settings_path(conn, :api_keys), %{+ post(conn, ~p"/settings/api-keys", %{"api_key" => %{"user_id" => user.id,"name" => "all your code are belong to us",@@ -1273,7 +1273,7 @@ defmodule PlausibleWeb.SettingsControllerTest donew_site(owner: user)conn =- post(conn, Routes.settings_path(conn, :api_keys), %{+ post(conn, ~p"/settings/api-keys", %{"api_key" => %{"user_id" => user.id,"name" => "all your code are belong to us",@@ -1282,7 +1282,7 @@ defmodule PlausibleWeb.SettingsControllerTest do}})- assert redirected_to(conn, 302) == Routes.settings_path(conn, :new_api_key)+ assert redirected_to(conn, 302) == ~p"/settings/api-keys/new"assert Phoenix.Flash.get(conn.assigns.flash, :error) =="Your current subscription plan does not include Sites API access"@@ -1298,7 +1298,7 @@ defmodule PlausibleWeb.SettingsControllerTest doconn = set_current_team(conn, team)conn =- post(conn, Routes.settings_path(conn, :api_keys), %{+ post(conn, ~p"/settings/api-keys", %{"api_key" => %{"user_id" => user.id,"name" => "all your code are belong to us",@@ -1317,7 +1317,7 @@ defmodule PlausibleWeb.SettingsControllerTest donew_site(owner: user)conn =- post(conn, Routes.settings_path(conn, :api_keys), %{+ post(conn, ~p"/settings/api-keys", %{"api_key" => %{"user_id" => user.id,"name" => "all your code are belong to us",@@ -1327,7 +1327,7 @@ defmodule PlausibleWeb.SettingsControllerTest do})conn2 =- post(conn, Routes.settings_path(conn, :api_keys), %{+ post(conn, ~p"/settings/api-keys", %{"api_key" => %{"user_id" => user.id,"name" => "all your code are belong to us",@@ -1345,7 +1345,7 @@ defmodule PlausibleWeb.SettingsControllerTest do_other_site = new_site(owner: other_user)conn =- post(conn, Routes.settings_path(conn, :api_keys), %{+ post(conn, ~p"/settings/api-keys", %{"api_key" => %{"user_id" => other_user.id,"name" => "all your code are belong to us",@@ -1374,7 +1374,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> ApiKey.changeset(team, %{"name" => "other user's key"})|> Repo.insert()- conn = delete(conn, Routes.settings_path(conn, :delete_api_key, api_key.id))+ conn = delete(conn, ~p"/settings/api-keys/#{api_key.id}")assert Phoenix.Flash.get(conn.assigns.flash, :error) == "Could not find API Key to delete"assert Repo.get(ApiKey, api_key.id)end@@ -1384,7 +1384,7 @@ defmodule PlausibleWeb.SettingsControllerTest dosetup [:create_user, :log_in, :create_team]test "without active subscription", %{conn: conn} do- conn = get(conn, Routes.settings_path(conn, :danger_zone))+ conn = get(conn, ~p"/settings/danger-zone")assert html = html_response(conn, 200)@@ -1396,7 +1396,7 @@ defmodule PlausibleWeb.SettingsControllerTest dotest "with active subscription", %{conn: conn, user: user} dosubscribe_to_growth_plan(user)- conn = get(conn, Routes.settings_path(conn, :danger_zone))+ conn = get(conn, ~p"/settings/danger-zone")assert html = html_response(conn, 200)@@ -1414,7 +1414,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> team_of()|> Plausible.Teams.complete_setup()- conn = get(conn, Routes.settings_path(conn, :danger_zone))+ conn = get(conn, ~p"/settings/danger-zone")assert html = html_response(conn, 200)@@ -1439,7 +1439,7 @@ defmodule PlausibleWeb.SettingsControllerTest dosetup [:create_user, :create_site, :create_team, :setup_sso, :provision_sso_user, :log_in]test "shows only expected menu items", %{conn: conn} do- conn = get(conn, Routes.settings_path(conn, :preferences))+ conn = get(conn, ~p"/settings/preferences")assert html = html_response(conn, 200)expected_account_menu = [:preferences, :security, :subscription, :api_keys]@@ -1457,19 +1457,19 @@ defmodule PlausibleWeb.SettingsControllerTest doendtest "does not allow to update name in preferences", %{conn: conn} do- conn = get(conn, Routes.settings_path(conn, :preferences))+ conn = get(conn, ~p"/settings/preferences")assert html = html_response(conn, 200)refute html =~ "Change name"endtest "does not allow to update email in security settings", %{conn: conn} do- conn = get(conn, Routes.settings_path(conn, :security))+ conn = get(conn, ~p"/settings/security")assert html = html_response(conn, 200)refute html =~ "Change email"endtest "does not allow to change password in security settings", %{conn: conn} do- conn = get(conn, Routes.settings_path(conn, :security))+ conn = get(conn, ~p"/settings/security")assert html = html_response(conn, 200)refute html =~ "Change password"end@@ -1478,7 +1478,7 @@ defmodule PlausibleWeb.SettingsControllerTest do{:ok, user, _} = Auth.TOTP.initiate(user){:ok, _, _} = Auth.TOTP.enable(user, :skip_verify)- conn = get(conn, Routes.settings_path(conn, :security))+ conn = get(conn, ~p"/settings/security")assert html = html_response(conn, 200)assert text_of_element(html, "button[disabled]") =~ "Disable 2FA"end@@ -1490,7 +1490,7 @@ defmodule PlausibleWeb.SettingsControllerTest dotest "when no team is assigned & the user doesn't have a subscription, limited account menu is present",%{conn: conn} do- conn = get(conn, Routes.settings_path(conn, :preferences))+ conn = get(conn, ~p"/settings/preferences")html = html_response(conn, 200)refute html =~ "Team"@@ -1519,7 +1519,7 @@ defmodule PlausibleWeb.SettingsControllerTest do} dosubscribe_to_growth_plan(user)- conn = get(conn, Routes.settings_path(conn, :preferences))+ conn = get(conn, ~p"/settings/preferences")html = html_response(conn, 200)expected_account_menu =@@ -1548,7 +1548,7 @@ defmodule PlausibleWeb.SettingsControllerTest do{:ok, team} = Plausible.Teams.get_or_create(user)team = Plausible.Teams.complete_setup(team)conn = set_current_team(conn, team)- conn = get(conn, Routes.settings_path(conn, :preferences))+ conn = get(conn, ~p"/settings/preferences")html = html_response(conn, 200)assert html =~ ~r/Team.*#{Regex.escape(team.name)}/sassert html =~ team.name@@ -1581,7 +1581,7 @@ defmodule PlausibleWeb.SettingsControllerTest doteam = Plausible.Teams.complete_setup(team)conn = set_current_team(conn, team)- conn = get(conn, Routes.settings_path(conn, :preferences))+ conn = get(conn, ~p"/settings/preferences")html = html_response(conn, 200)assert html =~ ~r/Team.*#{Regex.escape(team.name)}/sassert html =~ team.name@@ -1612,7 +1612,7 @@ defmodule PlausibleWeb.SettingsControllerTest dotest "does not render team settings, when team not set up", %{conn: conn, user: user} do{:ok, team} = Plausible.Teams.get_or_create(user)- conn = get(conn, Routes.settings_path(conn, :preferences))+ conn = get(conn, ~p"/settings/preferences")html = html_response(conn, 200)refute html =~ ~r/Team.*#{Regex.escape(team.name)}/srefute html =~ team.name@@ -1622,7 +1622,7 @@ defmodule PlausibleWeb.SettingsControllerTest do{:ok, team} = Plausible.Teams.get_or_create(user)team = Plausible.Teams.complete_setup(team)conn = set_current_team(conn, team)- conn = get(conn, Routes.settings_path(conn, :team_general))+ conn = get(conn, ~p"/settings/team/general")html = html_response(conn, 200)assert html =~ "Team name"assert html =~ "Change the name of your team"@@ -1633,12 +1633,12 @@ defmodule PlausibleWeb.SettingsControllerTest do{:ok, team} = Plausible.Teams.get_or_create(user)conn =- post(conn, Routes.settings_path(conn, :update_team_name), %{+ post(conn, ~p"/settings/team/general/name", %{"team" => %{"name" => "New name"}})assert redirected_to(conn, 302) ==- Routes.settings_path(conn, :team_general) <> "#update-name"+ ~p"/settings/team/general#update-name"assert Repo.reload!(team).name == "New name"end@@ -1649,7 +1649,7 @@ defmodule PlausibleWeb.SettingsControllerTest doconn = set_current_team(conn, team)conn =- post(conn, Routes.settings_path(conn, :update_team_name), %{+ post(conn, ~p"/settings/team/general/name", %{"team" => %{"name" => ""}})@@ -1665,7 +1665,7 @@ defmodule PlausibleWeb.SettingsControllerTest doconn = set_current_team(conn, team)conn =- post(conn, Routes.settings_path(conn, :update_team_name), %{+ post(conn, ~p"/settings/team/general/name", %{"team" => %{"name" => String.duplicate("a", 51)}})@@ -1682,7 +1682,7 @@ defmodule PlausibleWeb.SettingsControllerTest doconn = set_current_team(conn, team)conn =- post(conn, Routes.settings_path(conn, :update_team_name), %{+ post(conn, ~p"/settings/team/general/name", %{"team" => %{"name" => "Cheap meds at https://spam.example.com"}})@@ -1702,7 +1702,7 @@ defmodule PlausibleWeb.SettingsControllerTest doconn = set_current_team(conn, team)- html = html_response(get(conn, Routes.settings_path(conn, :team_general)), 200)+ html = html_response(get(conn, ~p"/settings/team/general"), 200)assert text_of_attr(html, "input#team_name", "value") == long_nameend@@ -1718,12 +1718,12 @@ defmodule PlausibleWeb.SettingsControllerTest doconn = set_current_team(conn, team)conn =- post(conn, Routes.settings_path(conn, :update_team_name), %{+ post(conn, ~p"/settings/team/general/name", %{"team" => %{"name" => "Shorter name"}})assert redirected_to(conn, 302) ==- Routes.settings_path(conn, :team_general) <> "#update-name"+ ~p"/settings/team/general#update-name"assert Repo.reload!(team).name == "Shorter name"end@@ -1734,9 +1734,9 @@ defmodule PlausibleWeb.SettingsControllerTest doconn = set_current_team(conn, team)add_member(team, role: :owner)- conn = post(conn, Routes.settings_path(conn, :leave_team))+ conn = post(conn, ~p"/settings/team/leave")- assert redirected_to(conn, 302) == Routes.site_path(conn, :index, __team: "none")+ assert redirected_to(conn, 302) == ~p"/sites?#{[__team: "none"]}"assert Phoenix.Flash.get(conn.assigns.flash, :success) =~ "You have left"end@@ -1745,9 +1745,9 @@ defmodule PlausibleWeb.SettingsControllerTest doteam = Plausible.Teams.complete_setup(team)conn = set_current_team(conn, team)- conn = post(conn, Routes.settings_path(conn, :leave_team))+ conn = post(conn, ~p"/settings/team/leave")- assert redirected_to(conn, 302) == Routes.settings_path(conn, :team_general)+ assert redirected_to(conn, 302) == ~p"/settings/team/general"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~ "You can't leave"end@@ -1761,7 +1761,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.update!()conn = set_current_team(conn, team)- conn = get(conn, Routes.settings_path(conn, :team_danger_zone))+ conn = get(conn, ~p"/settings/team/delete")assert html = html_response(conn, 200)@@ -1780,7 +1780,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.update!()conn = set_current_team(conn, team)- conn = get(conn, Routes.settings_path(conn, :team_danger_zone))+ conn = get(conn, ~p"/settings/team/delete")assert html = html_response(conn, 200)@@ -1793,9 +1793,9 @@ defmodule PlausibleWeb.SettingsControllerTest doteam = team_of(another_user)add_member(team, user: user, role: :admin)conn = set_current_team(conn, team)- conn = get(conn, Routes.settings_path(conn, :team_danger_zone))+ conn = get(conn, ~p"/settings/team/delete")- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"endtest "DELETE /settings/team/delete - deletes a team", %{conn: conn, user: user} do@@ -1808,9 +1808,9 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.update!()conn = set_current_team(conn, team)- conn = delete(conn, Routes.settings_path(conn, :delete_team))+ conn = delete(conn, ~p"/settings/team/delete")- assert redirected_to(conn, 302) == Routes.site_path(conn, :index, __team: "none")+ assert redirected_to(conn, 302) == ~p"/sites?#{[__team: "none"]}"assert Phoenix.Flash.get(conn.assigns.flash, :success) == "Team \"Foo Crew\" deleted"end@@ -1829,9 +1829,9 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Repo.update!()conn = set_current_team(conn, team)- conn = delete(conn, Routes.settings_path(conn, :delete_team))+ conn = delete(conn, ~p"/settings/team/delete")- assert redirected_to(conn, 302) == Routes.settings_path(conn, :team_danger_zone)+ assert redirected_to(conn, 302) == ~p"/settings/team/delete"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~ "Team has an active subscription"end@@ -1841,9 +1841,9 @@ defmodule PlausibleWeb.SettingsControllerTest doteam = team_of(another_user)add_member(team, user: user, role: :admin)conn = set_current_team(conn, team)- conn = delete(conn, Routes.settings_path(conn, :delete_team))+ conn = delete(conn, ~p"/settings/team/delete")- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"endend@@ -1853,9 +1853,9 @@ defmodule PlausibleWeb.SettingsControllerTest dotest "enables enforcing 2FA", %{conn: conn, team: team} dorefute team.policy.force_2fa- conn = post(conn, Routes.settings_path(conn, :enable_team_force_2fa))+ conn = post(conn, ~p"/settings/team/force_2fa/enable")- assert redirected_to(conn, 302) == Routes.settings_path(conn, :team_general)+ assert redirected_to(conn, 302) == ~p"/settings/team/general"assert Phoenix.Flash.get(conn.assigns.flash, :success) =~"2FA is now required for all team members"@@ -1865,9 +1865,9 @@ defmodule PlausibleWeb.SettingsControllerTest doon_ee dotest "adds entry to audit log", %{conn: conn, team: team, user: user} do- conn = post(conn, Routes.settings_path(conn, :enable_team_force_2fa))+ conn = post(conn, ~p"/settings/team/force_2fa/enable")- assert redirected_to(conn, 302) == Routes.settings_path(conn, :team_general)+ assert redirected_to(conn, 302) == ~p"/settings/team/general"assert_matches [%{@@ -1903,9 +1903,9 @@ defmodule PlausibleWeb.SettingsControllerTest doguest = add_guest(site, role: :viewer)- conn = post(conn, Routes.settings_path(conn, :enable_team_force_2fa))+ conn = post(conn, ~p"/settings/team/force_2fa/enable")- assert redirected_to(conn, 302) == Routes.settings_path(conn, :team_general)+ assert redirected_to(conn, 302) == ~p"/settings/team/general"# The email come in order in which they are sent.# As the logic sending them does not force any order,@@ -1943,9 +1943,9 @@ defmodule PlausibleWeb.SettingsControllerTest dotest "is idempotent", %{conn: conn, user: user, team: team} do{:ok, team} = Plausible.Teams.disable_force_2fa(team, user, "password")- conn = post(conn, Routes.settings_path(conn, :enable_team_force_2fa))+ conn = post(conn, ~p"/settings/team/force_2fa/enable")- assert redirected_to(conn, 302) == Routes.settings_path(conn, :team_general)+ assert redirected_to(conn, 302) == ~p"/settings/team/general"assert Repo.reload!(team).policy.force_2faend@@ -1958,9 +1958,9 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Keyword.fetch!(:conn)|> set_current_team(team)- conn = post(conn, Routes.settings_path(conn, :enable_team_force_2fa))+ conn = post(conn, ~p"/settings/team/force_2fa/enable")- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"refute Repo.reload!(team).policy.force_2faendend@@ -1981,11 +1981,11 @@ defmodule PlausibleWeb.SettingsControllerTest do{:ok, team} = Plausible.Teams.enable_force_2fa(team, user)conn =- post(conn, Routes.settings_path(conn, :disable_team_force_2fa), %{+ post(conn, ~p"/settings/team/force_2fa/disable", %{"password" => "password"})- assert redirected_to(conn, 302) == Routes.settings_path(conn, :team_general)+ assert redirected_to(conn, 302) == ~p"/settings/team/general"assert Phoenix.Flash.get(conn.assigns.flash, :success) =~"2FA is no longer enforced for team members"@@ -1998,11 +1998,11 @@ defmodule PlausibleWeb.SettingsControllerTest do{:ok, team} = Plausible.Teams.enable_force_2fa(team, user)conn =- post(conn, Routes.settings_path(conn, :disable_team_force_2fa), %{+ post(conn, ~p"/settings/team/force_2fa/disable", %{"password" => "password"})- assert redirected_to(conn, 302) == Routes.settings_path(conn, :team_general)+ assert redirected_to(conn, 302) == ~p"/settings/team/general"assert_matches [%{@@ -2026,19 +2026,19 @@ defmodule PlausibleWeb.SettingsControllerTest dotest "is idempotent", %{conn: conn, team: team} doconn =- post(conn, Routes.settings_path(conn, :disable_team_force_2fa), %{+ post(conn, ~p"/settings/team/force_2fa/disable", %{"password" => "password"})- assert redirected_to(conn, 302) == Routes.settings_path(conn, :team_general)+ assert redirected_to(conn, 302) == ~p"/settings/team/general"refute Repo.reload!(team).policy.force_2faendtest "returns error on invalid password", %{conn: conn} doconn =- post(conn, Routes.settings_path(conn, :disable_team_force_2fa), %{"password" => "invalid"})+ post(conn, ~p"/settings/team/force_2fa/disable", %{"password" => "invalid"})- assert redirected_to(conn, 302) == Routes.settings_path(conn, :team_general)+ assert redirected_to(conn, 302) == ~p"/settings/team/general"assert Phoenix.Flash.get(conn.assigns.flash, :error) =~ "Incorrect password provided"end@@ -2060,11 +2060,11 @@ defmodule PlausibleWeb.SettingsControllerTest do|> set_current_team(team)conn =- post(conn, Routes.settings_path(conn, :disable_team_force_2fa), %{+ post(conn, ~p"/settings/team/force_2fa/disable", %{"password" => "password"})- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert Repo.reload!(team).policy.force_2faendend@@ -2073,7 +2073,7 @@ defmodule PlausibleWeb.SettingsControllerTest dosetup [:create_user, :log_in, :create_team, :setup_team]test "is visible to owner", %{conn: conn} do- conn = get(conn, Routes.settings_path(conn, :team_general))+ conn = get(conn, ~p"/settings/team/general")html = html_response(conn, 200)assert element_exists?(html, "div#enable-force-2fa")@@ -2089,7 +2089,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Keyword.fetch!(:conn)|> set_current_team(team)- conn = get(conn, Routes.settings_path(conn, :team_general))+ conn = get(conn, ~p"/settings/team/general")html = html_response(conn, 200)refute element_exists?(html, "div#force-2fa")@@ -2113,7 +2113,7 @@ defmodule PlausibleWeb.SettingsControllerTest doendtest "is visible to owner", %{conn: conn} do- conn = get(conn, Routes.settings_path(conn, :team_general))+ conn = get(conn, ~p"/settings/team/general")html = html_response(conn, 200)refute element_exists?(html, "div#enable-force-2fa")@@ -2135,7 +2135,7 @@ defmodule PlausibleWeb.SettingsControllerTest do|> Keyword.fetch!(:conn)|> set_current_team(team)- conn = get(conn, Routes.settings_path(conn, :team_general))+ conn = get(conn, ~p"/settings/team/general")html = html_response(conn, 200)refute element_exists?(html, "div#force-2fa")@@ -2149,7 +2149,7 @@ defmodule PlausibleWeb.SettingsControllerTest dotest "renders the 'Create a team' option", %{conn: conn, user: user} dosubscribe_to_growth_plan(user)- conn = get(conn, Routes.settings_path(conn, :preferences))+ conn = get(conn, ~p"/settings/preferences")html = html_response(conn, 200)assert text_of_element(html, ~s/[data-test="create-a-team-cta"]/) == "Create a team"end@@ -2160,7 +2160,7 @@ defmodule PlausibleWeb.SettingsControllerTest do} do{:ok, team} = Plausible.Teams.get_or_create(user)Plausible.Teams.complete_setup(team)- conn = get(conn, Routes.settings_path(conn, :preferences))+ conn = get(conn, ~p"/settings/preferences")html = html_response(conn, 200)refute element_exists?(html, ~s/[data-test="create-a-team-cta"]/)enddiff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exsindex f5a961fef8..d84796e824 100644--- a/test/plausible_web/controllers/site_controller_test.exs+++ b/test/plausible_web/controllers/site_controller_test.exs@@ -232,12 +232,12 @@ defmodule PlausibleWeb.SiteControllerTest doassert element_exists?(resp,- ~s|a[href="#{Routes.settings_path(conn, :subscription)}"]|+ ~s|a[href="#{~p"/settings/billing/subscription"}"]|)assert text_of_element(resp,- ~s|a[href="#{Routes.settings_path(conn, :subscription)}"]|+ ~s|a[href="#{~p"/settings/billing/subscription"}"]|) =~ "Choose a plan"end@@ -253,7 +253,7 @@ defmodule PlausibleWeb.SiteControllerTest doassert element_exists?(resp,- ~s|a[href="#{Routes.settings_path(conn, :subscription)}"]|+ ~s|a[href="#{~p"/settings/billing/subscription"}"]|)end@@ -274,7 +274,7 @@ defmodule PlausibleWeb.SiteControllerTest doassert element_exists?(resp,- ~s|a[href="#{Routes.settings_path(conn, :subscription)}"]|+ ~s|a[href="#{~p"/settings/billing/subscription"}"]|)end@@ -294,7 +294,7 @@ defmodule PlausibleWeb.SiteControllerTest dorefute element_exists?(resp,- ~s|a[href="#{Routes.settings_path(conn, :subscription)}"]|+ ~s|a[href="#{~p"/settings/billing/subscription"}"]|),"expected no upgrade link for role #{role}"end@@ -679,22 +679,20 @@ defmodule PlausibleWeb.SiteControllerTest dosetup_patch_env(:google, client_id: "some", api_url: "https://www.googleapis.com")test "shows settings form", %{conn: conn, site: site} do- conn = get(conn, Routes.site_path(conn, :settings_general, site.domain))+ conn = get(conn, ~p"/#{site.domain}/settings/general")resp = html_response(conn, 200)assert resp =~ "Settings for #{site.domain}"assert resp =~ "Site details"assert resp =~ "Site domain"- assert resp =~ Routes.site_path(conn, :change_domain, site.domain)+ assert resp =~ ~p"/#{site.domain}/change-domain"assert resp =~ "Reporting timezone"assert resp =~ "Tracking"assert resp =~- Routes.site_path(conn, :installation, site.domain,- flow: PlausibleWeb.Flows.review()- )+ ~p"/#{site.domain}/installation?#{[flow: PlausibleWeb.Flows.review()]}"endon_ee do@@ -1935,7 +1933,7 @@ defmodule PlausibleWeb.SiteControllerTest doPlausible.Site.set_stats_start_date(site, ~D[2023-01-01])|> Repo.update!()- delete(conn, Routes.site_path(conn, :reset_stats, site.domain))+ delete(conn, ~p"/#{site.domain}/stats")assert Repo.reload(site).stats_start_date == nilend@@ -1945,7 +1943,7 @@ defmodule PlausibleWeb.SiteControllerTest dosetup [:create_user, :log_in, :create_site]test "renders the transfer tile", %{conn: conn, site: site} do- conn = get(conn, Routes.site_path(conn, :settings_danger_zone, site.domain))+ conn = get(conn, ~p"/#{site.domain}/settings/danger-zone")html = html_response(conn, 200)assert html =~ "Danger zone"assert html =~ "Transfer site"diff --git a/test/plausible_web/controllers/sso_controller_sync_test.exs b/test/plausible_web/controllers/sso_controller_sync_test.exsindex fcada7e443..977c8b35d3 100644--- a/test/plausible_web/controllers/sso_controller_sync_test.exs+++ b/test/plausible_web/controllers/sso_controller_sync_test.exs@@ -90,10 +90,7 @@ defmodule PlausibleWeb.SSOControllerSyncTest doconn =get(conn,- Routes.sso_path(conn, :saml_signin, integration.identifier,- email: email,- return_to: "/sites"- )+ ~p"/sso/saml/signin/#{integration.identifier}?#{[email: email, return_to: "/sites"]}")session = fetch_cookies(conn, encrypted: ["session_saml"]).cookies["session_saml"]@@ -133,13 +130,10 @@ defmodule PlausibleWeb.SSOControllerSyncTest doconn =get(conn,- Routes.sso_path(conn, :saml_signin, Ecto.UUID.generate(),- email: email,- return_to: "/sites"- )+ ~p"/sso/saml/signin/#{Ecto.UUID.generate()}?#{[email: email, return_to: "/sites"]}")- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form, return_to: "/sites")+ assert redirected_to(conn, 302) == ~p"/sso/login?#{[return_to: "/sites"]}"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="We couldn't find a Single Sign-On account for that email."@@ -181,10 +175,7 @@ defmodule PlausibleWeb.SSOControllerSyncTest doconn =get(conn,- Routes.sso_path(conn, :saml_signin, integration.identifier,- email: email,- return_to: "/sites"- )+ ~p"/sso/saml/signin/#{integration.identifier}?#{[email: email, return_to: "/sites"]}")saml_session = fetch_cookies(conn, encrypted: ["session_saml"]).cookies["session_saml"]@@ -219,7 +210,7 @@ defmodule PlausibleWeb.SSOControllerSyncTest do"RelayState" => relay_state}- conn = post(conn, Routes.sso_path(conn, :saml_consume, integration.identifier), params)+ conn = post(conn, ~p"/sso/saml/consume/#{integration.identifier}", params)assert redirected_to(conn, 302) == "/sites"@@ -262,9 +253,9 @@ defmodule PlausibleWeb.SSOControllerSyncTest do"RelayState" => relay_state}- conn = post(conn, Routes.sso_path(conn, :saml_consume, Ecto.UUID.generate()), params)+ conn = post(conn, ~p"/sso/saml/consume/#{Ecto.UUID.generate()}", params)- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form, return_to: "/sites")+ assert redirected_to(conn, 302) == ~p"/sso/login?#{[return_to: "/sites"]}"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="We couldn't find a Single Sign-On account for that email."@@ -279,9 +270,9 @@ defmodule PlausibleWeb.SSOControllerSyncTest do"RelayState" => Ecto.UUID.generate()}- conn = post(conn, Routes.sso_path(conn, :saml_consume, integration.identifier), params)+ conn = post(conn, ~p"/sso/saml/consume/#{integration.identifier}", params)- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form, return_to: "/sites")+ assert redirected_to(conn, 302) == ~p"/sso/login?#{[return_to: "/sites"]}"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="Authentication failed (reason: :invalid_relay_state)"@@ -300,9 +291,9 @@ defmodule PlausibleWeb.SSOControllerSyncTest do} doparams = %{"SAMLResponse" => Base.encode64(@assertion)}- conn = post(conn, Routes.sso_path(conn, :saml_consume, integration.identifier), params)+ conn = post(conn, ~p"/sso/saml/consume/#{integration.identifier}", params)- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form, return_to: "/sites")+ assert redirected_to(conn, 302) == ~p"/sso/login?#{[return_to: "/sites"]}"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="Authentication failed (reason: :invalid_relay_state)"@@ -325,9 +316,9 @@ defmodule PlausibleWeb.SSOControllerSyncTest do"RelayState" => relay_state}- conn = post(conn, Routes.sso_path(conn, :saml_consume, integration.identifier), params)+ conn = post(conn, ~p"/sso/saml/consume/#{integration.identifier}", params)- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form, return_to: "/sites")+ assert redirected_to(conn, 302) == ~p"/sso/login?#{[return_to: "/sites"]}"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="Authentication failed (reason: :base64_decoding_failed)"@@ -358,9 +349,9 @@ defmodule PlausibleWeb.SSOControllerSyncTest do"RelayState" => relay_state}- conn = post(conn, Routes.sso_path(conn, :saml_consume, integration.identifier), params)+ conn = post(conn, ~p"/sso/saml/consume/#{integration.identifier}", params)- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form, return_to: "/sites")+ assert redirected_to(conn, 302) == ~p"/sso/login?#{[return_to: "/sites"]}"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="Authentication failed (reason: :malformed_certificate)"@@ -385,9 +376,9 @@ defmodule PlausibleWeb.SSOControllerSyncTest do"RelayState" => relay_state}- conn = post(conn, Routes.sso_path(conn, :saml_consume, integration.identifier), params)+ conn = post(conn, ~p"/sso/saml/consume/#{integration.identifier}", params)- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form, return_to: "/sites")+ assert redirected_to(conn, 302) == ~p"/sso/login?#{[return_to: "/sites"]}"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="Authentication failed (reason: :digest_verification_failed)"@@ -410,9 +401,9 @@ defmodule PlausibleWeb.SSOControllerSyncTest do"RelayState" => relay_state}- conn = post(conn, Routes.sso_path(conn, :saml_consume, integration.identifier), params)+ conn = post(conn, ~p"/sso/saml/consume/#{integration.identifier}", params)- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form, return_to: "/sites")+ assert redirected_to(conn, 302) == ~p"/sso/login?#{[return_to: "/sites"]}"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="Authentication failed (reason: :missing_email_attribute)"@@ -435,9 +426,9 @@ defmodule PlausibleWeb.SSOControllerSyncTest do"RelayState" => relay_state}- conn = post(conn, Routes.sso_path(conn, :saml_consume, integration.identifier), params)+ conn = post(conn, ~p"/sso/saml/consume/#{integration.identifier}", params)- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form, return_to: "/sites")+ assert redirected_to(conn, 302) == ~p"/sso/login?#{[return_to: "/sites"]}"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="Authentication failed (reason: :invalid_email_attribute)"@@ -460,9 +451,9 @@ defmodule PlausibleWeb.SSOControllerSyncTest do"RelayState" => relay_state}- conn = post(conn, Routes.sso_path(conn, :saml_consume, integration.identifier), params)+ conn = post(conn, ~p"/sso/saml/consume/#{integration.identifier}", params)- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form, return_to: "/sites")+ assert redirected_to(conn, 302) == ~p"/sso/login?#{[return_to: "/sites"]}"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="Authentication failed (reason: :missing_name_attributes)"diff --git a/test/plausible_web/controllers/sso_controller_test.exs b/test/plausible_web/controllers/sso_controller_test.exsindex 874dc7a894..1d11e7c5ca 100644--- a/test/plausible_web/controllers/sso_controller_test.exs+++ b/test/plausible_web/controllers/sso_controller_test.exs@@ -30,7 +30,7 @@ defmodule PlausibleWeb.SSOControllerTest do{:ok, conn: conn} = log_in(%{conn: conn, user: user})conn = set_current_team(conn, team)- conn = get(conn, Routes.settings_path(conn, :team_general))+ conn = get(conn, ~p"/settings/team/general")assert html = html_response(conn, 200)@@ -44,7 +44,7 @@ defmodule PlausibleWeb.SSOControllerTest do{:ok, conn: conn} = log_in(%{conn: conn, user: user})conn = set_current_team(conn, team)- conn = get(conn, Routes.settings_path(conn, :team_general))+ conn = get(conn, ~p"/settings/team/general")assert html = html_response(conn, 200)@@ -55,7 +55,7 @@ defmodule PlausibleWeb.SSOControllerTest dodescribe "login_form/2" dotest "renders login view", %{conn: conn} do- conn = get(conn, Routes.sso_path(conn, :login_form, prefer: "sso"))+ conn = get(conn, ~p"/sso/login?#{[prefer: "sso"]}")assert html = html_response(conn, 200)@@ -68,11 +68,7 @@ defmodule PlausibleWeb.SSOControllerTest doconn =get(conn,- Routes.sso_path(conn, :login_form,- prefer: "sso",- email: "[email protected]",- autosubmit: true- )+ ~p"/sso/login?#{[prefer: "sso", email: "[email protected]", autosubmit: true]}")assert html = html_response(conn, 200)@@ -83,7 +79,7 @@ defmodule PlausibleWeb.SSOControllerTest doendtest "passes return_to parameter to form", %{conn: conn} do- conn = get(conn, Routes.sso_path(conn, :login_form, return_to: "/sites", prefer: "sso"))+ conn = get(conn, ~p"/sso/login?#{[return_to: ~p"/sites", prefer: "sso"]}")assert html = html_response(conn, 200)@@ -98,7 +94,7 @@ defmodule PlausibleWeb.SSOControllerTest do|> fetch_flash()|> put_flash(:login_error, "We couldn't find a Single Sign-On account for that email.")- conn = get(conn, Routes.sso_path(conn, :login_form, return_to: "/sites"))+ conn = get(conn, ~p"/sso/login?#{[return_to: "/sites"]}")assert html = html_response(conn, 200)@@ -116,13 +112,10 @@ defmodule PlausibleWeb.SSOControllerTest do} doemail = "paul@" <> domain- conn = post(conn, Routes.sso_path(conn, :login), %{"email" => email})+ conn = post(conn, ~p"/sso/login", %{"email" => email})assert redirected_to(conn, 302) ==- Routes.sso_path(conn, :saml_signin, integration.identifier,- email: email,- return_to: ""- )+ ~p"/sso/saml/signin/#{integration.identifier}?#{[email: email, return_to: ""]}"endtest "passes redirect path if provided", %{@@ -133,23 +126,20 @@ defmodule PlausibleWeb.SSOControllerTest doemail = "claire@" <> domainconn =- post(conn, Routes.sso_path(conn, :login), %{"email" => email, "return_to" => "/sites"})+ post(conn, ~p"/sso/login", %{"email" => email, "return_to" => "/sites"})assert redirected_to(conn, 302) ==- Routes.sso_path(conn, :saml_signin, integration.identifier,- email: email,- return_to: "/sites"- )+ ~p"/sso/saml/signin/#{integration.identifier}?#{[email: email, return_to: "/sites"]}"endtest "renders login form with error on no matching integration", %{conn: conn} doconn =- post(conn, Routes.sso_path(conn, :login), %{+ post(conn, ~p"/sso/login", %{"email" => "[email protected]","return_to" => "/sites"})- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form)+ assert redirected_to(conn, 302) == ~p"/sso/login"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="We couldn't find a Single Sign-On account for that email."@@ -163,10 +153,10 @@ defmodule PlausibleWeb.SSOControllerTest doeventually(fn ->Enum.each(1..5, fn _ ->- post(conn, Routes.sso_path(conn, :login), %{"email" => email})+ post(conn, ~p"/sso/login", %{"email" => email})end)- conn = post(conn, Routes.sso_path(conn, :login), %{"email" => email})+ conn = post(conn, ~p"/sso/login", %{"email" => email}){conn.status == 429, conn}end,@@ -184,10 +174,7 @@ defmodule PlausibleWeb.SSOControllerTest doconn =get(conn,- Routes.sso_path(conn, :saml_signin, integration.identifier,- email: email,- return_to: "/sites"- )+ ~p"/sso/saml/signin/#{integration.identifier}?#{[email: email, return_to: "/sites"]}")assert html = html_response(conn, 200)@@ -195,7 +182,7 @@ defmodule PlausibleWeb.SSOControllerTest doassert html =~ "Processing Single Sign-On request..."assert text_of_attr(html, "form#sso-req-form", "action") ==- Routes.sso_path(conn, :saml_consume, integration.identifier)+ ~p"/sso/saml/consume/#{integration.identifier}"assert text_of_attr(html, "input[name=email]", "value") == emailassert text_of_attr(html, "input[name=return_to]", "value") == "/sites"@@ -211,7 +198,7 @@ defmodule PlausibleWeb.SSOControllerTest doemail = "dana.lake@" <> domainconn =- post(conn, Routes.sso_path(conn, :saml_consume, integration.identifier), %{+ post(conn, ~p"/sso/saml/consume/#{integration.identifier}", %{"email" => email,"return_to" => "/sites"})@@ -240,7 +227,7 @@ defmodule PlausibleWeb.SSOControllerTest doadd_member(team, user: existing_user, role: :admin)conn =- post(conn, Routes.sso_path(conn, :saml_consume, integration.identifier), %{+ post(conn, ~p"/sso/saml/consume/#{integration.identifier}", %{"email" => email,"return_to" => "/sites"})@@ -258,12 +245,12 @@ defmodule PlausibleWeb.SSOControllerTest dotest "redirects to login when no matching integration found", %{conn: conn} doconn =- post(conn, Routes.sso_path(conn, :saml_consume, Ecto.UUID.generate()), %{+ post(conn, ~p"/sso/saml/consume/#{Ecto.UUID.generate()}", %{"email" => "[email protected]","return_to" => "/sites"})- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form, return_to: "/sites")+ assert redirected_to(conn, 302) == ~p"/sso/login?#{[return_to: "/sites"]}"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="We couldn't find a Single Sign-On account for that email."@@ -275,7 +262,7 @@ defmodule PlausibleWeb.SSOControllerTest dotest "redirects when team is not setup", %{conn: conn, team: team} doconn = set_current_team(conn, team)- conn = get(conn, Routes.sso_path(conn, :sso_settings))+ conn = get(conn, ~p"/settings/sso/general")assert redirected_to(conn, 302) == "/sites"end@@ -283,7 +270,7 @@ defmodule PlausibleWeb.SSOControllerTest dotest "redirects when team lacks SSO plan feature", %{conn: conn, team: team} doteam = Plausible.Teams.complete_setup(team)conn = set_current_team(conn, team)- conn = get(conn, Routes.sso_path(conn, :sso_settings))+ conn = get(conn, ~p"/settings/sso/general")assert redirected_to(conn, 302) == "/sites"end@@ -292,7 +279,7 @@ defmodule PlausibleWeb.SSOControllerTest douser |> subscribe_to_enterprise_plan(features: [Plausible.Billing.Feature.SSO])team = Plausible.Teams.complete_setup(team)conn = set_current_team(conn, team)- conn = get(conn, Routes.sso_path(conn, :sso_settings))+ conn = get(conn, ~p"/settings/sso/general")assert html = html_response(conn, 200)@@ -302,7 +289,7 @@ defmodule PlausibleWeb.SSOControllerTest dodescribe "provision_notice/2" dotest "renders the notice", %{conn: conn} do- conn = get(conn, Routes.sso_path(conn, :provision_notice))+ conn = get(conn, ~p"/sso/notice")assert html = html_response(conn, 200)@@ -316,7 +303,7 @@ defmodule PlausibleWeb.SSOControllerTest dodescribe "provision_issue/2" dotest "renders issue for not_a_member", %{conn: conn} do- conn = get(conn, Routes.sso_path(conn, :provision_issue, issue: "not_a_member"))+ conn = get(conn, ~p"/sso/issue?#{[issue: "not_a_member"]}")assert html = html_response(conn, 200)@@ -325,7 +312,7 @@ defmodule PlausibleWeb.SSOControllerTest doendtest "renders issue for multiple_memberships", %{conn: conn} do- conn = get(conn, Routes.sso_path(conn, :provision_issue, issue: "multiple_memberships"))+ conn = get(conn, ~p"/sso/issue?#{[issue: "multiple_memberships"]}")assert html = html_response(conn, 200)@@ -337,7 +324,7 @@ defmodule PlausibleWeb.SSOControllerTest doconn =get(conn,- Routes.sso_path(conn, :provision_issue, issue: "multiple_memberships_noforce")+ ~p"/sso/issue?#{[issue: "multiple_memberships_noforce"]}")assert html = html_response(conn, 200)@@ -350,7 +337,7 @@ defmodule PlausibleWeb.SSOControllerTest doendtest "renders issue for active_personal_team", %{conn: conn} do- conn = get(conn, Routes.sso_path(conn, :provision_issue, issue: "active_personal_team"))+ conn = get(conn, ~p"/sso/issue?#{[issue: "active_personal_team"]}")assert html = html_response(conn, 200)@@ -364,7 +351,7 @@ defmodule PlausibleWeb.SSOControllerTest doconn =get(conn,- Routes.sso_path(conn, :provision_issue, issue: "active_personal_team_noforce")+ ~p"/sso/issue?#{[issue: "active_personal_team_noforce"]}")assert html = html_response(conn, 200)@@ -415,7 +402,7 @@ defmodule PlausibleWeb.SSOControllerTest doAuth.UserSessions.create!(user3, "Device 4", now: NaiveDateTime.shift(now, hour: -2))- conn = get(conn, Routes.sso_path(conn, :team_sessions))+ conn = get(conn, ~p"/settings/sso/sessions")assert html = html_response(conn, 200)@@ -429,7 +416,7 @@ defmodule PlausibleWeb.SSOControllerTest doendtest "shows empty state when there are no sessions", %{conn: conn} do- conn = get(conn, Routes.sso_path(conn, :team_sessions))+ conn = get(conn, ~p"/settings/sso/sessions")assert html = html_response(conn, 200)@@ -459,9 +446,9 @@ defmodule PlausibleWeb.SSOControllerTest dosession = Auth.UserSessions.create!(user, "Unknown")- conn = delete(conn, Routes.sso_path(conn, :delete_session, session.id))+ conn = delete(conn, ~p"/settings/sso/sessions/#{session.id}")- assert redirected_to(conn, 302) == Routes.sso_path(conn, :team_sessions)+ assert redirected_to(conn, 302) == ~p"/settings/sso/sessions"assert Phoenix.Flash.get(conn.assigns.flash, :success) =="Session logged out successfully"diff --git a/test/plausible_web/controllers/stats_controller_test.exs b/test/plausible_web/controllers/stats_controller_test.exsindex d6c249a516..d63e6506c5 100644--- a/test/plausible_web/controllers/stats_controller_test.exs+++ b/test/plausible_web/controllers/stats_controller_test.exs@@ -605,7 +605,7 @@ defmodule PlausibleWeb.StatsControllerTest doresp = get(conn, "/" <> site.domain) |> html_response(200)assert resp =~- Routes.customer_support_site_path(PlausibleWeb.Endpoint, :show, site.id)+ ~p"/cs/sites/site/#{site.id}"endendenddiff --git a/test/plausible_web/email_test.exs b/test/plausible_web/email_test.exsindex ef565025d3..ce1bf15d78 100644--- a/test/plausible_web/email_test.exs+++ b/test/plausible_web/email_test.exs@@ -178,9 +178,7 @@ defmodule PlausibleWeb.EmailTest do) =="account settings"- assert html_body =~- PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan) <>- "?__team=#{team.identifier}"+ assert html_body =~ url(~p"/billing/choose-plan?#{[__team: team.identifier]}")endtest "asks enterprise level usage to contact us" do@@ -239,9 +237,7 @@ defmodule PlausibleWeb.EmailTest do) =="account settings"- assert html_body =~- PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan) <>- "?__team=#{team.identifier}"+ assert html_body =~ url(~p"/billing/choose-plan?#{[__team: team.identifier]}")endtest "asks enterprise level usage to contact us" dodiff --git a/test/plausible_web/live/change_domain_test.exs b/test/plausible_web/live/change_domain_test.exsindex ee0b76ed5b..094a8ee444 100644--- a/test/plausible_web/live/change_domain_test.exs+++ b/test/plausible_web/live/change_domain_test.exs@@ -75,7 +75,7 @@ defmodule PlausibleWeb.Live.ChangeDomainTest doassert html =~ "You already own this site"expected_settings_link =- Routes.site_path(conn, :settings_general, owned_site.domain)+ ~p"/#{owned_site.domain}/settings/general"assert html =~ expected_settings_link@@ -221,7 +221,7 @@ defmodule PlausibleWeb.Live.ChangeDomainTest dotest "renders back to settings link with correct path", %{conn: conn, site: site} do{:ok, _lv, html} = live(conn, "/#{site.domain}/change-domain")- expected_link = Routes.site_path(conn, :settings_general, site.domain)+ expected_link = ~p"/#{site.domain}/settings/general"assert html =~ expected_linkenddiff --git a/test/plausible_web/live/choose_plan_test.exs b/test/plausible_web/live/choose_plan_test.exsindex 749c8b554e..0f2ea28261 100644--- a/test/plausible_web/live/choose_plan_test.exs+++ b/test/plausible_web/live/choose_plan_test.exs@@ -278,7 +278,7 @@ defmodule PlausibleWeb.Live.ChoosePlanTest do"email" => user.email,"passthrough" => "ee:true;user:#{user.id};team:#{team.id}","product" => @v5_growth_200k_yearly_plan_id,- "success" => Routes.billing_path(PlausibleWeb.Endpoint, :upgrade_success),+ "success" => ~p"/billing/upgrade-success","theme" => "none"} == get_paddle_checkout_params(find(doc, @growth_checkout_button))@@ -684,7 +684,7 @@ defmodule PlausibleWeb.Live.ChoosePlanTest dogrowth_checkout_button = find(doc, @growth_checkout_button)assert text_of_attr(growth_checkout_button, "onclick") =~- "if (true) {window.location = '#{Routes.billing_path(conn, :change_plan_preview, @v5_growth_10k_yearly_plan_id)}'}"+ "if (true) {window.location = '#{~p"/billing/change-plan/preview/#{@v5_growth_10k_yearly_plan_id}"}'}"set_slider(lv, "5M")doc = element(lv, @monthly_interval_button) |> render_click()@@ -692,12 +692,12 @@ defmodule PlausibleWeb.Live.ChoosePlanTest dostarter_checkout_button = find(doc, @starter_checkout_button)assert text_of_attr(starter_checkout_button, "onclick") =~- "if (true) {window.location = '#{Routes.billing_path(conn, :change_plan_preview, @v5_starter_5m_monthly_plan_id)}'}"+ "if (true) {window.location = '#{~p"/billing/change-plan/preview/#{@v5_starter_5m_monthly_plan_id}"}'}"business_checkout_button = find(doc, @business_checkout_button)assert text_of_attr(business_checkout_button, "onclick") =~- "if (true) {window.location = '#{Routes.billing_path(conn, :change_plan_preview, @v5_business_5m_monthly_plan_id)}'}"+ "if (true) {window.location = '#{~p"/billing/change-plan/preview/#{@v5_business_5m_monthly_plan_id}"}'}"endend@@ -1256,7 +1256,7 @@ defmodule PlausibleWeb.Live.ChoosePlanTest do"email" => user.email,"passthrough" => "ee:true;user:#{user.id};team:#{team.id}","product" => @v5_growth_200k_yearly_plan_id,- "success" => Routes.billing_path(PlausibleWeb.Endpoint, :upgrade_success),+ "success" => ~p"/billing/upgrade-success","theme" => "none"} == get_paddle_checkout_params(find(doc, @growth_checkout_button))end@@ -1355,7 +1355,7 @@ defmodule PlausibleWeb.Live.ChoosePlanTest dodefp get_liveview(conn) doconn = assign(conn, :live_module, PlausibleWeb.Live.ChoosePlan)- {:ok, _lv, _doc} = live(conn, Routes.billing_path(conn, :choose_plan))+ {:ok, _lv, _doc} = live(conn, ~p"/billing/choose-plan")enddefp get_paddle_checkout_params(element) dodiff --git a/test/plausible_web/live/customer_support/sites_test.exs b/test/plausible_web/live/customer_support/sites_test.exsindex e647710901..b2bf60d0b5 100644--- a/test/plausible_web/live/customer_support/sites_test.exs+++ b/test/plausible_web/live/customer_support/sites_test.exs@@ -8,7 +8,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.SitesTest doimport Phoenix.LiveViewTestdefp open_site(id, opts \\ []) do- Routes.customer_support_site_path(PlausibleWeb.Endpoint, :show, id, opts)+ ~p"/cs/sites/site/#{id}?#{opts}"enddescribe "overview" do@@ -30,7 +30,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.SitesTest doassert element_exists?(html,- ~s|a[href="#{Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain)}"]|+ ~s|a[href="#{stats_path(site.domain)}"]|)end@@ -47,7 +47,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.SitesTest do|> element(~s|button[phx-click="delete-site"]|)|> render_click()- assert_redirect(lv, Routes.customer_support_path(PlausibleWeb.Endpoint, :index))+ assert_redirect(lv, ~p"/cs")refute Plausible.Sites.get_by_domain(site.domain)enddiff --git a/test/plausible_web/live/customer_support/teams_test.exs b/test/plausible_web/live/customer_support/teams_test.exsindex fdf4fcd13d..6bc3e6713e 100644--- a/test/plausible_web/live/customer_support/teams_test.exs+++ b/test/plausible_web/live/customer_support/teams_test.exs@@ -10,7 +10,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TeamsTest dorequire Plausible.Billing.Subscription.Statusdefp open_team(id, qs \\ []) do- Routes.customer_support_team_path(PlausibleWeb.Endpoint, :show, id, qs)+ ~p"/cs/teams/team/#{id}?#{qs}"endsetup [:create_user, :log_in, :create_site]@@ -57,7 +57,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TeamsTest do|> element(~s|button[phx-click="delete-team"]|)|> render_click()- assert_redirect(lv, Routes.customer_support_path(PlausibleWeb.Endpoint, :index))+ assert_redirect(lv, ~p"/cs")refute Plausible.Repo.get(Plausible.Teams.Team, team.id)end@@ -1122,7 +1122,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TeamsTest doassert {:error, {:live_redirect, %{to: to}}} =lv |> element("button#remove-sso-integration") |> render_click()- assert to == Routes.customer_support_team_path(PlausibleWeb.Endpoint, :show, team.id)+ assert to == ~p"/cs/teams/team/#{team.id}"endenddiff --git a/test/plausible_web/live/customer_support/trial_prospects_test.exs b/test/plausible_web/live/customer_support/trial_prospects_test.exsindex ace311724a..1b5c8609bf 100644--- a/test/plausible_web/live/customer_support/trial_prospects_test.exs+++ b/test/plausible_web/live/customer_support/trial_prospects_test.exs@@ -9,7 +9,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TrialProspectsTest doalias Plausible.CustomerSupport.TrialProspectdefp open_prospects(qs \\ []) do- Routes.customer_support_trial_prospects_path(PlausibleWeb.Endpoint, :index, qs)+ ~p"/cs/trial-prospects?#{qs}"endsetup [:create_user, :log_in]@@ -165,9 +165,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TrialProspectsTest do{:ok, lv, _html} = live(conn, open_prospects())assert lv- |> element(- ~s|a[href="#{Routes.customer_support_team_path(PlausibleWeb.Endpoint, :show, team.id)}"]|- )+ |> element(~s|a[href="#{~p"/cs/teams/team/#{team.id}"}"]|)|> has_element?()endenddiff --git a/test/plausible_web/live/customer_support/users_test.exs b/test/plausible_web/live/customer_support/users_test.exsindex 9406490c36..4ab38f2bd9 100644--- a/test/plausible_web/live/customer_support/users_test.exs+++ b/test/plausible_web/live/customer_support/users_test.exs@@ -6,7 +6,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.UsersTest doimport Phoenix.LiveViewTestdefp open_user(id, qs \\ []) do- Routes.customer_support_user_path(PlausibleWeb.Endpoint, :show, id, qs)+ ~p"/cs/users/user/#{id}?#{qs}"enddescribe "overview" do@@ -29,7 +29,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.UsersTest doassert element_exists?(html,- ~s|a[href="#{Routes.customer_support_team_path(PlausibleWeb.Endpoint, :show, team.id)}"]|+ ~s|a[href="#{~p"/cs/teams/team/#{team.id}"}"]|)end@@ -46,7 +46,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.UsersTest do|> element(~s|button[phx-click="delete-user"]|)|> render_click()- assert_redirect(lv, Routes.customer_support_path(PlausibleWeb.Endpoint, :index))+ assert_redirect(lv, ~p"/cs")refute Plausible.Repo.get(Plausible.Auth.User, user.id)enddiff --git a/test/plausible_web/live/customer_support_test.exs b/test/plausible_web/live/customer_support_test.exsindex 05f8c77676..f7753fa78f 100644--- a/test/plausible_web/live/customer_support_test.exs+++ b/test/plausible_web/live/customer_support_test.exs@@ -4,7 +4,7 @@ defmodule PlausibleWeb.Live.CustomerSupportTest do@moduletag :ee_onlyon_ee do- @cs_index Routes.customer_support_path(PlausibleWeb.Endpoint, :index)+ @cs_index "/cs"import Phoenix.LiveViewTest@@ -230,12 +230,14 @@ defmodule PlausibleWeb.Live.CustomerSupportTest dodefp assert_search_result(doc, type, id) doassert link = find(doc, ~s|a[data-test-type="#{type}"][data-test-id="#{id}"]|)- assert text_of_attr(link, "href") ==- apply(Routes, :"customer_support_#{type}_path", [- PlausibleWeb.Endpoint,- :show,- id- ])+ expected_href =+ case type do+ "site" -> ~p"/cs/sites/site/#{id}"+ "team" -> ~p"/cs/teams/team/#{id}"+ "user" -> ~p"/cs/users/user/#{id}"+ end++ assert text_of_attr(link, "href") == expected_hrefenddefp refute_search_result(doc, type, id) dodiff --git a/test/plausible_web/live/funnel_settings_test.exs b/test/plausible_web/live/funnel_settings_test.exsindex 5aec16db98..d2cee0bd19 100644--- a/test/plausible_web/live/funnel_settings_test.exs+++ b/test/plausible_web/live/funnel_settings_test.exs@@ -90,7 +90,7 @@ defmodule PlausibleWeb.Live.FunnelSettingsTest dodoc = conn |> html_response(200)assert text(doc) =~ "Set up a few goals"- add_goals_path = Routes.site_path(conn, :settings_goals, site.domain)+ add_goals_path = ~p"/#{site.domain}/settings/goals"assert element_exists?(doc, ~s/a[href="#{add_goals_path}"]/)refute element_exists?(doc, ~s/input[type="text"]#filter-text/)diff --git a/test/plausible_web/live/installation_test.exs b/test/plausible_web/live/installation_test.exsindex efb32aef27..4b202a294e 100644--- a/test/plausible_web/live/installation_test.exs+++ b/test/plausible_web/live/installation_test.exs@@ -226,10 +226,7 @@ defmodule PlausibleWeb.Live.InstallationTest doassert_redirect(lv,- Routes.stats_path(conn, :stats, site.domain,- verify_installation: true,- flow: "provisioning"- )+ stats_path(site.domain, verify_installation: true, flow: "provisioning"))endend@@ -250,7 +247,7 @@ defmodule PlausibleWeb.Live.InstallationTest do}})- assert_redirect(lv, Routes.stats_path(conn, :stats, site.domain))+ assert_redirect(lv, stats_path(site.domain))endtest "submitting form with review flow redirects to the dashboard with the flow param preserved",@@ -279,15 +276,12 @@ defmodule PlausibleWeb.Live.InstallationTest doon_ee doassert_redirect(lv,- Routes.stats_path(conn, :stats, site.domain,- verify_installation: true,- flow: "review"- )+ stats_path(site.domain, verify_installation: true, flow: "review"))endon_ce do- assert_redirect(lv, Routes.stats_path(conn, :stats, site.domain))+ assert_redirect(lv, stats_path(site.domain))endend@@ -562,7 +556,7 @@ defmodule PlausibleWeb.Live.InstallationTest dohtml = render_async(lv, 500)- href = Routes.site_path(PlausibleWeb.Endpoint, :settings_general, site.domain)+ href = ~p"/#{site.domain}/settings/general"assert text_of_element(html, ~s|a[href="#{href}"]|) == "Back to settings"end@@ -580,10 +574,7 @@ defmodule PlausibleWeb.Live.InstallationTest dohtml = render_async(lv, 500)href =- Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain,- verify_installation: true,- flow: "provisioning"- )+ stats_path(site.domain, verify_installation: true, flow: "provisioning")assert text_of_element(html, ~s|a[href="#{href}"]|) == "Back to dashboard"enddiff --git a/test/plausible_web/live/sso_management_test.exs b/test/plausible_web/live/sso_management_test.exsindex aeb8f64b4c..e092e67c04 100644--- a/test/plausible_web/live/sso_management_test.exs+++ b/test/plausible_web/live/sso_management_test.exs@@ -54,7 +54,7 @@ defmodule PlausibleWeb.Live.SSOMangementTest dotest "renders", %{conn: conn} doresp =conn- |> get(Routes.sso_path(conn, :sso_settings))+ |> get(~p"/settings/sso/general")|> html_response(200)|> text()@@ -312,7 +312,7 @@ defmodule PlausibleWeb.Live.SSOMangementTest dodefp get_lv(conn) doconn = assign(conn, :live_module, PlausibleWeb.Live.SSOManagement)- {:ok, lv, html} = live(conn, Routes.sso_path(conn, :sso_settings))+ {:ok, lv, html} = live(conn, ~p"/settings/sso/general"){lv, html}enddiff --git a/test/plausible_web/live/team_management_test.exs b/test/plausible_web/live/team_management_test.exsindex 5b220d2857..b38bde4b1e 100644--- a/test/plausible_web/live/team_management_test.exs+++ b/test/plausible_web/live/team_management_test.exs@@ -4,7 +4,7 @@ defmodule PlausibleWeb.Live.TeamMangementTest doimport Phoenix.LiveViewTest- def team_general_path(), do: Routes.settings_path(PlausibleWeb.Endpoint, :team_general)+ def team_general_path(), do: ~p"/settings/team/general"@subject_prefix if ee?(), do: "[Plausible Analytics] ", else: "[Plausible CE] "describe "/settings/team/general" dodiff --git a/test/plausible_web/live/tracking_settings_test.exs b/test/plausible_web/live/tracking_settings_test.exsindex 7531c38bdb..946e132aec 100644--- a/test/plausible_web/live/tracking_settings_test.exs+++ b/test/plausible_web/live/tracking_settings_test.exs@@ -77,9 +77,7 @@ defmodule PlausibleWeb.Live.TrackingSettingsTest dohtml = conn |> get_liveview(site) |> render()assert html =~- Routes.site_path(PlausibleWeb.Endpoint, :installation, site.domain,- flow: PlausibleWeb.Flows.review()- )+ ~p"/#{site.domain}/installation?#{[flow: PlausibleWeb.Flows.review()]}"end@tag :ee_onlydiff --git a/test/plausible_web/plugins/api/controllers/capabilities_test.exs b/test/plausible_web/plugins/api/controllers/capabilities_test.exsindex 75faa09a59..de11ac962f 100644--- a/test/plausible_web/plugins/api/controllers/capabilities_test.exs+++ b/test/plausible_web/plugins/api/controllers/capabilities_test.exs@@ -16,7 +16,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CapabilitiesTest dotest "no token", %{conn: conn} doresp =conn- |> get(Routes.plugins_api_capabilities_url(PlausibleWeb.Endpoint, :index))+ |> get(url(~p"/api/plugins/v1/capabilities"))|> json_response(200)assert resp ==@@ -46,7 +46,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CapabilitiesTest doconn|> put_req_header("content-type", "application/json")|> authenticate("foo", "bad token")- |> get(Routes.plugins_api_capabilities_url(PlausibleWeb.Endpoint, :index))+ |> get(url(~p"/api/plugins/v1/capabilities"))|> json_response(200)assert resp ==@@ -78,7 +78,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CapabilitiesTest doconn|> put_req_header("content-type", "application/json")|> authenticate(site.domain, token)- |> get(Routes.plugins_api_capabilities_url(PlausibleWeb.Endpoint, :index))+ |> get(url(~p"/api/plugins/v1/capabilities"))|> json_response(200)assert resp ==@@ -112,7 +112,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CapabilitiesTest doconn|> put_req_header("content-type", "application/json")|> authenticate(site.domain, token)- |> get(Routes.plugins_api_capabilities_url(PlausibleWeb.Endpoint, :index))+ |> get(url(~p"/api/plugins/v1/capabilities"))|> json_response(200)assert resp ==@@ -149,7 +149,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CapabilitiesTest doconn|> put_req_header("content-type", "application/json")|> authenticate(site.domain, token)- |> get(Routes.plugins_api_capabilities_url(PlausibleWeb.Endpoint, :index))+ |> get(url(~p"/api/plugins/v1/capabilities"))|> json_response(200)assert resp ==diff --git a/test/plausible_web/plugins/api/controllers/custom_props_test.exs b/test/plausible_web/plugins/api/controllers/custom_props_test.exsindex 16143d24c0..d8b69f9400 100644--- a/test/plausible_web/plugins/api/controllers/custom_props_test.exs+++ b/test/plausible_web/plugins/api/controllers/custom_props_test.exs@@ -22,12 +22,12 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest dodescribe "unauthorized calls" dofor {method, url} <- [- {:put, Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)},- {:delete, Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :disable)}+ {:put, "/api/plugins/v1/custom_props"},+ {:delete, "/api/plugins/v1/custom_props"}] dotest "unauthorized call: #{method} #{url}", %{conn: conn} doconn- |> unquote(method)(unquote(url))+ |> unquote(method)(unverified_url(PlausibleWeb.Endpoint, unquote(url)))|> json_response(401)|> assert_schema("UnauthorizedError", spec())end@@ -45,7 +45,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do[owner | _] = Plausible.Repo.preload(site, :owners).ownerssubscribe_to_growth_plan(owner)- url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)+ url = url(~p"/api/plugins/v1/custom_props")payload = %{custom_prop: %{key: "search_query"}@@ -69,7 +69,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do[owner | _] = Plausible.Repo.preload(site, :owners).ownerssubscribe_to_growth_plan(owner)- url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)+ url = url(~p"/api/plugins/v1/custom_props")payload = %{custom_props: [@@ -98,7 +98,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do[owner | _] = Plausible.Repo.preload(site, :owners).ownerssubscribe_to_growth_plan(owner)- url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)+ url = url(~p"/api/plugins/v1/custom_props")payload = %{custom_prop: %{key: "author"}@@ -122,7 +122,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do[owner | _] = Plausible.Repo.preload(site, :owners).ownerssubscribe_to_growth_plan(owner)- url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)+ url = url(~p"/api/plugins/v1/custom_props")payload = %{custom_props: [@@ -149,7 +149,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest dodescribe "put /custom_prop - enable single prop" dotest "validates input according to the schema", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)+ url = url(~p"/api/plugins/v1/custom_props")conn|> authenticate(site.domain, token)@@ -160,7 +160,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest doendtest "enables single custom prop", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)+ url = url(~p"/api/plugins/v1/custom_props")payload = %{custom_prop: %{key: "author"}@@ -187,7 +187,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest doendtest "is idempotent", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)+ url = url(~p"/api/plugins/v1/custom_props")initial_conn =conn@@ -223,7 +223,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest dodescribe "put /custom_props - bulk creation" dotest "creates many custom props", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)+ url = url(~p"/api/plugins/v1/custom_props")payload = %{custom_props: [@@ -266,7 +266,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest dotest "disable one prop", %{conn: conn, site: site, token: token} do{:ok, ["author"]} = Plausible.Plugins.API.CustomProps.enable(site, "author")- url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)+ url = url(~p"/api/plugins/v1/custom_props")payload = %{custom_prop: %{key: "author"}}@@ -283,7 +283,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do{:ok, [_, _, _]} =Plausible.Plugins.API.CustomProps.enable(site, ["author", "category", "third"])- url = Routes.plugins_api_custom_props_url(PlausibleWeb.Endpoint, :enable)+ url = url(~p"/api/plugins/v1/custom_props")payload = %{custom_props: [diff --git a/test/plausible_web/plugins/api/controllers/funnels_test.exs b/test/plausible_web/plugins/api/controllers/funnels_test.exsindex 1467ddc4b4..90d0e68b4d 100644--- a/test/plausible_web/plugins/api/controllers/funnels_test.exs+++ b/test/plausible_web/plugins/api/controllers/funnels_test.exs@@ -26,13 +26,13 @@ defmodule PlausibleWeb.Plugins.API.Controllers.FunnelsTest dodescribe "unauthorized calls" dofor {method, url} <- [- {:get, Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :index)},- {:get, Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :get, 1)},- {:put, Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :create, %{})}+ {:get, "/api/plugins/v1/funnels"},+ {:get, "/api/plugins/v1/funnels/1"},+ {:put, "/api/plugins/v1/funnels"}] dotest "unauthorized call: #{method} #{url}", %{conn: conn} doconn- |> unquote(method)(unquote(url))+ |> unquote(method)(unverified_url(PlausibleWeb.Endpoint, unquote(url)))|> json_response(401)|> assert_schema("UnauthorizedError", spec())end@@ -41,7 +41,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.FunnelsTest dodescribe "get /funnels/:id" dotest "validates input out of the box", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :get, "hello")+ url = url(~p"/api/plugins/v1/funnels/hello")resp =conn@@ -54,7 +54,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.FunnelsTest doendtest "retrieves no funnel on non-existing ID", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :get, 9999)+ url = url(~p"/api/plugins/v1/funnels/9999")resp =conn@@ -81,7 +81,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.FunnelsTest do[g1, g2, g3])- url = Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :get, funnel.id)+ url = url(~p"/api/plugins/v1/funnels/#{funnel.id}")resp =conn@@ -108,7 +108,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.FunnelsTest dotoken: token,site: site} do- url = Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :index)+ url = url(~p"/api/plugins/v1/funnels")resp =conn@@ -140,7 +140,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.FunnelsTest do)end- url = Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :index)+ url = url(~p"/api/plugins/v1/funnels")resp =conn@@ -171,7 +171,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.FunnelsTest do)end- url = Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :index, limit: 2)+ url = url(~p"/api/plugins/v1/funnels?#{[limit: 2]}")initial_conn = authenticate(conn, site.domain, token)page1 =@@ -201,7 +201,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.FunnelsTest dodescribe "put /funnels - funnel creation" dotest "creates a funnel including its goals", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/funnels")payload = %{funnel: %{@@ -239,7 +239,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.FunnelsTest do[location] = get_resp_header(conn, "location")assert location ==- Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :get, resp.funnel.id)+ url(~p"/api/plugins/v1/funnels/#{resp.funnel.id}")funnel = Plausible.Funnels.get(site, resp.funnel.id)@@ -252,7 +252,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.FunnelsTest do[owner | _] = Plausible.Repo.preload(site, :owners).ownerssubscribe_to_growth_plan(owner)- url = Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/funnels")payload = %{funnel: %{@@ -285,7 +285,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.FunnelsTest dotoken: token,site: site} do- url = Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/funnels")payload = %{funnel: %{@@ -311,7 +311,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.FunnelsTest doendtest "is idempotent on full creation", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/funnels"){:ok, _g1} =Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "EUR"})@@ -363,7 +363,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.FunnelsTest dotoken: token,site: site} do- url = Routes.plugins_api_funnels_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/funnels"){:ok, _g1} =Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "USD"})diff --git a/test/plausible_web/plugins/api/controllers/goals_test.exs b/test/plausible_web/plugins/api/controllers/goals_test.exsindex df2e7c089a..d420eb3efb 100644--- a/test/plausible_web/plugins/api/controllers/goals_test.exs+++ b/test/plausible_web/plugins/api/controllers/goals_test.exs@@ -30,15 +30,15 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest dodescribe "unauthorized calls" dofor {method, url} <- [- {:get, Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :index)},- {:get, Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :get, 1)},- {:put, Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create, %{})},- {:delete, Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :delete, 1)},- {:delete, Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :delete_bulk, %{})}+ {:get, "/api/plugins/v1/goals"},+ {:get, "/api/plugins/v1/goals/1"},+ {:put, "/api/plugins/v1/goals"},+ {:delete, "/api/plugins/v1/goals/1"},+ {:delete, "/api/plugins/v1/goals"}] dotest "unauthorized call: #{method} #{url}", %{conn: conn} doconn- |> unquote(method)(unquote(url))+ |> unquote(method)(unverified_url(PlausibleWeb.Endpoint, unquote(url)))|> json_response(401)|> assert_schema("UnauthorizedError", spec())end@@ -54,7 +54,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do} dosubscribe_to_growth_plan(site.team)- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload = %{goal_type: "Goal.Revenue",@@ -79,7 +79,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do} dosubscribe_to_growth_plan(site.team)- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload = %{goals: [@@ -111,7 +111,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest dotest "creates a custom event goal with custom props", %{conn: conn, token: token, site: site} dosubscribe_to_business_plan(site.team)- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload = %{goal_type: "Goal.CustomEvent",@@ -138,11 +138,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do[location] = get_resp_header(conn, "location")assert location ==- Routes.plugins_api_goals_url(- PlausibleWeb.Endpoint,- :get,- List.first(schema.goals).goal.id- )+ url(~p"/api/plugins/v1/goals/#{List.first(schema.goals).goal.id}")[goal] = Plausible.Goals.for_site(site)assert goal.event_name == "Signup"@@ -159,7 +155,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do} dosubscribe_to_business_plan(site.team)- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload = %{goal_type: "Goal.CustomEvent",@@ -184,7 +180,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do} dosubscribe_to_business_plan(site.team)- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload = %{goal_type: "Goal.CustomEvent",@@ -215,7 +211,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do} dosubscribe_to_business_plan(site.team)- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload = %{goal_type: "Goal.CustomEvent",@@ -245,7 +241,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do|> Ecto.Changeset.change(%{trial_expiry_date: Date.add(Date.utc_today(), -1)})|> Plausible.Repo.update!()- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload = %{goal_type: "Goal.CustomEvent",@@ -261,7 +257,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest doendtest "validates input according to the schema", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")conn|> authenticate(site.domain, token)@@ -272,7 +268,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest doendtest "creates a custom event goal", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload = %{goal_type: "Goal.CustomEvent", goal: %{event_name: "Signup"}}@@ -296,18 +292,14 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do[location] = get_resp_header(conn, "location")assert location ==- Routes.plugins_api_goals_url(- PlausibleWeb.Endpoint,- :get,- List.first(schema.goals).goal.id- )+ url(~p"/api/plugins/v1/goals/#{List.first(schema.goals).goal.id}")assert [%{event_name: "Signup"}] = Plausible.Goals.for_site(site)end@tag :ee_onlytest "creates a revenue goal", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload = %{goal_type: "Goal.Revenue",@@ -334,11 +326,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do[location] = get_resp_header(conn, "location")assert location ==- Routes.plugins_api_goals_url(- PlausibleWeb.Endpoint,- :get,- List.first(schema.goals).goal.id- )+ url(~p"/api/plugins/v1/goals/#{List.first(schema.goals).goal.id}")assert [%{event_name: "Purchase", currency: :EUR}] = Plausible.Goals.for_site(site)end@@ -349,7 +337,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest dotoken: token,site: site} do- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload = %{goal_type: "Goal.Revenue",@@ -378,7 +366,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest dotoken: token,site: site} do- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals"){:ok, _} = Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "USD"})@@ -398,7 +386,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest doendtest "creates a pageview goal", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload = %{goal_type: "Goal.Pageview", goal: %{path: "/checkout"}}assert_request_schema(payload, "Goal.CreateRequest.Pageview", spec())@@ -420,11 +408,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do[location] = get_resp_header(conn, "location")assert location ==- Routes.plugins_api_goals_url(- PlausibleWeb.Endpoint,- :get,- List.first(schema.goals).goal.id- )+ url(~p"/api/plugins/v1/goals/#{List.first(schema.goals).goal.id}")assert [%{page_path: "/checkout"}] = Plausible.Goals.for_site(site)end@@ -436,7 +420,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do} dofor i <- 1..10, do: {:ok, _} = Plausible.Goals.create(site, %{"event_name" => "G#{i}"})- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload = %{goal_type: "Goal.Pageview", goal: %{path: "/checkout"}}@@ -456,7 +440,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest doendtest "is idempotent", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")initial_conn =conn@@ -485,7 +469,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest dodescribe "put /goals - bulk creation" do@tag :ee_onlytest "creates a goal of each type", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload = %{goals: [@@ -520,25 +504,13 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do[l1, l2, l3] = get_resp_header(conn, "location")assert l1 ==- Routes.plugins_api_goals_url(- PlausibleWeb.Endpoint,- :get,- Enum.at(resp.goals, 0).goal.id- )+ url(~p"/api/plugins/v1/goals/#{Enum.at(resp.goals, 0).goal.id}")assert l2 ==- Routes.plugins_api_goals_url(- PlausibleWeb.Endpoint,- :get,- Enum.at(resp.goals, 1).goal.id- )+ url(~p"/api/plugins/v1/goals/#{Enum.at(resp.goals, 1).goal.id}")assert l3 ==- Routes.plugins_api_goals_url(- PlausibleWeb.Endpoint,- :get,- Enum.at(resp.goals, 2).goal.id- )+ url(~p"/api/plugins/v1/goals/#{Enum.at(resp.goals, 2).goal.id}")assert Enum.count(resp.goals) == 3@@ -553,7 +525,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do# if this test fails due to implementation change, consider what to do with the pagination meta# object returned in the response and also revise how funnels are created based on a list of goals# - the funnels creation endpoint will likely reuse this schema's constraints- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")payload =Enum.map(1..9, fn i ->@@ -577,7 +549,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do@tag :ee_onlytest "is idempotent", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")initial_conn =conn@@ -616,7 +588,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest dotoken: token,site: site} do- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/goals")initial_conn =conn@@ -644,7 +616,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest dodescribe "get /goals/:id" dotest "validates input out of the box", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :get, "hello")+ url = url(~p"/api/plugins/v1/goals/hello")resp =conn@@ -661,7 +633,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do{:ok, goal} =Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "EUR"})- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :get, goal.id)+ url = url(~p"/api/plugins/v1/goals/#{goal.id}")resp =conn@@ -680,7 +652,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest dotest "retrieves pageview goal by ID", %{conn: conn, site: site, token: token} do{:ok, goal} = Plausible.Goals.create(site, %{"page_path" => "/checkout"})- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :get, goal.id)+ url = url(~p"/api/plugins/v1/goals/#{goal.id}")resp =conn@@ -703,7 +675,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do"custom_props" => %{"tier" => "premium"}})- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :get, goal.id)+ url = url(~p"/api/plugins/v1/goals/#{goal.id}")resp =conn@@ -732,7 +704,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do{:ok, _g2} =Plausible.Goals.create(site, %{"page_path" => "/checkout", "custom_props" => %{}})- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :index)+ url = url(~p"/api/plugins/v1/goals")resp =conn@@ -755,7 +727,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest dotoken: token,site: site} do- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :index)+ url = url(~p"/api/plugins/v1/goals")resp =conn@@ -780,7 +752,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do{:ok, g2} = Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "EUR"}){:ok, g3} = Plausible.Goals.create(site, %{"page_path" => "/checkout"})- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :index)+ url = url(~p"/api/plugins/v1/goals")resp =conn@@ -812,7 +784,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest doinsert(:goal, site: site, event_name: "Goal #{i}")end- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :index, limit: 2)+ url = url(~p"/api/plugins/v1/goals?#{[limit: 2]}")initial_conn = authenticate(conn, site.domain, token)@@ -854,7 +826,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do{:ok, %{id: goal_id}} =Plausible.Goals.create(site, %{"event_name" => "Purchase", "currency" => "USD"})- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :delete, goal_id)+ url = url(~p"/api/plugins/v1/goals/#{goal_id}")conn|> authenticate(site.domain, token)@@ -865,7 +837,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest doendtest "is idempotent", %{conn: conn, site: site, token: token} do- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :delete, 666)+ url = url(~p"/api/plugins/v1/goals/666")conn|> authenticate(site.domain, token)@@ -885,7 +857,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do{:ok, g3} =Plausible.Goals.create(site, %{"page_path" => "/home"})- url = Routes.plugins_api_goals_url(PlausibleWeb.Endpoint, :delete_bulk)+ url = url(~p"/api/plugins/v1/goals")payload = %{goal_ids: [diff --git a/test/plausible_web/plugins/api/controllers/shared_links_test.exs b/test/plausible_web/plugins/api/controllers/shared_links_test.exsindex af1c86c47f..e0e6f28075 100644--- a/test/plausible_web/plugins/api/controllers/shared_links_test.exs+++ b/test/plausible_web/plugins/api/controllers/shared_links_test.exs@@ -13,13 +13,13 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest dodescribe "unauthorized calls" dofor {method, url} <- [- {:get, Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :get, 1)},- {:put, Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :create)},- {:get, Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :index)}+ {:get, "/api/plugins/v1/shared_links/1"},+ {:put, "/api/plugins/v1/shared_links"},+ {:get, "/api/plugins/v1/shared_links"}] dotest "unauthorized call: #{method} #{url}", %{conn: conn} doconn- |> unquote(method)(unquote(url))+ |> unquote(method)(unverified_url(PlausibleWeb.Endpoint, unquote(url)))|> json_response(401)|> assert_schema("UnauthorizedError", spec())end@@ -28,7 +28,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest dodescribe "get /shared_links/:id" dotest "validates input out of the box", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :get, "hello")+ url = url(~p"/api/plugins/v1/shared_links/hello")resp =conn@@ -43,7 +43,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest dotest "retrieve shared link by ID", %{conn: conn, site: site, token: token} doshared_link = insert(:shared_link, name: "Some Link Name", site: site)- url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :get, shared_link.id)+ url = url(~p"/api/plugins/v1/shared_links/#{shared_link.id}")resp =conn@@ -61,7 +61,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest doendtest "fails to retrieve non-existing link", %{conn: conn, site: site, token: token} do- url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :get, 666)+ url = url(~p"/api/plugins/v1/shared_links/666")conn|> authenticate(site.domain, token)@@ -72,7 +72,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest dotest "fails to retrieve link from another site", %{conn: conn, site: site, token: token} doshared_link = insert(:shared_link, name: "Some Link Name", site: build(:site))- url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :get, shared_link.id)+ url = url(~p"/api/plugins/v1/shared_links/#{shared_link.id}")conn|> authenticate(site.domain, token)@@ -88,7 +88,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest dosite: site,token: token} do- url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/shared_links")initial_conn = authenticate(conn, site.domain, token)@@ -114,11 +114,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest do[location] = get_resp_header(conn, "location")assert location ==- Routes.plugins_api_shared_links_url(- PlausibleWeb.Endpoint,- :get,- resp.shared_link.id- )+ url(~p"/api/plugins/v1/shared_links/#{resp.shared_link.id}")assert ^resp =initial_conn@@ -132,7 +128,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest dosite: site,token: token} do- url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/shared_links")initial_conn = authenticate(conn, site.domain, token)@@ -165,7 +161,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest doendtest "validates input out of the box", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/shared_links")resp =conn@@ -185,7 +181,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest do} doinsert(:starter_subscription, team: site.team)- url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/shared_links")resp =authenticate(conn, site.domain, token)@@ -210,7 +206,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest dosite: site,token: token} do- url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :create)+ url = url(~p"/api/plugins/v1/shared_links")resp =authenticate(conn, site.domain, token)@@ -237,7 +233,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest dotoken: token,site: site} do- url = Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :index)+ url = url(~p"/api/plugins/v1/shared_links")resp =conn@@ -262,7 +258,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.SharedLinksTest doendurl =- Routes.plugins_api_shared_links_url(PlausibleWeb.Endpoint, :index, limit: 2)+ url(~p"/api/plugins/v1/shared_links?#{[limit: 2]}")initial_conn = authenticate(conn, site.domain, token)diff --git a/test/plausible_web/plugins/api/controllers/tracker_script_configuration_test.exs b/test/plausible_web/plugins/api/controllers/tracker_script_configuration_test.exsindex 9e1415e52f..70f5857118 100644--- a/test/plausible_web/plugins/api/controllers/tracker_script_configuration_test.exs+++ b/test/plausible_web/plugins/api/controllers/tracker_script_configuration_test.exs@@ -23,18 +23,12 @@ defmodule PlausibleWeb.Plugins.API.Controllers.TrackerScriptConfigurationTest dodescribe "unauthorized calls" dofor {method, url} <- [- {:get,- Routes.plugins_api_tracker_script_configuration_url(PlausibleWeb.Endpoint, :get)},- {:put,- Routes.plugins_api_tracker_script_configuration_url(- PlausibleWeb.Endpoint,- :update,- %{}- )}+ {:get, "/api/plugins/v1/tracker_script_configuration"},+ {:put, "/api/plugins/v1/tracker_script_configuration"}] dotest "unauthorized call: #{method} #{url}", %{conn: conn} doconn- |> unquote(method)(unquote(url))+ |> unquote(method)(unverified_url(PlausibleWeb.Endpoint, unquote(url)))|> json_response(401)|> assert_schema("UnauthorizedError", spec())end@@ -150,7 +144,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.TrackerScriptConfigurationTest doendtest "installation_type parameter is required", %{conn: conn, token: token, site: site} do- url = Routes.plugins_api_tracker_script_configuration_url(PlausibleWeb.Endpoint, :update)+ url = url(~p"/api/plugins/v1/tracker_script_configuration")payload = %{tracker_script_configuration: %{hash_based_routing: true}}@@ -170,7 +164,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.TrackerScriptConfigurationTest dotoken: token,site: site} do- url = Routes.plugins_api_tracker_script_configuration_url(PlausibleWeb.Endpoint, :update)+ url = url(~p"/api/plugins/v1/tracker_script_configuration")payload = %{tracker_script_configuration: %{installation_type: "unknown", hash_based_routing: "1234"}@@ -194,7 +188,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.TrackerScriptConfigurationTest doenddefp get_tracker_script_configuration(conn, site, token) do- url = Routes.plugins_api_tracker_script_configuration_url(PlausibleWeb.Endpoint, :get)+ url = url(~p"/api/plugins/v1/tracker_script_configuration")conn|> authenticate(site.domain, token)@@ -204,7 +198,7 @@ defmodule PlausibleWeb.Plugins.API.Controllers.TrackerScriptConfigurationTest doenddefp update_tracker_script_configuration(conn, site, token, payload) do- url = Routes.plugins_api_tracker_script_configuration_url(PlausibleWeb.Endpoint, :update)+ url = url(~p"/api/plugins/v1/tracker_script_configuration")conn|> authenticate(site.domain, token)diff --git a/test/plausible_web/plugs/handle_expired_session_test.exs b/test/plausible_web/plugs/handle_expired_session_test.exsindex 506284eca9..97ee982d51 100644--- a/test/plausible_web/plugs/handle_expired_session_test.exs+++ b/test/plausible_web/plugs/handle_expired_session_test.exs@@ -6,8 +6,6 @@ defmodule Plausible.Plugs.HandleExpiredSessionTest doalias Plausible.Plugs.HandleExpiredSessionalias Plausible.Repo- alias PlausibleWeb.Router.Helpers, as: Routes-test "passes through when there's no expired_session" doconn = HandleExpiredSession.call(build_conn(), [])refute conn.halted@@ -40,12 +38,7 @@ defmodule Plausible.Plugs.HandleExpiredSessionTest doassert conn.haltedassert redirected_to(conn, 302) ==- Routes.sso_path(conn, :login_form,- prefer: "manual",- email: user.email,- autosubmit: true,- return_to: "/some/url?with=param"- )+ ~p"/sso/login?#{[prefer: "manual", email: user.email, autosubmit: true, return_to: "/some/url?with=param"]}"refute Repo.reload(session)end@@ -63,11 +56,7 @@ defmodule Plausible.Plugs.HandleExpiredSessionTest doassert conn.haltedassert redirected_to(conn, 302) ==- Routes.sso_path(conn, :login_form,- prefer: "manual",- email: user.email,- autosubmit: true- )+ ~p"/sso/login?#{[prefer: "manual", email: user.email, autosubmit: true]}"refute Repo.reload(session)enddiff --git a/test/plausible_web/plugs/require_account_plug_test.exs b/test/plausible_web/plugs/require_account_plug_test.exsindex cb9066b4ca..3c1b24380c 100644--- a/test/plausible_web/plugs/require_account_plug_test.exs+++ b/test/plausible_web/plugs/require_account_plug_test.exs@@ -4,7 +4,6 @@ defmodule PlausibleWeb.RequireAccountPlugTest doimport Plug.Connalias PlausibleWeb.RequireAccountPlug- alias PlausibleWeb.Router.Helpers, as: Routesdescribe "enforcing 2FA" dotest "passes when 2FA enforcement is disabled" do@@ -34,7 +33,7 @@ defmodule PlausibleWeb.RequireAccountPlugTest do|> RequireAccountPlug.call(nil)assert conn.halted- assert redirected_to(conn, 302) == Routes.auth_path(conn, :force_initiate_2fa_setup)+ assert redirected_to(conn, 302) == ~p"/2fa/setup/force-initiate"endtest "does not override for unverified account" do@@ -50,7 +49,7 @@ defmodule PlausibleWeb.RequireAccountPlugTest do|> RequireAccountPlug.call(nil)assert conn.halted- assert redirected_to(conn, 302) == Routes.auth_path(conn, :activate_form)+ assert redirected_to(conn, 302) == ~p"/activate"end@force_2fa_exceptions [diff --git a/test/plausible_web/plugs/sso_team_access_test.exs b/test/plausible_web/plugs/sso_team_access_test.exsindex 167f85f38d..4e7bd7f34f 100644--- a/test/plausible_web/plugs/sso_team_access_test.exs+++ b/test/plausible_web/plugs/sso_team_access_test.exs@@ -109,7 +109,7 @@ defmodule Plausible.Plugs.SSOTeamAccessTest do|> SSOTeamAccess.call([])assert conn.halted- assert redirected_to(conn, 302) == Routes.sso_path(conn, :provision_notice)+ assert redirected_to(conn, 302) == ~p"/sso/notice"endtest "redirects to issue notice for SSO team with force SSO and user in invalid state", %{@@ -136,7 +136,7 @@ defmodule Plausible.Plugs.SSOTeamAccessTest doassert conn.haltedassert redirected_to(conn, 302) ==- Routes.sso_path(conn, :provision_issue, issue: "multiple_memberships")+ ~p"/sso/issue?#{[issue: "multiple_memberships"]}"endendenddiff --git a/test/plausible_web/user_auth_test.exs b/test/plausible_web/user_auth_test.exsindex 67c27883ac..e8df4917b9 100644--- a/test/plausible_web/user_auth_test.exs+++ b/test/plausible_web/user_auth_test.exs@@ -8,8 +8,6 @@ defmodule PlausibleWeb.UserAuthTest doalias Plausible.Auth.SSOend- alias PlausibleWeb.Router.Helpers, as: Routes-describe "log_in_user/2,3" dosetup [:create_user]@@ -26,7 +24,7 @@ defmodule PlausibleWeb.UserAuthTest doassert NaiveDateTime.compare(session.last_used_at, now) in [:eq, :gt]assert NaiveDateTime.compare(session.timeout_at, session.last_used_at) == :gt- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert conn.private[:plug_session_info] == :renewassert conn.resp_cookies["logged_in"].max_age > 0assert get_session(conn, :user_token) == session.token@@ -63,7 +61,7 @@ defmodule PlausibleWeb.UserAuthTest doassert session.user_id == user.idassert NaiveDateTime.compare(session.timeout_at, identity.expires_at) == :eq- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"assert conn.private[:plug_session_info] == :renewassert conn.resp_cookies["logged_in"].max_age > 0assert get_session(conn, :current_team_id) == team.identifier@@ -95,7 +93,7 @@ defmodule PlausibleWeb.UserAuthTest doassert session.user_id == user.idassert session.token == get_session(conn, :user_token)- assert redirected_to(conn, 302) == Routes.site_path(conn, :index)+ assert redirected_to(conn, 302) == ~p"/sites"endtest "invalidates any existing sessions of user logging in when converting", %{@@ -144,7 +142,7 @@ defmodule PlausibleWeb.UserAuthTest doassert %{sessions: []} = user |> Repo.reload!() |> Repo.preload(:sessions)- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form, return_to: "")+ assert redirected_to(conn, 302) == ~p"/sso/login?#{[return_to: ""]}"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="We couldn't find a Single Sign-On account for that email."@@ -178,7 +176,7 @@ defmodule PlausibleWeb.UserAuthTest doassert %{sessions: []} = user |> Repo.reload!() |> Repo.preload(:sessions)- assert redirected_to(conn, 302) == Routes.sso_path(conn, :login_form, return_to: "")+ assert redirected_to(conn, 302) == ~p"/sso/login?#{[return_to: ""]}"assert Phoenix.Flash.get(conn.assigns.flash, :login_error) =="Team can't accept more members. Please contact the owner."@@ -211,7 +209,7 @@ defmodule PlausibleWeb.UserAuthTest do|> UserAuth.log_in_user(identity)assert redirected_to(conn, 302) ==- Routes.sso_path(conn, :provision_issue, issue: "multiple_memberships_noforce")+ ~p"/sso/issue?#{[issue: "multiple_memberships_noforce"]}"refute get_session(conn, :user_token)end@@ -240,7 +238,7 @@ defmodule PlausibleWeb.UserAuthTest do|> UserAuth.log_in_user(identity)assert redirected_to(conn, 302) ==- Routes.sso_path(conn, :provision_issue, issue: "active_personal_team_noforce")+ ~p"/sso/issue?#{[issue: "active_personal_team_noforce"]}"refute get_session(conn, :user_token)enddiff --git a/test/support/conn_case.ex b/test/support/conn_case.exindex 13344a8bcf..cc1f0fac91 100644--- a/test/support/conn_case.ex+++ b/test/support/conn_case.ex@@ -21,11 +21,12 @@ defmodule PlausibleWeb.ConnCase douse Plausibleuse Plausible.Teams.Test+ use PlausibleWeb.VerifiedRoutes+import Plausible.Test.Support.HTMLimport Plug.Connimport Phoenix.ConnTest- alias PlausibleWeb.Router.Helpers, as: Routesimport Plausible.Factoryimport Plausible.AssertMatchesdiff --git a/test/support/data_case.ex b/test/support/data_case.exindex e379994e68..c9da7f3c93 100644--- a/test/support/data_case.ex+++ b/test/support/data_case.ex@@ -20,6 +20,7 @@ defmodule Plausible.DataCase douse Plausible.TestUtilsuse Plausibleuse Plausible.Teams.Test+ use PlausibleWeb.VerifiedRoutesimport Plausible.Test.Support.HTMLdiff --git a/test/support/dev/billing/dev_subscriptions.ex b/test/support/dev/billing/dev_subscriptions.exindex 2622cf360d..f92a28028f 100644--- a/test/support/dev/billing/dev_subscriptions.ex+++ b/test/support/dev/billing/dev_subscriptions.ex@@ -6,11 +6,12 @@ defmodule Plausible.Billing.DevSubscriptions douse Plausibleon_ee do+ use PlausibleWeb.VerifiedRoutes+import Ecto.Queryalias Plausible.{Repo, Billing}alias Plausible.Billing.{Plan, EnterprisePlan, DevPaddleApiMock}- alias PlausibleWeb.Router.Helpers, as: Routesdef create_after_1s(team_id, plan_id) doTask.start(fn ->@@ -34,8 +35,8 @@ defmodule Plausible.Billing.DevSubscriptions do"email" => "","subscription_id" => Ecto.UUID.generate(),"subscription_plan_id" => plan_id,- "update_url" => Routes.dev_subscription_path(PlausibleWeb.Endpoint, :update_form),- "cancel_url" => Routes.dev_subscription_path(PlausibleWeb.Endpoint, :cancel_form),+ "update_url" => ~p"/dev/billing/update-subscription-form",+ "cancel_url" => ~p"/dev/billing/cancel-subscription-form","status" => "active","next_bill_date" => next_bill_date(plan_or_enterprise_plan, plan_id),"unit_price" => "#{to_string(DevPaddleApiMock.all_prices()[plan_id])}.00",diff --git a/test/support/dev/controllers/dev_subscription_controller.ex b/test/support/dev/controllers/dev_subscription_controller.exindex 0d2f9cb356..3e48bf16c7 100644--- a/test/support/dev/controllers/dev_subscription_controller.ex+++ b/test/support/dev/controllers/dev_subscription_controller.ex@@ -17,7 +17,7 @@ defmodule PlausibleWeb.DevSubscriptionController dodef create_form(conn, %{"plan_id" => plan_id}) dorender(conn, "create_dev_subscription.html",- back_link: Routes.billing_path(conn, :choose_plan),+ back_link: ~p"/billing/choose-plan",plan_id: plan_id)end@@ -29,7 +29,7 @@ defmodule PlausibleWeb.DevSubscriptionController dodo: raise("Can't render subscription update form without subscription")render(conn, "update_dev_subscription.html",- back_link: Routes.settings_path(conn, :subscription),+ back_link: ~p"/settings/billing/subscription",current_status: team.subscription.status)end@@ -41,7 +41,7 @@ defmodule PlausibleWeb.DevSubscriptionController dodo: raise("Can't render subscription cancel form without subscription")render(conn, "cancel_dev_subscription.html",- back_link: Routes.settings_path(conn, :subscription),+ back_link: ~p"/settings/billing/subscription",enterprise_plan?: Teams.Billing.enterprise_configured?(team))end@@ -54,7 +54,7 @@ defmodule PlausibleWeb.DevSubscriptionController doendDevSubscriptions.create_after_1s(for_team.id, plan_id)- redirect(conn, to: Routes.billing_path(PlausibleWeb.Endpoint, :upgrade_success))+ redirect(conn, to: ~p"/billing/upgrade-success")enddef update(conn, %{"status" => status}) do@@ -64,7 +64,7 @@ defmodule PlausibleWeb.DevSubscriptionController doconn|> put_flash(:success, "Subscription status set to '#{status}'")- |> redirect(to: Routes.settings_path(conn, :subscription))+ |> redirect(to: ~p"/settings/billing/subscription")enddef cancel(conn, %{"action" => action}) do@@ -91,7 +91,7 @@ defmodule PlausibleWeb.DevSubscriptionController doconn|> put_flash(:success, flash_msg)- |> redirect(to: Routes.settings_path(conn, :subscription))+ |> redirect(to: ~p"/settings/billing/subscription")endendenddiff --git a/test/support/dev/templates/dev_subscription/cancel_dev_subscription.heex b/test/support/dev/templates/dev_subscription/cancel_dev_subscription.heexindex b16d8edd68..7036434889 100644--- a/test/support/dev/templates/dev_subscription/cancel_dev_subscription.heex+++ b/test/support/dev/templates/dev_subscription/cancel_dev_subscription.heex@@ -2,7 +2,7 @@<div class="text-lg mb-6 font-bold dark:text-gray-100">[Test Mode] Cancel your subscription</div>- <form action={Routes.dev_subscription_path(@conn, :cancel)} method="POST" class="text-sm">+ <form action={~p"/dev/billing/cancel-subscription"} method="POST" class="text-sm"><div class="block text-gray-500 dark:text-gray-200 text-sm">In development mode you can choose how exactly you want to "cancel" your subscription.<br /><br /></div>diff --git a/test/support/dev/templates/dev_subscription/create_dev_subscription.heex b/test/support/dev/templates/dev_subscription/create_dev_subscription.heexindex c23228ea99..4ef694a8b7 100644--- a/test/support/dev/templates/dev_subscription/create_dev_subscription.heex+++ b/test/support/dev/templates/dev_subscription/create_dev_subscription.heex@@ -32,7 +32,7 @@Back</a><.button_link- href={Routes.dev_subscription_path(PlausibleWeb.Endpoint, :create, @plan_id)}+ href={~p"/dev/billing/create-subscription/#{@plan_id}"}method="post"mt?={false}>diff --git a/test/support/dev/templates/dev_subscription/update_dev_subscription.heex b/test/support/dev/templates/dev_subscription/update_dev_subscription.heexindex 9e02f7b23d..4955c46b4e 100644--- a/test/support/dev/templates/dev_subscription/update_dev_subscription.heex+++ b/test/support/dev/templates/dev_subscription/update_dev_subscription.heex@@ -2,7 +2,7 @@<div class="text-lg mb-6 font-bold dark:text-gray-100">[Test Mode] Update your subscription status</div>- <form action={Routes.dev_subscription_path(@conn, :update)} method="POST" class="text-sm">+ <form action={~p"/dev/billing/update-subscription"} method="POST" class="text-sm"><div class="block text-gray-500 dark:text-gray-200 text-sm">Simulate subscription status change events. On production, this happens through Paddle webhooks.This implementation is calling the underlying functions as close as possible to how it happens ondiff --git a/test/support/dev/views/dev_subscription_view.ex b/test/support/dev/views/dev_subscription_view.exindex 1e051e91ee..d4cef7150b 100644--- a/test/support/dev/views/dev_subscription_view.ex+++ b/test/support/dev/views/dev_subscription_view.ex@@ -5,8 +5,9 @@ defmodule PlausibleWeb.DevSubscriptionView douse Phoenix.View,root: "test/support/dev/templates"+ use PlausibleWeb.VerifiedRoutes+require Plausible.Billing.Subscription.Statusimport PlausibleWeb.Components.Generic- alias PlausibleWeb.Router.Helpers, as: Routesendenddiff --git a/test/support/plugins_api_case.ex b/test/support/plugins_api_case.exindex f0eec2e631..704a32ea57 100644--- a/test/support/plugins_api_case.ex+++ b/test/support/plugins_api_case.ex@@ -13,6 +13,7 @@ defmodule PlausibleWeb.PluginsAPICase douse Plausible.TestUtilsuse Plausible.Teams.Testuse Plausible+ use PlausibleWeb.VerifiedRoutesimport Plug.Connimport Phoenix.ConnTest@@ -21,7 +22,6 @@ defmodule PlausibleWeb.PluginsAPICase doimport OpenApiSpex.TestAssertions- alias PlausibleWeb.Router.Helpers, as: Routesalias PlausibleWeb.Plugins.API.Schemasdef authenticate(conn, domain, raw_token) do