mirror of
https://github.com/plausible/analytics.git
synced 2024-12-18 06:41:29 +03:00
a4b9c3b8ba
* Disable super-admin checks on small build * Mute a test writing to stdout * Move sampling outside of small build * Convert waiting_first_pageview to heex and stop relying on env vars * Set site limit unlimited on small build * Stop relying on app env to get trial expiry * Remove custom domains - including migration * Remove is_selfhosted from layout view * Quota fixup * Stop relying on app env for self hosted registration * Stop relying on app env for pass reset success * Apply on_trial? check only on full build * Update templates relying on app env * Adjusts auth controller tests for small build * Trial fixup * Fixup * Stop relying on app env * Rest of the fsckn owl * Update typespecs * Fix dialyzer warning * Remove unused module * Credo + format * GeoIP is not, for full build * Use `small_build?()` where applicable * Implement bypassing FirstLaunchPlug without insertions * Get Marko's patchde58a18a85
* Test is-dbip=false presence * Fix typespec * Remove future hardcodes * Handle `nil` from `Plausible.Geo.database_type()` * Remove XXX marker * Use one typespec for two clauses * Introduce `MIX_ENV=small_dev` * Revert "Use one typespec for two clauses" This reverts commit8d8cd21764
.
39 lines
937 B
Elixir
39 lines
937 B
Elixir
defmodule PlausibleWeb.FirstLaunchPlug do
|
|
@moduledoc """
|
|
Redirects first-launch users to registration page.
|
|
"""
|
|
|
|
defmodule Test do
|
|
@moduledoc """
|
|
Test helper for setup blocks allowing to skip the plug processing
|
|
"""
|
|
@spec skip(map()) :: {:ok, map()}
|
|
def skip(context) do
|
|
conn = Plug.Conn.put_private(context.conn, PlausibleWeb.FirstLaunchPlug, :skip)
|
|
{:ok, Map.put(context, :conn, conn)}
|
|
end
|
|
end
|
|
|
|
@behaviour Plug
|
|
alias Plausible.Release
|
|
|
|
@impl true
|
|
def init(opts) do
|
|
_path = Keyword.fetch!(opts, :redirect_to)
|
|
end
|
|
|
|
@impl true
|
|
def call(%Plug.Conn{private: %{__MODULE__ => :skip}} = conn, _), do: conn
|
|
def call(%Plug.Conn{request_path: path} = conn, path), do: conn
|
|
|
|
def call(conn, redirect_to) do
|
|
if Release.should_be_first_launch?() do
|
|
conn
|
|
|> Phoenix.Controller.redirect(to: redirect_to)
|
|
|> Plug.Conn.halt()
|
|
else
|
|
conn
|
|
end
|
|
end
|
|
end
|