analytics/extra/lib/plausible_web/dogfood.ex
hq1 74675f0cbc
Move dogfooding to full build (#3576)
* Move dogfooding to `extra/`

* Remove unused view functions
2023-12-04 10:30:20 +01:00

32 lines
1.0 KiB
Elixir

defmodule PlausibleWeb.Dogfood do
@moduledoc """
Plausible tracking itself functions
"""
@doc """
Temporary override to do more testing of the new ingest.plausible.io endpoint for accepting events. In staging and locally
will fall back to staging.plausible.io/api/event and localhost:8000/api/event respectively.
"""
def api_destination() do
if Application.get_env(:plausible, :environment) == "prod" do
"https://ingest.plausible.io/api/event"
end
end
def script_url() do
if Application.get_env(:plausible, :environment) in ["prod", "staging"] do
"#{PlausibleWeb.Endpoint.url()}/js/script.manual.pageview-props.tagged-events.js"
else
"#{PlausibleWeb.Endpoint.url()}/js/script.local.manual.pageview-props.tagged-events.js"
end
end
def domain(conn) do
cond do
Application.get_env(:plausible, :is_selfhost) -> "ee.plausible.io"
conn.assigns[:embedded] -> "embed." <> PlausibleWeb.Endpoint.host()
true -> PlausibleWeb.Endpoint.host()
end
end
end