Capture exceptions and send them to the Bugsnag API!
# Add it to your deps in your projects mix.exs
defp deps do
[{:bugsnag, "~> 1.3.2"}]
end
# Now, list the :bugsnag application as your application dependency:
def application do
[applications: [:bugsnag]]
end
# Open up your config/config.exs (or appropriate project config)
config :bugsnag, api_key: "bbf085fc54ff99498ebd18ab49a832dd"
# Set the release stage in your environment configs (e.g. config/prod.exs)
config :bugsnag, release_stage: "prod"
# Report an exception.
try do
:foo = :bar
rescue
exception -> Bugsnag.report(exception)
end
These are optional fields to fill the bugsnag report with more information, depending on your specific usage scenario.
They can be passed into the Bugsnag.report/2
function like so:
# ...an exception occured
Bugsnag.report(exception, severity: "warn", user: %{name: "Jane Doe"})
stacktrace
- Allows explicitly passing in a stacktrace used to generate the stacktrace object that is sent to bugsnagseverity
- Sets the severity explicitly to "error", "warning" or "info"release_stage
- Explicitly sets an arbitrary release stage e.g. "development", "test" or "production"context
- Allows passing in context information, like e.g. the name of the file the crash occured inuser
- Allows passing in user information, needs to be a map with one or more of the following fields (which are then searchable):id
- Any binary identifier for the username
- Full name of the useremail
- Full email of the user
os_version
andhostname
- Will be aggregated within Bugsnag'sdevice
field and can be used as a filtermetadata
- Arbitrary metadata (See Bugsnag docs for more information)
Set the use_logger
option to true in your application's config.exs
.
Then run Bugsnag.start
and any SASL
compliant processes that crash will send an error report to the Bugsnag.Logger
.
The logger will take care of sending the error to Bugsnag.