Skip to content

Commit

Permalink
drop Bamboo.SMTPAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslandoga committed Feb 27, 2024
1 parent f3423ae commit db27584
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 48 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ All notable changes to this project will be documented in this file.
- Removed the `prop_names` returned in the Stats API `event:goal` breakdown response
- Removed the `prop-breakdown.csv` file from CSV export
- Deprecated `CLICKHOUSE_MAX_BUFFER_SIZE`
- Drop `Bamboo.SMTPAdapter`

### Changed
- Limit the number of Goal Conversions shown on the dashboard and render a "Details" link when there are more entries to show
- Show Outbound Links / File Downloads / 404 Pages / Cloaked Links instead of Goal Conversions when filtering by the corresponding goal
- Require custom properties to be explicitly added from Site Settings > Custom Properties in order for them to show up on the dashboard
- GA/SC sections moved to new settings: Integrations
- Replace `CLICKHOUSE_MAX_BUFFER_SIZE` with `CLICKHOUSE_MAX_BUFFER_SIZE_BYTES`
- Make `Bamboo.Mua` the default as opposed to `Bamboo.SMTPAdapter`

### Fixed
- Fix `conversion_rate` metric in a `browser_versions` breakdown
Expand Down
34 changes: 17 additions & 17 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ super_admin_user_ids =
|> Enum.filter(& &1)

env = get_var_from_path_or_env(config_dir, "ENVIRONMENT", "prod")
mailer_adapter = get_var_from_path_or_env(config_dir, "MAILER_ADAPTER", "Bamboo.SMTPAdapter")
mailer_email = get_var_from_path_or_env(config_dir, "MAILER_EMAIL", "[email protected]")
mailer_adapter = get_var_from_path_or_env(config_dir, "MAILER_ADAPTER", "Bamboo.Mua")

mailer_email =
get_var_from_path_or_env(config_dir, "MAILER_EMAIL", "plausible-ce@#{base_url.host}")

mailer_email =
if mailer_name = get_var_from_path_or_env(config_dir, "MAILER_NAME") do
Expand Down Expand Up @@ -462,23 +464,21 @@ case mailer_adapter do
hackney_opts: [recv_timeout: :timer.seconds(10)],
api_key: get_var_from_path_or_env(config_dir, "SENDGRID_API_KEY")

"Bamboo.SMTPAdapter" ->
config :plausible, Plausible.Mailer,
adapter: Bamboo.SMTPAdapter,
server: get_var_from_path_or_env(config_dir, "SMTP_HOST_ADDR", "mail"),
hostname: base_url.host,
port: get_var_from_path_or_env(config_dir, "SMTP_HOST_PORT", "25"),
username: get_var_from_path_or_env(config_dir, "SMTP_USER_NAME"),
password: get_var_from_path_or_env(config_dir, "SMTP_USER_PWD"),
tls: :if_available,
allowed_tls_versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"],
ssl: get_var_from_path_or_env(config_dir, "SMTP_HOST_SSL_ENABLED") || false,
retries: get_var_from_path_or_env(config_dir, "SMTP_RETRIES") || 2,
no_mx_lookups: get_var_from_path_or_env(config_dir, "SMTP_MX_LOOKUPS_ENABLED") || true

"Bamboo.Mua" ->
smtp_adapter when smtp_adapter in ["Bamboo.SMTPAdapter", "Bamboo.Mua"] ->
config :plausible, Plausible.Mailer, adapter: Bamboo.Mua

if smtp_adapter == "Bamboo.SMTPAdapter" do
Logger.warning(
"Bamboo.SMTPAdapter has been replaced with Bamboo.Mua, falling back to using Bamboo.Mua"
)
end

for env_var <- ["SMTP_MX_LOOKUPS_ENABLED", "SMTP_RETRIES", "SMTP_HOST_SSL_ENABLED"] do
if get_var_from_path_or_env(config_dir, env_var) do
Logger.warning("#{env_var} env var is no longer supported")
end
end

