Skip to content

Commit 5f1c901

Browse files
committed
Filter context only when tracking errors
We don't need to filter context for ignored errors.
1 parent fd552ad commit 5f1c901

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/error_tracker.ex

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ defmodule ErrorTracker do
118118
{kind, reason} = normalize_exception(exception, stacktrace)
119119
{:ok, stacktrace} = ErrorTracker.Stacktrace.new(stacktrace)
120120
{:ok, error} = Error.new(kind, reason, stacktrace)
121-
context = get_context() |> Map.merge(given_context) |> filter_context_data()
121+
context = Map.merge(get_context(), given_context)
122122

123123
if enabled?() && !ignored?(error, context) do
124-
{_error, occurrence} = upsert_error!(error, stacktrace, context, reason)
124+
sanitized_context = sanitize_context(context)
125+
{_error, occurrence} = upsert_error!(error, stacktrace, sanitized_context, reason)
125126
occurrence
126127
else
127128
:noop
@@ -209,14 +210,12 @@ defmodule ErrorTracker do
209210
ignorer && ignorer.ignore?(error, context)
210211
end
211212

212-
defp filter_context_data(context) do
213+
defp sanitize_context(context) do
213214
filter_mod = Application.get_env(:error_tracker, :filter)
214215

215-
if filter_mod do
216-
filter_mod.sanitize(context)
217-
else
218-
context
219-
end
216+
if filter_mod,
217+
do: filter_mod.sanitize(context),
218+
else: context
220219
end
221220

222221
defp normalize_exception(%struct{} = ex, _stacktrace) when is_exception(ex) do

0 commit comments

Comments
 (0)