Skip to content
Merged
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion lib/sentry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,18 @@ defmodule Sentry do

config :sentry,
before_send: {MyModule, :before_send},
after_send_event: {MyModule, :after_send}
after_send_event: {MyModule, :after_send_event}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we instead change the function name in the code example to be :after_send?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whatyouhide sure, changed that.


`MyModule` could look like this:

defmodule MyModule do
@spec before_send(Sentry.Event.t()) :: Sentry.Event.t()
def before_send(event) do
metadata = Map.new(Logger.metadata())
%Sentry.Event{event | extra: Map.merge(event.extra, metadata)}
end

@spec after_send_event(Sentry.Event.t(), {:ok, String.t()} | {:error, any()}) :: any()
def after_send_event(event, result) do
case result do
{:ok, id} ->
Expand All @@ -145,6 +147,8 @@ defmodule Sentry do
end
end

If the `before_send` callback returns `nil` or `false`, the event is not reported.

## Reporting Source Code

Sentry supports reporting the source code of (and around) the line that
Expand Down
Loading