Skip to content

Commit

Permalink
add MAILGUN_BASE_URI (#2935)
Browse files Browse the repository at this point in the history
* add MAILGUN_BASE_URI support

* add changelog entry
  • Loading branch information
ruslandoga authored May 25, 2023
1 parent f489d96 commit 7b22aff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 17 additions & 0 deletions test/plausible/config_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 7b22aff

Please sign in to comment.