Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Remove fallbacks for /js/s-... urls (#5629)
Artur Pata4b0fa1f1affc
diff --git a/lib/plausible_web/live/installationv2/instructions.ex b/lib/plausible_web/live/installationv2/instructions.exindex 8b4d602e0d..b12d0f7371 100644--- a/lib/plausible_web/live/installationv2/instructions.ex+++ b/lib/plausible_web/live/installationv2/instructions.ex@@ -245,10 +245,6 @@ defmodule PlausibleWeb.Live.InstallationV2.Instructions doenddefp tracker_url(tracker_script_configuration) do- if String.starts_with?(tracker_script_configuration.id, "pa-") do- "https://plausible.io/js/#{tracker_script_configuration.id}.js"- else- "https://plausible.io/js/s-#{tracker_script_configuration.id}.js"- end+ "https://plausible.io/js/#{tracker_script_configuration.id}.js"endenddiff --git a/lib/plausible_web/plugs/tracker_plug.ex b/lib/plausible_web/plugs/tracker_plug.exindex 08285169e5..9e464fdccb 100644--- a/lib/plausible_web/plugs/tracker_plug.ex+++ b/lib/plausible_web/plugs/tracker_plug.ex@@ -40,14 +40,6 @@ defmodule PlausibleWeb.TrackerPlug dodef call(conn, files_available: files_available) docase conn.request_path do- "/js/s-" <> path ->- if String.ends_with?(path, ".js") do- id = String.replace_trailing(path, ".js", "")- request_tracker_script(id, conn)- else- conn- end-"/js/pa-" <> path ->if String.ends_with?(path, ".js") doid = String.replace_trailing(path, ".js", "")@@ -69,7 +61,6 @@ defmodule PlausibleWeb.TrackerPlug dodef telemetry_event(name), do: [:plausible, :tracker_script, :request, name]- # at this point, id might be both with and without the `pa-` prefixdefp request_tracker_script(id, conn) docase get_plausible_web_script(id) do{:ok, script_tag} ->@@ -104,7 +95,6 @@ defmodule PlausibleWeb.TrackerPlug doendend- # at this point, id can be both with and without the `pa-` prefixdefp get_plausible_web_script(id) doscript =on_ee do@@ -118,12 +108,7 @@ defmodule PlausibleWeb.TrackerPlug doif script do{:ok, script}else- if not String.starts_with?(id, "pa-") do- # maybe the script been migrated to the new format already- get_plausible_web_script("pa-" <> id)- else- {:error, :not_found}- end+ {:error, :not_found}endenddiff --git a/test/plausible_web/plugs/tracker_plug_test.exs b/test/plausible_web/plugs/tracker_plug_test.exsindex 7601ebb60e..87776bf564 100644--- a/test/plausible_web/plugs/tracker_plug_test.exs+++ b/test/plausible_web/plugs/tracker_plug_test.exs@@ -67,36 +67,9 @@ defmodule PlausibleWeb.TrackerPlugTest doassert String.contains?(response, "window.plausible")end- test "returns the script requested with the legacy s- prefix, even if the id has been prefixed with pa- in the database",- %{conn: conn} do- site = new_site()-- tracker_script_configuration =- Tracker.update_script_configuration!(- site,- Map.put(@example_config, :site_id, site.id),- :installation- )-- assert String.starts_with?(tracker_script_configuration.id, "pa-")-- response =- get(- conn,- "/js/s-#{String.replace_leading(tracker_script_configuration.id, "pa-", "")}.js"- )- |> response(200)-- assert String.contains?(response, "!function(){var")- assert String.contains?(response, "domain:\"#{site.domain}\"")- assert String.contains?(response, "formSubmissions:!0")- refute String.contains?(response, "outboundLinks:!0")- refute String.contains?(response, "fileDownloads:!0")- end-test "returns 404 for unknown site", %{conn: conn} doconn- |> get("/js/s-a14125a2-000-000-0000-000000000000.js")+ |> get("/js/pa-a14125a2-000-000-0000-000000000000.js")|> response(404)endend