mirror of
https://github.com/plausible/analytics.git
synced 2024-12-29 04:22:34 +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
.
53 lines
1.0 KiB
Elixir
53 lines
1.0 KiB
Elixir
defmodule Plausible do
|
|
@moduledoc """
|
|
Build-related macros
|
|
"""
|
|
|
|
@small_builds [:small, :small_test, :small_dev]
|
|
|
|
defmacro __using__(_) do
|
|
quote do
|
|
require Plausible
|
|
import Plausible
|
|
end
|
|
end
|
|
|
|
defmacro on_full_build(clauses) do
|
|
do_on_full_build(clauses)
|
|
end
|
|
|
|
def do_on_full_build(do: block) do
|
|
do_on_full_build(do: block, else: nil)
|
|
end
|
|
|
|
def do_on_full_build(do: do_block, else: else_block) do
|
|
if Mix.env() not in @small_builds do
|
|
quote do
|
|
unquote(do_block)
|
|
end
|
|
else
|
|
quote do
|
|
unquote(else_block)
|
|
end
|
|
end
|
|
end
|
|
|
|
defmacro full_build?() do
|
|
full_build? = Mix.env() not in @small_builds
|
|
|
|
# Tricking dialyzer as per:
|
|
# https://github.com/elixir-lang/elixir/blob/v1.12.3/lib/elixir/lib/gen_server.ex#L771-L778
|
|
quote do
|
|
:erlang.phash2(1, 1) == 0 and unquote(full_build?)
|
|
end
|
|
end
|
|
|
|
defmacro small_build?() do
|
|
small_build? = Mix.env() in @small_builds
|
|
|
|
quote do
|
|
unquote(small_build?)
|
|
end
|
|
end
|
|
end
|