Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add MAILGUN_BASE_URI #2935

Merged
merged 2 commits into from
May 25, 2023
Merged

add MAILGUN_BASE_URI #2935

merged 2 commits into from
May 25, 2023

Conversation

ruslandoga
Copy link
Contributor

@ruslandoga ruslandoga commented May 17, 2023

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
Copy link

bundlemon bot commented May 17, 2023

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

@@ -334,6 +334,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
Copy link
Contributor Author

@ruslandoga ruslandoga May 17, 2023

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

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
Contributor Author

@tenfourty thank you!

@ukutaht ukutaht merged commit 7b22aff into master May 25, 2023
5 checks passed
@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.

None yet

3 participants