2019-09-02 14:29:19 +03:00
|
|
|
defmodule PlausibleWeb.StatsController do
|
2023-11-20 14:52:20 +03:00
|
|
|
use Plausible
|
|
|
|
|
2022-09-20 15:37:18 +03:00
|
|
|
@moduledoc """
|
|
|
|
This controller is responsible for rendering stats dashboards.
|
|
|
|
|
|
|
|
The stats dashboards are currently the only part of the app that uses client-side
|
|
|
|
rendering. Since the dashboards are heavily interactive, they are built with React
|
2022-10-25 14:17:09 +03:00
|
|
|
which is an appropriate choice for highly interactive browser UIs.
|
2022-09-20 15:37:18 +03:00
|
|
|
|
|
|
|
<div class="mermaid">
|
|
|
|
sequenceDiagram
|
|
|
|
Browser->>StatsController: GET /mydomain.com
|
|
|
|
StatsController-->>Browser: StatsView.render("stats.html")
|
|
|
|
Note left of Browser: ReactDom.render(Dashboard)
|
|
|
|
|
|
|
|
Browser -) Api.StatsController: GET /api/stats/mydomain.com/top-stats
|
|
|
|
Api.StatsController --) Browser: {"top_stats": [...]}
|
|
|
|
Note left of Browser: TopStats.render()
|
|
|
|
|
|
|
|
Browser -) Api.StatsController: GET /api/stats/mydomain.com/main-graph
|
|
|
|
Api.StatsController --) Browser: [{"plot": [...], "labels": [...]}, ...]
|
|
|
|
Note left of Browser: VisitorGraph.render()
|
|
|
|
|
|
|
|
Browser -) Api.StatsController: GET /api/stats/mydomain.com/sources
|
|
|
|
Api.StatsController --) Browser: [{"name": "Google", "visitors": 292150}, ...]
|
|
|
|
Note left of Browser: Sources.render()
|
|
|
|
|
|
|
|
Note over Browser,StatsController: And so on, for all reports in the viewport
|
|
|
|
</div>
|
|
|
|
|
|
|
|
This reasoning for this sequence is as follows:
|
|
|
|
1. First paint is fast because it doesn't do any data aggregation yet - good UX
|
|
|
|
2. The basic structure of the dashboard is rendered with spinners before reports are ready - good UX
|
|
|
|
2. Rendering on the frontend allows for maximum interactivity. Re-rendering and re-fetching can be as granular as needed.
|
|
|
|
3. Routing on the frontend allows the user to navigate the dashboard without reloading the page and losing context
|
|
|
|
4. Rendering on the frontend allows caching results in the browser to reduce pressure on backends and storage
|
|
|
|
3.1 No client-side caching has been implemented yet. This is still theoretical. See https://github.com/plausible/analytics/discussions/1278
|
|
|
|
3.2 This is a big potential opportunity, because analytics data is mostly immutable. Clients can cache all historical data.
|
|
|
|
5. Since frontend rendering & navigation is harder to build and maintain than regular server-rendered HTML, we don't use SPA-style rendering anywhere else
|
2022-10-25 14:17:09 +03:00
|
|
|
.The only place currently where the benefits outweigh the costs is the dashboard.
|
2022-09-20 15:37:18 +03:00
|
|
|
"""
|
|
|
|
|
2019-09-02 14:29:19 +03:00
|
|
|
use PlausibleWeb, :controller
|
|
|
|
use Plausible.Repo
|
2022-10-04 15:34:45 +03:00
|
|
|
|
|
|
|
alias Plausible.Sites
|
2024-01-29 13:16:47 +03:00
|
|
|
alias Plausible.Stats.Query
|
2022-10-04 15:34:45 +03:00
|
|
|
alias PlausibleWeb.Api
|
2019-09-02 14:29:19 +03:00
|
|
|
|
2022-11-05 05:42:03 +03:00
|
|
|
plug(PlausibleWeb.AuthorizeSiteAccess when action in [:stats, :csv_export])
|
2020-05-26 16:09:34 +03:00
|
|
|
|
2020-10-02 12:02:32 +03:00
|
|
|
def stats(%{assigns: %{site: site}} = conn, _params) do
|
2023-10-17 16:00:00 +03:00
|
|
|
site = Plausible.Repo.preload(site, :owner)
|
2022-04-06 11:52:19 +03:00
|
|
|
stats_start_date = Plausible.Sites.stats_start_date(site)
|
2022-10-04 15:34:45 +03:00
|
|
|
can_see_stats? = not Sites.locked?(site) or conn.assigns[:current_user_role] == :super_admin
|
2023-09-21 13:05:50 +03:00
|
|
|
demo = site.domain == PlausibleWeb.Endpoint.host()
|
|
|
|
dogfood_page_path = if !demo, do: "/:dashboard"
|
2021-06-16 15:00:07 +03:00
|
|
|
|
|
|
|
cond do
|
2022-10-04 15:34:45 +03:00
|
|
|
stats_start_date && can_see_stats? ->
|
2021-06-16 15:00:07 +03:00
|
|
|
conn
|
2023-05-16 14:19:55 +03:00
|
|
|
|> put_resp_header("x-robots-tag", "noindex, nofollow")
|
2021-06-16 15:00:07 +03:00
|
|
|
|> render("stats.html",
|
|
|
|
site: site,
|
|
|
|
has_goals: Plausible.Sites.has_goals?(site),
|
2024-04-04 15:39:55 +03:00
|
|
|
revenue_goals: list_revenue_goals(site),
|
2023-11-20 14:52:20 +03:00
|
|
|
funnels: list_funnels(site),
|
2023-08-05 16:35:31 +03:00
|
|
|
has_props: Plausible.Props.configured?(site),
|
2022-04-06 11:52:19 +03:00
|
|
|
stats_start_date: stats_start_date,
|
2023-05-03 11:46:13 +03:00
|
|
|
native_stats_start_date: NaiveDateTime.to_date(site.native_stats_start_at),
|
2023-07-11 11:47:03 +03:00
|
|
|
title: title(conn, site),
|
2022-04-21 10:54:08 +03:00
|
|
|
demo: demo,
|
2024-04-04 11:48:30 +03:00
|
|
|
flags: get_flags(conn.assigns[:current_user], site),
|
2023-09-21 13:05:50 +03:00
|
|
|
is_dbip: is_dbip(),
|
2023-11-01 19:54:19 +03:00
|
|
|
dogfood_page_path: dogfood_page_path,
|
|
|
|
load_dashboard_js: true
|
2021-06-16 15:00:07 +03:00
|
|
|
)
|
|
|
|
|
2022-10-04 15:34:45 +03:00
|
|
|
!stats_start_date && can_see_stats? ->
|
2023-09-21 13:05:50 +03:00
|
|
|
render(conn, "waiting_first_pageview.html",
|
|
|
|
site: site,
|
|
|
|
dogfood_page_path: dogfood_page_path
|
|
|
|
)
|
2021-06-16 15:00:07 +03:00
|
|
|
|
2022-10-04 15:34:45 +03:00
|
|
|
Sites.locked?(site) ->
|
2023-10-11 15:40:01 +03:00
|
|
|
site = Plausible.Repo.preload(site, :owner)
|
|
|
|
render(conn, "site_locked.html", site: site, dogfood_page_path: dogfood_page_path)
|
2019-09-02 14:29:19 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-11-20 14:52:20 +03:00
|
|
|
on_full_build do
|
|
|
|
defp list_funnels(site) do
|
|
|
|
Plausible.Funnels.list(site)
|
|
|
|
end
|
2024-04-04 15:39:55 +03:00
|
|
|
|
|
|
|
defp list_revenue_goals(site) do
|
|
|
|
Plausible.Goals.list_revenue_goals(site)
|
2023-11-20 14:52:20 +03:00
|
|
|
end
|
2024-04-04 15:39:55 +03:00
|
|
|
else
|
|
|
|
defp list_funnels(_site), do: []
|
|
|
|
defp list_revenue_goals(_site), do: []
|
2023-11-20 14:52:20 +03:00
|
|
|
end
|
|
|
|
|
2021-11-15 18:06:39 +03:00
|
|
|
@doc """
|
|
|
|
The export is limited to 300 entries for other reports and 100 entries for pages because bigger result sets
|
|
|
|
start causing failures. Since we request data like time on page or bounce_rate for pages in a separate query
|
|
|
|
using the IN filter, it causes the requests to balloon in payload size.
|
|
|
|
"""
|
2021-10-26 16:54:50 +03:00
|
|
|
def csv_export(conn, params) do
|
2023-07-17 15:50:56 +03:00
|
|
|
if is_nil(params["interval"]) or Plausible.Stats.Interval.valid?(params["interval"]) do
|
2023-10-17 16:00:00 +03:00
|
|
|
site = Plausible.Repo.preload(conn.assigns.site, :owner)
|
2024-01-29 13:16:47 +03:00
|
|
|
query = Query.from(site, params)
|
2023-07-17 15:50:56 +03:00
|
|
|
|
|
|
|
filename =
|
2023-10-24 11:33:48 +03:00
|
|
|
~c"Plausible export #{params["domain"]} #{Timex.format!(query.date_range.first, "{ISOdate} ")} to #{Timex.format!(query.date_range.last, "{ISOdate} ")}.zip"
|
2023-07-17 15:50:56 +03:00
|
|
|
|
|
|
|
params = Map.merge(params, %{"limit" => "300", "csv" => "True", "detailed" => "True"})
|
|
|
|
limited_params = Map.merge(params, %{"limit" => "100"})
|
|
|
|
|
|
|
|
csvs = %{
|
2024-03-22 12:35:23 +03:00
|
|
|
~c"visitors.csv" => fn -> main_graph_csv(site, query) end,
|
2023-10-24 11:33:48 +03:00
|
|
|
~c"sources.csv" => fn -> Api.StatsController.sources(conn, params) end,
|
|
|
|
~c"utm_mediums.csv" => fn -> Api.StatsController.utm_mediums(conn, params) end,
|
|
|
|
~c"utm_sources.csv" => fn -> Api.StatsController.utm_sources(conn, params) end,
|
|
|
|
~c"utm_campaigns.csv" => fn -> Api.StatsController.utm_campaigns(conn, params) end,
|
|
|
|
~c"utm_contents.csv" => fn -> Api.StatsController.utm_contents(conn, params) end,
|
|
|
|
~c"utm_terms.csv" => fn -> Api.StatsController.utm_terms(conn, params) end,
|
|
|
|
~c"pages.csv" => fn -> Api.StatsController.pages(conn, limited_params) end,
|
|
|
|
~c"entry_pages.csv" => fn -> Api.StatsController.entry_pages(conn, params) end,
|
|
|
|
~c"exit_pages.csv" => fn -> Api.StatsController.exit_pages(conn, limited_params) end,
|
|
|
|
~c"countries.csv" => fn -> Api.StatsController.countries(conn, params) end,
|
|
|
|
~c"regions.csv" => fn -> Api.StatsController.regions(conn, params) end,
|
|
|
|
~c"cities.csv" => fn -> Api.StatsController.cities(conn, params) end,
|
|
|
|
~c"browsers.csv" => fn -> Api.StatsController.browsers(conn, params) end,
|
2023-12-12 16:39:08 +03:00
|
|
|
~c"browser_versions.csv" => fn -> Api.StatsController.browser_versions(conn, params) end,
|
2023-10-24 11:33:48 +03:00
|
|
|
~c"operating_systems.csv" => fn -> Api.StatsController.operating_systems(conn, params) end,
|
2024-02-22 18:58:50 +03:00
|
|
|
~c"operating_system_versions.csv" => fn ->
|
|
|
|
Api.StatsController.operating_system_versions(conn, params)
|
|
|
|
end,
|
2023-10-24 11:33:48 +03:00
|
|
|
~c"devices.csv" => fn -> Api.StatsController.screen_sizes(conn, params) end,
|
|
|
|
~c"conversions.csv" => fn -> Api.StatsController.conversions(conn, params) end,
|
2024-01-02 15:31:08 +03:00
|
|
|
~c"referrers.csv" => fn -> Api.StatsController.referrers(conn, params) end,
|
|
|
|
~c"custom_props.csv" => fn -> Api.StatsController.all_custom_prop_values(conn, params) end
|
2023-07-17 15:50:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
csv_values =
|
|
|
|
Map.values(csvs)
|
|
|
|
|> Plausible.ClickhouseRepo.parallel_tasks()
|
|
|
|
|
|
|
|
csvs =
|
|
|
|
Map.keys(csvs)
|
|
|
|
|> Enum.zip(csv_values)
|
2024-01-02 15:31:08 +03:00
|
|
|
|> Enum.reject(fn {_k, v} -> is_nil(v) end)
|
2023-07-17 15:50:56 +03:00
|
|
|
|
|
|
|
{:ok, {_, zip_content}} = :zip.create(filename, csvs, [:memory])
|
|
|
|
|
|
|
|
conn
|
|
|
|
|> put_resp_content_type("application/zip")
|
|
|
|
|> put_resp_header("content-disposition", "attachment; filename=\"#{filename}\"")
|
|
|
|
|> delete_resp_cookie("exporting")
|
|
|
|
|> send_resp(200, zip_content)
|
|
|
|
else
|
|
|
|
conn
|
|
|
|
|> send_resp(400, "")
|
|
|
|
|> halt()
|
|
|
|
end
|
2020-01-13 16:16:35 +03:00
|
|
|
end
|
|
|
|
|
2024-03-22 12:35:23 +03:00
|
|
|
defp main_graph_csv(site, query) do
|
|
|
|
{metrics, column_headers} = csv_graph_metrics(query)
|
|
|
|
|
|
|
|
map_bucket_to_row = fn bucket -> Enum.map([:date | metrics], &bucket[&1]) end
|
|
|
|
prepend_column_headers = fn data -> [column_headers | data] end
|
|
|
|
|
|
|
|
Plausible.Stats.timeseries(site, query, metrics)
|
|
|
|
|> Enum.map(map_bucket_to_row)
|
|
|
|
|> prepend_column_headers.()
|
|
|
|
|> CSV.encode()
|
|
|
|
|> Enum.join()
|
|
|
|
end
|
|
|
|
|
|
|
|
defp csv_graph_metrics(%Query{filters: %{"event:goal" => _}}) do
|
|
|
|
metrics = [:visitors, :events, :conversion_rate]
|
|
|
|
column_headers = [:date, :unique_conversions, :total_conversions, :conversion_rate]
|
|
|
|
|
|
|
|
{metrics, column_headers}
|
|
|
|
end
|
|
|
|
|
|
|
|
defp csv_graph_metrics(_) do
|
|
|
|
metrics = [:visitors, :pageviews, :visits, :views_per_visit, :bounce_rate, :visit_duration]
|
|
|
|
column_headers = [:date | metrics]
|
|
|
|
|
|
|
|
{metrics, column_headers}
|
|
|
|
end
|
|
|
|
|
2022-09-20 15:37:18 +03:00
|
|
|
@doc """
|
|
|
|
Authorizes and renders a shared link:
|
|
|
|
1. Shared link with no password protection: needs to just make sure the shared link entry is still
|
|
|
|
in our database. This check makes sure shared link access can be revoked by the site admins. If the
|
|
|
|
shared link exists, render it directly.
|
|
|
|
|
|
|
|
2. Shared link with password protection: Same checks as without the password, but an extra step is taken to
|
|
|
|
protect the page with a password. When the user passes the password challenge, a cookie is set with Plausible.Auth.Token.sign_shared_link().
|
|
|
|
The cookie allows the user to access the dashboard for 24 hours without entering the password again.
|
|
|
|
|
|
|
|
### Backwards compatibility
|
|
|
|
|
|
|
|
The URL format for shared links was changed in [this pull request](https://github.com/plausible/analytics/pull/752) in order
|
|
|
|
to make the URLs easier to bookmark. The old format is supported along with the new in order to not break old links.
|
|
|
|
|
|
|
|
See: https://plausible.io/docs/shared-links
|
|
|
|
"""
|
2022-02-22 22:46:57 +03:00
|
|
|
def shared_link(conn, %{"domain" => domain, "auth" => auth}) do
|
2022-09-20 15:37:18 +03:00
|
|
|
case find_shared_link(domain, auth) do
|
|
|
|
{:password_protected, shared_link} ->
|
|
|
|
render_password_protected_shared_link(conn, shared_link)
|
2020-01-29 12:29:11 +03:00
|
|
|
|
2022-09-20 15:37:18 +03:00
|
|
|
{:unlisted, shared_link} ->
|
2021-03-02 12:15:43 +03:00
|
|
|
render_shared_link(conn, shared_link)
|
2022-09-20 15:37:18 +03:00
|
|
|
|
|
|
|
:not_found ->
|
|
|
|
render_error(conn, 404)
|
2021-03-02 12:15:43 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-09-20 15:37:18 +03:00
|
|
|
@old_format_deprecation_date ~N[2022-01-01 00:00:00]
|
|
|
|
def shared_link(conn, %{"domain" => slug}) do
|
2021-03-02 12:15:43 +03:00
|
|
|
shared_link =
|
2022-09-20 15:37:18 +03:00
|
|
|
Repo.one(
|
2022-11-05 05:42:03 +03:00
|
|
|
from(l in Plausible.Site.SharedLink,
|
2022-09-20 15:37:18 +03:00
|
|
|
where: l.slug == ^slug and l.inserted_at < ^@old_format_deprecation_date,
|
|
|
|
preload: :site
|
2022-11-05 05:42:03 +03:00
|
|
|
)
|
2022-09-20 15:37:18 +03:00
|
|
|
)
|
2021-03-02 12:15:43 +03:00
|
|
|
|
|
|
|
if shared_link do
|
2022-09-20 15:37:18 +03:00
|
|
|
new_link_format = Routes.stats_path(conn, :shared_link, shared_link.site.domain, auth: slug)
|
|
|
|
redirect(conn, to: new_link_format)
|
2020-01-29 12:29:11 +03:00
|
|
|
else
|
|
|
|
render_error(conn, 404)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-09-05 12:15:09 +03:00
|
|
|
def shared_link(conn, _) do
|
|
|
|
render_error(conn, 400)
|
|
|
|
end
|
|
|
|
|
2022-09-20 15:37:18 +03:00
|
|
|
defp render_password_protected_shared_link(conn, shared_link) do
|
|
|
|
with conn <- Plug.Conn.fetch_cookies(conn),
|
|
|
|
{:ok, token} <- Map.fetch(conn.req_cookies, shared_link_cookie_name(shared_link.slug)),
|
|
|
|
{:ok, %{slug: token_slug}} <- Plausible.Auth.Token.verify_shared_link(token),
|
|
|
|
true <- token_slug == shared_link.slug do
|
|
|
|
render_shared_link(conn, shared_link)
|
|
|
|
else
|
|
|
|
_e ->
|
|
|
|
conn
|
|
|
|
|> render("shared_link_password.html",
|
|
|
|
link: shared_link,
|
2023-09-21 13:05:50 +03:00
|
|
|
layout: {PlausibleWeb.LayoutView, "focus.html"},
|
|
|
|
dogfood_page_path: "/share/:dashboard"
|
2022-09-20 15:37:18 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
defp find_shared_link(domain, auth) do
|
|
|
|
link_query =
|
2022-11-05 05:42:03 +03:00
|
|
|
from(link in Plausible.Site.SharedLink,
|
2022-09-20 15:37:18 +03:00
|
|
|
inner_join: site in assoc(link, :site),
|
|
|
|
where: link.slug == ^auth,
|
|
|
|
where: site.domain == ^domain,
|
|
|
|
limit: 1,
|
|
|
|
preload: [site: site]
|
2022-11-05 05:42:03 +03:00
|
|
|
)
|
2022-09-20 15:37:18 +03:00
|
|
|
|
|
|
|
case Repo.one(link_query) do
|
|
|
|
%Plausible.Site.SharedLink{password_hash: hash} = link when not is_nil(hash) ->
|
|
|
|
{:password_protected, link}
|
|
|
|
|
|
|
|
%Plausible.Site.SharedLink{} = link ->
|
|
|
|
{:unlisted, link}
|
|
|
|
|
|
|
|
nil ->
|
|
|
|
:not_found
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-01-29 12:29:11 +03:00
|
|
|
def authenticate_shared_link(conn, %{"slug" => slug, "password" => password}) do
|
2020-06-08 10:35:13 +03:00
|
|
|
shared_link =
|
|
|
|
Repo.get_by(Plausible.Site.SharedLink, slug: slug)
|
|
|
|
|> Repo.preload(:site)
|
2020-01-29 12:29:11 +03:00
|
|
|
|
|
|
|
if shared_link do
|
|
|
|
if Plausible.Auth.Password.match?(password, shared_link.password_hash) do
|
2021-03-02 12:15:43 +03:00
|
|
|
token = Plausible.Auth.Token.sign_shared_link(slug)
|
|
|
|
|
|
|
|
conn
|
2022-02-22 22:46:57 +03:00
|
|
|
|> put_resp_cookie(shared_link_cookie_name(slug), token)
|
2021-03-02 12:15:43 +03:00
|
|
|
|> redirect(to: "/share/#{URI.encode_www_form(shared_link.site.domain)}?auth=#{slug}")
|
2020-01-29 12:29:11 +03:00
|
|
|
else
|
2020-05-19 16:20:21 +03:00
|
|
|
conn
|
2020-06-08 10:35:13 +03:00
|
|
|
|> render("shared_link_password.html",
|
|
|
|
link: shared_link,
|
|
|
|
error: "Incorrect password. Please try again.",
|
2023-09-21 13:05:50 +03:00
|
|
|
layout: {PlausibleWeb.LayoutView, "focus.html"},
|
|
|
|
dogfood_page_path: "/share/:dashboard"
|
2020-06-08 10:35:13 +03:00
|
|
|
)
|
2020-01-29 12:29:11 +03:00
|
|
|
end
|
|
|
|
else
|
|
|
|
render_error(conn, 404)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-02 12:15:43 +03:00
|
|
|
defp render_shared_link(conn, shared_link) do
|
2021-12-14 13:10:34 +03:00
|
|
|
cond do
|
|
|
|
!shared_link.site.locked ->
|
2024-01-03 14:32:21 +03:00
|
|
|
shared_link = Plausible.Repo.preload(shared_link, site: :owner)
|
2024-02-14 11:32:36 +03:00
|
|
|
stats_start_date = Plausible.Sites.stats_start_date(shared_link.site)
|
2024-01-03 14:32:21 +03:00
|
|
|
|
2021-12-14 13:10:34 +03:00
|
|
|
conn
|
2023-05-16 14:19:55 +03:00
|
|
|
|> put_resp_header("x-robots-tag", "noindex, nofollow")
|
2021-12-14 13:10:34 +03:00
|
|
|
|> delete_resp_header("x-frame-options")
|
|
|
|
|> render("stats.html",
|
|
|
|
site: shared_link.site,
|
2022-10-04 15:34:45 +03:00
|
|
|
has_goals: Sites.has_goals?(shared_link.site),
|
2024-04-04 15:39:55 +03:00
|
|
|
revenue_goals: list_revenue_goals(shared_link.site),
|
2023-11-20 14:52:20 +03:00
|
|
|
funnels: list_funnels(shared_link.site),
|
2023-08-05 16:35:31 +03:00
|
|
|
has_props: Plausible.Props.configured?(shared_link.site),
|
2024-02-14 11:32:36 +03:00
|
|
|
stats_start_date: stats_start_date,
|
2023-05-03 11:46:13 +03:00
|
|
|
native_stats_start_date: NaiveDateTime.to_date(shared_link.site.native_stats_start_at),
|
2023-07-11 11:47:03 +03:00
|
|
|
title: title(conn, shared_link.site),
|
2021-12-14 13:10:34 +03:00
|
|
|
demo: false,
|
2023-09-21 13:05:50 +03:00
|
|
|
dogfood_page_path: "/share/:dashboard",
|
2021-12-14 13:10:34 +03:00
|
|
|
shared_link_auth: shared_link.slug,
|
|
|
|
embedded: conn.params["embed"] == "true",
|
|
|
|
background: conn.params["background"],
|
2022-04-21 10:54:08 +03:00
|
|
|
theme: conn.params["theme"],
|
2024-04-04 11:48:30 +03:00
|
|
|
flags: get_flags(conn.assigns[:current_user], shared_link.site),
|
2023-11-01 19:54:19 +03:00
|
|
|
is_dbip: is_dbip(),
|
|
|
|
load_dashboard_js: true
|
2021-12-14 13:10:34 +03:00
|
|
|
)
|
|
|
|
|
2022-10-04 15:34:45 +03:00
|
|
|
Sites.locked?(shared_link.site) ->
|
2023-10-11 15:40:01 +03:00
|
|
|
owner = Plausible.Repo.preload(shared_link.site, :owner)
|
2021-12-14 13:10:34 +03:00
|
|
|
|
2023-09-21 13:05:50 +03:00
|
|
|
render(conn, "site_locked.html",
|
|
|
|
owner: owner,
|
|
|
|
site: shared_link.site,
|
|
|
|
dogfood_page_path: "/share/:dashboard"
|
|
|
|
)
|
2021-12-14 13:10:34 +03:00
|
|
|
end
|
2020-01-29 12:29:11 +03:00
|
|
|
end
|
|
|
|
|
2022-02-22 22:46:57 +03:00
|
|
|
defp shared_link_cookie_name(slug), do: "shared-link-" <> slug
|
2022-04-21 10:54:08 +03:00
|
|
|
|
2024-04-18 21:18:38 +03:00
|
|
|
defp get_flags(_user, _site), do: %{}
|
2022-05-03 10:38:59 +03:00
|
|
|
|
|
|
|
defp is_dbip() do
|
2023-11-29 13:04:54 +03:00
|
|
|
on_full_build do
|
2024-03-26 13:01:59 +03:00
|
|
|
false
|
2023-11-29 13:04:54 +03:00
|
|
|
else
|
|
|
|
Plausible.Geo.database_type()
|
|
|
|
|> to_string()
|
|
|
|
|> String.starts_with?("DBIP")
|
|
|
|
end
|
2022-05-03 10:38:59 +03:00
|
|
|
end
|
2023-07-11 11:47:03 +03:00
|
|
|
|
|
|
|
defp title(%{path_info: ["plausible.io"]}, _) do
|
|
|
|
"Plausible Analytics: Live Demo"
|
|
|
|
end
|
|
|
|
|
|
|
|
defp title(_conn, site) do
|
|
|
|
"Plausible · " <> site.domain
|
|
|
|
end
|
2019-09-02 14:29:19 +03:00
|
|
|
end
|