if relay = get_var_from_path_or_env(config_dir, "SMTP_HOST_ADDR") do
port = get_int_from_path_or_env(config_dir, "SMTP_HOST_PORT", 25)
username = get_var_from_path_or_env(config_dir, "SMTP_USER_NAME")
Expand Down
1 change: 0 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ defmodule Plausible.MixProject do
{:bamboo, "~> 2.3", override: true},
{:bamboo_phoenix, "~> 1.0.0"},
{:bamboo_postmark, git: "https://github.com/plausible/bamboo_postmark.git", branch: "main"},
{:bamboo_smtp, "~> 4.1"},
{:bamboo_mua, "~> 0.1.4"},
{:bcrypt_elixir, "~> 3.0"},
{:bypass, "~> 2.1", only: [:dev, :test, :small_test]},
Expand Down
2 changes: 0 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"bamboo_mua": {:hex, :bamboo_mua, "0.1.4", "6f3a48284f8a5d4d20caa66df5d918dea98f73f4d0c9e5d30d02a9b2a5b8134d", [:mix], [{:bamboo, "~> 2.0", [hex: :bamboo, repo: "hexpm", optional: false]}, {:mail, "~> 0.3.0", [hex: :mail, repo: "hexpm", optional: false]}, {:mua, "~> 0.1.5", [hex: :mua, repo: "hexpm", optional: false]}], "hexpm", "1443a9829fa69eb0fadf463476b9f3c5c9bac0dcd3065407f48cd180698010da"},
"bamboo_phoenix": {:hex, :bamboo_phoenix, "1.0.0", "f3cc591ffb163ed0bf935d256f1f4645cd870cf436545601215745fb9cc9953f", [:mix], [{:bamboo, ">= 2.0.0", [hex: :bamboo, repo: "hexpm", optional: false]}, {:phoenix, ">= 1.3.0", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "6db88fbb26019c84a47994bb2bd879c0887c29ce6c559bc6385fd54eb8b37dee"},
"bamboo_postmark": {:git, "https://github.com/plausible/bamboo_postmark.git", "5eac6dfdffacd273bd9aacdd3e494a600bb0b170", [branch: "main"]},
"bamboo_smtp": {:hex, :bamboo_smtp, "4.2.2", "e9f57a2300df9cb496c48751bd7668a86a2b89aa2e79ccaa34e0c46a5f64c3ae", [:mix], [{:bamboo, "~> 2.2.0", [hex: :bamboo, repo: "hexpm", optional: false]}, {:gen_smtp, "~> 1.2.0", [hex: :gen_smtp, repo: "hexpm", optional: false]}], "hexpm", "28cac2ec8adaae02aed663bf68163992891a3b44cfd7ada0bebe3e09bed7207f"},
"bcrypt_elixir": {:hex, :bcrypt_elixir, "3.1.0", "0b110a9a6c619b19a7f73fa3004aa11d6e719a67e672d1633dc36b6b2290a0f7", [:make, :mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "2ad2acb5a8bc049e8d5aa267802631912bb80d5f4110a178ae7999e69dca1bf7"},
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"bypass": {:hex, :bypass, "2.1.0", "909782781bf8e20ee86a9cabde36b259d44af8b9f38756173e8f5e2e1fabb9b1", [:mix], [{:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "d9b5df8fa5b7a6efa08384e9bbecfe4ce61c77d28a4282f79e02f1ef78d96b80"},
Expand Down Expand Up @@ -60,7 +59,6 @@
"fun_with_flags": {:hex, :fun_with_flags, "1.11.0", "a9019d0300e9755c53111cf5b2aba640d7f0de2a8a03a0bd0c593e943c3e9ec5", [:mix], [{:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: true]}, {:redix, "~> 1.0", [hex: :redix, repo: "hexpm", optional: true]}], "hexpm", "448ec640cd1ade4728979ae5b3e7592b0fc8b0f99cf40785d048515c27d09743"},
"fun_with_flags_ui": {:hex, :fun_with_flags_ui, "1.0.0", "d764a4d1cc1233bdbb18dfb416a6ef96d0ecf4a5dc5a0201f7aa0b13cf2e7802", [:mix], [{:cowboy, ">= 2.0.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:fun_with_flags, "~> 1.11", [hex: :fun_with_flags, repo: "hexpm", optional: false]}, {:plug, "~> 1.12", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, ">= 2.0.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm", "b0c145894c00d65d5dc20ee5b1f18457985d1fd0b87866f0b41894d5979e55e0"},
"gen_cycle": {:hex, :gen_cycle, "1.0.4", "2315199f1256116328fad6a9d4371c2fb0bc39c7f5111b88d2de582300c931cc", [:rebar3], [], "hexpm", "67817e31b352bb00715f80a5571b3c069e26e994b2ebafa376acf76a2d0f66d8"},
"gen_smtp": {:hex, :gen_smtp, "1.2.0", "9cfc75c72a8821588b9b9fe947ae5ab2aed95a052b81237e0928633a13276fd3", [:rebar3], [{:ranch, ">= 1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "5ee0375680bca8f20c4d85f58c2894441443a743355430ff33a783fe03296779"},
"gettext": {:hex, :gettext, "0.24.0", "6f4d90ac5f3111673cbefc4ebee96fe5f37a114861ab8c7b7d5b30a1108ce6d8", [:mix], [{:expo, "~> 0.5.1", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "bdf75cdfcbe9e4622dd18e034b227d77dd17f0f133853a1c73b97b3d6c770e8b"},
"gproc": {:hex, :gproc, "0.9.1", "f1df0364423539cf0b80e8201c8b1839e229e5f9b3ccb944c5834626998f5b8c", [:rebar3], [], "hexpm", "905088e32e72127ed9466f0bac0d8e65704ca5e73ee5a62cb073c3117916d507"},
"grpcbox": {:hex, :grpcbox, "0.17.1", "6e040ab3ef16fe699ffb513b0ef8e2e896da7b18931a1ef817143037c454bcce", [:rebar3], [{:acceptor_pool, "~> 1.0.0", [hex: :acceptor_pool, repo: "hexpm", optional: false]}, {:chatterbox, "~> 0.15.1", [hex: :ts_chatterbox, repo: "hexpm", optional: false]}, {:ctx, "~> 0.6.0", [hex: :ctx, repo: "hexpm", optional: false]}, {:gproc, "~> 0.9.1", [hex: :gproc, repo: "hexpm", optional: false]}], "hexpm", "4a3b5d7111daabc569dc9cbd9b202a3237d81c80bf97212fbc676832cb0ceb17"},
Expand Down
49 changes: 21 additions & 28 deletions test/plausible/config_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Plausible.ConfigTest do
describe "mailer" do
test "mailer email default" do
env = [{"MAILER_EMAIL", nil}]
assert get_in(runtime_config(env), [:plausible, :mailer_email]) == "hello@plausible.local"
assert get_in(runtime_config(env), [:plausible, :mailer_email]) == "plausible-ce@localhost"
end

test "mailer email custom" do
Expand All @@ -16,29 +16,19 @@ defmodule Plausible.ConfigTest do
env = [{"MAILER_EMAIL", nil}, {"MAILER_NAME", "John"}]

assert get_in(runtime_config(env), [:plausible, :mailer_email]) ==
{"John", "hello@plausible.local"}
{"John", "plausible-ce@localhost"}

env = [{"MAILER_EMAIL", "[email protected]"}, {"MAILER_NAME", "John"}]

assert get_in(runtime_config(env), [:plausible, :mailer_email]) ==
{"John", "[email protected]"}
end

test "defaults to Bamboo.SMTPAdapter" do
test "defaults to Bamboo.Mua" do
env = {"MAILER_ADAPTER", nil}

assert get_in(runtime_config(env), [:plausible, Plausible.Mailer]) == [
adapter: Bamboo.SMTPAdapter,
server: "mail",
hostname: "localhost",
port: "25",
username: nil,
password: nil,
tls: :if_available,
allowed_tls_versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"],
ssl: false,
retries: 2,
no_mx_lookups: true
adapter: Bamboo.Mua
]
end

Expand Down Expand Up @@ -113,7 +103,7 @@ defmodule Plausible.ConfigTest do
]
end

test "Bamboo.SMTPAdapter" do
test "Bamboo.SMTPAdapter is deprecated" do
env = [
{"MAILER_ADAPTER", "Bamboo.SMTPAdapter"},
{"SMTP_HOST_ADDR", "localhost"},
Expand All @@ -125,19 +115,22 @@ defmodule Plausible.ConfigTest do
{"SMTP_MX_LOOKUPS_ENABLED", "true"}
]

assert get_in(runtime_config(env), [:plausible, Plausible.Mailer]) == [
{:adapter, Bamboo.SMTPAdapter},
{:server, "localhost"},
{:hostname, "localhost"},
{:port, "2525"},
{:username, "neo"},
{:password, "one"},
{:tls, :if_available},
{:allowed_tls_versions, [:tlsv1, :"tlsv1.1", :"tlsv1.2"]},
{:ssl, "true"},
{:retries, "3"},
{:no_mx_lookups, "true"}
]
log =
ExUnit.CaptureLog.capture_log(fn ->
assert get_in(runtime_config(env), [:plausible, Plausible.Mailer]) == [
adapter: Bamboo.Mua,
auth: [username: "neo", password: "one"],
relay: "localhost",
port: 2525
]
end)

assert log =~
"[warning] Bamboo.SMTPAdapter has been replaced with Bamboo.Mua, falling back to using Bamboo.Mua"

assert log =~ "[warning] SMTP_MX_LOOKUPS_ENABLED env var is no longer supported"
assert log =~ "[warning] SMTP_RETRIES env var is no longer supported"
assert log =~ "[warning] SMTP_HOST_SSL_ENABLED env var is no longer supported"
end

test "Bamboo.Mua (no config)" do
Expand Down

0 comments on commit db27584

Please sign in to comment.