Skip to content

mimiquate/tower_email

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TowerEmail

ci Hex.pm Documentation

Error tracking and reporting to your e-mail inbox.

Simple send-me-an-email reporter for Tower error handler.

Installation

The package can be installed by adding tower_email to your list of dependencies in mix.exs:

# mix.exs

def deps do
  [
    {:tower_email, "~> 0.6.0"}
  ]
end

Setup

Register the reporter with Tower.

# config/config.exs

config(
  :tower,
  :reporters,
  [
    # along any other possible reporters
    TowerEmail
  ]
)

And make any additional configurations specific to this reporter.

# Build-time config (config/{config, dev, test, prod}.exs)

config :tower_email,
  otp_app: :your_app,
  from: {"Tower", "tower@<your_domain>"},
  to: "<recipient email address>"

# config/runtime.exs
config :tower_email,
  environment: System.get_env("DEPLOYMENT_ENV", to_string(config_env()))

Configuring Swoosh adapter for TowerEmail.Mailer:

# config/dev.exs
config :tower_email, TowerEmail.Mailer, adapter: Swoosh.Adapters.Local

# config/prod.exs
config :tower_email, TowerEmail.Mailer, adapter: Swoosh.Adapters.Postmark,

# config/runtime.exs
config :tower_email, TowerEmail.Mailer, api_key: System.fetch_env!("POSTMARK_API_KEY")

Configuring TowerEmail.Mailer is analogous on how to configure any Swoosh.Mailer https://hexdocs.pm/swoosh/Swoosh.Mailer.html.

Reporting

That's it. There's no extra source code needed to get reports in your e-mail inbox.

Tower will automatically report any errors (exceptions, throws or abnormal exits) occurring in your application. That includes errors in any plug call (including Phoenix), Oban jobs, async task or any other Elixir process.

Manual reporting

You can manually report errors just by informing Tower about any manually caught exceptions, throws or abnormal exits.

try do
  # possibly crashing code
rescue
  exception ->
    Tower.report_exception(exception, __STACKTRACE__)
end

More details on https://hexdocs.pm/tower/Tower.html#module-manual-reporting.

License

Copyright 2024 Mimiquate

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages