Skip to content

add MAILGUN_BASE_URI - #2935

Merged
ukutaht merged 2 commits into
masterfrom
add-base_uri_option-mailgun
May 25, 2023
Merged

add MAILGUN_BASE_URI#2935
ukutaht merged 2 commits into
masterfrom
add-base_uri_option-mailgun

Conversation

@ruslandoga

@ruslandoga ruslandoga commented May 17, 2023

Copy link
Copy Markdown
Contributor

Changes

This PR adds MAILGUN_BASE_URI support as suggested in #2649 (comment)

Tests

  • Automated tests have been added

Changelog

  • Entry has been added to changelog

Documentation

  • Docs have been updated (it probably should be updated after v2 release)

Dark mode

  • This PR does not change the UI

@bundlemon

bundlemon Bot commented May 17, 2023

Copy link
Copy Markdown

BundleMon

Unchanged files (7)
Status Path Size Limits
static/css/app.css
492.34KB -
static/js/dashboard.js
298.88KB -
static/js/app.js
12.13KB -
static/js/embed.host.js
5.58KB -
static/js/embed.content.js
5.06KB -
tracker/js/plausible.js
733B -
static/js/applyTheme.js
314B -

No change in files bundle size

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

Comment thread config/runtime.exs

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

@ruslandoga ruslandoga May 17, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm doing it this way because the alternatives either don't work:

config :plausible, Plausible.Mailer,
  adapter: Bamboo.MailgunAdapter,
  hackney_opts: [recv_timeout: :timer.seconds(10)],
  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 is not set, `base_uri: nil` and it causes a runtime error during delivery
  # https://github.com/thoughtbot/bamboo/blob/53bd3929da6778ccf4ec7817070ec19f2b12b772/lib/bamboo/adapters/mailgun_adapter.ex#L63-L65
  # it would've worked if base_uri used `Application.get_env(:bamboo, :base_uri) || @default_base_uri` instead.
  base_uri: get_var_from_path_or_env(config_dir, "MAILGUN_BASE_URI")

Or require more maintenance:

config :plausible, Plausible.Mailer,
  adapter: Bamboo.MailgunAdapter,
  hackney_opts: [recv_timeout: :timer.seconds(10)],
  api_key: get_var_from_path_or_env(config_dir, "MAILGUN_API_KEY"),
  domain: get_var_from_path_or_env(config_dir, "MAILGUN_DOMAIN"),
  # this works now but would require us to keep an eye on newer api version and keep it up to date
  base_uri: get_var_from_path_or_env(config_dir, "MAILGUN_BASE_URI", "https://api.mailgun.net/v3")

@ruslandoga
ruslandoga requested a review from a team May 17, 2023 05:26
@ruslandoga ruslandoga changed the title add MAILGUN_BASE_URI support add MAILGUN_BASE_URI May 17, 2023
@tenfourty

Copy link
Copy Markdown

Thank you for this work. I started working on a similar PR until I saw this one. So I've written some docs for this PR and sent out a PR for the docs side plausible/docs#396

@ruslandoga

Copy link
Copy Markdown
Contributor Author

@tenfourty thank you!

@ukutaht
ukutaht merged commit 7b22aff into master May 25, 2023
@ukutaht
ukutaht deleted the add-base_uri_option-mailgun branch May 25, 2023 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants