Skip to content

Commit

Permalink
feat: simplifies reporter config UX
Browse files Browse the repository at this point in the history
  • Loading branch information
grzuy committed Oct 7, 2024
1 parent 89d2f7d commit e9f0c0b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ config(
:reporters,
[
# along any other possible reporters
TowerRollbar.Reporter
TowerRollbar
]
)
```
Expand Down
9 changes: 9 additions & 0 deletions lib/tower_rollbar.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
defmodule TowerRollbar do
@moduledoc """
A [Rollbar](https://rollbar.com) reporter for `Tower` error handler.
## Example
config :tower, :reporters, [TowerRollbar]
"""

@behaviour Tower.Reporter

@impl true
defdelegate report_event(event), to: TowerRollbar.Reporter
end
7 changes: 1 addition & 6 deletions lib/tower_rollbar/reporter.ex
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
defmodule TowerRollbar.Reporter do
@moduledoc """
The reporter module that needs to be added to the list of Tower reporters.
"""

@behaviour Tower.Reporter
@moduledoc false

alias TowerRollbar.Rollbar

@impl true
def report_event(%Tower.Event{} = event) do
if Rollbar.Client.enabled?() do
{:ok, _} =
Expand Down
2 changes: 1 addition & 1 deletion test/tower_rollbar_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule TowerRollbarTest do
setup do
bypass = Bypass.open()

Application.put_env(:tower, :reporters, [TowerRollbar.Reporter])
Application.put_env(:tower, :reporters, [TowerRollbar])
Application.put_env(:tower_rollbar, :rollbar_base_url, "http://localhost:#{bypass.port}/")
Application.put_env(:tower_rollbar, :environment, :test)
Application.put_env(:tower_rollbar, :access_token, "fake-token")
Expand Down

0 comments on commit e9f0c0b

Please sign in to comment.