Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

add MAILGUN_BASE_URI (#2935)

ruslandoga7b22aff11c43
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 59b8abcbf6..b293d0c130 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
- 'Last updated X seconds ago' info to 'current visitors' tooltips
- Add support for more Bamboo adapters, i.e. `Bamboo.MailgunAdapter`, `Bamboo.MandrillAdapter`, `Bamboo.SendGridAdapter` plausible/analytics#2649
- Ability to change domain for existing site (requires numeric IDs data migration, instructions will be provided separately) UI + API (`PUT /api/v1/sites`)
+- Add `MAILGUN_BASE_URI` support for `Bamboo.MailgunAdapter` plausible/analytics#2935
### Fixed
- Fix tracker bug - call callback function even when event is ignored
diff --git a/config/runtime.exs b/config/runtime.exs
index 155a8d1e1a..46ad8e0b43 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -337,6 +337,10 @@ case mailer_adapter do
api_key: get_var_from_path_or_env(config_dir, "MAILGUN_API_KEY"),
domain: get_var_from_path_or_env(config_dir, "MAILGUN_DOMAIN")
+ if mailgun_base_uri = get_var_from_path_or_env(config_dir, "MAILGUN_BASE_URI") do
+ config :plausible, Plausible.Mailer, base_uri: mailgun_base_uri
+ end
+
"Bamboo.MandrillAdapter" ->
config :plausible, Plausible.Mailer,
adapter: Bamboo.MandrillAdapter,
diff --git a/test/plausible/config_test.exs b/test/plausible/config_test.exs
index c21f4885d0..5071b7cb28 100644
--- a/test/plausible/config_test.exs
+++ b/test/plausible/config_test.exs
@@ -48,6 +48,23 @@ defmodule Plausible.ConfigTest do
]
end
+ test "Bamboo.MailgunAdapter with custom MAILGUN_BASE_URI" do
+ env = [
+ {"MAILER_ADAPTER", "Bamboo.MailgunAdapter"},
+ {"MAILGUN_API_KEY", "some-mailgun-key"},
+ {"MAILGUN_DOMAIN", "example.com"},
+ {"MAILGUN_BASE_URI", "https://api.eu.mailgun.net/v3"}
+ ]
+
+ assert get_in(runtime_config(env), [:plausible, Plausible.Mailer]) == [
+ adapter: Bamboo.MailgunAdapter,
+ hackney_opts: [recv_timeout: 10_000],
+ api_key: "some-mailgun-key",
+ domain: "example.com",
+ base_uri: "https://api.eu.mailgun.net/v3"
+ ]
+ end
+
test "Bamboo.MandrillAdapter" do
env = [
{"MAILER_ADAPTER", "Bamboo.MandrillAdapter"},