Adds an option to rename the script file

pull/1209/head
Uku Taht 5 years ago
parent 5d8d21f685
commit 369f63bc58

@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
- Menu (with auto-complete) to add new and edit existing filters directly plausible/analytics#1089
- Added `CLICKHOUSE_FLUSH_INTERVAL_MS` and `CLICKHOUSE_MAX_BUFFER_SIZE` configuration parameters plausible/analytics#1073
- Ability to invite users to sites with different roles plausible/analytics#1122
- Option to configure a custom name for the script file
### Fixed
- Fix weekly report time range plausible/analytics#951

@ -136,6 +136,10 @@ is_selfhost =
|> get_var_from_path_or_env("SELFHOST", "true")
|> String.to_existing_atom()
custom_script_name =
config_dir
|> get_var_from_path_or_env("CUSTOM_SCRIPT_NAME", "script")
{site_limit, ""} =
config_dir
|> get_var_from_path_or_env("SITE_LIMIT", "50")
@ -171,7 +175,8 @@ config :plausible,
admin_user_ids: admin_user_ids,
site_limit: site_limit,
site_limit_exempt: site_limit_exempt,
is_selfhost: is_selfhost
is_selfhost: is_selfhost,
custom_script_name: custom_script_name
config :plausible, :selfhost,
disable_authentication: disable_auth,

@ -2,7 +2,9 @@ defmodule PlausibleWeb.Tracker do
import Plug.Conn
use Agent
custom_script_name = Application.get_env(:plausible, :custom_script_name)
base_variants = ["hash", "outbound-links", "exclusions", "compat"]
base_filenames = ["plausible", custom_script_name]
# Generates Power Set of all variants
variants =
@ -24,8 +26,8 @@ defmodule PlausibleWeb.Tracker do
String.split(x, ".")
|> Combination.permutate()
|> Enum.map(fn p -> Enum.join(p, ".") end)
|> Enum.filter(fn permutation -> permutation != x end)
|> Enum.map(fn v -> "plausible.#{v}.js" end)
|> Enum.map(fn v -> Enum.map(base_filenames, fn filename -> "#{filename}.#{v}.js" end) end)
|> List.flatten()
if Enum.count(variants) > 0 do
{"plausible.#{x}.js", variants}
@ -33,7 +35,7 @@ defmodule PlausibleWeb.Tracker do
end)
|> Enum.reject(fn x -> x == nil end)
|> Enum.into(%{})
|> Map.put("plausible.js", ["analytics.js"])
|> Map.put("plausible.js", ["analytics.js", "#{custom_script_name}.js"])
@templates files_available
@aliases aliases_available

Loading…
Cancel
Save