Skip to content

Improve Event callback docs #922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2025
Merged
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
6 changes: 5 additions & 1 deletion lib/sentry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,14 @@ defmodule Sentry do
`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

def after_send_event(event, result) do
@spec after_send(Sentry.Event.t(), {:ok, String.t()} | {:error, any()}) :: any()
def after_send(event, result) do
case result do
{:ok, id} ->
Logger.info("Successfully sent event!")
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