Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

## 2.0.0

* Enhancements
* Return a task when sending a Sentry event

* Bug Fixes
* Ensure `mix sentry.send_test_event` finishes sending event before ending Mix task

* Backward incompatible changes
* `Sentry.capture_exception/1` now returns a `Task` instead of `{:ok, PID}`
4 changes: 3 additions & 1 deletion lib/mix/tasks/sentry.send_test_event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ defmodule Mix.Tasks.Sentry.SendTestEvent do

def maybe_send_event(env_name, included_envs) do
if env_name in included_envs do
Mix.shell.info "Sending test event!"
Mix.shell.info "Sending test event..."
Sentry.capture_exception(RuntimeError.exception("Testing sending Sentry event"))
|> Task.await()
Mix.shell.info "Test event sent!"
else
Mix.shell.info "#{inspect env_name} is not in #{inspect included_envs} so no test event will be sent"
end
Expand Down
6 changes: 4 additions & 2 deletions lib/sentry.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Sentry do
use Application

import Supervisor.Spec
alias Sentry.Event
require Logger

Expand Down Expand Up @@ -66,7 +66,9 @@ defmodule Sentry do
@use_error_logger Application.get_env(:sentry, :use_error_logger, false)

def start(_type, _opts) do
children = []
children = [
supervisor(Task.Supervisor, [[name: Sentry.TaskSupervisor]]),
]
opts = [strategy: :one_for_one, name: Sentry.Supervisor]


Expand Down
2 changes: 1 addition & 1 deletion lib/sentry/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Sentry.Client do
auth_headers = authorization_headers(public_key, secret_key)
body = Poison.encode!(event)

Task.start(fn ->
Task.Supervisor.async_nolink(Sentry.TaskSupervisor, fn ->
try_request(:post, endpoint, auth_headers, body)
end)
end
Expand Down