Skip to content

Commit 3c944f8

Browse files
committed
Update Plausible script
1 parent dfa930c commit 3c944f8

File tree

5 files changed

+29
-28
lines changed

5 files changed

+29
-28
lines changed

config/runtime.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ if config_env() == :prod do
88
queue_id: System.fetch_env!("PREVIEW_QUEUE_ID"),
99
queue_concurrency: String.to_integer(System.fetch_env!("PREVIEW_QUEUE_CONCURRENCY")),
1010
fastly_key: System.fetch_env!("PREVIEW_FASTLY_KEY"),
11-
fastly_repo: System.fetch_env!("PREVIEW_FASTLY_REPO"),
12-
plausible_url: "https://stats.hex.pm/js/plausible.js"
11+
fastly_repo: System.fetch_env!("PREVIEW_FASTLY_REPO")
1312

1413
config :preview, :repo_bucket,
1514
implementation: Preview.Storage.S3,

lib/preview_web.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmodule PreviewWeb do
1919

2020
def controller do
2121
quote do
22-
use Phoenix.Controller, namespace: PreviewWeb
22+
use Phoenix.Controller, formats: [:html, :json]
2323

2424
import Plug.Conn
2525
import PreviewWeb.Gettext

lib/preview_web/controllers/sitemap_controller.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
defmodule PreviewWeb.SitemapController do
22
use PreviewWeb, :controller
3+
plug :put_format, "xml"
34

45
def index(conn, _params) do
56
bucket = Application.get_env(:preview, :preview_bucket)

lib/preview_web/templates/layout/root.html.heex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
>
2525
</script>
2626

27-
<%= if plausible_url = Application.get_env(:preview, :plausible_url) do %>
28-
<% host = Application.fetch_env!(:preview, :host) %>
29-
<script async defer data-domain={host} src={plausible_url}>
27+
<%= if host = Application.get_env(:preview, :host) do %>
28+
<script async defer src={"https://s.#{host}/js/script.js"}>
29+
</script>
30+
<script>
31+
window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};plausible.init({endpoint:"https://s.<%= host %>/api/event"})
3032
</script>
3133
<% end %>
3234
</head>

0 commit comments

Comments
 (0)