Skip to content

Commit 45f83d6

Browse files
Merge pull request #341 from getsentry/change-default-send-behaviour
default result type to :none
2 parents 5cbfab2 + 43906ac commit 45f83d6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/sentry/client.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ defmodule Sentry.Client do
5959
Errors will be logged unless the source is the Sentry.LoggerBackend, which can deadlock by logging within a logger.
6060
6161
### Options
62-
* `:result` - Allows specifying how the result should be returned. Options include `:sync`, `:none`, and `:async`. `:sync` will make the API call synchronously, and return `{:ok, event_id}` if successful. `:none` sends the event from an unlinked child process under `Sentry.TaskSupervisor` and will return `{:ok, ""}` regardless of the result. `:async` will start an unlinked task and return a tuple of `{:ok, Task.t}` on success where the Task can be awaited upon to receive the result asynchronously. When used in an OTP behaviour like GenServer, the task will send a message that needs to be matched with `GenServer.handle_info/2`. See `Task.Supervisor.async_nolink/2` for more information. `:async` is the default.
62+
* `:result` - Allows specifying how the result should be returned. Options include `:sync`, `:none`, and `:async`. `:sync` will make the API call synchronously, and return `{:ok, event_id}` if successful. `:none` sends the event from an unlinked child process under `Sentry.TaskSupervisor` and will return `{:ok, ""}` regardless of the result. `:async` will start an unlinked task and return a tuple of `{:ok, Task.t}` on success where the Task should be awaited upon to receive the result asynchronously. If you do not call `Task.await/2`, messages will be leaked to the inbox of the current process. See `Task.Supervisor.async_nolink/2` for more information. `:none` is the default.
6363
* `:sample_rate` - The sampling factor to apply to events. A value of 0.0 will deny sending any events, and a value of 1.0 will send 100% of events.
6464
* Other options, such as `:stacktrace` or `:extra` will be passed to `Sentry.Event.create_event/1` downstream. See `Sentry.Event.create_event/1` for available options.
6565
"""
6666
@spec send_event(Event.t()) :: send_event_result
6767
def send_event(%Event{} = event, opts \\ []) do
68-
result = Keyword.get(opts, :result, :async)
68+
result = Keyword.get(opts, :result, :none)
6969
sample_rate = Keyword.get(opts, :sample_rate) || Config.sample_rate()
7070
should_log = event.event_source != :logger
7171

test/client_test.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ defmodule Sentry.ClientTest do
334334
{:ok, task} =
335335
Sentry.capture_exception(
336336
e,
337-
stacktrace: __STACKTRACE__
337+
stacktrace: __STACKTRACE__,
338+
result: :async
338339
)
339340

340341
assert_receive "API called"

0 commit comments

Comments
 (0)